1 !***********************************************************************
2 !* GNU Lesser General Public License
4 !* This file
is part of the GFDL Flexible Modeling System (FMS).
6 !* FMS
is free software: you can redistribute it and/or modify it under
7 !* the terms of the GNU Lesser General Public License as published by
8 !* the Free Software Foundation, either
version 3 of the License, or (at
9 !* your option) any later
version.
11 !* FMS
is distributed in the hope that it
will be useful, but WITHOUT
12 !* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 !* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 !* You should have
received a copy of the GNU Lesser General Public
17 !* License along with FMS. If
not, see <http:
18 !***********************************************************************
20 if( group%k_loop_inside ) then
21 !$OMP parallel
do default(
none) shared(npack,group,ptr,nvector,
ksize,buffer_start_pos) &
23 !$OMP ptr_field, ptr_fieldx, ptr_fieldy,
n,
k)
25 buffer_pos = group%pack_buffer_pos(
n) + buffer_start_pos
27 is = group%pack_is(
n);
ie = group%pack_ie(
n)
28 js = group%pack_js(
n);
je = group%pack_je(
n)
29 rotation = group%pack_rotation(
n)
30 if( group%pack_type(
n) == FIELD_S ) then
31 select
case( rotation )
33 do l=1, group%nscalar ! loop over number of
fields 34 ptr_field = group%addrs_s(l)
45 do l=1,group%nscalar ! loop over number of
fields 46 ptr_field = group%addrs_s(l)
57 do l=1,group%nscalar ! loop over number of
fields 58 ptr_field = group%addrs_s(l)
68 case( ONE_HUNDRED_EIGHTY )
69 do l=1,group%nscalar ! loop over number of
fields 70 ptr_field = group%addrs_s(l)
81 else if( group%pack_type(
n) == FIELD_X ) then
82 select
case( rotation )
84 do l=1, nvector ! loop over number of
fields 85 ptr_fieldx = group%addrs_x(l)
90 buffer(
pos) = fieldx(
i,
j,
k)
96 if( BTEST(group%flags_v,SCALAR_BIT) ) then
97 do l=1,nvector ! loop over number of
fields 98 ptr_fieldy = group%addrs_y(l)
103 buffer(
pos) = fieldy(
i,
j,
k)
109 do l=1,nvector ! loop over number of
fields 110 ptr_fieldy = group%addrs_y(l)
115 buffer(
pos) = -fieldy(
i,
j,
k)
122 do l=1, nvector ! loop over number of
fields 123 ptr_fieldy = group%addrs_y(l)
128 buffer(
pos) = fieldy(
i,
j,
k)
133 case( ONE_HUNDRED_EIGHTY )
134 if( BTEST(group%flags_v,SCALAR_BIT) ) then
135 do l=1,nvector ! loop over number of
fields 136 ptr_fieldx = group%addrs_x(l)
141 buffer(
pos) = fieldx(
i,
j,
k)
147 do l=1,nvector ! loop over number of
fields 148 ptr_fieldx = group%addrs_x(l)
153 buffer(
pos) = -fieldx(
i,
j,
k)
159 end select ! select
case( rotation(
n) )
160 else if( group%pack_type(
n) == FIELD_Y ) then
161 select
case( rotation )
163 do l=1, nvector ! loop over number of
fields 164 ptr_fieldy = group%addrs_y(l)
169 buffer(
pos) = fieldy(
i,
j,
k)
175 do l=1,nvector ! loop over number of
fields 176 ptr_fieldx = group%addrs_x(l)
181 buffer(
pos) = fieldx(
i,
j,
k)
187 if( BTEST(group%flags_v,SCALAR_BIT) ) then
188 do l=1, nvector ! loop over number of
fields 189 ptr_fieldx = group%addrs_x(l)
194 buffer(
pos) = fieldx(
i,
j,
k)
200 do l=1,nvector ! loop over number of
fields 201 ptr_fieldx = group%addrs_x(l)
206 buffer(
pos) = -fieldx(
i,
j,
k)
212 case( ONE_HUNDRED_EIGHTY )
213 if( BTEST(group%flags_v,SCALAR_BIT) ) then
214 do l=1,nvector ! loop over number of
fields 215 ptr_fieldy = group%addrs_y(l)
220 buffer(
pos) = fieldy(
i,
j,
k)
226 do l=1,nvector ! loop over number of
fields 227 ptr_fieldy = group%addrs_y(l)
232 buffer(
pos) = -fieldy(
i,
j,
k)
238 end select ! select
case( rotation(
n) )
242 !$OMP parallel
do default(
none) shared(npack,group,ptr,nvector,
ksize,buffer_start_pos) &
244 !$OMP ptr_field, ptr_fieldx, ptr_fieldy,
n,
k)
248 buffer_pos = group%pack_buffer_pos(
n) + buffer_start_pos
250 is = group%pack_is(
n);
ie = group%pack_ie(
n)
251 js = group%pack_js(
n);
je = group%pack_je(
n)
252 rotation = group%pack_rotation(
n)
253 if( group%pack_type(
n) == FIELD_S ) then
254 select
case( rotation )
256 do l=1, group%nscalar ! loop over number of
fields 257 ptr_field = group%addrs_s(l)
266 do l=1,group%nscalar ! loop over number of
fields 267 ptr_field = group%addrs_s(l)
276 do l=1,group%nscalar ! loop over number of
fields 277 ptr_field = group%addrs_s(l)
285 case( ONE_HUNDRED_EIGHTY )
286 do l=1,group%nscalar ! loop over number of
fields 287 ptr_field = group%addrs_s(l)
296 else if( group%pack_type(
n) == FIELD_X ) then
297 select
case( rotation )
299 do l=1, nvector ! loop over number of
fields 300 ptr_fieldx = group%addrs_x(l)
304 buffer(
pos) = fieldx(
i,
j,
k)
309 if( BTEST(group%flags_v,SCALAR_BIT) ) then
310 do l=1,nvector ! loop over number of
fields 311 ptr_fieldy = group%addrs_y(l)
315 buffer(
pos) = fieldy(
i,
j,
k)
320 do l=1,nvector ! loop over number of
fields 321 ptr_fieldy = group%addrs_y(l)
325 buffer(
pos) = -fieldy(
i,
j,
k)
331 do l=1, nvector ! loop over number of
fields 332 ptr_fieldy = group%addrs_y(l)
336 buffer(
pos) = fieldy(
i,
j,
k)
340 case( ONE_HUNDRED_EIGHTY )
341 if( BTEST(group%flags_v,SCALAR_BIT) ) then
342 do l=1,nvector ! loop over number of
fields 343 ptr_fieldx = group%addrs_x(l)
347 buffer(
pos) = fieldx(
i,
j,
k)
352 do l=1,nvector ! loop over number of
fields 353 ptr_fieldx = group%addrs_x(l)
357 buffer(
pos) = -fieldx(
i,
j,
k)
362 end select ! select
case( rotation(
n) )
363 else if( group%pack_type(
n) == FIELD_Y ) then
364 select
case( rotation )
366 do l=1, nvector ! loop over number of
fields 367 ptr_fieldy = group%addrs_y(l)
371 buffer(
pos) = fieldy(
i,
j,
k)
376 do l=1,nvector ! loop over number of
fields 377 ptr_fieldx = group%addrs_x(l)
381 buffer(
pos) = fieldx(
i,
j,
k)
386 if( BTEST(group%flags_v,SCALAR_BIT) ) then
387 do l=1, nvector ! loop over number of
fields 388 ptr_fieldx = group%addrs_x(l)
392 buffer(
pos) = fieldx(
i,
j,
k)
397 do l=1,nvector ! loop over number of
fields 398 ptr_fieldx = group%addrs_x(l)
402 buffer(
pos) = -fieldx(
i,
j,
k)
407 case( ONE_HUNDRED_EIGHTY )
408 if( BTEST(group%flags_v,SCALAR_BIT) ) then
409 do l=1,nvector ! loop over number of
fields 410 ptr_fieldy = group%addrs_y(l)
414 buffer(
pos) = fieldy(
i,
j,
k)
419 do l=1,nvector ! loop over number of
fields 420 ptr_fieldy = group%addrs_y(l)
424 buffer(
pos) = -fieldy(
i,
j,
k)
429 end select ! select
case( rotation(
n) )
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version will
type(ext_fieldtype), dimension(:), pointer, save, private field
l_size ! loop over number of fields ke do je do i
*f90 *************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine MPP_UPDATE_NEST_FINE_2D_(field, nest_domain, wbuffer, ebuffer, sbuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::field3D(size(field, 1), size(field, 2), 1) MPP_TYPE_ ::wbuffer3D(size(wbuffer, 1), size(wbuffer, 2), 1) MPP_TYPE_ ::ebuffer3D(size(ebuffer, 1), size(ebuffer, 2), 1) MPP_TYPE_ ::sbuffer3D(size(sbuffer, 1), size(sbuffer, 2), 1) MPP_TYPE_ ::nbuffer3D(size(nbuffer, 1), size(nbuffer, 2), 1) pointer(ptr, field3D) pointer(ptr_w, wbuffer3D) pointer(ptr_e, ebuffer3D) pointer(ptr_s, sbuffer3D) pointer(ptr_n, nbuffer3D) ptr=LOC(field) ptr_w=LOC(wbuffer) ptr_e=LOC(ebuffer) ptr_s=LOC(sbuffer) ptr_n=LOC(nbuffer) call mpp_update_nest_fine(field3D, nest_domain, wbuffer3D, ebuffer3D, sbuffer3D, nbuffer3D, &flags, complete, position, extra_halo, name, tile_count) returnend subroutine MPP_UPDATE_NEST_FINE_2D_subroutine MPP_UPDATE_NEST_FINE_3D_(field, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::d_type type(nestSpec), pointer ::update=> set_mismatch integer ::tile update_position nbuffersz ksize
integer, save, private nk
subroutine, public copy(self, rhs)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT end
type(field_mgr_type), dimension(max_fields), private fields
integer, parameter, public none
l_size ! loop over number of fields ke do j
character(len=128) version
l_size ! loop over number of fields ke do je do ie to is
logical function received(this, seqno)
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version and mpp_transmit will remain !backward compatible intent(inout) a
*f90 *************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If not
l_size ! loop over number of fields ke do je do ie pos
l_size ! loop over number of fields ke do je do ie to js