Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFLU_ModMPI.F90
Go to the documentation of this file.
1 ! *********************************************************************
2 ! * Rocstar Simulation Suite *
3 ! * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4 ! * *
5 ! * Illinois Rocstar LLC *
6 ! * Champaign, IL *
7 ! * www.illinoisrocstar.com *
8 ! * sales@illinoisrocstar.com *
9 ! * *
10 ! * License: See LICENSE file in top level of distribution package or *
11 ! * http://opensource.org/licenses/NCSA *
12 ! *********************************************************************
13 ! *********************************************************************
14 ! * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15 ! * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16 ! * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17 ! * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18 ! * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19 ! * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20 ! * Arising FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21 ! * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22 ! *********************************************************************
23 ! ******************************************************************************
24 !
25 ! Purpose: Suite of routines for MPI interaction.
26 !
27 ! Description: None.
28 !
29 ! Notes: None.
30 !
31 ! ******************************************************************************
32 !
33 ! $Id: RFLU_ModMPI.F90,v 1.17 2008/12/06 08:44:22 mtcampbe Exp $
34 !
35 ! Copyright: (c) 2005 by the University of Illinois
36 !
37 ! ******************************************************************************
38 
40 
41  USE modglobal, ONLY: t_global
42  USE moddatatypes
43  USE modparameters
44  USE moderror
45  USE moddatastruct, ONLY: t_region
46  USE modgrid, ONLY: t_grid
47  USE modmixture, ONLY: t_mixt_input
49  USE modmpi
50 
51  IMPLICIT NONE
52 
53  PRIVATE
54  PUBLIC :: rflu_mpi_clearrequestwrapper, &
64 
65 ! ******************************************************************************
66 ! Declarations and definitions
67 ! ******************************************************************************
68 
69  CHARACTER(CHRLEN) :: &
70  RCSIdentString = '$RCSfile: RFLU_ModMPI.F90,v $ $Revision: 1.17 $'
71 
72 ! ******************************************************************************
73 ! Routines
74 ! ******************************************************************************
75 
76  CONTAINS
77 
78 
79 
80 
81 
82 
83 ! ******************************************************************************
84 !
85 ! Purpose: Clearing send requests.
86 !
87 ! Description: None.
88 !
89 ! Input:
90 ! global Pointer to global data
91 ! request Request (to be cleared)
92 !
93 ! Output:
94 ! request Request (cleared)
95 !
96 ! Notes: None.
97 !
98 ! ******************************************************************************
99 
100  SUBROUTINE rflu_mpi_clearrequest(global,request)
101 
102  IMPLICIT NONE
103 
104 ! ******************************************************************************
105 ! Declarations and definitions
106 ! ******************************************************************************
107 
108 ! ==============================================================================
109 ! Arguments
110 ! ==============================================================================
111 
112  INTEGER, INTENT(INOUT) :: request
113  TYPE(t_global), POINTER :: global
114 
115 ! ==============================================================================
116 ! Local variables
117 ! ==============================================================================
118 
119  INTEGER :: errorflag
120  INTEGER :: status(mpi_status_size)
121 
122 ! ******************************************************************************
123 ! Start
124 ! ******************************************************************************
125 
126  CALL registerfunction(global,'RFLU_MPI_ClearRequest',&
127  'RFLU_ModMPI.F90')
128 
129 ! ******************************************************************************
130 ! Set pointers
131 ! ******************************************************************************
132 
133  CALL mpi_wait(request,status,errorflag)
134  global%error = errorflag
135  IF ( global%error /= err_none ) THEN
136  CALL errorstop(global,err_mpi_output,__line__)
137  END IF ! global%error
138 
139 ! ******************************************************************************
140 ! End
141 ! ******************************************************************************
142 
143  CALL deregisterfunction(global)
144 
145  END SUBROUTINE rflu_mpi_clearrequest
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 ! ******************************************************************************
156 !
157 ! Purpose: Wrapper for clearing send requests.
158 !
159 ! Description: None.
160 !
161 ! Input:
162 ! pRegion Pointer to region
163 !
164 ! Output: None.
165 !
166 ! Notes: None.
167 !
168 ! ******************************************************************************
169 
170  SUBROUTINE rflu_mpi_clearrequestwrapper(pRegion)
171 
172  IMPLICIT NONE
173 
174 ! ******************************************************************************
175 ! Declarations and definitions
176 ! ******************************************************************************
177 
178 ! ==============================================================================
179 ! Arguments
180 ! ==============================================================================
181 
182  TYPE(t_region), POINTER :: pregion
183 
184 ! ==============================================================================
185 ! Local variables
186 ! ==============================================================================
187 
188  INTEGER :: errorflag,iborder
189  TYPE(t_border), POINTER :: pborder
190  TYPE(t_global), POINTER :: global
191  TYPE(t_grid), POINTER :: pgrid
192 
193 ! ******************************************************************************
194 ! Start
195 ! ******************************************************************************
196 
197  global => pregion%global
198 
199  CALL registerfunction(global,'RFLU_MPI_ClearRequestWrapper',&
200  'RFLU_ModMPI.F90')
201 
202 #ifdef ROCPROF
203  CALL fprofiler_begins("RFLU::ClearRequestWrapper")
204 #endif
205 
206 ! ******************************************************************************
207 ! Set pointers
208 ! ******************************************************************************
209 
210  pgrid => pregion%grid
211 
212 ! ******************************************************************************
213 ! Loop over borders
214 ! ******************************************************************************
215 
216  DO iborder = 1,pgrid%nBorders
217  pborder => pgrid%borders(iborder)
218 
219 ! ==============================================================================
220 ! Clear request if not on same process
221 ! ==============================================================================
222 
223  IF ( pborder%iProc /= global%myProcid ) THEN
224  IF ( pborder%nCellsSend > 0 ) THEN
225 
226 ! ------------------------------------------------------------------------------
227 ! Mixture
228 ! ------------------------------------------------------------------------------
229 
230  CALL rflu_mpi_clearrequest(global,pborder%mixt%sendRequest)
231 
232 ! ------------------------------------------------------------------------------
233 ! Physical modules
234 ! ------------------------------------------------------------------------------
235 
236 #ifdef SPEC
237  IF ( global%specUsed .EQV. .true. ) THEN
238  CALL rflu_mpi_clearrequest(global,pborder%spec%sendRequest)
239  END IF ! global%specUsed
240 #endif
241  END IF ! pBorder%nCellsSend
242  END IF ! pBorder
243  END DO ! iBorder
244 
245 ! ******************************************************************************
246 ! End
247 ! ******************************************************************************
248 
249 #ifdef ROCPROF
250  CALL fprofiler_ends("RFLU::ClearRequestWrapper")
251 #endif
252 
253  CALL deregisterfunction(global)
254 
255  END SUBROUTINE rflu_mpi_clearrequestwrapper
256 
257 
258 
259 
260 
261 
262 ! ******************************************************************************
263 !
264 ! Purpose: Copy cell data.
265 !
266 ! Description: None.
267 !
268 ! Input:
269 ! global Pointer to global data
270 ! pBorder Pointer to border
271 ! cellData Array with cell data
272 !
273 ! Output: None.
274 !
275 ! Notes: None.
276 !
277 ! ******************************************************************************
278 
279  SUBROUTINE rflu_mpi_copycelldata(global,pBorder,pBorder2,cellData,cellData2)
280 
281  IMPLICIT NONE
282 
283 ! ******************************************************************************
284 ! Declarations and definitions
285 ! ******************************************************************************
286 
287 ! ==============================================================================
288 ! Arguments
289 ! ==============================================================================
290 
291  REAL(RFREAL), DIMENSION(:,:), INTENT(IN) :: celldata
292  REAL(RFREAL), DIMENSION(:,:), INTENT(OUT) :: celldata2
293  TYPE(t_border), POINTER :: pborder,pborder2
294  TYPE(t_global), POINTER :: global
295 
296 ! ==============================================================================
297 ! Local variables
298 ! ==============================================================================
299 
300  INTEGER :: errorflag,icg,icg2,icl,ivar,nvars
301 
302 ! ******************************************************************************
303 ! Start
304 ! ******************************************************************************
305 
306  CALL registerfunction(global,'RFLU_MPI_CopyCellData',&
307  'RFLU_ModMPI.F90')
308 
309 ! ******************************************************************************
310 ! Set variables
311 ! ******************************************************************************
312 
313  nvars = SIZE(celldata,1)
314 
315  IF ( nvars /= SIZE(celldata2,1) ) THEN
316  CALL errorstop(global,err_datadim_mismatch,__line__)
317  END IF ! nVars
318 
319 ! ******************************************************************************
320 ! Copy data
321 ! ******************************************************************************
322 
323  DO icl = 1,pborder%nCellsSend
324  icg = pborder%icgSend(icl)
325  icg2 = pborder2%icgRecv(icl)
326 
327  DO ivar = 1,nvars
328  celldata2(ivar,icg2) = celldata(ivar,icg)
329  END DO ! iVar
330  END DO ! icl
331 
332 ! ******************************************************************************
333 ! End
334 ! ******************************************************************************
335 
336  CALL deregisterfunction(global)
337 
338  END SUBROUTINE rflu_mpi_copycelldata
339 
340 
341 
342 
343 
344 
345 
346 
347 
348 ! ******************************************************************************
349 !
350 ! Purpose: Wrapper for copying data.
351 !
352 ! Description: None.
353 !
354 ! Input:
355 ! pRegion Pointer to region
356 !
357 ! Output: None.
358 !
359 ! Notes: None.
360 !
361 ! ******************************************************************************
362 
363  SUBROUTINE rflu_mpi_copywrapper(regions)
364 
365  IMPLICIT NONE
366 
367 ! ******************************************************************************
368 ! Declarations and definitions
369 ! ******************************************************************************
370 
371 ! ==============================================================================
372 ! Arguments
373 ! ==============================================================================
374 
375  TYPE(t_region), DIMENSION(:), POINTER :: regions
376 
377 ! ==============================================================================
378 ! Local variables
379 ! ==============================================================================
380 
381  INTEGER :: errorflag,iborder,iborder2,ireg,ireg2
382  TYPE(t_border), POINTER :: pborder,pborder2
383  TYPE(t_global), POINTER :: global
384  TYPE(t_grid), POINTER :: pgrid
385  TYPE(t_region), POINTER :: pregion,pregion2
386 
387 ! ******************************************************************************
388 ! Start
389 ! ******************************************************************************
390 
391  global => regions(0)%global
392 
393  CALL registerfunction(global,'RFLU_MPI_CopyWrapper',&
394  'RFLU_ModMPI.F90')
395 
396 #ifdef ROCPROF
397  CALL fprofiler_begins("RFLU::CopyWrapper")
398 #endif
399 
400 ! ******************************************************************************
401 ! Set pointers
402 ! ******************************************************************************
403 
404 ! ******************************************************************************
405 ! Loop over borders
406 ! ******************************************************************************
407 
408  DO ireg = 1,global%nRegionsLocal
409  pregion => regions(ireg)
410  pgrid => pregion%grid
411 
412  DO iborder = 1,pgrid%nBorders
413  pborder => pgrid%borders(iborder)
414 
415 ! ==============================================================================
416 ! Copy data if on same process
417 ! ==============================================================================
418 
419  IF ( pborder%iProc == global%myProcid ) THEN
420  ireg2 = pborder%iRegionLocal
421  iborder2 = pborder%iBorder
422 
423  pregion2 => regions(ireg2)
424  pborder2 => pregion2%grid%borders(iborder2)
425 
426 ! ------------------------------------------------------------------------------
427 ! Check dimensions
428 ! ------------------------------------------------------------------------------
429 
430  IF ( pborder%nCellsSend /= pborder2%nCellsRecv ) THEN
431  CALL errorstop(global,err_bufferdim_mismatch,__line__)
432  END IF ! pBorder
433 
434 ! ------------------------------------------------------------------------------
435 ! Mixture
436 ! ------------------------------------------------------------------------------
437 
438  CALL rflu_mpi_copycelldata(global,pborder,pborder2, &
439  pregion%mixt%cv,pregion2%mixt%cv)
440 
441 ! ------------------------------------------------------------------------------
442 ! Physical modules
443 ! ------------------------------------------------------------------------------
444 
445 #ifdef SPEC
446  IF ( global%specUsed .EQV. .true. ) THEN
447  CALL rflu_mpi_copycelldata(global,pborder,pborder2, &
448  pregion%spec%cv,pregion2%spec%cv)
449  END IF ! global%specUsed
450 #endif
451 
452  END IF ! pBorder
453  END DO ! iBorder
454  END DO ! iReg
455 
456 ! ******************************************************************************
457 ! End
458 ! ******************************************************************************
459 
460 #ifdef ROCPROF
461  CALL fprofiler_ends("RFLU::CopyWrapper")
462 #endif
463 
464  CALL deregisterfunction(global)
465 
466  END SUBROUTINE rflu_mpi_copywrapper
467 
468 
469 
470 
471 
472 
473 
474 
475 ! ******************************************************************************
476 !
477 ! Purpose: Create iPclSend buffers.
478 !
479 ! Description: None.
480 !
481 ! Input:
482 ! pRegion Pointer to region
483 ! pBorder Pointer to border (Optional)
484 !
485 ! Output: None.
486 !
487 ! Notes: None.
488 !
489 ! ******************************************************************************
490 
491  SUBROUTINE rflu_mpi_createbufferipclsend(pRegion,pBorder)
492 
493  IMPLICIT NONE
494 
495 ! ******************************************************************************
496 ! Declarations and definitions
497 ! ******************************************************************************
498 
499 ! ==============================================================================
500 ! Arguments
501 ! ==============================================================================
502 
503  TYPE(t_border), POINTER, OPTIONAL :: pborder
504  TYPE(t_region), POINTER :: pregion
505 
506 ! ==============================================================================
507 ! Local variables
508 ! ==============================================================================
509 
510  INTEGER :: errorflag,iborder,nvars
511  TYPE(t_global), POINTER :: global
512  TYPE(t_grid), POINTER :: pgrid
513  TYPE(t_border), POINTER :: pborder2
514 
515 ! ******************************************************************************
516 ! Start
517 ! ******************************************************************************
518 
519  global => pregion%global
520 
521  CALL registerfunction(global,'RFLU_MPI_CreateBufferIPclSend',&
522  'RFLU_ModMPI.F90')
523 
524 ! ******************************************************************************
525 ! Set pointers
526 ! ******************************************************************************
527 
528  pgrid => pregion%grid
529 
530 ! ******************************************************************************
531 ! Loop over borders when pBorder is not present
532 ! else allocate only for select pBorder
533 ! ******************************************************************************
534 
535 #ifdef PLAG
536  IF ( present(pborder) ) THEN
537  nvars = SIZE(pborder%iPclSend,1)
538 
539  ALLOCATE(pborder%iPclSend(nvars,pborder%nPclsSendMax),stat=errorflag)
540  global%error = errorflag
541  IF ( global%error /= err_none ) THEN
542  CALL errorstop(global,err_allocate,__line__,'pBorder%iPclSend')
543  END IF ! global%error
544 
545  ELSE
546  DO iborder = 1,pgrid%nBorders
547  pborder2 => pgrid%borders(iborder)
548 
549  nvars = 2
550  pborder2%nPclsSendMax = 1000
551 
552  ALLOCATE(pborder2%iPclSend(nvars,pborder2%nPclsSendMax),stat=errorflag)
553  global%error = errorflag
554  IF ( global%error /= err_none ) THEN
555  CALL errorstop(global,err_allocate,__line__,'pBorder%iPclSend')
556  END IF ! global%error
557  END DO ! iBorder
558  END IF ! PRESENT(pBorder)
559 #endif
560 
561 ! ******************************************************************************
562 ! End
563 ! ******************************************************************************
564 
565  CALL deregisterfunction(global)
566 
567  END SUBROUTINE rflu_mpi_createbufferipclsend
568 
569 
570 
571 
572 
573 
574 
575 
576 ! ******************************************************************************
577 !
578 ! Purpose: Create buffers.
579 !
580 ! Description: None.
581 !
582 ! Input:
583 ! global Pointer to global data
584 ! pBorder Pointer to border
585 ! borderData Border data
586 ! nVars Number of variables in borderData
587 !
588 ! Output: None.
589 !
590 ! Notes: None.
591 !
592 ! ******************************************************************************
593 
594  SUBROUTINE rflu_mpi_createbuffers(global,pBorder,borderData,nVars)
595 
596  IMPLICIT NONE
597 
598 ! ******************************************************************************
599 ! Declarations and definitions
600 ! ******************************************************************************
601 
602 ! ==============================================================================
603 ! Arguments
604 ! ==============================================================================
605 
606  INTEGER, INTENT(IN) :: nvars
607  TYPE(t_global), POINTER :: global
608  TYPE(t_border), POINTER :: pborder
609  TYPE(t_border_data) :: borderdata
610 
611 ! ==============================================================================
612 ! Local variables
613 ! ==============================================================================
614 
615  INTEGER :: errorflag
616 
617 ! ******************************************************************************
618 ! Start
619 ! ******************************************************************************
620 
621  CALL registerfunction(global,'RFLU_MPI_CreateBuffers',&
622  'RFLU_ModMPI.F90')
623 
624 ! ******************************************************************************
625 ! Allocate memory
626 ! ******************************************************************************
627 
628  ALLOCATE(borderdata%sendBuff(nvars,pborder%nCellsSend),stat=errorflag)
629  global%error = errorflag
630  IF ( global%error /= err_none ) THEN
631  CALL errorstop(global,err_allocate,__line__,'borderData%sendBuff')
632  END IF ! global%error
633 
634  ALLOCATE(borderdata%recvBuff(nvars,pborder%nCellsRecv),stat=errorflag)
635  global%error = errorflag
636  IF ( global%error /= err_none ) THEN
637  CALL errorstop(global,err_allocate,__line__,'borderData%recvBuff')
638  END IF ! global%error
639 
640 ! ******************************************************************************
641 ! End
642 ! ******************************************************************************
643 
644  CALL deregisterfunction(global)
645 
646  END SUBROUTINE rflu_mpi_createbuffers
647 
648 
649 
650 
651 
652 
653 
654 ! ******************************************************************************
655 !
656 ! Purpose: Wrapper for creating buffers.
657 !
658 ! Description: None.
659 !
660 ! Input:
661 ! pRegion Pointer to region
662 !
663 ! Output: None.
664 !
665 ! Notes: None.
666 !
667 ! ******************************************************************************
668 
669  SUBROUTINE rflu_mpi_createbufferswrapper(pRegion)
670 
671  IMPLICIT NONE
672 
673 ! ******************************************************************************
674 ! Declarations and definitions
675 ! ******************************************************************************
676 
677 ! ==============================================================================
678 ! Arguments
679 ! ==============================================================================
680 
681  TYPE(t_region), POINTER :: pregion
682 
683 ! ==============================================================================
684 ! Local variables
685 ! ==============================================================================
686 
687  INTEGER :: errorflag,iborder
688  TYPE(t_border), POINTER :: pborder
689  TYPE(t_global), POINTER :: global
690  TYPE(t_grid), POINTER :: pgrid
691 
692 ! ******************************************************************************
693 ! Start
694 ! ******************************************************************************
695 
696  global => pregion%global
697 
698  CALL registerfunction(global,'RFLU_MPI_CreateBuffersWrapper',&
699  'RFLU_ModMPI.F90')
700 
701  IF ( global%myProcid == masterproc .AND. &
702  global%verbLevel >= verbose_high ) THEN
703  WRITE(stdout,'(A,1X,A)') solver_name,'Creating buffers...'
704  END IF ! global%verbLevel
705 
706 ! ******************************************************************************
707 ! Set pointers
708 ! ******************************************************************************
709 
710  pgrid => pregion%grid
711 
712 ! ******************************************************************************
713 ! Loop over borders
714 ! ******************************************************************************
715 
716  DO iborder = 1,pgrid%nBorders
717  pborder => pgrid%borders(iborder)
718 
719 ! ==============================================================================
720 ! Create buffers if not on same process
721 ! ==============================================================================
722 
723  IF ( pborder%iProc /= global%myProcid ) THEN
724 
725 ! ------------------------------------------------------------------------------
726 ! Mixture
727 ! ------------------------------------------------------------------------------
728 
729  CALL rflu_mpi_createbuffers(global,pborder,pborder%mixt, &
730  pregion%mixtInput%nCv)
731 
732 ! ------------------------------------------------------------------------------
733 ! Physical modules
734 ! ------------------------------------------------------------------------------
735 
736 #ifdef SPEC
737  IF ( global%specUsed .EQV. .true. ) THEN
738  CALL rflu_mpi_createbuffers(global,pborder,pborder%spec, &
739  pregion%specInput%nSpecies)
740 
741  END IF ! global%specUsed
742 #endif
743  END IF ! pBorder%iProc
744  END DO ! iBorder
745 
746 ! ******************************************************************************
747 ! End
748 ! ******************************************************************************
749 
750  CALL deregisterfunction(global)
751 
752  IF ( global%myProcid == masterproc .AND. &
753  global%verbLevel >= verbose_high ) THEN
754  WRITE(stdout,'(A,1X,A)') solver_name,'Creating buffers done.'
755  END IF ! global%verbLevel
756 
757  END SUBROUTINE rflu_mpi_createbufferswrapper
758 
759 
760 
761 
762 
763 
764 
765 
766 ! ******************************************************************************
767 !
768 ! Purpose: Destroy iPclSend buffers.
769 !
770 ! Description: None.
771 !
772 ! Input:
773 ! pRegion Pointer to region
774 ! pBorder Pointer to border (optional)
775 !
776 ! Output: None.
777 !
778 ! Notes: None.
779 !
780 ! ******************************************************************************
781 
782  SUBROUTINE rflu_mpi_destroybufferipclsend(pRegion,pBorder)
783 
784  IMPLICIT NONE
785 
786 ! ******************************************************************************
787 ! Declarations and definitions
788 ! ******************************************************************************
789 
790 ! ==============================================================================
791 ! Arguments
792 ! ==============================================================================
793 
794  TYPE(t_border), POINTER, OPTIONAL :: pborder
795  TYPE(t_region), POINTER :: pregion
796 
797 ! ==============================================================================
798 ! Local variables
799 ! ==============================================================================
800 
801  INTEGER :: errorflag,iborder
802  TYPE(t_global), POINTER :: global
803  TYPE(t_grid), POINTER :: pgrid
804  TYPE(t_border), POINTER :: pborder2
805 
806 ! ******************************************************************************
807 ! Start
808 ! ******************************************************************************
809 
810  global => pregion%global
811 
812  CALL registerfunction(global,'RFLU_MPI_DestroyBufferIPclSend',&
813  'RFLU_ModMPI.F90')
814 
815 ! ******************************************************************************
816 ! Set pointers
817 ! ******************************************************************************
818 
819  pgrid => pregion%grid
820 
821 ! ******************************************************************************
822 ! Loop over borders when pBorder is not present
823 ! else deallocate only for select pBorder
824 ! ******************************************************************************
825 
826 #ifdef PLAG
827  IF ( present(pborder) ) THEN
828  DEALLOCATE(pborder%iPclSend,stat=errorflag)
829  global%error = errorflag
830  IF ( global%error /= err_none ) THEN
831  CALL errorstop(global,err_deallocate,__line__,'pBorder%iPclSend')
832  END IF ! global%error
833 
834  ELSE
835  DO iborder = 1,pgrid%nBorders
836  pborder2 => pgrid%borders(iborder)
837 
838  DEALLOCATE(pborder2%iPclSend,stat=errorflag)
839  global%error = errorflag
840  IF ( global%error /= err_none ) THEN
841  CALL errorstop(global,err_deallocate,__line__,'pBorder%iPclSend')
842  END IF ! global%error
843  END DO ! iBorder
844  END IF ! PRESENT(pBorder)
845 #endif
846 
847 ! ******************************************************************************
848 ! End
849 ! ******************************************************************************
850 
851  CALL deregisterfunction(global)
852 
853  END SUBROUTINE rflu_mpi_destroybufferipclsend
854 
855 
856 
857 
858 
859 
860 
861 
862 ! ******************************************************************************
863 !
864 ! Purpose: Destroy buffers.
865 !
866 ! Description: None.
867 !
868 ! Input:
869 ! global Pointer to global data
870 ! pBorder Pointer to border
871 ! borderData Border data
872 !
873 ! Output: None.
874 !
875 ! Notes: None.
876 !
877 ! ******************************************************************************
878 
879  SUBROUTINE rflu_mpi_destroybuffers(global,pBorder,borderData)
880 
881  IMPLICIT NONE
882 
883 ! ******************************************************************************
884 ! Declarations and definitions
885 ! ******************************************************************************
886 
887 ! ==============================================================================
888 ! Arguments
889 ! ==============================================================================
890 
891  TYPE(t_global), POINTER :: global
892  TYPE(t_border), POINTER :: pborder
893  TYPE(t_border_data) :: borderdata
894 
895 ! ==============================================================================
896 ! Local variables
897 ! ==============================================================================
898 
899  INTEGER :: errorflag
900 
901 ! ******************************************************************************
902 ! Start
903 ! ******************************************************************************
904 
905  CALL registerfunction(global,'RFLU_MPI_DestroyBuffers',&
906  'RFLU_ModMPI.F90')
907 
908 ! ******************************************************************************
909 ! Allocate memory
910 ! ******************************************************************************
911 
912  DEALLOCATE(borderdata%sendBuff,stat=errorflag)
913  global%error = errorflag
914  IF ( global%error /= err_none ) THEN
915  CALL errorstop(global,err_deallocate,__line__,'borderData%sendBuff')
916  END IF ! global%error
917 
918  DEALLOCATE(borderdata%recvBuff,stat=errorflag)
919  global%error = errorflag
920  IF ( global%error /= err_none ) THEN
921  CALL errorstop(global,err_deallocate,__line__,'borderData%recvBuff')
922  END IF ! global%error
923 
924 ! ******************************************************************************
925 ! End
926 ! ******************************************************************************
927 
928  CALL deregisterfunction(global)
929 
930  END SUBROUTINE rflu_mpi_destroybuffers
931 
932 
933 
934 
935 
936 
937 
938 ! ******************************************************************************
939 !
940 ! Purpose: Wrapper for destroying buffers.
941 !
942 ! Description: None.
943 !
944 ! Input:
945 ! pRegion Pointer to region
946 !
947 ! Output: None.
948 !
949 ! Notes: None.
950 !
951 ! ******************************************************************************
952 
953  SUBROUTINE rflu_mpi_destroybufferswrapper(pRegion)
954 
955  IMPLICIT NONE
956 
957 ! ******************************************************************************
958 ! Declarations and definitions
959 ! ******************************************************************************
960 
961 ! ==============================================================================
962 ! Arguments
963 ! ==============================================================================
964 
965  TYPE(t_region), POINTER :: pregion
966 
967 ! ==============================================================================
968 ! Local variables
969 ! ==============================================================================
970 
971  INTEGER :: errorflag,iborder
972  TYPE(t_border), POINTER :: pborder
973  TYPE(t_global), POINTER :: global
974  TYPE(t_grid), POINTER :: pgrid
975 
976 ! ******************************************************************************
977 ! Start
978 ! ******************************************************************************
979 
980  global => pregion%global
981 
982  CALL registerfunction(global,'RFLU_MPI_DestroyBuffersWrapper',&
983  'RFLU_ModMPI.F90')
984 
985  IF ( global%myProcid == masterproc .AND. &
986  global%verbLevel >= verbose_high ) THEN
987  WRITE(stdout,'(A,1X,A)') solver_name,'Destroying buffers...'
988  END IF ! global%verbLevel
989 
990 ! ******************************************************************************
991 ! Set pointers
992 ! ******************************************************************************
993 
994  pgrid => pregion%grid
995 
996 ! ******************************************************************************
997 ! Loop over borders
998 ! ******************************************************************************
999 
1000  DO iborder = 1,pgrid%nBorders
1001  pborder => pgrid%borders(iborder)
1002 
1003 ! ==============================================================================
1004 ! Create buffers if not on same process
1005 ! ==============================================================================
1006 
1007  IF ( pborder%iProc /= global%myProcid ) THEN
1008 
1009 ! ------------------------------------------------------------------------------
1010 ! Mixture
1011 ! ------------------------------------------------------------------------------
1012 
1013  CALL rflu_mpi_destroybuffers(global,pborder,pborder%mixt)
1014 
1015 ! ------------------------------------------------------------------------------
1016 ! Physical modules
1017 ! ------------------------------------------------------------------------------
1018 
1019 #ifdef SPEC
1020  IF ( global%specUsed .EQV. .true. ) THEN
1021  CALL rflu_mpi_destroybuffers(global,pborder,pborder%spec)
1022  END IF ! global%specUsed
1023 #endif
1024  END IF ! pBorder%iProc
1025  END DO ! iBorder
1026 
1027 ! ******************************************************************************
1028 ! End
1029 ! ******************************************************************************
1030 
1031  CALL deregisterfunction(global)
1032 
1033  IF ( global%myProcid == masterproc .AND. &
1034  global%verbLevel >= verbose_high ) THEN
1035  WRITE(stdout,'(A,1X,A)') solver_name,'Destroying buffers done.'
1036  END IF ! global%verbLevel
1037 
1038  END SUBROUTINE rflu_mpi_destroybufferswrapper
1039 
1040 
1041 
1042 
1043 
1044 
1045 
1046 
1047 
1048 ! ******************************************************************************
1049 !
1050 ! Purpose: Send cell data.
1051 !
1052 ! Description: None.
1053 !
1054 ! Input:
1055 ! global Pointer to global data
1056 ! pBorder Pointer to border
1057 ! cellDataBuff Buffer array
1058 ! cellData Data array
1059 ! tag Tag
1060 !
1061 ! Output:
1062 ! request Request
1063 !
1064 ! Notes: None.
1065 !
1066 ! ******************************************************************************
1067 
1068  SUBROUTINE rflu_mpi_isendcelldata(global,pBorder,cellDataBuff,cellData,tag, &
1069  request)
1070 
1071  IMPLICIT NONE
1072 
1073 ! ******************************************************************************
1074 ! Declarations and definitions
1075 ! ******************************************************************************
1076 
1077 ! ==============================================================================
1078 ! Arguments
1079 ! ==============================================================================
1080 
1081  INTEGER, INTENT(IN) :: tag
1082  INTEGER, INTENT(OUT) :: request
1083  REAL(RFREAL), DIMENSION(:,:), INTENT(IN) :: celldata
1084  REAL(RFREAL), DIMENSION(:,:), INTENT(OUT) :: celldatabuff
1085  TYPE(t_border), POINTER :: pborder
1086  TYPE(t_global), POINTER :: global
1087 
1088 ! ==============================================================================
1089 ! Local variables
1090 ! ==============================================================================
1091 
1092  INTEGER :: errorflag,icg,icl,ivar,nvars
1093 
1094 ! ******************************************************************************
1095 ! Start
1096 ! ******************************************************************************
1097 
1098  CALL registerfunction(global,'RFLU_MPI_ISendCellData',&
1099  'RFLU_ModMPI.F90')
1100 
1101 ! ******************************************************************************
1102 ! Set variables
1103 ! ******************************************************************************
1104 
1105  nvars = SIZE(celldata,1)
1106 
1107 ! ******************************************************************************
1108 ! Pack data into buffer
1109 ! ******************************************************************************
1110 
1111  DO icl = 1,pborder%nCellsSend
1112  icg = pborder%icgSend(icl)
1113 
1114  DO ivar = 1,nvars
1115  celldatabuff(ivar,icl) = celldata(ivar,icg)
1116  END DO ! iVar
1117  END DO ! icl
1118 
1119 ! ******************************************************************************
1120 ! Send data
1121 ! ******************************************************************************
1122 
1123  IF ( pborder%nCellsSend > 0 ) THEN
1124  CALL mpi_isend(celldatabuff,pborder%nCellsSend*nvars,mpi_rfreal, &
1125  pborder%iProc,tag,global%mpiComm,request,errorflag)
1126  global%error = errorflag
1127  IF ( global%error /= err_none ) THEN
1128  CALL errorstop(global,err_mpi_output,__line__)
1129  END IF ! global%error
1130  END IF ! pBorder%nCellsSend
1131 
1132 ! ******************************************************************************
1133 ! End
1134 ! ******************************************************************************
1135 
1136  CALL deregisterfunction(global)
1137 
1138  END SUBROUTINE rflu_mpi_isendcelldata
1139 
1140 
1141 
1142 
1143 
1144 
1145 
1146 
1147 ! ******************************************************************************
1148 !
1149 ! Purpose: Recreate iPclSend buffers.
1150 !
1151 ! Description: None.
1152 !
1153 ! Input:
1154 ! pRegion Pointer to region
1155 ! pBorder Pointer to border (Optional)
1156 !
1157 ! Output: None.
1158 !
1159 ! Notes: None.
1160 !
1161 ! ******************************************************************************
1162 
1163  SUBROUTINE rflu_mpi_recreatebufferipclsend(pRegion,pBorder)
1164 
1165  IMPLICIT NONE
1166 
1167 ! ******************************************************************************
1168 ! Declarations and definitions
1169 ! ******************************************************************************
1170 
1171 ! ==============================================================================
1172 ! Arguments
1173 ! ==============================================================================
1174 
1175  TYPE(t_border), POINTER, OPTIONAL :: pborder
1176  TYPE(t_region), POINTER :: pregion
1177 
1178 ! ==============================================================================
1179 ! Local variables
1180 ! ==============================================================================
1181 
1182  INTEGER :: errorflag,ipcl,ivar,npclssendmax,npclssendmaxold,nvars
1183  INTEGER, ALLOCATABLE, DIMENSION(:,:) :: ipclsendtemp
1184  TYPE(t_global), POINTER :: global
1185  TYPE(t_grid), POINTER :: pgrid
1186 
1187 ! ******************************************************************************
1188 ! Start
1189 ! ******************************************************************************
1190 
1191  global => pregion%global
1192 
1193  CALL registerfunction(global,'RFLU_MPI_RecreateBufferIPclSend',&
1194  'RFLU_ModMPI.F90')
1195 
1196 ! ******************************************************************************
1197 ! Set pointers
1198 ! ******************************************************************************
1199 
1200  pgrid => pregion%grid
1201 
1202 #ifdef PLAG
1203 ! ******************************************************************************
1204 ! Set variables
1205 ! ******************************************************************************
1206 
1207  nvars = SIZE(pborder%iPclSend,1)
1208  npclssendmaxold = SIZE(pborder%iPclSend,2)
1209 
1210  pborder%nPclsSendMax = &
1211  nint(1.20_rfreal*REAL(pborder%npclssend,kind=rfreal))
1212 
1213 ! ******************************************************************************
1214 ! Allocate temporary array
1215 ! ******************************************************************************
1216 
1217  ALLOCATE(ipclsendtemp(nvars,pborder%nPclsSendMax),stat=errorflag)
1218  global%error = errorflag
1219  IF ( global%error /= err_none ) THEN
1220  CALL errorstop(global,err_allocate,__line__,'iPclSendTemp')
1221  END IF ! global%error
1222 
1223 ! ******************************************************************************
1224 ! Copy array
1225 ! ******************************************************************************
1226 
1227  DO ipcl = 1,npclssendmaxold
1228  DO ivar = 1,nvars
1229  ipclsendtemp(ivar,ipcl) = pborder%iPclSend(ivar,ipcl)
1230  END DO ! iVar
1231  END DO ! iPcl
1232 
1233 ! ******************************************************************************
1234 ! Deallocate iPclSend array
1235 ! ******************************************************************************
1236 
1237  CALL rflu_mpi_destroybufferipclsend(pregion,pborder)
1238 
1239 ! ******************************************************************************
1240 ! Reallocate iPclSend array
1241 ! ******************************************************************************
1242 
1243  CALL rflu_mpi_createbufferipclsend(pregion,pborder)
1244 
1245 ! ******************************************************************************
1246 ! Copy array
1247 ! ******************************************************************************
1248 
1249  DO ipcl = 1,pborder%nPclsSend
1250  DO ivar = 1,nvars
1251  pborder%iPclSend(ivar,ipcl) = ipclsendtemp(ivar,ipcl)
1252  END DO ! iVar
1253  END DO ! iPcl
1254 
1255 ! ******************************************************************************
1256 ! Deallocate temporary array
1257 ! ******************************************************************************
1258 
1259  DEALLOCATE(ipclsendtemp,stat=errorflag)
1260  global%error = errorflag
1261  IF ( global%error /= err_none ) THEN
1262  CALL errorstop(global,err_deallocate,__line__,'iPclSendTemp')
1263  END IF ! global%error
1264 #endif
1265 
1266 ! ******************************************************************************
1267 ! End
1268 ! ******************************************************************************
1269 
1270  CALL deregisterfunction(global)
1271 
1272  END SUBROUTINE rflu_mpi_recreatebufferipclsend
1273 
1274 
1275 
1276 
1277 
1278 
1279 
1280 ! ******************************************************************************
1281 !
1282 ! Purpose: Wrapper for sending data.
1283 !
1284 ! Description: None.
1285 !
1286 ! Input:
1287 ! pRegion Pointer to region
1288 !
1289 ! Output: None.
1290 !
1291 ! Notes: None.
1292 !
1293 ! ******************************************************************************
1294 
1295  SUBROUTINE rflu_mpi_isendwrapper(pRegion)
1296 
1297  IMPLICIT NONE
1298 
1299 ! ******************************************************************************
1300 ! Declarations and definitions
1301 ! ******************************************************************************
1302 
1303 ! ==============================================================================
1304 ! Arguments
1305 ! ==============================================================================
1306 
1307  TYPE(t_region), POINTER :: pregion
1308 
1309 ! ==============================================================================
1310 ! Local variables
1311 ! ==============================================================================
1312 
1313  INTEGER :: errorflag,iborder
1314  TYPE(t_border), POINTER :: pborder
1315  TYPE(t_global), POINTER :: global
1316  TYPE(t_grid), POINTER :: pgrid
1317 
1318 ! ******************************************************************************
1319 ! Start
1320 ! ******************************************************************************
1321 
1322  global => pregion%global
1323 
1324  CALL registerfunction(global,'RFLU_MPI_ISendWrapper',&
1325  'RFLU_ModMPI.F90')
1326 
1327 #ifdef ROCPROF
1328  CALL fprofiler_begins("RFLU::ISendWrapper")
1329 #endif
1330 
1331 ! ******************************************************************************
1332 ! Set pointers
1333 ! ******************************************************************************
1334 
1335  pgrid => pregion%grid
1336 
1337 ! ******************************************************************************
1338 ! Loop over borders
1339 ! ******************************************************************************
1340 
1341  DO iborder = 1,pgrid%nBorders
1342  pborder => pgrid%borders(iborder)
1343 
1344 ! ==============================================================================
1345 ! Send data if not on same process
1346 ! ==============================================================================
1347 
1348  IF ( pborder%iProc /= global%myProcid ) THEN
1349 
1350 ! ------------------------------------------------------------------------------
1351 ! Mixture
1352 ! ------------------------------------------------------------------------------
1353 
1354  CALL rflu_mpi_isendcelldata(global,pborder,pborder%mixt%sendBuff, &
1355  pregion%mixt%cv,pborder%mixt%tag, &
1356  pborder%mixt%sendRequest)
1357 
1358 ! ------------------------------------------------------------------------------
1359 ! Physical modules
1360 ! ------------------------------------------------------------------------------
1361 
1362 #ifdef SPEC
1363  IF ( global%specUsed .EQV. .true. ) THEN
1364  CALL rflu_mpi_isendcelldata(global,pborder,pborder%spec%sendBuff, &
1365  pregion%spec%cv,pborder%spec%tag, &
1366  pborder%spec%sendRequest)
1367  END IF ! global%specUsed
1368 #endif
1369  END IF ! pBorder
1370  END DO ! iBorder
1371 
1372 ! ******************************************************************************
1373 ! End
1374 ! ******************************************************************************
1375 
1376 #ifdef ROCPROF
1377  CALL fprofiler_ends("RFLU::ISendWrapper")
1378 #endif
1379 
1380  CALL deregisterfunction(global)
1381 
1382  END SUBROUTINE rflu_mpi_isendwrapper
1383 
1384 
1385 
1386 
1387 
1388 
1389 
1390 
1391 ! ******************************************************************************
1392 !
1393 ! Purpose: Receive cell data.
1394 !
1395 ! Description: None.
1396 !
1397 ! Input:
1398 ! global Pointer to global data
1399 ! pBorder Pointer to border
1400 ! cellDataBuff Buffer array
1401 ! cellData Data array
1402 ! tag Tag
1403 !
1404 ! Output: None.
1405 !
1406 ! Notes: None.
1407 !
1408 ! ******************************************************************************
1409 
1410  SUBROUTINE rflu_mpi_recvcelldata(global,pBorder,cellDataBuff,cellData,tag)
1411 
1412  IMPLICIT NONE
1413 
1414 ! ******************************************************************************
1415 ! Declarations and definitions
1416 ! ******************************************************************************
1417 
1418 ! ==============================================================================
1419 ! Arguments
1420 ! ==============================================================================
1421 
1422  INTEGER, INTENT(IN) :: tag
1423  REAL(RFREAL), DIMENSION(:,:), INTENT(IN) :: celldatabuff
1424  REAL(RFREAL), DIMENSION(:,:), INTENT(OUT) :: celldata
1425  TYPE(t_border), POINTER :: pborder
1426  TYPE(t_global), POINTER :: global
1427 
1428 ! ==============================================================================
1429 ! Local variables
1430 ! ==============================================================================
1431 
1432  INTEGER :: errorflag,icg,icl,ivar,nvars
1433  INTEGER :: status(mpi_status_size)
1434 
1435 ! ******************************************************************************
1436 ! Start
1437 ! ******************************************************************************
1438 
1439  CALL registerfunction(global,'RFLU_MPI_RecvCellData',&
1440  'RFLU_ModMPI.F90')
1441 
1442 ! ******************************************************************************
1443 ! Set variables
1444 ! ******************************************************************************
1445 
1446  nvars = SIZE(celldata,1)
1447 
1448 ! ******************************************************************************
1449 ! Recv data
1450 ! ******************************************************************************
1451 
1452  IF ( pborder%nCellsRecv > 0 ) THEN
1453  CALL mpi_recv(celldatabuff,pborder%nCellsRecv*nvars,mpi_rfreal, &
1454  pborder%iProc,tag,global%mpiComm,status,errorflag)
1455  global%error = errorflag
1456  IF ( global%error /= err_none ) THEN
1457  CALL errorstop(global,err_mpi_output,__line__)
1458  END IF ! global%error
1459  END IF ! pBorder%nCellsRecv
1460 
1461 ! ******************************************************************************
1462 ! Unpack data from buffer
1463 ! ******************************************************************************
1464 
1465  DO icl = 1,pborder%nCellsRecv
1466  icg = pborder%icgRecv(icl)
1467 
1468  DO ivar = 1,nvars
1469  celldata(ivar,icg) = celldatabuff(ivar,icl)
1470  END DO ! iVar
1471  END DO ! icl
1472 
1473 ! ******************************************************************************
1474 ! End
1475 ! ******************************************************************************
1476 
1477  CALL deregisterfunction(global)
1478 
1479  END SUBROUTINE rflu_mpi_recvcelldata
1480 
1481 
1482 
1483 
1484 
1485 
1486 
1487 ! ******************************************************************************
1488 !
1489 ! Purpose: Wrapper for receiving data.
1490 !
1491 ! Description: None.
1492 !
1493 ! Input:
1494 ! pRegion Pointer to region
1495 !
1496 ! Output: None.
1497 !
1498 ! Notes: None.
1499 !
1500 ! ******************************************************************************
1501 
1502  SUBROUTINE rflu_mpi_recvwrapper(pRegion)
1503 
1504  IMPLICIT NONE
1505 
1506 ! ******************************************************************************
1507 ! Declarations and definitions
1508 ! ******************************************************************************
1509 
1510 ! ==============================================================================
1511 ! Arguments
1512 ! ==============================================================================
1513 
1514  TYPE(t_region), POINTER :: pregion
1515 
1516 ! ==============================================================================
1517 ! Local variables
1518 ! ==============================================================================
1519 
1520  INTEGER :: errorflag,iborder
1521  TYPE(t_border), POINTER :: pborder
1522  TYPE(t_global), POINTER :: global
1523  TYPE(t_grid), POINTER :: pgrid
1524 
1525 ! ******************************************************************************
1526 ! Start
1527 ! ******************************************************************************
1528 
1529  global => pregion%global
1530 
1531  CALL registerfunction(global,'RFLU_MPI_RecvWrapper',&
1532  'RFLU_ModMPI.F90')
1533 
1534 #ifdef ROCPROF
1535  CALL fprofiler_begins("RFLU::RecvWrapper")
1536 #endif
1537 
1538 ! ******************************************************************************
1539 ! Set pointers
1540 ! ******************************************************************************
1541 
1542  pgrid => pregion%grid
1543 
1544 ! ******************************************************************************
1545 ! Loop over borders
1546 ! ******************************************************************************
1547 
1548  DO iborder = 1,pgrid%nBorders
1549  pborder => pgrid%borders(iborder)
1550 
1551 ! ==============================================================================
1552 ! Receive data if not on same process
1553 ! ==============================================================================
1554 
1555  IF ( pborder%iProc /= global%myProcid ) THEN
1556 
1557 ! ------------------------------------------------------------------------------
1558 ! Mixture
1559 ! ------------------------------------------------------------------------------
1560 
1561  CALL rflu_mpi_recvcelldata(global,pborder,pborder%mixt%recvBuff, &
1562  pregion%mixt%cv,pborder%mixt%tag)
1563 
1564 ! ------------------------------------------------------------------------------
1565 ! Physical modules
1566 ! ------------------------------------------------------------------------------
1567 
1568 #ifdef SPEC
1569  IF ( global%specUsed .EQV. .true. ) THEN
1570  CALL rflu_mpi_recvcelldata(global,pborder,pborder%spec%recvBuff, &
1571  pregion%spec%cv,pborder%spec%tag)
1572  END IF ! global%specUsed
1573 #endif
1574  END IF ! pBorder
1575  END DO ! iBorder
1576 
1577 ! ******************************************************************************
1578 ! End
1579 ! ******************************************************************************
1580 
1581 #ifdef ROCPROF
1582  CALL fprofiler_ends("RFLU::RecvWrapper")
1583 #endif
1584 
1585  CALL deregisterfunction(global)
1586 
1587  END SUBROUTINE rflu_mpi_recvwrapper
1588 
1589 
1590 
1591 
1592 
1593 ! ******************************************************************************
1594 !
1595 ! Purpose: Set tag.
1596 !
1597 ! Description: None.
1598 !
1599 ! Input:
1600 ! global Pointer to global data
1601 ! iReg1 Index of first region
1602 ! iReg2 Index of second region
1603 ! iMsg Index of message
1604 ! tagMax Maximum allowed value of tag
1605 !
1606 ! Output: None.
1607 !
1608 ! Notes: None.
1609 !
1610 ! ******************************************************************************
1611 
1612  INTEGER FUNCTION rflu_mpi_settag(global,iReg1,iReg2,iMsg,tagMax)
1613 
1614  IMPLICIT NONE
1615 
1616 ! ******************************************************************************
1617 ! Declarations and definitions
1618 ! ******************************************************************************
1619 
1620 ! ==============================================================================
1621 ! Arguments
1622 ! ==============================================================================
1623 
1624  INTEGER, INTENT(IN) :: imsg,ireg1,ireg2,tagmax
1625  TYPE(t_global), POINTER :: global
1626 
1627 ! ==============================================================================
1628 ! Local variables
1629 ! ==============================================================================
1630 
1631  INTEGER :: iregmax,iregmin
1632 
1633 ! ******************************************************************************
1634 ! Start
1635 ! ******************************************************************************
1636 
1637  CALL registerfunction(global,'RFLU_MPI_SetTag',&
1638  'RFLU_ModMPI.F90')
1639 
1640 ! ******************************************************************************
1641 ! Set tag
1642 ! ******************************************************************************
1643 
1644  iregmax = max(ireg1,ireg2)
1645  iregmin = min(ireg1,ireg2)
1646 
1647  rflu_mpi_settag = iregmin + (iregmax-1)*global%nRegions &
1648  + (iregmax-1)*(imsg-1)*global%nRegions*global%nRegions
1649 
1650  IF ( rflu_mpi_settag > tagmax ) THEN
1651  CALL errorstop(global,err_mpi_tagmax,__line__)
1652  END IF ! RFLU_MPI_SetTag
1653 
1654 ! ******************************************************************************
1655 ! End
1656 ! ******************************************************************************
1657 
1658  CALL deregisterfunction(global)
1659 
1660  END FUNCTION rflu_mpi_settag
1661 
1662 
1663 
1664 
1665 
1666 
1667 
1668 
1669 
1670 
1671 ! ******************************************************************************
1672 !
1673 ! Purpose: Wrapper for setting tags.
1674 !
1675 ! Description: None.
1676 !
1677 ! Input:
1678 ! pRegion Pointer to region
1679 !
1680 ! Output: None.
1681 !
1682 ! Notes: None.
1683 !
1684 ! ******************************************************************************
1685 
1686  SUBROUTINE rflu_mpi_settagswrapper(pRegion)
1687 
1688  IMPLICIT NONE
1689 
1690 ! ******************************************************************************
1691 ! Declarations and definitions
1692 ! ******************************************************************************
1693 
1694 ! ==============================================================================
1695 ! Arguments
1696 ! ==============================================================================
1697 
1698  TYPE(t_region), POINTER :: pregion
1699 
1700 ! ==============================================================================
1701 ! Local variables
1702 ! ==============================================================================
1703 
1704  LOGICAL :: dummylogical
1705  INTEGER :: errorflag,iborder,imsg,tagmax
1706  TYPE(t_border), POINTER :: pborder
1707  TYPE(t_global), POINTER :: global
1708  TYPE(t_grid), POINTER :: pgrid
1709 
1710 ! ******************************************************************************
1711 ! Start
1712 ! ******************************************************************************
1713 
1714  global => pregion%global
1715 
1716  CALL registerfunction(global,'RFLU_MPI_SetTagsWrapper',&
1717  'RFLU_ModMPI.F90')
1718 
1719 ! ******************************************************************************
1720 ! Set pointers
1721 ! ******************************************************************************
1722 
1723  pgrid => pregion%grid
1724 
1725 ! ******************************************************************************
1726 ! Get maximum allowed value of tag. NOTE must always use MPI_COMM_WORLD -
1727 ! cannot use global%mpiComm because may be split off in GENx computations
1728 ! and get zero tagMax as a result.
1729 ! ******************************************************************************
1730 
1731  CALL mpi_attr_get(mpi_comm_world,mpi_tag_ub,tagmax,dummylogical,errorflag)
1732  global%error = errorflag
1733  IF ( global%error /= err_none ) THEN
1734  CALL errorstop(global,err_mpi_output,__line__)
1735  END IF ! global%error
1736 
1737 ! ******************************************************************************
1738 ! Loop over borders
1739 ! ******************************************************************************
1740 
1741  DO iborder = 1,pgrid%nBorders
1742  pborder => pgrid%borders(iborder)
1743 
1744 ! ==============================================================================
1745 ! Mixture
1746 ! ==============================================================================
1747 
1748  imsg = 1
1749 
1750  pborder%mixt%tag = rflu_mpi_settag(global,pregion%iRegionGlobal, &
1751  pborder%iRegionGlobal,imsg,tagmax)
1752 
1753 ! ==============================================================================
1754 ! Physical modules
1755 ! ==============================================================================
1756 
1757 #ifdef SPEC
1758  imsg = imsg + 1
1759 
1760  pborder%spec%tag = rflu_mpi_settag(global,pregion%iRegionGlobal, &
1761  pborder%iRegionGlobal,imsg,tagmax)
1762 #endif
1763 
1764 #ifdef PLAG
1765  imsg = imsg + 1
1766 
1767  pborder%plag%tagCount = rflu_mpi_settag(global,pregion%iRegionGlobal, &
1768  pborder%iRegionGlobal,imsg,tagmax)
1769  imsg = imsg + 1
1770 
1771  pborder%plag%tagInt = rflu_mpi_settag(global,pregion%iRegionGlobal, &
1772  pborder%iRegionGlobal,imsg,tagmax)
1773  imsg = imsg + 1
1774 
1775  pborder%plag%tag = rflu_mpi_settag(global,pregion%iRegionGlobal, &
1776  pborder%iRegionGlobal,imsg,tagmax)
1777 #endif
1778  END DO ! iBorder
1779 
1780 ! ******************************************************************************
1781 ! End
1782 ! ******************************************************************************
1783 
1784  CALL deregisterfunction(global)
1785 
1786  END SUBROUTINE rflu_mpi_settagswrapper
1787 
1788 
1789 
1790 
1791 
1792 
1793 
1794 
1795 
1796 ! ******************************************************************************
1797 ! End
1798 ! ******************************************************************************
1799 
1800 END MODULE rflu_modmpi
1801 
1802 
1803 ! ******************************************************************************
1804 !
1805 ! RCS Revision history:
1806 !
1807 ! $Log: RFLU_ModMPI.F90,v $
1808 ! Revision 1.17 2008/12/06 08:44:22 mtcampbe
1809 ! Updated license.
1810 !
1811 ! Revision 1.16 2008/11/19 22:17:33 mtcampbe
1812 ! Added Illinois Open Source License/Copyright
1813 !
1814 ! Revision 1.15 2007/07/08 21:45:03 gzheng
1815 ! changed the PRESENT is used for PGI compiler
1816 !
1817 ! Revision 1.14 2006/04/07 15:19:19 haselbac
1818 ! Removed tabs
1819 !
1820 ! Revision 1.13 2006/02/09 03:37:44 haselbac
1821 ! Bug fix: Must always use MPI_COMM_WORLD to get max tag
1822 !
1823 ! Revision 1.12 2005/12/14 21:50:32 haselbac
1824 ! Cosmetics
1825 !
1826 ! Revision 1.11 2005/12/14 21:20:28 fnajjar
1827 ! Added subroutine and made changes for dynamic allocation of iPclsSend
1828 !
1829 ! Revision 1.10 2005/12/13 23:30:53 haselbac
1830 ! Cosmetics
1831 !
1832 ! Revision 1.9 2005/12/13 23:06:56 fnajjar
1833 ! Added defs of tag for PLAG
1834 !
1835 ! Revision 1.8 2005/12/08 03:01:01 haselbac
1836 ! Major bug fix: spec tag was not set
1837 !
1838 ! Revision 1.7 2005/12/03 19:48:23 haselbac
1839 ! Bug fix: Only clear request if have indeed sent message, cosmetics
1840 !
1841 ! Revision 1.6 2005/09/19 18:40:37 haselbac
1842 ! Added IFs for border sizes before send and recv
1843 !
1844 ! Revision 1.5 2005/07/08 15:01:29 haselbac
1845 ! Added profiling calls
1846 !
1847 ! Revision 1.4 2005/05/26 22:01:01 haselbac
1848 ! Fixed two serious bugs: status is array in recv and wait
1849 !
1850 ! Revision 1.3 2005/05/18 22:12:04 fnajjar
1851 ! ACH: Added routines to create and destroy iPclSend buffers
1852 !
1853 ! Revision 1.2 2005/04/29 00:05:47 haselbac
1854 ! Added MPI_Wait routines
1855 !
1856 ! Revision 1.1 2005/04/15 15:06:43 haselbac
1857 ! Initial revision
1858 !
1859 ! ******************************************************************************
1860 
1861 
1862 
1863 
1864 
1865 
1866 
1867 
1868 
1869 
1870 
1871 
1872 
1873 
1874 
1875 
1876 
1877 
1878 
1879 
1880 
1881 
1882 
subroutine, public rflu_mpi_destroybufferipclsend(pRegion, pBorder)
subroutine rflu_mpi_createbuffers(global, pBorder, borderData, nVars)
subroutine, public rflu_mpi_createbufferipclsend(pRegion, pBorder)
subroutine rflu_mpi_copycelldata(global, pBorder, pBorder2, cellData, cellData2)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:354
subroutine, public rflu_mpi_isendwrapper(pRegion)
subroutine registerfunction(global, funName, fileName)
Definition: ModError.F90:449
int status() const
Obtain the status of the attribute.
Definition: Attribute.h:240
INTEGER function rflu_mpi_settag(global, iReg1, iReg2, iMsg, tagMax)
subroutine, public rflu_mpi_clearrequestwrapper(pRegion)
subroutine rflu_mpi_recvcelldata(global, pBorder, cellDataBuff, cellData, tag)
subroutine, public rflu_mpi_recvwrapper(pRegion)
subroutine, public rflu_mpi_settagswrapper(pRegion)
subroutine, public rflu_mpi_createbufferswrapper(pRegion)
subroutine, public rflu_mpi_destroybufferswrapper(pRegion)
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
Definition: Vector_n.h:346
subroutine errorstop(global, errorCode, errorLine, addMessage)
Definition: ModError.F90:483
subroutine, public rflu_mpi_copywrapper(regions)
subroutine rflu_mpi_destroybuffers(global, pBorder, borderData)
subroutine rflu_mpi_clearrequest(global, request)
subroutine deregisterfunction(global)
Definition: ModError.F90:469
subroutine rflu_mpi_isendcelldata(global, pBorder, cellDataBuff, cellData, tag, request)
subroutine, public rflu_mpi_recreatebufferipclsend(pRegion, pBorder)