29 use mpp_mod,
only : fatal, mpp_debug, note, mpp_clock_sync,mpp_clock_detailed, warning
30 use mpp_mod,
only : mpp_pe, mpp_npes, mpp_node, mpp_root_pe,
mpp_error, mpp_set_warn_level
31 use mpp_mod,
only : mpp_declare_pelist, mpp_set_current_pelist, mpp_sync
32 use mpp_mod,
only : mpp_clock_begin, mpp_clock_end, mpp_clock_id
35 use mpp_domains_mod,
only : global_data_domain, bitwise_exact_sum, bgrid_ne, fold_north_edge, cgrid_ne
36 use mpp_domains_mod,
only : mpp_domain_time, cyclic_global_domain, nupdate,eupdate, xupdate, yupdate, scalar_pair
52 use mpp_mod,
only : mpp_get_current_pelist, mpp_set_current_pelist
63 integer,
parameter:: ng = 3
66 integer,
parameter :: XDir=1
67 integer,
parameter :: YDir=2
68 integer :: commglobal, ierror, npes
73 integer,
allocatable,
dimension(:) :: npes_tile, tile1, tile2
74 integer,
allocatable,
dimension(:) :: istart1, iend1, jstart1, jend1
75 integer,
allocatable,
dimension(:) :: istart2, iend2, jstart2, jend2
76 integer,
allocatable,
dimension(:,:) :: layout2D, global_indices
77 integer :: numthreads, gid, masterproc
81 type(nest_domain_type),
allocatable,
dimension(:) :: nest_domain
82 integer :: this_pe_grid = 0
83 integer,
EXTERNAL :: omp_get_thread_num, omp_get_num_threads
85 integer :: npes_this_grid
90 integer :: is, ie, js, je
91 integer :: isd, ied, jsd, jed
92 integer :: isc, iec, jsc, jec
94 public mp_start, mp_assign_gid, mp_barrier, mp_stop
95 public domain_decomp, mp_bcst, mp_reduce_max, mp_reduce_sum, mp_gather
97 public fill_corners, xdir, ydir
98 public switch_current_domain, switch_current_atm, broadcast_domains
99 public is_master, setup_master
103 public is, ie, js, je, isd, ied, jsd, jed, isc, iec, jsc, jec, ng, tile
104 public start_group_halo_update, complete_group_halo_update
105 public group_halo_update_type
107 interface start_group_halo_update
108 module procedure start_var_group_update_2d
109 module procedure start_var_group_update_3d
110 module procedure start_var_group_update_4d
111 module procedure start_vector_group_update_2d
112 module procedure start_vector_group_update_3d
113 end interface start_group_halo_update
115 INTERFACE fill_corners
116 MODULE PROCEDURE fill_corners_2d_r4
117 MODULE PROCEDURE fill_corners_2d_r8
118 MODULE PROCEDURE fill_corners_xy_2d_r4
119 MODULE PROCEDURE fill_corners_xy_2d_r8
120 MODULE PROCEDURE fill_corners_xy_3d_r4
121 MODULE PROCEDURE fill_corners_xy_3d_r8
124 INTERFACE fill_corners_agrid
125 MODULE PROCEDURE fill_corners_agrid_r4
126 MODULE PROCEDURE fill_corners_agrid_r8
129 INTERFACE fill_corners_cgrid
130 MODULE PROCEDURE fill_corners_cgrid_r4
131 MODULE PROCEDURE fill_corners_cgrid_r8
134 INTERFACE fill_corners_dgrid
135 MODULE PROCEDURE fill_corners_dgrid_r4
136 MODULE PROCEDURE fill_corners_dgrid_r8
140 MODULE PROCEDURE mp_bcst_i4
141 MODULE PROCEDURE mp_bcst_r4
142 MODULE PROCEDURE mp_bcst_r8
143 MODULE PROCEDURE mp_bcst_3d_r4
144 MODULE PROCEDURE mp_bcst_3d_r8
145 MODULE PROCEDURE mp_bcst_4d_r4
146 MODULE PROCEDURE mp_bcst_4d_r8
147 MODULE PROCEDURE mp_bcst_3d_i8
148 MODULE PROCEDURE mp_bcst_4d_i8
151 INTERFACE mp_reduce_min
152 MODULE PROCEDURE mp_reduce_min_r4
153 MODULE PROCEDURE mp_reduce_min_r8
156 INTERFACE mp_reduce_max
157 MODULE PROCEDURE mp_reduce_max_r4_1d
158 MODULE PROCEDURE mp_reduce_max_r4
159 MODULE PROCEDURE mp_reduce_max_r8_1d
160 MODULE PROCEDURE mp_reduce_max_r8
161 MODULE PROCEDURE mp_reduce_max_i4
164 INTERFACE mp_reduce_sum
165 MODULE PROCEDURE mp_reduce_sum_r4
166 MODULE PROCEDURE mp_reduce_sum_r4_1d
167 MODULE PROCEDURE mp_reduce_sum_r8
168 MODULE PROCEDURE mp_reduce_sum_r8_1d
172 MODULE PROCEDURE mp_gather_4d_r4
173 MODULE PROCEDURE mp_gather_3d_r4
174 MODULE PROCEDURE mp_gather_3d_r8
177 integer :: halo_update_type = 1
181 subroutine mp_assign_gid
186 end subroutine mp_assign_gid
193 subroutine mp_start(commID, halo_update_type_in)
194 integer,
intent(in),
optional :: commID
195 integer,
intent(in),
optional :: halo_update_type_in
200 masterproc = mpp_root_pe()
201 commglobal = mpi_comm_world
202 if(
PRESENT(commid) )
then 205 halo_update_type = halo_update_type_in
214 if ( mpp_pe()==mpp_root_pe() )
then 217 write(unit,*)
'Starting PEs : ', mpp_npes()
218 write(unit,*)
'Starting Threads : ', numthreads
223 if (mpp_npes() > 1)
call mpi_barrier(commglobal, ierror)
225 end subroutine mp_start
230 logical function is_master()
234 end function is_master
236 subroutine setup_master(pelist_local)
238 integer,
intent(IN) :: pelist_local(:)
240 if (any(gid == pelist_local))
then 242 masterproc = pelist_local(1)
243 master = (gid == masterproc)
247 end subroutine setup_master
254 subroutine mp_barrier()
256 call mpi_barrier(commglobal, ierror)
258 end subroutine mp_barrier
270 call mpi_barrier(commglobal, ierror)
271 if (gid==masterproc) print*,
'Stopping PEs : ', npes
275 end subroutine mp_stop
285 subroutine domain_decomp(npx,npy,nregions,grid_type,nested,Atm,layout,io_layout)
287 integer,
intent(IN) :: npx,npy,grid_type
288 integer,
intent(INOUT) :: nregions
289 logical,
intent(IN):: nested
290 type(fv_atmos_type),
intent(INOUT),
target :: Atm
291 integer,
intent(INOUT) :: layout(2), io_layout(2)
293 integer,
allocatable :: pe_start(:), pe_end(:)
295 integer :: nx,ny,n,num_alloc
296 character(len=32) ::
type =
"unknown" 297 logical :: is_symmetry
298 logical :: debug=.false.
299 integer,
allocatable :: tile_id(:)
302 integer :: npes_x, npes_y
304 integer,
pointer :: pelist(:), grid_number, num_contact, npes_per_tile
305 logical,
pointer :: square_domain
306 type(domain2D),
pointer :: domain, domain_for_coupler
313 grid_number => atm%grid_number
314 num_contact => atm%num_contact
316 domain_for_coupler => atm%domain_for_coupler
317 npes_per_tile => atm%npes_per_tile
323 call mpp_domains_init(mpp_domain_time)
329 call mpp_domains_set_stack_size(6000000)
331 call mpp_domains_set_stack_size(3000000)
334 select case(nregions)
340 type =
"Cubed-sphere nested grid" 342 type =
"Cubed-sphere, single face" 346 npes_per_tile = npes_x*npes_y
347 if (npes_per_tile==0)
then 348 npes_per_tile = npes/nregions
353 if ( npes_x == 0 )
then 356 if ( npes_y == 0 )
then 360 if ( npes_x==npes_y .and. (npx-1)==((npx-1)/npes_x)*npes_x ) atm%gridstruct%square_domain = .true.
362 if ( (npx/npes_x < ng) .or. (npy/npes_y < ng) )
then 363 write(*,310) npes_x, npes_y, npx/npes_x, npy/npes_y
368 layout = (/npes_x,npes_y/)
370 type=
"Lat-Lon: cyclic" 373 if( mod(npes,nregions) .NE. 0 )
then 374 call mpp_error(note,
'TEST_MPP_DOMAINS: for Cyclic mosaic, npes should be multiple of nregions. ' // &
375 'No test is done for Cyclic mosaic. ' )
378 npes_per_tile = npes/nregions
380 layout = (/1,npes_per_tile/)
382 type=
"Cartesian: double periodic" 385 npes_per_tile = npes/nregions
386 if(npes_x*npes_y == npes_per_tile)
then 387 layout = (/npes_x,npes_y/)
392 type=
"Lat-Lon: patch" 395 npes_per_tile = npes/nregions
398 type=
"Lat-Lon: strip" 401 npes_per_tile = npes/nregions
404 type=
"Cartesian: channel" 407 npes_per_tile = npes/nregions
412 type=
"Cubic: cubed-sphere" 414 call mpp_error(fatal,
'For a nested grid with grid_type < 3 nregions_domain must equal 1.')
419 npes_per_tile = npes_x*npes_y
420 if (npes_per_tile==0)
then 421 npes_per_tile = npes/nregions
425 if ( npes_x == 0 )
then 428 if ( npes_y == 0 )
then 432 if ( npes_x==npes_y .and. (npx-1)==((npx-1)/npes_x)*npes_x ) atm%gridstruct%square_domain = .true.
434 if ( (npx/npes_x < ng) .or. (npy/npes_y < ng) )
then 435 write(*,310) npes_x, npes_y, npx/npes_x, npy/npes_y
436 310
format(
'Invalid layout, NPES_X:',i4.4,
'NPES_Y:',i4.4,
'ncells_X:',i4.4,
'ncells_Y:',i4.4)
441 layout = (/npes_x,npes_y/)
443 call mpp_error(fatal,
'domain_decomp: no such test: '//type)
446 allocate(layout2d(2,nregions), global_indices(4,nregions), npes_tile(nregions) )
447 allocate(pe_start(nregions),pe_end(nregions))
448 npes_tile = npes_per_tile
450 global_indices(:,n) = (/1,npx-1,1,npy-1/)
451 layout2d(:,n) = layout
452 pe_start(n) = pelist(1) + (n-1)*layout(1)*layout(2)
453 pe_end(n) = pe_start(n) + layout(1)*layout(2) -1
455 num_alloc=
max(1,num_contact)
456 allocate(tile1(num_alloc), tile2(num_alloc) )
457 allocate(istart1(num_alloc), iend1(num_alloc), jstart1(num_alloc), jend1(num_alloc) )
458 allocate(istart2(num_alloc), iend2(num_alloc), jstart2(num_alloc), jend2(num_alloc) )
461 select case(nregions)
469 tile1(1) = 1; tile2(1) = 2
470 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
471 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
473 tile1(2) = 1; tile2(2) = 3
474 istart1(2) = 1; iend1(2) = nx; jstart1(2) = 1; jend1(2) = 1
475 istart2(2) = 1; iend2(2) = nx; jstart2(2) = ny; jend2(2) = ny
477 tile1(3) = 1; tile2(3) = 2
478 istart1(3) = 1; iend1(3) = 1; jstart1(3) = 1; jend1(3) = ny
479 istart2(3) = nx; iend2(3) = nx; jstart2(3) = 1; jend2(3) = ny
481 tile1(4) = 1; tile2(4) = 3
482 istart1(4) = 1; iend1(4) = nx; jstart1(4) = ny; jend1(4) = ny
483 istart2(4) = 1; iend2(4) = nx; jstart2(4) = 1; jend2(4) = 1
485 tile1(5) = 2; tile2(5) = 4
486 istart1(5) = 1; iend1(5) = nx; jstart1(5) = 1; jend1(5) = 1
487 istart2(5) = 1; iend2(5) = nx; jstart2(5) = ny; jend2(5) = ny
489 tile1(6) = 2; tile2(6) = 4
490 istart1(6) = 1; iend1(6) = nx; jstart1(6) = ny; jend1(6) = ny
491 istart2(6) = 1; iend2(6) = nx; jstart2(6) = 1; jend2(6) = 1
493 tile1(7) = 3; tile2(7) = 4
494 istart1(7) = nx; iend1(7) = nx; jstart1(7) = 1; jend1(7) = ny
495 istart2(7) = 1; iend2(7) = 1; jstart2(7) = 1; jend2(7) = ny
497 tile1(8) = 3; tile2(8) = 4
498 istart1(8) = 1; iend1(8) = 1; jstart1(8) = 1; jend1(8) = ny
499 istart2(8) = nx; iend2(8) = nx; jstart2(8) = 1; jend2(8) = ny
500 is_symmetry = .false.
503 tile1(1) = 1; tile2(1) = 1
504 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
505 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
507 tile1(2) = 1; tile2(2) = 1
508 istart1(2) = 1; iend1(2) = nx; jstart1(2) = 1; jend1(2) = 1
509 istart2(2) = 1; iend2(2) = nx; jstart2(2) = ny; jend2(2) = ny
514 tile1(1) = 1; tile2(1) = 1
515 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
516 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
519 tile1(1) = 1; tile2(1) = 1
520 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
521 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
526 tile1(1) = 1; tile2(1) = 2
527 istart1(1) = nx; iend1(1) = nx; jstart1(1) = 1; jend1(1) = ny
528 istart2(1) = 1; iend2(1) = 1; jstart2(1) = 1; jend2(1) = ny
530 tile1(2) = 1; tile2(2) = 3
531 istart1(2) = 1; iend1(2) = nx; jstart1(2) = ny; jend1(2) = ny
532 istart2(2) = 1; iend2(2) = 1; jstart2(2) = ny; jend2(2) = 1
534 tile1(3) = 1; tile2(3) = 5
535 istart1(3) = 1; iend1(3) = 1; jstart1(3) = 1; jend1(3) = ny
536 istart2(3) = nx; iend2(3) = 1; jstart2(3) = ny; jend2(3) = ny
538 tile1(4) = 1; tile2(4) = 6
539 istart1(4) = 1; iend1(4) = nx; jstart1(4) = 1; jend1(4) = 1
540 istart2(4) = 1; iend2(4) = nx; jstart2(4) = ny; jend2(4) = ny
542 tile1(5) = 2; tile2(5) = 3
543 istart1(5) = 1; iend1(5) = nx; jstart1(5) = ny; jend1(5) = ny
544 istart2(5) = 1; iend2(5) = nx; jstart2(5) = 1; jend2(5) = 1
546 tile1(6) = 2; tile2(6) = 4
547 istart1(6) = nx; iend1(6) = nx; jstart1(6) = 1; jend1(6) = ny
548 istart2(6) = nx; iend2(6) = 1; jstart2(6) = 1; jend2(6) = 1
550 tile1(7) = 2; tile2(7) = 6
551 istart1(7) = 1; iend1(7) = nx; jstart1(7) = 1; jend1(7) = 1
552 istart2(7) = nx; iend2(7) = nx; jstart2(7) = ny; jend2(7) = 1
554 tile1(8) = 3; tile2(8) = 4
555 istart1(8) = nx; iend1(8) = nx; jstart1(8) = 1; jend1(8) = ny
556 istart2(8) = 1; iend2(8) = 1; jstart2(8) = 1; jend2(8) = ny
558 tile1(9) = 3; tile2(9) = 5
559 istart1(9) = 1; iend1(9) = nx; jstart1(9) = ny; jend1(9) = ny
560 istart2(9) = 1; iend2(9) = 1; jstart2(9) = ny; jend2(9) = 1
562 tile1(10) = 4; tile2(10) = 5
563 istart1(10) = 1; iend1(10) = nx; jstart1(10) = ny; jend1(10) = ny
564 istart2(10) = 1; iend2(10) = nx; jstart2(10) = 1; jend2(10) = 1
566 tile1(11) = 4; tile2(11) = 6
567 istart1(11) = nx; iend1(11) = nx; jstart1(11) = 1; jend1(11) = ny
568 istart2(11) = nx; iend2(11) = 1; jstart2(11) = 1; jend2(11) = 1
570 tile1(12) = 5; tile2(12) = 6
571 istart1(12) = nx; iend1(12) = nx; jstart1(12) = 1; jend1(12) = ny
572 istart2(12) = 1; iend2(12) = 1; jstart2(12) = 1; jend2(12) = ny
575 if ( any(pelist == gid) )
then 576 allocate(tile_id(nregions))
578 if( nregions .NE. 1 )
then 579 call mpp_error(fatal,
'domain_decomp: nregions should be 1 for nested region, contact developer')
588 call mpp_define_mosaic(global_indices, layout2d, domain, nregions, num_contact, tile1, tile2, &
589 istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2, &
590 pe_start=pe_start, pe_end=pe_end, symmetry=is_symmetry, &
591 shalo = ng, nhalo = ng, whalo = ng, ehalo = ng, tile_id=tile_id, name = type)
592 call mpp_define_mosaic(global_indices, layout2d, domain_for_coupler, nregions, num_contact, tile1, tile2, &
593 istart1, iend1, jstart1, jend1, istart2, iend2, jstart2, jend2, &
594 pe_start=pe_start, pe_end=pe_end, symmetry=is_symmetry, &
595 shalo = 1, nhalo = 1, whalo = 1, ehalo = 1, tile_id=tile_id, name = type)
597 call mpp_define_io_domain(domain, io_layout)
598 call mpp_define_io_domain(domain_for_coupler, io_layout)
602 deallocate(pe_start,pe_end)
603 deallocate(layout2d, global_indices, npes_tile)
604 deallocate(tile1, tile2)
605 deallocate(istart1, iend1, jstart1, jend1)
606 deallocate(istart2, iend2, jstart2, jend2)
609 atm%tile = (gid-pelist(1))/npes_per_tile+1
610 if (any(pelist == gid))
then 611 npes_this_grid = npes_per_tile*nregions
631 if (debug .and. nregions==1)
then 633 write(*,200) tile, is, ie, js, je
637 200
format(i4.4,
' ', i4.4,
' ', i4.4,
' ', i4.4,
' ', i4.4,
' ')
657 end subroutine domain_decomp
662 subroutine start_var_group_update_2d(group, array, domain, flags, position, whalo, ehalo, shalo, nhalo, complete)
663 type(group_halo_update_type),
intent(inout) :: group
664 real,
dimension(:,:),
intent(inout) :: array
665 type(domain2D),
intent(inout) :: domain
666 integer,
optional,
intent(in) :: flags
667 integer,
optional,
intent(in) :: position
668 integer,
optional,
intent(in) :: whalo, ehalo, shalo, nhalo
669 logical,
optional,
intent(in) :: complete
671 logical :: is_complete
686 if (mpp_group_update_initialized(group))
then 690 whalo=whalo, ehalo=ehalo, shalo=shalo, nhalo=nhalo)
694 if(
present(complete)) is_complete = complete
695 if(is_complete .and. halo_update_type == 1)
then 699 end subroutine start_var_group_update_2d
702 subroutine start_var_group_update_3d(group, array, domain, flags, position, whalo, ehalo, shalo, nhalo, complete)
703 type(group_halo_update_type),
intent(inout) :: group
704 real,
dimension(:,:,:),
intent(inout) :: array
705 type(domain2D),
intent(inout) :: domain
706 integer,
optional,
intent(in) :: flags
707 integer,
optional,
intent(in) :: position
708 integer,
optional,
intent(in) :: whalo, ehalo, shalo, nhalo
709 logical,
optional,
intent(in) :: complete
711 logical :: is_complete
727 if (mpp_group_update_initialized(group))
then 731 whalo=whalo, ehalo=ehalo, shalo=shalo, nhalo=nhalo)
735 if(
present(complete)) is_complete = complete
736 if(is_complete .and. halo_update_type == 1 )
then 740 end subroutine start_var_group_update_3d
742 subroutine start_var_group_update_4d(group, array, domain, flags, position, whalo, ehalo, shalo, nhalo, complete)
743 type(group_halo_update_type),
intent(inout) :: group
744 real,
dimension(:,:,:,:),
intent(inout) :: array
745 type(domain2D),
intent(inout) :: domain
746 integer,
optional,
intent(in) :: flags
747 integer,
optional,
intent(in) :: position
748 integer,
optional,
intent(in) :: whalo, ehalo, shalo, nhalo
749 logical,
optional,
intent(in) :: complete
751 logical :: is_complete
769 if (mpp_group_update_initialized(group))
then 773 whalo=whalo, ehalo=ehalo, shalo=shalo, nhalo=nhalo)
777 if(
present(complete)) is_complete = complete
778 if(is_complete .and. halo_update_type == 1 )
then 782 end subroutine start_var_group_update_4d
786 subroutine start_vector_group_update_2d(group, u_cmpt, v_cmpt, domain, flags, gridtype, whalo, ehalo, shalo, nhalo, complete)
787 type(group_halo_update_type),
intent(inout) :: group
788 real,
dimension(:,:),
intent(inout) :: u_cmpt, v_cmpt
789 type(domain2d),
intent(inout) :: domain
790 integer,
optional,
intent(in) :: flags
791 integer,
optional,
intent(in) :: gridtype
792 integer,
optional,
intent(in) :: whalo, ehalo, shalo, nhalo
793 logical,
optional,
intent(in) :: complete
795 logical :: is_complete
815 if (mpp_group_update_initialized(group))
then 819 flags=flags, gridtype=gridtype, &
820 whalo=whalo, ehalo=ehalo, shalo=shalo, nhalo=nhalo)
824 if(
present(complete)) is_complete = complete
825 if(is_complete .and. halo_update_type == 1 )
then 829 end subroutine start_vector_group_update_2d
831 subroutine start_vector_group_update_3d(group, u_cmpt, v_cmpt, domain, flags, gridtype, whalo, ehalo, shalo, nhalo, complete)
832 type(group_halo_update_type),
intent(inout) :: group
833 real,
dimension(:,:,:),
intent(inout) :: u_cmpt, v_cmpt
834 type(domain2d),
intent(inout) :: domain
835 integer,
optional,
intent(in) :: flags
836 integer,
optional,
intent(in) :: gridtype
837 integer,
optional,
intent(in) :: whalo, ehalo, shalo, nhalo
838 logical,
optional,
intent(in) :: complete
840 logical :: is_complete
860 if (mpp_group_update_initialized(group))
then 864 flags=flags, gridtype=gridtype, &
865 whalo=whalo, ehalo=ehalo, shalo=shalo, nhalo=nhalo)
869 if(
present(complete)) is_complete = complete
870 if(is_complete .and. halo_update_type == 1)
then 874 end subroutine start_vector_group_update_3d
877 subroutine complete_group_halo_update(group, domain)
878 type(group_halo_update_type),
intent(inout) :: group
879 type(domain2d),
intent(inout) :: domain
886 if( halo_update_type == 1 )
then 892 end subroutine complete_group_halo_update
897 subroutine broadcast_domains(Atm)
899 type(fv_atmos_type),
intent(INOUT) :: Atm(:)
901 integer :: n, i1, i2, j1, j2, i
902 integer :: ens_root_pe, ensemble_id
910 ens_root_pe = (ensemble_id-1)*npes
913 call mpp_set_current_pelist((/ (i,i=ens_root_pe,npes-1+ens_root_pe) /))
919 end subroutine broadcast_domains
921 subroutine switch_current_domain(new_domain,new_domain_for_coupler)
923 type(domain2D),
intent(in),
target :: new_domain, new_domain_for_coupler
924 logical,
parameter :: debug = .false.
941 end subroutine switch_current_domain
943 subroutine switch_current_atm(new_Atm, switch_domain)
945 type(fv_atmos_type),
intent(IN),
target :: new_Atm
946 logical,
intent(IN),
optional :: switch_domain
947 logical,
parameter :: debug = .false.
950 if (debug .AND. (gid==masterproc)) print*,
'SWITCHING ATM STRUCTURES', new_atm%grid_number
951 if (
present(switch_domain))
then 956 if (swd)
call switch_current_domain(new_atm%domain, new_atm%domain_for_coupler)
961 end subroutine switch_current_atm
966 subroutine fill_corners_2d_r4(q, npx, npy, FILL, AGRID, BGRID)
967 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: q
968 integer,
intent(IN):: npx,npy
969 integer,
intent(IN):: FILL
970 logical,
OPTIONAL,
intent(IN) :: AGRID, BGRID
973 if (
present(bgrid))
then 979 if ((is== 1) .and. (js== 1)) q(1-i ,1-j ) = q(1-j ,i+1 )
980 if ((is== 1) .and. (je==npy-1)) q(1-i ,npy+j) = q(1-j ,npy-i )
981 if ((ie==npx-1) .and. (js== 1)) q(npx+i,1-j ) = q(npx+j,i+1 )
982 if ((ie==npx-1) .and. (je==npy-1)) q(npx+i,npy+j) = q(npx+j,npy-i )
988 if ((is== 1) .and. (js== 1)) q(1-j ,1-i ) = q(i+1 ,1-j )
989 if ((is== 1) .and. (je==npy-1)) q(1-j ,npy+i) = q(i+1 ,npy+j )
990 if ((ie==npx-1) .and. (js== 1)) q(npx+j,1-i ) = q(npx-i,1-j )
991 if ((ie==npx-1) .and. (je==npy-1)) q(npx+j,npy+i) = q(npx-i,npy+j )
997 if ((is== 1) .and. (js== 1)) q(1-i ,1-j ) = q(1-j ,i+1 )
998 if ((is== 1) .and. (je==npy-1)) q(1-i ,npy+j) = q(1-j ,npy-i )
999 if ((ie==npx-1) .and. (js== 1)) q(npx+i,1-j ) = q(npx+j,i+1 )
1000 if ((ie==npx-1) .and. (je==npy-1)) q(npx+i,npy+j) = q(npx+j,npy-i )
1005 elseif (
present(agrid))
then 1011 if ((is== 1) .and. (js== 1)) q(1-i ,1-j ) = q(1-j ,i )
1012 if ((is== 1) .and. (je==npy-1)) q(1-i ,npy-1+j) = q(1-j ,npy-1-i+1)
1013 if ((ie==npx-1) .and. (js== 1)) q(npx-1+i,1-j ) = q(npx-1+j,i )
1014 if ((ie==npx-1) .and. (je==npy-1)) q(npx-1+i,npy-1+j) = q(npx-1+j,npy-1-i+1)
1020 if ((is== 1) .and. (js== 1)) q(1-j ,1-i ) = q(i ,1-j )
1021 if ((is== 1) .and. (je==npy-1)) q(1-j ,npy-1+i) = q(i ,npy-1+j)
1022 if ((ie==npx-1) .and. (js== 1)) q(npx-1+j,1-i ) = q(npx-1-i+1,1-j )
1023 if ((ie==npx-1) .and. (je==npy-1)) q(npx-1+j,npy-1+i) = q(npx-1-i+1,npy-1+j)
1029 if ((is== 1) .and. (js== 1)) q(1-j ,1-i ) = q(i ,1-j )
1030 if ((is== 1) .and. (je==npy-1)) q(1-j ,npy-1+i) = q(i ,npy-1+j)
1031 if ((ie==npx-1) .and. (js== 1)) q(npx-1+j,1-i ) = q(npx-1-i+1,1-j )
1032 if ((ie==npx-1) .and. (je==npy-1)) q(npx-1+j,npy-1+i) = q(npx-1-i+1,npy-1+j)
1039 end subroutine fill_corners_2d_r4
1046 subroutine fill_corners_2d_r8(q, npx, npy, FILL, AGRID, BGRID)
1047 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: q
1048 integer,
intent(IN):: npx,npy
1049 integer,
intent(IN):: FILL
1050 logical,
OPTIONAL,
intent(IN) :: AGRID, BGRID
1053 if (
present(bgrid))
then 1059 if ((is== 1) .and. (js== 1)) q(1-i ,1-j ) = q(1-j ,i+1 )
1060 if ((is== 1) .and. (je==npy-1)) q(1-i ,npy+j) = q(1-j ,npy-i )
1061 if ((ie==npx-1) .and. (js== 1)) q(npx+i,1-j ) = q(npx+j,i+1 )
1062 if ((ie==npx-1) .and. (je==npy-1)) q(npx+i,npy+j) = q(npx+j,npy-i )
1068 if ((is== 1) .and. (js== 1)) q(1-j ,1-i ) = q(i+1 ,1-j )
1069 if ((is== 1) .and. (je==npy-1)) q(1-j ,npy+i) = q(i+1 ,npy+j )
1070 if ((ie==npx-1) .and. (js== 1)) q(npx+j,1-i ) = q(npx-i,1-j )
1071 if ((ie==npx-1) .and. (je==npy-1)) q(npx+j,npy+i) = q(npx-i,npy+j )
1077 if ((is== 1) .and. (js== 1)) q(1-i ,1-j ) = q(1-j ,i+1 )
1078 if ((is== 1) .and. (je==npy-1)) q(1-i ,npy+j) = q(1-j ,npy-i )
1079 if ((ie==npx-1) .and. (js== 1)) q(npx+i,1-j ) = q(npx+j,i+1 )
1080 if ((ie==npx-1) .and. (je==npy-1)) q(npx+i,npy+j) = q(npx+j,npy-i )
1085 elseif (
present(agrid))
then 1091 if ((is== 1) .and. (js== 1)) q(1-i ,1-j ) = q(1-j ,i )
1092 if ((is== 1) .and. (je==npy-1)) q(1-i ,npy-1+j) = q(1-j ,npy-1-i+1)
1093 if ((ie==npx-1) .and. (js== 1)) q(npx-1+i,1-j ) = q(npx-1+j,i )
1094 if ((ie==npx-1) .and. (je==npy-1)) q(npx-1+i,npy-1+j) = q(npx-1+j,npy-1-i+1)
1100 if ((is== 1) .and. (js== 1)) q(1-j ,1-i ) = q(i ,1-j )
1101 if ((is== 1) .and. (je==npy-1)) q(1-j ,npy-1+i) = q(i ,npy-1+j)
1102 if ((ie==npx-1) .and. (js== 1)) q(npx-1+j,1-i ) = q(npx-1-i+1,1-j )
1103 if ((ie==npx-1) .and. (je==npy-1)) q(npx-1+j,npy-1+i) = q(npx-1-i+1,npy-1+j)
1109 if ((is== 1) .and. (js== 1)) q(1-j ,1-i ) = q(i ,1-j )
1110 if ((is== 1) .and. (je==npy-1)) q(1-j ,npy-1+i) = q(i ,npy-1+j)
1111 if ((ie==npx-1) .and. (js== 1)) q(npx-1+j,1-i ) = q(npx-1-i+1,1-j )
1112 if ((ie==npx-1) .and. (je==npy-1)) q(npx-1+j,npy-1+i) = q(npx-1-i+1,npy-1+j)
1119 end subroutine fill_corners_2d_r8
1127 subroutine fill_corners_xy_2d_r8(x, y, npx, npy, DGRID, AGRID, CGRID, VECTOR)
1128 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1129 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1130 integer,
intent(IN):: npx,npy
1131 logical,
OPTIONAL,
intent(IN) :: DGRID, AGRID, CGRID, VECTOR
1134 real(kind=8) :: mySign
1137 if (
present(vector))
then 1138 if (vector) mysign = -1.0
1141 if (
present(dgrid))
then 1142 call fill_corners_dgrid(x, y, npx, npy, mysign)
1143 elseif (
present(cgrid))
then 1144 call fill_corners_cgrid(x, y, npx, npy, mysign)
1145 elseif (
present(agrid))
then 1146 call fill_corners_agrid(x, y, npx, npy, mysign)
1148 call fill_corners_agrid(x, y, npx, npy, mysign)
1151 end subroutine fill_corners_xy_2d_r8
1159 subroutine fill_corners_xy_2d_r4(x, y, npx, npy, DGRID, AGRID, CGRID, VECTOR)
1160 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1161 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1162 integer,
intent(IN):: npx,npy
1163 logical,
OPTIONAL,
intent(IN) :: DGRID, AGRID, CGRID, VECTOR
1166 real(kind=4) :: mySign
1169 if (
present(vector))
then 1170 if (vector) mysign = -1.0
1173 if (
present(dgrid))
then 1174 call fill_corners_dgrid(x, y, npx, npy, mysign)
1175 elseif (
present(cgrid))
then 1176 call fill_corners_cgrid(x, y, npx, npy, mysign)
1177 elseif (
present(agrid))
then 1178 call fill_corners_agrid(x, y, npx, npy, mysign)
1180 call fill_corners_agrid(x, y, npx, npy, mysign)
1183 end subroutine fill_corners_xy_2d_r4
1191 subroutine fill_corners_xy_3d_r8(x, y, npx, npy, npz, DGRID, AGRID, CGRID, VECTOR)
1192 real(kind=8),
DIMENSION(isd:,jsd:,:),
intent(INOUT):: x
1193 real(kind=8),
DIMENSION(isd:,jsd:,:),
intent(INOUT):: y
1194 integer,
intent(IN):: npx,npy,npz
1195 logical,
OPTIONAL,
intent(IN) :: DGRID, AGRID, CGRID, VECTOR
1198 real(kind=8) :: mySign
1201 if (
present(vector))
then 1202 if (vector) mysign = -1.0
1205 if (
present(dgrid))
then 1207 call fill_corners_dgrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1209 elseif (
present(cgrid))
then 1211 call fill_corners_cgrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1213 elseif (
present(agrid))
then 1215 call fill_corners_agrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1219 call fill_corners_agrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1223 end subroutine fill_corners_xy_3d_r8
1231 subroutine fill_corners_xy_3d_r4(x, y, npx, npy, npz, DGRID, AGRID, CGRID, VECTOR)
1232 real(kind=4),
DIMENSION(isd:,jsd:,:),
intent(INOUT):: x
1233 real(kind=4),
DIMENSION(isd:,jsd:,:),
intent(INOUT):: y
1234 integer,
intent(IN):: npx,npy,npz
1235 logical,
OPTIONAL,
intent(IN) :: DGRID, AGRID, CGRID, VECTOR
1238 real(kind=4) :: mySign
1241 if (
present(vector))
then 1242 if (vector) mysign = -1.0
1245 if (
present(dgrid))
then 1247 call fill_corners_dgrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1249 elseif (
present(cgrid))
then 1251 call fill_corners_cgrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1253 elseif (
present(agrid))
then 1255 call fill_corners_agrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1259 call fill_corners_agrid(x(:,:,k), y(:,:,k), npx, npy, mysign)
1263 end subroutine fill_corners_xy_3d_r4
1271 subroutine fill_corners_dgrid_r8(x, y, npx, npy, mySign)
1272 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1273 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1274 integer,
intent(IN):: npx,npy
1275 real(kind=8),
intent(IN) :: mySign
1284 if ((is == 1) .and. (js == 1)) x(1-i ,1-j ) = mysign*y(1-j ,i )
1285 if ((is == 1) .and. (je+1==npy)) x(1-i ,npy+j) = y(1-j ,npy-i)
1286 if ((ie+1==npx) .and. (js == 1)) x(npx-1+i,1-j ) = y(npx+j,i )
1287 if ((ie+1==npx) .and. (je+1==npy)) x(npx-1+i,npy+j) = mysign*y(npx+j,npy-i)
1296 if ((is == 1) .and. (js == 1)) y(1-i ,1-j ) = mysign*x(j ,1-i )
1297 if ((is == 1) .and. (je+1==npy)) y(1-i ,npy-1+j) = x(j ,npy+i)
1298 if ((ie+1==npx) .and. (js == 1)) y(npx+i ,1-j ) = x(npx-j ,1-i )
1299 if ((ie+1==npx) .and. (je+1==npy)) y(npx+i ,npy-1+j) = mysign*x(npx-j ,npy+i)
1303 end subroutine fill_corners_dgrid_r8
1311 subroutine fill_corners_dgrid_r4(x, y, npx, npy, mySign)
1312 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1313 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1314 integer,
intent(IN):: npx,npy
1315 real(kind=4),
intent(IN) :: mySign
1324 if ((is == 1) .and. (js == 1)) x(1-i ,1-j ) = mysign*y(1-j ,i )
1325 if ((is == 1) .and. (je+1==npy)) x(1-i ,npy+j) = y(1-j ,npy-i)
1326 if ((ie+1==npx) .and. (js == 1)) x(npx-1+i,1-j ) = y(npx+j,i )
1327 if ((ie+1==npx) .and. (je+1==npy)) x(npx-1+i,npy+j) = mysign*y(npx+j,npy-i)
1336 if ((is == 1) .and. (js == 1)) y(1-i ,1-j ) = mysign*x(j ,1-i )
1337 if ((is == 1) .and. (je+1==npy)) y(1-i ,npy-1+j) = x(j ,npy+i)
1338 if ((ie+1==npx) .and. (js == 1)) y(npx+i ,1-j ) = x(npx-j ,1-i )
1339 if ((ie+1==npx) .and. (je+1==npy)) y(npx+i ,npy-1+j) = mysign*x(npx-j ,npy+i)
1343 end subroutine fill_corners_dgrid_r4
1351 subroutine fill_corners_cgrid_r4(x, y, npx, npy, mySign)
1352 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1353 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1354 integer,
intent(IN):: npx,npy
1355 real(kind=4),
intent(IN) :: mySign
1360 if ((is == 1) .and. (js == 1)) x(1-i ,1-j ) = y(j ,1-i )
1361 if ((is == 1) .and. (je+1==npy)) x(1-i ,npy-1+j) = mysign*y(j ,npy+i)
1362 if ((ie+1==npx) .and. (js == 1)) x(npx+i ,1-j ) = mysign*y(npx-j ,1-i )
1363 if ((ie+1==npx) .and. (je+1==npy)) x(npx+i ,npy-1+j) = y(npx-j ,npy+i)
1368 if ((is == 1) .and. (js == 1)) y(1-i ,1-j ) = x(1-j ,i )
1369 if ((is == 1) .and. (je+1==npy)) y(1-i ,npy+j) = mysign*x(1-j ,npy-i)
1370 if ((ie+1==npx) .and. (js == 1)) y(npx-1+i,1-j ) = mysign*x(npx+j,i )
1371 if ((ie+1==npx) .and. (je+1==npy)) y(npx-1+i,npy+j) = x(npx+j,npy-i)
1375 end subroutine fill_corners_cgrid_r4
1383 subroutine fill_corners_cgrid_r8(x, y, npx, npy, mySign)
1384 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1385 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1386 integer,
intent(IN):: npx,npy
1387 real(kind=8),
intent(IN) :: mySign
1392 if ((is == 1) .and. (js == 1)) x(1-i ,1-j ) = y(j ,1-i )
1393 if ((is == 1) .and. (je+1==npy)) x(1-i ,npy-1+j) = mysign*y(j ,npy+i)
1394 if ((ie+1==npx) .and. (js == 1)) x(npx+i ,1-j ) = mysign*y(npx-j ,1-i )
1395 if ((ie+1==npx) .and. (je+1==npy)) x(npx+i ,npy-1+j) = y(npx-j ,npy+i)
1400 if ((is == 1) .and. (js == 1)) y(1-i ,1-j ) = x(1-j ,i )
1401 if ((is == 1) .and. (je+1==npy)) y(1-i ,npy+j) = mysign*x(1-j ,npy-i)
1402 if ((ie+1==npx) .and. (js == 1)) y(npx-1+i,1-j ) = mysign*x(npx+j,i )
1403 if ((ie+1==npx) .and. (je+1==npy)) y(npx-1+i,npy+j) = x(npx+j,npy-i)
1407 end subroutine fill_corners_cgrid_r8
1415 subroutine fill_corners_agrid_r4(x, y, npx, npy, mySign)
1416 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1417 real(kind=4),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1418 integer,
intent(IN):: npx,npy
1419 real(kind=4),
intent(IN) :: mySign
1424 if ((is== 1) .and. (js== 1)) x(1-i ,1-j ) = mysign*y(1-j ,i )
1425 if ((is== 1) .and. (je==npy-1)) x(1-i ,npy-1+j) = y(1-j ,npy-1-i+1)
1426 if ((ie==npx-1) .and. (js== 1)) x(npx-1+i,1-j ) = y(npx-1+j,i )
1427 if ((ie==npx-1) .and. (je==npy-1)) x(npx-1+i,npy-1+j) = mysign*y(npx-1+j,npy-1-i+1)
1432 if ((is== 1) .and. (js== 1)) y(1-j ,1-i ) = mysign*x(i ,1-j )
1433 if ((is== 1) .and. (je==npy-1)) y(1-j ,npy-1+i) = x(i ,npy-1+j)
1434 if ((ie==npx-1) .and. (js== 1)) y(npx-1+j,1-i ) = x(npx-1-i+1,1-j )
1435 if ((ie==npx-1) .and. (je==npy-1)) y(npx-1+j,npy-1+i) = mysign*x(npx-1-i+1,npy-1+j)
1439 end subroutine fill_corners_agrid_r4
1447 subroutine fill_corners_agrid_r8(x, y, npx, npy, mySign)
1448 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: x
1449 real(kind=8),
DIMENSION(isd:,jsd:),
intent(INOUT):: y
1450 integer,
intent(IN):: npx,npy
1451 real(kind=8),
intent(IN) :: mySign
1456 if ((is== 1) .and. (js== 1)) x(1-i ,1-j ) = mysign*y(1-j ,i )
1457 if ((is== 1) .and. (je==npy-1)) x(1-i ,npy-1+j) = y(1-j ,npy-1-i+1)
1458 if ((ie==npx-1) .and. (js== 1)) x(npx-1+i,1-j ) = y(npx-1+j,i )
1459 if ((ie==npx-1) .and. (je==npy-1)) x(npx-1+i,npy-1+j) = mysign*y(npx-1+j,npy-1-i+1)
1464 if ((is== 1) .and. (js== 1)) y(1-j ,1-i ) = mysign*x(i ,1-j )
1465 if ((is== 1) .and. (je==npy-1)) y(1-j ,npy-1+i) = x(i ,npy-1+j)
1466 if ((ie==npx-1) .and. (js== 1)) y(npx-1+j,1-i ) = x(npx-1-i+1,1-j )
1467 if ((ie==npx-1) .and. (je==npy-1)) y(npx-1+j,npy-1+i) = mysign*x(npx-1-i+1,npy-1+j)
1471 end subroutine fill_corners_agrid_r8
1858 subroutine mp_gather_4d_r4(q, i1,i2, j1,j2, idim, jdim, kdim, ldim)
1859 integer,
intent(IN) :: i1,i2, j1,j2
1860 integer,
intent(IN) :: idim, jdim, kdim, ldim
1861 real(kind=4),
intent(INOUT):: q(idim,jdim,kdim,ldim)
1862 integer :: i,j,k,l,n,icnt
1863 integer :: Lsize, Lsize_buf(1)
1865 integer :: LsizeS(npes_this_grid), Ldispl(npes_this_grid), cnts(npes_this_grid)
1866 integer :: Ldims(5), Gdims(5*npes_this_grid)
1867 real(kind=4),
allocatable,
dimension(:) :: larr, garr
1874 do l=1,npes_this_grid
1881 lsize = ( (i2 - i1 + 1) * (j2 - j1 + 1) ) * kdim
1882 do l=1,npes_this_grid
1887 lsize_buf(1) = lsize
1891 allocate ( larr(lsize) )
1896 larr(icnt) = q(i,j,k,tile)
1905 do l=2,npes_this_grid
1907 ldispl(l) = ldispl(l-1) + lsizes(l-1)
1908 gsize = gsize + lsizes(l)
1910 allocate ( garr(gsize) )
1915 if (gid==masterproc)
then 1916 do n=2,npes_this_grid
1918 do l=gdims( (n-1)*5 + 5 ), gdims( (n-1)*5 + 5 )
1920 do j=gdims( (n-1)*5 + 3 ), gdims( (n-1)*5 + 4 )
1921 do i=gdims( (n-1)*5 + 1 ), gdims( (n-1)*5 + 2 )
1922 q(i,j,k,l) = garr(ldispl(n)+icnt)
1933 end subroutine mp_gather_4d_r4
1944 subroutine mp_gather_3d_r4(q, i1,i2, j1,j2, idim, jdim, ldim)
1945 integer,
intent(IN) :: i1,i2, j1,j2
1946 integer,
intent(IN) :: idim, jdim, ldim
1947 real(kind=4),
intent(INOUT):: q(idim,jdim,ldim)
1948 integer :: i,j,l,n,icnt
1949 integer :: Lsize, Lsize_buf(1)
1951 integer :: LsizeS(npes_this_grid), Ldispl(npes_this_grid), cnts(npes_this_grid)
1952 integer :: Ldims(5), Gdims(5*npes_this_grid)
1953 real(kind=4),
allocatable,
dimension(:) :: larr, garr
1960 do l=1,npes_this_grid
1967 lsize = ( (i2 - i1 + 1) * (j2 - j1 + 1) )
1968 do l=1,npes_this_grid
1973 lsize_buf(1) = lsize
1977 allocate ( larr(lsize) )
1981 larr(icnt) = q(i,j,tile)
1989 do l=2,npes_this_grid
1991 ldispl(l) = ldispl(l-1) + lsizes(l-1)
1992 gsize = gsize + lsizes(l)
1994 allocate ( garr(gsize) )
1997 if (gid==masterproc)
then 1998 do n=2,npes_this_grid
2000 do l=gdims( (n-1)*5 + 5 ), gdims( (n-1)*5 + 5 )
2001 do j=gdims( (n-1)*5 + 3 ), gdims( (n-1)*5 + 4 )
2002 do i=gdims( (n-1)*5 + 1 ), gdims( (n-1)*5 + 2 )
2003 q(i,j,l) = garr(ldispl(n)+icnt)
2013 end subroutine mp_gather_3d_r4
2023 subroutine mp_gather_3d_r8(q, i1,i2, j1,j2, idim, jdim, ldim)
2024 integer,
intent(IN) :: i1,i2, j1,j2
2025 integer,
intent(IN) :: idim, jdim, ldim
2026 real(kind=8),
intent(INOUT):: q(idim,jdim,ldim)
2027 integer :: i,j,l,n,icnt
2028 integer :: Lsize, Lsize_buf(1)
2030 integer :: LsizeS(npes_this_grid), Ldispl(npes_this_grid), cnts(npes_this_grid)
2031 integer :: Ldims(5), Gdims(5*npes_this_grid)
2032 real(kind=8),
allocatable,
dimension(:) :: larr, garr
2039 do l=1,npes_this_grid
2045 lsize = ( (i2 - i1 + 1) * (j2 - j1 + 1) )
2046 do l=1,npes_this_grid
2053 lsize_buf(1) = lsize
2056 allocate ( larr(lsize) )
2060 larr(icnt) = q(i,j,tile)
2068 do l=2,npes_this_grid
2070 ldispl(l) = ldispl(l-1) + lsizes(l-1)
2071 gsize = gsize + lsizes(l)
2074 allocate ( garr(gsize) )
2077 if (gid==masterproc)
then 2078 do n=2,npes_this_grid
2080 do l=gdims( (n-1)*5 + 5 ), gdims( (n-1)*5 + 5 )
2081 do j=gdims( (n-1)*5 + 3 ), gdims( (n-1)*5 + 4 )
2082 do i=gdims( (n-1)*5 + 1 ), gdims( (n-1)*5 + 2 )
2083 q(i,j,l) = garr(ldispl(n)+icnt)
2093 end subroutine mp_gather_3d_r8
2103 subroutine mp_bcst_i4(q)
2104 integer,
intent(INOUT) :: q
2106 call mpi_bcast(q, 1, mpi_integer, masterproc, commglobal, ierror)
2108 end subroutine mp_bcst_i4
2118 subroutine mp_bcst_r4(q)
2119 real(kind=4),
intent(INOUT) :: q
2121 call mpi_bcast(q, 1, mpi_real, masterproc, commglobal, ierror)
2123 end subroutine mp_bcst_r4
2133 subroutine mp_bcst_r8(q)
2134 real(kind=8),
intent(INOUT) :: q
2136 call mpi_bcast(q, 1, mpi_double_precision, masterproc, commglobal, ierror)
2138 end subroutine mp_bcst_r8
2148 subroutine mp_bcst_3d_r4(q, idim, jdim, kdim)
2149 integer,
intent(IN) :: idim, jdim, kdim
2150 real(kind=4),
intent(INOUT) :: q(idim,jdim,kdim)
2152 call mpi_bcast(q, idim*jdim*kdim, mpi_real, masterproc, commglobal, ierror)
2154 end subroutine mp_bcst_3d_r4
2164 subroutine mp_bcst_3d_r8(q, idim, jdim, kdim)
2165 integer,
intent(IN) :: idim, jdim, kdim
2166 real(kind=8),
intent(INOUT) :: q(idim,jdim,kdim)
2168 call mpi_bcast(q, idim*jdim*kdim, mpi_double_precision, masterproc, commglobal, ierror)
2170 end subroutine mp_bcst_3d_r8
2180 subroutine mp_bcst_4d_r4(q, idim, jdim, kdim, ldim)
2181 integer,
intent(IN) :: idim, jdim, kdim, ldim
2182 real(kind=4),
intent(INOUT) :: q(idim,jdim,kdim,ldim)
2184 call mpi_bcast(q, idim*jdim*kdim*ldim, mpi_real, masterproc, commglobal, ierror)
2186 end subroutine mp_bcst_4d_r4
2196 subroutine mp_bcst_4d_r8(q, idim, jdim, kdim, ldim)
2197 integer,
intent(IN) :: idim, jdim, kdim, ldim
2198 real(kind=8),
intent(INOUT) :: q(idim,jdim,kdim,ldim)
2200 call mpi_bcast(q, idim*jdim*kdim*ldim, mpi_double_precision, masterproc, commglobal, ierror)
2202 end subroutine mp_bcst_4d_r8
2212 subroutine mp_bcst_3d_i8(q, idim, jdim, kdim)
2213 integer,
intent(IN) :: idim, jdim, kdim
2214 integer,
intent(INOUT) :: q(idim,jdim,kdim)
2216 call mpi_bcast(q, idim*jdim*kdim, mpi_integer, masterproc, commglobal, ierror)
2218 end subroutine mp_bcst_3d_i8
2228 subroutine mp_bcst_4d_i8(q, idim, jdim, kdim, ldim)
2229 integer,
intent(IN) :: idim, jdim, kdim, ldim
2230 integer,
intent(INOUT) :: q(idim,jdim,kdim,ldim)
2232 call mpi_bcast(q, idim*jdim*kdim*ldim, mpi_integer, masterproc, commglobal, ierror)
2234 end subroutine mp_bcst_4d_i8
2245 subroutine mp_reduce_max_r4_1d(mymax,npts)
2246 integer,
intent(IN) :: npts
2247 real(kind=4),
intent(INOUT) :: mymax(npts)
2249 real(kind=4) :: gmax(npts)
2251 call mpi_allreduce( mymax, gmax, npts, mpi_real, mpi_max, &
2252 commglobal, ierror )
2256 end subroutine mp_reduce_max_r4_1d
2267 subroutine mp_reduce_max_r8_1d(mymax,npts)
2268 integer,
intent(IN) :: npts
2269 real(kind=8),
intent(INOUT) :: mymax(npts)
2271 real(kind=8) :: gmax(npts)
2273 call mpi_allreduce( mymax, gmax, npts, mpi_double_precision, mpi_max, &
2274 commglobal, ierror )
2278 end subroutine mp_reduce_max_r8_1d
2289 subroutine mp_reduce_max_r4(mymax)
2290 real(kind=4),
intent(INOUT) :: mymax
2292 real(kind=4) :: gmax
2294 call mpi_allreduce( mymax, gmax, 1, mpi_real, mpi_max, &
2295 commglobal, ierror )
2299 end subroutine mp_reduce_max_r4
2306 subroutine mp_reduce_max_r8(mymax)
2307 real(kind=8),
intent(INOUT) :: mymax
2309 real(kind=8) :: gmax
2311 call mpi_allreduce( mymax, gmax, 1, mpi_double_precision, mpi_max, &
2312 commglobal, ierror )
2316 end subroutine mp_reduce_max_r8
2318 subroutine mp_reduce_min_r4(mymin)
2319 real(kind=4),
intent(INOUT) :: mymin
2321 real(kind=4) :: gmin
2323 call mpi_allreduce( mymin, gmin, 1, mpi_real, mpi_min, &
2324 commglobal, ierror )
2328 end subroutine mp_reduce_min_r4
2330 subroutine mp_reduce_min_r8(mymin)
2331 real(kind=8),
intent(INOUT) :: mymin
2333 real(kind=8) :: gmin
2335 call mpi_allreduce( mymin, gmin, 1, mpi_double_precision, mpi_min, &
2336 commglobal, ierror )
2340 end subroutine mp_reduce_min_r8
2350 subroutine mp_reduce_max_i4(mymax)
2351 integer,
intent(INOUT) :: mymax
2355 call mpi_allreduce( mymax, gmax, 1, mpi_integer, mpi_max, &
2356 commglobal, ierror )
2360 end subroutine mp_reduce_max_i4
2370 subroutine mp_reduce_sum_r4(mysum)
2371 real(kind=4),
intent(INOUT) :: mysum
2373 real(kind=4) :: gsum
2375 call mpi_allreduce( mysum, gsum, 1, mpi_real, mpi_sum, &
2376 commglobal, ierror )
2380 end subroutine mp_reduce_sum_r4
2390 subroutine mp_reduce_sum_r8(mysum)
2391 real(kind=8),
intent(INOUT) :: mysum
2393 real(kind=8) :: gsum
2395 call mpi_allreduce( mysum, gsum, 1, mpi_double_precision, mpi_sum, &
2396 commglobal, ierror )
2400 end subroutine mp_reduce_sum_r8
2410 subroutine mp_reduce_sum_r4_1d(mysum, sum1d, npts)
2411 integer,
intent(in) :: npts
2412 real(kind=4),
intent(in) :: sum1d(npts)
2413 real(kind=4),
intent(INOUT) :: mysum
2415 real(kind=4) :: gsum
2420 mysum = mysum + sum1d(i)
2423 call mpi_allreduce( mysum, gsum, 1, mpi_double_precision, mpi_sum, &
2424 commglobal, ierror )
2428 end subroutine mp_reduce_sum_r4_1d
2438 subroutine mp_reduce_sum_r8_1d(mysum, sum1d, npts)
2439 integer,
intent(in) :: npts
2440 real(kind=8),
intent(in) :: sum1d(npts)
2441 real(kind=8),
intent(INOUT) :: mysum
2443 real(kind=8) :: gsum
2448 mysum = mysum + sum1d(i)
2451 call mpi_allreduce( mysum, gsum, 1, mpi_double_precision, mpi_sum, &
2452 commglobal, ierror )
2456 end subroutine mp_reduce_sum_r8_1d
2463 integer :: masterproc = 0
2465 integer,
parameter:: ng = 3
2466 public gid, masterproc, ng
subroutine, public set_domain(Domain2)
integer, parameter, public nupdate
integer, parameter, public wupdate
integer, parameter, public yupdate
subroutine, public fms_init(localcomm)
integer, parameter, public supdate
subroutine, public fms_end()
integer, parameter, public xupdate
integer, parameter, public eupdate
integer function, public get_ensemble_id()
Derived type containing the data.