1 !-----------------------------------------------------------------------
3 !NCEP_MESO:MODEL_LAYER: SOLVER
5 !-----------------------------------------------------------------------
7 MODULE MODULE_PATCH_QUILT
9 !-----------------------------------------------------------------------
10 USE MODULE_EXT_INTERNAL
11 !-----------------------------------------------------------------------
14 PUBLIC :: PATCH,QUILT_2,QUILT_2_R8
16 !-----------------------------------------------------------------------
20 !-----------------------------------------------------------------------
21 !***********************************************************************
22 !-----------------------------------------------------------------------
23 SUBROUTINE PATCH(ARRAYG,ARRAYL &
24 &, IDS,IDE,JDS,JDE,KDS,KDE &
25 &, IMS,IME,JMS,JME,KMS,KME &
26 &, ITS,ITE,JTS,JTE,KTS,KTE)
27 !-----------------------------------------------------------------------
28 ! PATCH DISTRIBUTES THE ELEMENTS OF REAL GLOBAL 2-D ARRAY ARRAYG TO
29 ! THE REAL LOCAL 2-D ARRAY ARRAYL.
32 !-----------------------------------------------------------------------
36 !-----------------------------------------------------------------------
40 !-----------------------------------------------------------------------
41 !*** ARGUMENT VARIABLES
42 !-----------------------------------------------------------------------
44 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
45 &, IMS,IME,JMS,JME,KMS,KME &
46 &, ITS,ITE,JTS,JTE,KTS,KTE
48 REAL,DIMENSION(IDS:IDE,JDS:JDE),INTENT(IN) :: ARRAYG
49 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(OUT) :: ARRAYL
51 !-----------------------------------------------------------------------
53 !-----------------------------------------------------------------------
55 REAL,ALLOCATABLE,DIMENSION(:) :: ARRAYX
57 INTEGER :: I,IEND,IPE,IRECV,IRTN,ISEND,ISTART,J,JEND,JSTART,KNT &
58 &, L,MPI_COMM_COMP,NUMVALS,MYPE,NPES
60 INTEGER,DIMENSION(4) :: LIMITS
62 INTEGER,DIMENSION(MPI_STATUS_SIZE) :: ISTAT
64 ! SUBROUTINE wrf_global_to_patch_real (globbuf,buf,domdesc,stagger,ordering,&
65 ! DS1,DE1,DS2,DE2,DS3,DE3,&
66 ! MS1,ME1,MS2,ME2,MS3,ME3,&
67 ! PS1,PE1,PS2,PE2,PS3,PE3 )
69 ! INTEGER DS1,DE1,DS2,DE2,DS3,DE3,&
70 ! MS1,ME1,MS2,ME2,MS3,ME3,&
71 ! PS1,PE1,PS2,PE2,PS3,PE3
72 ! CHARACTER *(*) stagger,ordering
77 CALL WRF_GET_DM_COMMUNICATOR(MPI_COMM_COMP)
84 CALL wrf_global_to_patch_real( &
85 & arrayg, arrayl, mpi_comm_comp, 'xy', 'xy' &
86 &, IDS,IDE,JDS,JDE,1,1 &
87 &, IMS,IME,JMS,JME,1,1 &
88 &, ITS,ITE,JTS,JTE,1,1 )
91 !!-----------------------------------------------------------------------
92 !!***********************************************************************
93 !!-----------------------------------------------------------------------
95 !!-----------------------------------------------------------------------
96 !!*** GET OUR TASK ID AND THE COMMUNICATOR
97 !!-----------------------------------------------------------------------
99 ! CALL WRF_GET_MYPROC(MYPE)
100 ! CALL WRF_GET_DM_COMMUNICATOR(MPI_COMM_COMP)
101 ! CALL WRF_GET_NPROC(NPES)
102 ! allocate(requests(npes))
104 !!-----------------------------------------------------------------------
105 !!*** INITIALIZE THE OUTPUT ARRAY
106 !!-----------------------------------------------------------------------
114 !!-----------------------------------------------------------------------
115 !!*** TASK 0 FILLS ITS OWN LOCAL DOMAIN THEN PARCELS OUT ALL THE OTHER
116 !!*** PIECES TO THE OTHER TASKS.
117 !!-----------------------------------------------------------------------
119 !!-----------------------------------------------------------------------
120 ! tasks : IF(MYPE==0)THEN
121 !!-----------------------------------------------------------------------
125 ! ARRAYL(I,J)=ARRAYG(I,J)
129 !!-----------------------------------------------------------------------
130 !!*** TASK 0 NEEDS THE LIMITS FROM EACH OF THE OTHER TASKS AND THEN
131 !!*** SENDS OUT THE APPROPRIATE PIECE OF THE GLOBAL ARRAY.
132 !!-----------------------------------------------------------------------
136 ! CALL MPI_RECV(LIMITS,4,MPI_INTEGER,IPE,IPE,MPI_COMM_COMP &
144 ! NUMVALS=(IEND-ISTART+1)*(JEND-JSTART+1)
145 ! ALLOCATE(ARRAYX(NUMVALS),STAT=I)
152 ! ARRAYX(KNT)=ARRAYG(I,J)
156 ! CALL MPI_SEND(ARRAYX,KNT,MPI_REAL,IPE,IPE,MPI_COMM_COMP,ISEND)
162 !!-----------------------------------------------------------------------
163 !!*** ALL OTHER TASKS TELL TASK 0 WHAT THEIR HORIZONTAL LIMITS ARE AND
164 !!*** RECEIVE THEIR PIECE OF THE GLOBAL ARRAY FROM TASK 0.
165 !!-----------------------------------------------------------------------
174 ! CALL MPI_SEND(LIMITS,4,MPI_INTEGER,0,MYPE,MPI_COMM_COMP,ISEND)
176 ! NUMVALS=(ITE-ITS+1)*(JTE-JTS+1)
177 ! ALLOCATE(ARRAYX(NUMVALS),STAT=I)
179 ! CALL MPI_RECV(ARRAYX,NUMVALS,MPI_REAL,0,MYPE,MPI_COMM_COMP &
187 ! ARRAYL(I,J)=ARRAYX(KNT)
193 !!-----------------------------------------------------------------------
197 !-----------------------------------------------------------------------
198 ! CALL MPI_BARRIER(MPI_COMM_COMP,IRTN)
199 !-----------------------------------------------------------------------
203 !-----------------------------------------------------------------------
204 !***********************************************************************
205 !-----------------------------------------------------------------------
206 SUBROUTINE QUILT_2(ARRAYL,ARRAYG &
207 & ,IDS,IDE,JDS,JDE,KDS,KDE &
208 & ,IMS,IME,JMS,JME,KMS,KME &
209 & ,ITS,ITE,JTS,JTE,KTS,KTE)
210 !-----------------------------------------------------------------------
211 ! QUILT_2 PULLS TOGETHER THE MPI TASKS' LOCAL ARRAYS ARRAYL AND
212 ! THEN QUILTS THEM TOGETHER INTO A SINGLE GLOBAL ARRAY ARRAYG.
215 !-----------------------------------------------------------------------
219 !-----------------------------------------------------------------------
223 !-----------------------------------------------------------------------
224 !*** ARGUMENT VARIABLES
225 !-----------------------------------------------------------------------
227 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
228 &, IMS,IME,JMS,JME,KMS,KME &
229 &, ITS,ITE,JTS,JTE,KTS,KTE
231 REAL,DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: ARRAYL
232 REAL,DIMENSION(IDS:IDE,JDS:JDE),INTENT(OUT) :: ARRAYG
234 !-----------------------------------------------------------------------
236 !-----------------------------------------------------------------------
238 REAL,ALLOCATABLE,DIMENSION(:) :: ARRAYX
240 INTEGER :: I,IEND,IPE,IRECV,IRTN,ISEND,ISTART,J,JEND,JSTART,KNT &
241 &, L,MPI_COMM_COMP,NUMVALS,MYPE,NPES
243 INTEGER,DIMENSION(4) :: LIMITS
245 INTEGER,DIMENSION(MPI_STATUS_SIZE) :: ISTAT
246 !-----------------------------------------------------------------------
247 !***********************************************************************
248 !-----------------------------------------------------------------------
250 !-----------------------------------------------------------------------
251 !*** GET OUR TASK ID AND THE COMMUNICATOR
252 !-----------------------------------------------------------------------
254 CALL WRF_GET_MYPROC(MYPE)
255 CALL WRF_GET_DM_COMMUNICATOR(MPI_COMM_COMP)
256 CALL WRF_GET_NPROC(NPES)
258 !-----------------------------------------------------------------------
259 !*** INITIALIZE THE OUTPUT ARRAY
260 !-----------------------------------------------------------------------
268 CALL wrf_patch_to_global_real( &
269 & arrayl, arrayg, mpi_comm_comp, 'xy', 'xy' &
270 &, IDS,IDE,JDS,JDE,1,1 &
271 &, IMS,IME,JMS,JME,1,1 &
272 &, ITS,ITE,JTS,JTE,1,1 )
277 !!-----------------------------------------------------------------------
278 !!*** TASK 0 FILLS ITS OWN PART OF THE GLOBAL FIRST.
279 !!-----------------------------------------------------------------------
281 !!-----------------------------------------------------------------------
282 ! tasks : IF(MYPE==0)THEN
283 !!-----------------------------------------------------------------------
287 ! ARRAYG(I,J)=ARRAYL(I,J)
291 !!-----------------------------------------------------------------------
292 !!*** TASK 0 NEEDS THE LIMITS FROM EACH OF THE OTHER TASKS AND THEN
293 !!*** PULLS IN THE APPROPRIATE PIECES FROM ALL OTHER TASKS.
294 !!-----------------------------------------------------------------------
298 ! CALL MPI_RECV(LIMITS,4,MPI_INTEGER,IPE,IPE,MPI_COMM_COMP &
306 ! NUMVALS=(IEND-ISTART+1)*(JEND-JSTART+1)
307 ! ALLOCATE(ARRAYX(NUMVALS),STAT=I)
309 ! CALL MPI_RECV(ARRAYX,NUMVALS,MPI_REAL,IPE,IPE,MPI_COMM_COMP &
317 ! ARRAYG(I,J)=ARRAYX(KNT)
325 !!-----------------------------------------------------------------------
326 !!*** ALL OTHER TASKS TELL TASK 0 WHAT THEIR HORIZONTAL LIMITS ARE AND
327 !!*** SEND THEIR LOCAL ARRAY TO TASK 0.
328 !!-----------------------------------------------------------------------
337 ! CALL MPI_SEND(LIMITS,4,MPI_INTEGER,0,MYPE,MPI_COMM_COMP,ISEND)
339 ! NUMVALS=(ITE-ITS+1)*(JTE-JTS+1)
340 ! ALLOCATE(ARRAYX(NUMVALS),STAT=I)
347 ! ARRAYX(KNT)=ARRAYL(I,J)
351 ! CALL MPI_SEND(ARRAYX,NUMVALS,MPI_REAL,0,MYPE,MPI_COMM_COMP &
356 !!-----------------------------------------------------------------------
360 !-----------------------------------------------------------------------
361 ! CALL MPI_BARRIER(MPI_COMM_COMP,IRTN)
362 !-----------------------------------------------------------------------
364 END SUBROUTINE QUILT_2
366 !-----------------------------------------------------------------------
367 SUBROUTINE QUILT_2_R8(ARRAYL,ARRAYG &
368 & ,IDS,IDE,JDS,JDE,KDS,KDE &
369 & ,IMS,IME,JMS,JME,KMS,KME &
370 & ,ITS,ITE,JTS,JTE,KTS,KTE)
371 !-----------------------------------------------------------------------
372 ! QUILT_2 PULLS TOGETHER THE MPI TASKS' LOCAL ARRAYS ARRAYL AND
373 ! THEN QUILTS THEM TOGETHER INTO A SINGLE GLOBAL ARRAY ARRAYG.
376 !-----------------------------------------------------------------------
380 !-----------------------------------------------------------------------
384 !-----------------------------------------------------------------------
385 !*** ARGUMENT VARIABLES
386 !-----------------------------------------------------------------------
388 INTEGER,INTENT(IN) :: IDS,IDE,JDS,JDE,KDS,KDE &
389 &, IMS,IME,JMS,JME,KMS,KME &
390 &, ITS,ITE,JTS,JTE,KTS,KTE
392 REAL(kind=8),DIMENSION(IMS:IME,JMS:JME),INTENT(IN) :: ARRAYL
393 REAL(kind=8),DIMENSION(IDS:IDE,JDS:JDE),INTENT(OUT) :: ARRAYG
395 !-----------------------------------------------------------------------
397 !-----------------------------------------------------------------------
399 REAL,ALLOCATABLE,DIMENSION(:) :: ARRAYX
401 INTEGER :: I,IEND,IPE,IRECV,IRTN,ISEND,ISTART,J,JEND,JSTART,KNT &
402 &, L,MPI_COMM_COMP,NUMVALS,MYPE,NPES
404 INTEGER,DIMENSION(4) :: LIMITS
406 INTEGER,DIMENSION(MPI_STATUS_SIZE) :: ISTAT
407 !-----------------------------------------------------------------------
408 !***********************************************************************
409 !-----------------------------------------------------------------------
411 !-----------------------------------------------------------------------
412 !*** GET OUR TASK ID AND THE COMMUNICATOR
413 !-----------------------------------------------------------------------
415 CALL WRF_GET_MYPROC(MYPE)
416 CALL WRF_GET_DM_COMMUNICATOR(MPI_COMM_COMP)
417 CALL WRF_GET_NPROC(NPES)
419 !-----------------------------------------------------------------------
420 !*** INITIALIZE THE OUTPUT ARRAY
421 !-----------------------------------------------------------------------
429 CALL wrf_patch_to_global_double( &
430 & arrayl, arrayg, mpi_comm_comp, 'xy', 'xy' &
431 &, IDS,IDE,JDS,JDE,1,1 &
432 &, IMS,IME,JMS,JME,1,1 &
433 &, ITS,ITE,JTS,JTE,1,1 )
438 !!-----------------------------------------------------------------------
439 !!*** TASK 0 FILLS ITS OWN PART OF THE GLOBAL FIRST.
440 !!-----------------------------------------------------------------------
442 !!-----------------------------------------------------------------------
443 ! tasks : IF(MYPE==0)THEN
444 !!-----------------------------------------------------------------------
448 ! ARRAYG(I,J)=ARRAYL(I,J)
452 !!-----------------------------------------------------------------------
453 !!*** TASK 0 NEEDS THE LIMITS FROM EACH OF THE OTHER TASKS AND THEN
454 !!*** PULLS IN THE APPROPRIATE PIECES FROM ALL OTHER TASKS.
455 !!-----------------------------------------------------------------------
459 ! CALL MPI_RECV(LIMITS,4,MPI_INTEGER,IPE,IPE,MPI_COMM_COMP &
467 ! NUMVALS=(IEND-ISTART+1)*(JEND-JSTART+1)
468 ! ALLOCATE(ARRAYX(NUMVALS),STAT=I)
470 ! CALL MPI_RECV(ARRAYX,NUMVALS,MPI_REAL,IPE,IPE,MPI_COMM_COMP &
478 ! ARRAYG(I,J)=ARRAYX(KNT)
486 !!-----------------------------------------------------------------------
487 !!*** ALL OTHER TASKS TELL TASK 0 WHAT THEIR HORIZONTAL LIMITS ARE AND
488 !!*** SEND THEIR LOCAL ARRAY TO TASK 0.
489 !!-----------------------------------------------------------------------
498 ! CALL MPI_SEND(LIMITS,4,MPI_INTEGER,0,MYPE,MPI_COMM_COMP,ISEND)
500 ! NUMVALS=(ITE-ITS+1)*(JTE-JTS+1)
501 ! ALLOCATE(ARRAYX(NUMVALS),STAT=I)
508 ! ARRAYX(KNT)=ARRAYL(I,J)
512 ! CALL MPI_SEND(ARRAYX,NUMVALS,MPI_REAL,0,MYPE,MPI_COMM_COMP &
517 !!-----------------------------------------------------------------------
521 !-----------------------------------------------------------------------
522 ! CALL MPI_BARRIER(MPI_COMM_COMP,IRTN)
523 !-----------------------------------------------------------------------
525 END SUBROUTINE QUILT_2_R8
527 !-----------------------------------------------------------------------
529 END MODULE MODULE_PATCH_QUILT
531 !-----------------------------------------------------------------------