FV3 Bundle
mpp_update_domains2D.h
Go to the documentation of this file.
1 ! -*-f90-*-
2 !***********************************************************************
3 !* GNU Lesser General Public License
4 !*
5 !* This file is part of the GFDL Flexible Modeling System (FMS).
6 !*
7 !* FMS is free software: you can redistribute it and/or modify it under
8 !* the terms of the GNU Lesser General Public License as published by
9 !* the Free Software Foundation, either version 3 of the License, or (at
10 !* your option) any later version.
11 !*
12 !* FMS is distributed in the hope that it will be useful, but WITHOUT
13 !* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 !* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 !* for more details.
16 !*
17 !* You should have received a copy of the GNU Lesser General Public
18 !* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
19 !***********************************************************************
20  subroutine MPP_UPDATE_DOMAINS_2D_( field, domain, flags, complete, position, &
21  whalo, ehalo, shalo, nhalo, name, tile_count)
22 !updates data domain of 2D field whose computational domains have been computed
23  MPP_TYPE_, intent(inout) :: field(:,:)
24  type(domain2D), intent(inout) :: domain
25  integer, intent(in), optional :: flags
26  logical, intent(in), optional :: complete
27  integer, intent(in), optional :: position
28  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo
29  character(len=*), intent(in), optional :: name
30  integer, intent(in), optional :: tile_count
31 
32  MPP_TYPE_ :: field3D(size(field,1),size(field,2),1)
33  pointer( ptr, field3D )
34  ptr = LOC(field)
35  call mpp_update_domains( field3D, domain, flags, complete, position, &
36  whalo, ehalo, shalo, nhalo, name, tile_count )
37  return
38  end subroutine MPP_UPDATE_DOMAINS_2D_
39 
40  subroutine MPP_UPDATE_DOMAINS_3D_( field, domain, flags, complete, position, &
41  whalo, ehalo, shalo, nhalo, name, tile_count)
42 !updates data domain of 3D field whose computational domains have been computed
43  MPP_TYPE_, intent(inout) :: field(:,:,:)
44  type(domain2D), intent(inout) :: domain
45  integer, intent(in), optional :: flags
46  logical, intent(in), optional :: complete
47  integer, intent(in), optional :: position
48  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo ! specify halo region to be updated.
49  character(len=*), intent(in), optional :: name
50  integer, intent(in), optional :: tile_count
51 
52  integer :: update_position, update_whalo, update_ehalo, update_shalo, update_nhalo, ntile
53 
54  integer(LONG_KIND),dimension(MAX_DOMAIN_FIELDS, MAX_TILES),save :: f_addrs=-9999
55  integer :: tile, max_ntile
56  character(len=3) :: text
57  logical :: set_mismatch, is_complete
58  logical :: do_update
59  integer, save :: isize=0, jsize=0, ke=0, l_size=0, list=0
60  integer, save :: pos, whalosz, ehalosz, shalosz, nhalosz
61  MPP_TYPE_ :: d_type
62  type(overlapSpec), pointer :: update => NULL()
63  type(overlapSpec), pointer :: check => NULL()
64 
65  if(present(whalo)) then
66  update_whalo = whalo
67  if(abs(update_whalo) > domain%whalo ) call mpp_error(FATAL, "MPP_UPDATE_3D: "// &
68  "optional argument whalo should not be larger than the whalo when define domain.")
69  else
70  update_whalo = domain%whalo
71  end if
72  if(present(ehalo)) then
73  update_ehalo = ehalo
74  if(abs(update_ehalo) > domain%ehalo ) call mpp_error(FATAL, "MPP_UPDATE_3D: "// &
75  "optional argument ehalo should not be larger than the ehalo when define domain.")
76  else
77  update_ehalo = domain%ehalo
78  end if
79  if(present(shalo)) then
80  update_shalo = shalo
81  if(abs(update_shalo) > domain%shalo ) call mpp_error(FATAL, "MPP_UPDATE_3D: "// &
82  "optional argument shalo should not be larger than the shalo when define domain.")
83  else
84  update_shalo = domain%shalo
85  end if
86  if(present(nhalo)) then
87  update_nhalo = nhalo
88  if(abs(update_nhalo) > domain%nhalo ) call mpp_error(FATAL, "MPP_UPDATE_3D: "// &
89  "optional argument nhalo should not be larger than the nhalo when define domain.")
90  else
91  update_nhalo = domain%nhalo
92  end if
93 
94  !--- when there is NINETY or MINUS_NINETY rotation for some contact, the salar data can not be on E or N-cell,
95  if(present(position)) then
96  if(domain%rotated_ninety .AND. ( position == EAST .OR. position == NORTH ) ) &
97  call mpp_error(FATAL, 'MPP_UPDATE_3D: hen there is NINETY or MINUS_NINETY rotation, ' // &
98  'can not use scalar version update_domain for data on E or N-cell' )
99  end if
100 
101  max_ntile = domain%max_ntile_pe
102  ntile = size(domain%x(:))
103  is_complete = .true.
104  if(PRESENT(complete)) then
105  is_complete = complete
106  end if
107  tile = 1
108 
109  if(max_ntile>1) then
110  if(ntile>MAX_TILES) then
111  write( text,'(i2)' ) MAX_TILES
112  call mpp_error(FATAL,'MPP_UPDATE_3D: MAX_TILES='//text//' is less than number of tiles on this pe.' )
113  endif
114  if(.NOT. present(tile_count) ) call mpp_error(FATAL, "MPP_UPDATE_3D: "// &
115  "optional argument tile_count should be present when number of tiles on this pe is more than 1")
116  tile = tile_count
117  end if
118  do_update = (tile == ntile) .AND. is_complete
119  list = list+1
120  if(list > MAX_DOMAIN_FIELDS)then
121  write( text,'(i2)' ) MAX_DOMAIN_FIELDS
122  call mpp_error(FATAL,'MPP_UPDATE_3D: MAX_DOMAIN_FIELDS='//text//' exceeded for group update.' )
123  endif
124  f_addrs(list, tile) = LOC(field)
125  update_position = CENTER
126  if(present(position)) update_position = position
127  if(list == 1 .AND. tile == 1 )then
128  isize=size(field,1); jsize=size(field,2); ke = size(field,3); pos = update_position
129  whalosz = update_whalo; ehalosz = update_ehalo; shalosz = update_shalo; nhalosz = update_nhalo
130  else
131  set_mismatch = .false.
132  set_mismatch = set_mismatch .OR. (isize /= size(field,1))
133  set_mismatch = set_mismatch .OR. (jsize /= size(field,2))
134  set_mismatch = set_mismatch .OR. (ke /= size(field,3))
135  set_mismatch = set_mismatch .OR. (update_position /= pos)
136  set_mismatch = set_mismatch .OR. (update_whalo /= whalosz)
137  set_mismatch = set_mismatch .OR. (update_ehalo /= ehalosz)
138  set_mismatch = set_mismatch .OR. (update_shalo /= shalosz)
139  set_mismatch = set_mismatch .OR. (update_nhalo /= nhalosz)
140  if(set_mismatch)then
141  write( text,'(i2)' ) list
142  call mpp_error(FATAL,'MPP_UPDATE_3D: Incompatible field at count '//text//' for group update.' )
143  endif
144  endif
145  if(is_complete) then
146  l_size = list
147  list = 0
148  end if
149  if(do_update )then
150  if( domain_update_is_needed(domain, update_whalo, update_ehalo, update_shalo, update_nhalo) )then
151  if(debug_update_level .NE. NO_CHECK) then
152  check => search_check_overlap(domain, update_position)
153  if(ASSOCIATED(check) ) then
154  call mpp_do_check(f_addrs(1:l_size,1:ntile), domain, check, d_type, ke, flags, name )
155  endif
156  endif
157  update => search_update_overlap(domain, update_whalo, update_ehalo, update_shalo, update_nhalo, update_position)
158 
159  !call mpp_do_update( f_addrs(1:l_size,1:ntile), domain, update, d_type, ke, &
160  ! b_addrs(1:l_size,1:ntile), bsize, flags)
161 
162  if ( PRESENT ( flags ) ) then
163  call mpp_do_update( f_addrs(1:l_size,1:ntile), domain, update, d_type, ke, flags )
164  else
165  call mpp_do_update( f_addrs(1:l_size,1:ntile), domain, update, d_type, ke )
166  endif
167 
168 
169  end if
170  l_size=0; f_addrs=-9999; isize=0; jsize=0; ke=0
171  endif
172  return
173 
174  end subroutine MPP_UPDATE_DOMAINS_3D_
175 
176  subroutine MPP_UPDATE_DOMAINS_4D_( field, domain, flags, complete, position, &
177  whalo, ehalo, shalo, nhalo, name, tile_count )
178 !updates data domain of 4D field whose computational domains have been computed
179  MPP_TYPE_, intent(inout) :: field(:,:,:,:)
180  type(domain2D), intent(inout) :: domain
181  integer, intent(in), optional :: flags
182  logical, intent(in), optional :: complete
183  integer, intent(in), optional :: position
184  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo
185  character(len=*), intent(in), optional :: name
186  integer, intent(in), optional :: tile_count
187 
188  MPP_TYPE_ :: field3D(size(field,1),size(field,2),size(field,3)*size(field,4))
189  pointer( ptr, field3D )
190  ptr = LOC(field)
191  call mpp_update_domains( field3D, domain, flags, complete, position, &
192  whalo, ehalo, shalo, nhalo, name, tile_count)
193  return
194  end subroutine MPP_UPDATE_DOMAINS_4D_
195 
196  subroutine MPP_UPDATE_DOMAINS_5D_( field, domain, flags, complete, position, &
197  whalo, ehalo, shalo, nhalo, name, tile_count )
198 !updates data domain of 5D field whose computational domains have been computed
199  MPP_TYPE_, intent(inout) :: field(:,:,:,:,:)
200  type(domain2D), intent(inout) :: domain
201  integer, intent(in), optional :: flags
202  logical, intent(in), optional :: complete
203  integer, intent(in), optional :: position
204  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo
205  character(len=*), intent(in), optional :: name
206  integer, intent(in), optional :: tile_count
207 
208  MPP_TYPE_ :: field3D(size(field,1),size(field,2),size(field,3)*size(field,4)*size(field,5))
209 
210  pointer( ptr, field3D )
211  ptr = LOC(field)
212  call mpp_update_domains( field3D, domain, flags, complete, position, &
213  whalo, ehalo, shalo, nhalo, name, tile_count )
214  return
215  end subroutine MPP_UPDATE_DOMAINS_5D_
216 
217  subroutine MPP_REDISTRIBUTE_2D_( domain_in, field_in, domain_out, field_out, complete, free, list_size, dc_handle, position )
218  type(domain2D), intent(in) :: domain_in, domain_out
219  MPP_TYPE_, intent(in) :: field_in (:,:)
220  MPP_TYPE_, intent(out) :: field_out(:,:)
221  logical, intent(in), optional :: complete, free
222  integer, intent(in), optional :: list_size
223  integer, intent(in), optional :: position
224  MPP_TYPE_ :: field3D_in (size(field_in, 1),size(field_in, 2),1)
225  MPP_TYPE_ :: field3D_out(size(field_out,1),size(field_out,2),1)
226  type(DomainCommunicator2D),pointer,optional :: dc_handle
227  pointer( ptr_in, field3D_in )
228  pointer( ptr_out, field3D_out )
229 
230  ptr_in = 0
231  ptr_out = 0
232  if(domain_in%initialized) ptr_in = LOC(field_in )
233  if(domain_out%initialized) ptr_out = LOC(field_out)
234  call mpp_redistribute( domain_in, field3D_in, domain_out, field3D_out, complete, free, list_size, dc_handle, position )
235 
236  return
237  end subroutine MPP_REDISTRIBUTE_2D_
238 
239 
240  subroutine MPP_REDISTRIBUTE_3D_( domain_in, field_in, domain_out, field_out, complete, free, list_size, dc_handle, position )
241  type(domain2D), intent(in) :: domain_in, domain_out
242  MPP_TYPE_, intent(in) :: field_in (:,:,:)
243  MPP_TYPE_, intent(out) :: field_out(:,:,:)
244  logical, intent(in), optional :: complete, free
245  integer, intent(in), optional :: list_size
246  integer, intent(in), optional :: position
247  type(DomainCommunicator2D),pointer,optional :: dc_handle
248  type(DomainCommunicator2D),pointer,save :: d_comm =>NULL()
249  logical :: do_redist,free_comm
250  integer :: lsize
251  integer(LONG_KIND),dimension(MAX_DOMAIN_FIELDS),save :: l_addrs_in=-9999, l_addrs_out=-9999
252  integer, save :: isize_in=0,jsize_in=0,ke_in=0,l_size=0
253  integer, save :: isize_out=0,jsize_out=0,ke_out=0
254  logical :: set_mismatch
255  integer :: ke
256  character(len=2) :: text
257  MPP_TYPE_ :: d_type
258  integer(LONG_KIND) :: floc_in, floc_out
259 
260  floc_in = 0
261  floc_out = 0
262  if(domain_in%initialized) floc_in = LOC(field_in)
263  if(domain_out%initialized) floc_out = LOC(field_out)
264 
265  if(present(position)) then
266  if(position .NE. CENTER) call mpp_error( FATAL, &
267  'MPP_REDISTRIBUTE_3Dold_: only position = CENTER is implemented, contact author')
268  endif
269 
270  do_redist=.true.; if(PRESENT(complete))do_redist=complete
271  free_comm=.false.; if(PRESENT(free))free_comm=free
272  if(free_comm)then
273  l_addrs_in(1) = floc_in; l_addrs_out(1) = floc_out
274  if(l_addrs_out(1)>0)then
275  ke = size(field_out,3)
276  else
277  ke = size(field_in,3)
278  end if
279  lsize=1; if(PRESENT(list_size))lsize=list_size
280  call mpp_redistribute_free_comm(domain_in,l_addrs_in(1),domain_out,l_addrs_out(1),ke,lsize)
281  else
282  l_size = l_size+1
283  if(l_size > MAX_DOMAIN_FIELDS)then
284  write( text,'(i2)' ) MAX_DOMAIN_FIELDS
285  call mpp_error(FATAL,'MPP_REDISTRIBUTE_3D: MAX_DOMAIN_FIELDS='//text//' exceeded for group redistribute.' )
286  end if
287  l_addrs_in(l_size) = floc_in; l_addrs_out(l_size) = floc_out
288  if(l_size == 1)then
289  if(l_addrs_in(l_size) > 0)then
290  isize_in=size(field_in,1); jsize_in=size(field_in,2); ke_in = size(field_in,3)
291  end if
292  if(l_addrs_out(l_size) > 0)then
293  isize_out=size(field_out,1); jsize_out=size(field_out,2); ke_out = size(field_out,3)
294  endif
295  else
296  set_mismatch = .false.
297  set_mismatch = l_addrs_in(l_size) == 0 .AND. l_addrs_in(l_size-1) /= 0
298  set_mismatch = set_mismatch .OR. (l_addrs_in(l_size) > 0 .AND. l_addrs_in(l_size-1) == 0)
299  set_mismatch = set_mismatch .OR. (l_addrs_out(l_size) == 0 .AND. l_addrs_out(l_size-1) /= 0)
300  set_mismatch = set_mismatch .OR. (l_addrs_out(l_size) > 0 .AND. l_addrs_out(l_size-1) == 0)
301  if(l_addrs_in(l_size) > 0)then
302  set_mismatch = set_mismatch .OR. (isize_in /= size(field_in,1))
303  set_mismatch = set_mismatch .OR. (jsize_in /= size(field_in,2))
304  set_mismatch = set_mismatch .OR. (ke_in /= size(field_in,3))
305  endif
306  if(l_addrs_out(l_size) > 0)then
307  set_mismatch = set_mismatch .OR. (isize_out /= size(field_out,1))
308  set_mismatch = set_mismatch .OR. (jsize_out /= size(field_out,2))
309  set_mismatch = set_mismatch .OR. (ke_out /= size(field_out,3))
310  endif
311  if(set_mismatch)then
312  write( text,'(i2)' ) l_size
313  call mpp_error(FATAL,'MPP_REDISTRIBUTE_3D: Incompatible field at count '//text//' for group redistribute.' )
314  endif
315  endif
316  if(do_redist)then
317  if(PRESENT(dc_handle))d_comm =>dc_handle ! User has kept pointer to d_comm
318  if(.not.ASSOCIATED(d_comm))then ! d_comm needs initialization or lookup
319  d_comm =>mpp_redistribute_init_comm(domain_in,l_addrs_in(1:l_size),domain_out,l_addrs_out(1:l_size), &
320  isize_in,jsize_in,ke_in,isize_out,jsize_out,ke_out)
321  if(PRESENT(dc_handle))dc_handle =>d_comm ! User wants to keep pointer to d_comm
322  endif
323  call mpp_do_redistribute( l_addrs_in(1:l_size), l_addrs_out(1:l_size), d_comm, d_type )
324  l_size=0; l_addrs_in=-9999; l_addrs_out=-9999
325  isize_in=0; jsize_in=0; ke_in=0
326  isize_out=0; jsize_out=0; ke_out=0
327  d_comm =>NULL()
328  endif
329  endif
330 
331  end subroutine MPP_REDISTRIBUTE_3D_
332 
333 
334  subroutine MPP_REDISTRIBUTE_4D_( domain_in, field_in, domain_out, field_out, complete, free, list_size, dc_handle, position )
335  type(domain2D), intent(in) :: domain_in, domain_out
336  MPP_TYPE_, intent(in) :: field_in (:,:,:,:)
337  MPP_TYPE_, intent(out) :: field_out(:,:,:,:)
338  logical, intent(in), optional :: complete, free
339  integer, intent(in), optional :: list_size
340  integer, intent(in), optional :: position
341  MPP_TYPE_ :: field3D_in (size(field_in, 1),size(field_in, 2),size(field_in ,3)*size(field_in ,4))
342  MPP_TYPE_ :: field3D_out(size(field_out,1),size(field_out,2),size(field_out,3)*size(field_out,4))
343  type(DomainCommunicator2D),pointer,optional :: dc_handle
344  pointer( ptr_in, field3D_in )
345  pointer( ptr_out, field3D_out )
346 
347  ptr_in = 0
348  ptr_out = 0
349  if(domain_in%initialized) ptr_in = LOC(field_in )
350  if(domain_out%initialized) ptr_out = LOC(field_out)
351  call mpp_redistribute( domain_in, field3D_in, domain_out, field3D_out, complete, free, list_size, dc_handle, position )
352 
353  return
354  end subroutine MPP_REDISTRIBUTE_4D_
355 
356  subroutine MPP_REDISTRIBUTE_5D_( domain_in, field_in, domain_out, field_out, complete, free, list_size, dc_handle, position )
357  type(domain2D), intent(in) :: domain_in, domain_out
358  MPP_TYPE_, intent(in) :: field_in (:,:,:,:,:)
359  MPP_TYPE_, intent(out) :: field_out(:,:,:,:,:)
360  logical, intent(in), optional :: complete, free
361  integer, intent(in), optional :: list_size
362  integer, intent(in), optional :: position
363  MPP_TYPE_ :: field3D_in (size(field_in, 1),size(field_in, 2),size(field_in ,3)*size(field_in ,4)*size(field_in ,5))
364  MPP_TYPE_ :: field3D_out(size(field_out,1),size(field_out,2),size(field_out,3)*size(field_out,4)*size(field_out,5))
365 
366  type(DomainCommunicator2D),pointer,optional :: dc_handle
367  pointer( ptr_in, field3D_in )
368  pointer( ptr_out, field3D_out )
369 
370  ptr_in = 0
371  ptr_out = 0
372  if(domain_in%initialized) ptr_in = LOC(field_in )
373  if(domain_out%initialized) ptr_out = LOC(field_out)
374  call mpp_redistribute( domain_in, field3D_in, domain_out, field3D_out, complete, free, list_size, dc_handle, position )
375 
376  return
377  end subroutine MPP_REDISTRIBUTE_5D_
378 
379 #ifdef VECTOR_FIELD_
380 
381 !VECTOR_FIELD_ is set to false for MPP_TYPE_ integer.
382 !vector fields
383  subroutine MPP_UPDATE_DOMAINS_2D_V_( fieldx, fieldy, domain, flags, gridtype, complete, &
384  whalo, ehalo, shalo, nhalo, name, tile_count)
385 !updates data domain of 2D field whose computational domains have been computed
386  MPP_TYPE_, intent(inout) :: fieldx(:,:), fieldy(:,:)
387  type(domain2D), intent(inout) :: domain
388  integer, intent(in), optional :: flags, gridtype
389  logical, intent(in), optional :: complete
390  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo
391  character(len=*), intent(in), optional :: name
392  integer, intent(in), optional :: tile_count
393 
394  MPP_TYPE_ :: field3Dx(size(fieldx,1),size(fieldx,2),1)
395  MPP_TYPE_ :: field3Dy(size(fieldy,1),size(fieldy,2),1)
396  pointer( ptrx, field3Dx )
397  pointer( ptry, field3Dy )
398  ptrx = LOC(fieldx)
399  ptry = LOC(fieldy)
400  call mpp_update_domains( field3Dx, field3Dy, domain, flags, gridtype, complete, &
401  whalo, ehalo, shalo, nhalo, name, tile_count)
402  return
403  end subroutine MPP_UPDATE_DOMAINS_2D_V_
404 
405 
406  subroutine MPP_UPDATE_DOMAINS_3D_V_( fieldx, fieldy, domain, flags, gridtype, complete, &
407  whalo, ehalo, shalo, nhalo, name, tile_count)
408 !updates data domain of 3D field whose computational domains have been computed
409  MPP_TYPE_, intent(inout) :: fieldx(:,:,:), fieldy(:,:,:)
410  type(domain2D), intent(inout) :: domain
411  integer, intent(in), optional :: flags, gridtype
412  logical, intent(in), optional :: complete
413  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo
414  character(len=*), intent(in), optional :: name
415  integer, intent(in), optional :: tile_count
416 
417  integer :: update_whalo, update_ehalo, update_shalo, update_nhalo, ntile
418  integer :: grid_offset_type
419  logical :: exchange_uv
420 
421  integer(LONG_KIND),dimension(MAX_DOMAIN_FIELDS, MAX_TILES),save :: f_addrsx=-9999, f_addrsy=-9999
422  logical :: do_update, is_complete
423  integer, save :: isize(2)=0,jsize(2)=0,ke=0,l_size=0, offset_type=0, list=0
424  integer, save :: whalosz, ehalosz, shalosz, nhalosz
425  integer :: tile, max_ntile
426  integer :: position_x, position_y
427  logical :: set_mismatch
428  character(len=3) :: text
429  MPP_TYPE_ :: d_type
430  type(overlapSpec), pointer :: updatex => NULL()
431  type(overlapSpec), pointer :: updatey => NULL()
432  type(overlapSpec), pointer :: checkx => NULL()
433  type(overlapSpec), pointer :: checky => NULL()
434 
435  if(present(whalo)) then
436  update_whalo = whalo
437  if(abs(update_whalo) > domain%whalo ) call mpp_error(FATAL, "MPP_UPDATE_3D_V: "// &
438  "optional argument whalo should not be larger than the whalo when define domain.")
439  else
440  update_whalo = domain%whalo
441  end if
442  if(present(ehalo)) then
443  update_ehalo = ehalo
444  if(abs(update_ehalo) > domain%ehalo ) call mpp_error(FATAL, "MPP_UPDATE_3D_V: "// &
445  "optional argument ehalo should not be larger than the ehalo when define domain.")
446  else
447  update_ehalo = domain%ehalo
448  end if
449  if(present(shalo)) then
450  update_shalo = shalo
451  if(abs(update_shalo) > domain%shalo ) call mpp_error(FATAL, "MPP_UPDATE_3D_V: "// &
452  "optional argument shalo should not be larger than the shalo when define domain.")
453  else
454  update_shalo = domain%shalo
455  end if
456  if(present(nhalo)) then
457  update_nhalo = nhalo
458  if(abs(update_nhalo) > domain%nhalo ) call mpp_error(FATAL, "MPP_UPDATE_3D_V: "// &
459  "optional argument nhalo should not be larger than the nhalo when define domain.")
460  else
461  update_nhalo = domain%nhalo
462  end if
463 
464  grid_offset_type = AGRID
465  if( PRESENT(gridtype) ) grid_offset_type = gridtype
466 
467  exchange_uv = .false.
468  if(grid_offset_type == DGRID_NE) then
469  exchange_uv = .true.
470  grid_offset_type = CGRID_NE
471  else if( grid_offset_type == DGRID_SW ) then
472  exchange_uv = .true.
473  grid_offset_type = CGRID_SW
474  end if
475 
476  max_ntile = domain%max_ntile_pe
477  ntile = size(domain%x(:))
478 
479  is_complete = .true.
480  if(PRESENT(complete)) then
481  is_complete = complete
482  end if
483  tile = 1
484 
485  if(max_ntile>1) then
486  if(ntile>MAX_TILES) then
487  write( text,'(i2)' ) MAX_TILES
488  call mpp_error(FATAL,'MPP_UPDATE_3D_V: MAX_TILES='//text//' is less than number of tiles on this pe.' )
489  endif
490  if(.NOT. present(tile_count) ) call mpp_error(FATAL, "MPP_UPDATE_3D_V: "// &
491  "optional argument tile_count should be present when number of tiles on some pe is more than 1")
492  tile = tile_count
493  end if
494 
495  do_update = (tile == ntile) .AND. is_complete
496  list = list+1
497  if(list > MAX_DOMAIN_FIELDS)then
498  write( text,'(i2)' ) MAX_DOMAIN_FIELDS
499  call mpp_error(FATAL,'MPP_UPDATE_3D_V: MAX_DOMAIN_FIELDS='//text//' exceeded for group update.' )
500  endif
501 
502  f_addrsx(list, tile) = LOC(fieldx)
503  f_addrsy(list, tile) = LOC(fieldy)
504 
505  if(list == 1 .AND. tile == 1)then
506  isize(1)=size(fieldx,1); jsize(1)=size(fieldx,2); ke = size(fieldx,3)
507  isize(2)=size(fieldy,1); jsize(2)=size(fieldy,2)
508  offset_type = grid_offset_type
509  whalosz = update_whalo; ehalosz = update_ehalo; shalosz = update_shalo; nhalosz = update_nhalo
510  else
511  set_mismatch = .false.
512  set_mismatch = set_mismatch .OR. (isize(1) /= size(fieldx,1))
513  set_mismatch = set_mismatch .OR. (jsize(1) /= size(fieldx,2))
514  set_mismatch = set_mismatch .OR. (ke /= size(fieldx,3))
515  set_mismatch = set_mismatch .OR. (isize(2) /= size(fieldy,1))
516  set_mismatch = set_mismatch .OR. (jsize(2) /= size(fieldy,2))
517  set_mismatch = set_mismatch .OR. (ke /= size(fieldy,3))
518  set_mismatch = set_mismatch .OR. (grid_offset_type /= offset_type)
519  set_mismatch = set_mismatch .OR. (update_whalo /= whalosz)
520  set_mismatch = set_mismatch .OR. (update_ehalo /= ehalosz)
521  set_mismatch = set_mismatch .OR. (update_shalo /= shalosz)
522  set_mismatch = set_mismatch .OR. (update_nhalo /= nhalosz)
523  if(set_mismatch)then
524  write( text,'(i2)' ) list
525  call mpp_error(FATAL,'MPP_UPDATE_3D_V: Incompatible field at count '//text//' for group vector update.' )
526  end if
527  end if
528  if(is_complete) then
529  l_size = list
530  list = 0
531  end if
532  if(do_update)then
533  if( domain_update_is_needed(domain, update_whalo, update_ehalo, update_shalo, update_nhalo) )then
534  select case(grid_offset_type)
535  case (AGRID)
536  position_x = CENTER
537  position_y = CENTER
538  case (BGRID_NE, BGRID_SW)
539  position_x = CORNER
540  position_y = CORNER
541  case (CGRID_NE, CGRID_SW)
542  position_x = EAST
543  position_y = NORTH
544  case default
545  call mpp_error(FATAL, "mpp_update_domains2D.h: invalid value of grid_offset_type")
546  end select
547 
548  if(debug_update_level .NE. NO_CHECK) then
549  checkx => search_check_overlap(domain, position_x)
550  checky => search_check_overlap(domain, position_y)
551  if(ASSOCIATED(checkx)) then
552  if(exchange_uv) then
553  call mpp_do_check(f_addrsx(1:l_size,1:ntile),f_addrsy(1:l_size,1:ntile), domain, &
554  checky, checkx, d_type, ke, flags, name)
555  else
556  call mpp_do_check(f_addrsx(1:l_size,1:ntile),f_addrsy(1:l_size,1:ntile), domain, &
557  checkx, checky, d_type, ke, flags, name)
558  end if
559  endif
560  endif
561  updatex => search_update_overlap(domain, update_whalo, update_ehalo, update_shalo, update_nhalo, position_x)
562  updatey => search_update_overlap(domain, update_whalo, update_ehalo, update_shalo, update_nhalo, position_y)
563  if(exchange_uv) then
564  call mpp_do_update(f_addrsx(1:l_size,1:ntile),f_addrsy(1:l_size,1:ntile), domain, updatey, updatex, &
565  d_type,ke, grid_offset_type, flags)
566  else
567  call mpp_do_update(f_addrsx(1:l_size,1:ntile),f_addrsy(1:l_size,1:ntile), domain, updatex, updatey, &
568  d_type,ke,grid_offset_type, flags)
569  end if
570  end if
571  l_size=0; f_addrsx=-9999; f_addrsy=-9999; isize=0; jsize=0; ke=0
572  end if
573 
574  return
575  end subroutine MPP_UPDATE_DOMAINS_3D_V_
576 
577 
578  subroutine MPP_UPDATE_DOMAINS_4D_V_( fieldx, fieldy, domain, flags, gridtype, complete, &
579  whalo, ehalo, shalo, nhalo, name, tile_count )
580 !updates data domain of 4D field whose computational domains have been computed
581  MPP_TYPE_, intent(inout) :: fieldx(:,:,:,:), fieldy(:,:,:,:)
582  type(domain2D), intent(inout) :: domain
583  integer, intent(in), optional :: flags, gridtype
584  logical, intent(in), optional :: complete
585  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo
586  character(len=*), intent(in), optional :: name
587  integer, intent(in), optional :: tile_count
588 
589  MPP_TYPE_ :: field3Dx(size(fieldx,1),size(fieldx,2),size(fieldx,3)*size(fieldx,4))
590  MPP_TYPE_ :: field3Dy(size(fieldy,1),size(fieldy,2),size(fieldy,3)*size(fieldy,4))
591 
592  pointer( ptrx, field3Dx )
593  pointer( ptry, field3Dy )
594  ptrx = LOC(fieldx)
595  ptry = LOC(fieldy)
596  call mpp_update_domains( field3Dx, field3Dy, domain, flags, gridtype, complete, &
597  whalo, ehalo, shalo, nhalo, name, tile_count)
598  return
599  end subroutine MPP_UPDATE_DOMAINS_4D_V_
600 
601  subroutine MPP_UPDATE_DOMAINS_5D_V_( fieldx, fieldy, domain, flags, gridtype, complete, &
602  whalo, ehalo, shalo, nhalo, name, tile_count )
603 !updates data domain of 5D field whose computational domains have been computed
604  MPP_TYPE_, intent(inout) :: fieldx(:,:,:,:,:), fieldy(:,:,:,:,:)
605  type(domain2D), intent(inout) :: domain
606  integer, intent(in), optional :: flags, gridtype
607  logical, intent(in), optional :: complete
608  integer, intent(in), optional :: whalo, ehalo, shalo, nhalo
609  character(len=*), intent(in), optional :: name
610  integer, intent(in), optional :: tile_count
611 
612  MPP_TYPE_ :: field3Dx(size(fieldx,1),size(fieldx,2),size(fieldx,3)*size(fieldx,4)*size(fieldx,5))
613  MPP_TYPE_ :: field3Dy(size(fieldy,1),size(fieldy,2),size(fieldy,3)*size(fieldy,4)*size(fieldy,5))
614  pointer( ptrx, field3Dx )
615  pointer( ptry, field3Dy )
616  ptrx = LOC(fieldx)
617  ptry = LOC(fieldy)
618  call mpp_update_domains( field3Dx, field3Dy, domain, flags, gridtype, complete, &
619  whalo, ehalo, shalo, nhalo, name, tile_count)
620 
621  return
622  end subroutine MPP_UPDATE_DOMAINS_5D_V_
623 #endif /* VECTOR_FIELD_ */
************************************************************************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
*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 l_size integer
string author
Definition: conf.py:58
*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_DOMAINS_2D_(field, domain, flags, complete, position, &whalo, ehalo, shalo, nhalo, name, tile_count)!updates data domain of 2D field whose computational domains have been computed MPP_TYPE_, intent(inout) ::field(:,:) type(domain2D), intent(inout) ::domain integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::whalo, ehalo, shalo, nhalo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::field3D(size(field, 1), size(field, 2), 1) pointer(ptr, field3D) ptr=LOC(field) call mpp_update_domains(field3D, domain, flags, complete, position, &whalo, ehalo, shalo, nhalo, name, tile_count) return end subroutine MPP_UPDATE_DOMAINS_2D_ subroutine MPP_UPDATE_DOMAINS_3D_(field, domain, flags, complete, position, &whalo, ehalo, shalo, nhalo, name, tile_count)!updates data domain of 3D field whose computational domains have been computed MPP_TYPE_, intent(inout) ::field(:,:,:) type(domain2D), intent(inout) ::domain integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::whalo, ehalo, shalo, nhalo ! specify halo region to be updated. character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count integer ::update_position, update_whalo, update_ehalo, update_shalo, update_nhalo, ntile integer(LONG_KIND), dimension(MAX_DOMAIN_FIELDS, MAX_TILES), save ::f_addrs=-9999 integer ::tile, max_ntile character(len=3) ::text logical ::set_mismatch, is_complete logical ::do_update integer, save ::isize=0, jsize=0, ke=0, l_size=0, list=0 integer, save ::pos, whalosz, ehalosz, shalosz, nhalosz MPP_TYPE_ ::d_type type(overlapSpec), pointer ::update=> NULL() type(overlapSpec)
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
*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
character(len=256) text
Definition: mpp_io.F90:1051
integer(long), parameter true
************************************************************************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_DO_REDISTRIBUTE_3D_(f_in, f_out, d_comm, d_type) integer(LONG_KIND), intent(in) ::f_in(:), f_out(:) type(DomainCommunicator2D), intent(in) ::d_comm MPP_TYPE_, intent(in) ::d_type MPP_TYPE_ ::field_in(d_comm%domain_in%x(1)%data%begin:d_comm%domain_in%x(1)%data%end, &d_comm%domain_in%y(1)%data%begin:d_comm%domain_in%y(1)%data%end, d_comm%ke) pointer(ptr_field_in, field_in) MPP_TYPE_ ::field_out(d_comm%domain_out%x(1)%data%begin:d_comm%domain_out%x(1)%data%end, &d_comm%domain_out%y(1)%data%begin:d_comm%domain_out%y(1)%data%end, d_comm%ke) pointer(ptr_field_out, field_out) type(domain2D), pointer ::domain_in, domain_out integer ::i, j, k, l, n, l_size integer ::is, ie, js, je integer ::ke integer ::list, pos, msgsize integer ::to_pe, from_pe MPP_TYPE_ ::buffer(size(mpp_domains_stack(:))) pointer(ptr, buffer) integer ::buffer_pos, wordlen, errunit!fix ke errunit=stderr() l_size=size(f_out(:)) ! equal to size(f_in(:)) ke=d_comm%ke domain_in=> d_comm domain_in
type(field_mgr_type), dimension(max_fields), private fields
integer(long), parameter false
************************************************************************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 MPP_TYPE_
character(len=32) name
l_size ! loop over number of fields ke do je do ie to je n if(.NOT. d_comm%R_do_buf(list)) cycle from_pe
character(len=128) version
l_size ! loop over number of fields ke do je do ie to is
type
Definition: c2f.py:15
************************************************************************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_GLOBAL_FIELD_2D_(domain, local, global, flags, position, tile_count, default_data) type(domain2D), intent(in) ::domain MPP_TYPE_, intent(in) ::local(:,:) MPP_TYPE_, intent(out) ::global(:,:) integer, intent(in), optional ::flags integer, intent(in), optional ::position integer, intent(in), optional ::tile_count MPP_TYPE_, intent(in), optional ::default_data MPP_TYPE_ ::local3D(size(local, 1), size(local, 2), 1) MPP_TYPE_ ::global3D(size(global, 1), size(global, 2), 1) pointer(lptr, local3D) pointer(gptr, global3D) lptr=LOC(local) gptr=LOC(global) call mpp_global_field(domain, local3D, global3D, flags, position, tile_count, default_data) end subroutine MPP_GLOBAL_FIELD_2D_ subroutine MPP_GLOBAL_FIELD_3D_(domain, local, global, flags, position, tile_count, default_data)!get a global field from a local field!local field may be on compute OR data domain type(domain2D), intent(in) ::domain MPP_TYPE_, intent(in) ::local(:,:,:) MPP_TYPE_, intent(out) ::global(:,:,:) integer, intent(in), optional ::flags integer, intent(in), optional ::position integer, intent(in), optional ::tile_count MPP_TYPE_, intent(in), optional ::default_data integer ::ishift, jshift integer ::tile integer ::isize, jsize tile=1;if(PRESENT(tile_count)) tile=tile_count call mpp_get_domain_shift(domain, ishift, jshift, position) ! The alltoallw method requires that local and global be contiguous. ! We presume that `local` is contiguous if it matches the data domain;! `global` is presumed to always be contiguous. ! Ideally we would use the F2015 function IS_CONTIGUOUS() to validate ! contiguity, but it is not yet suppored in many compilers. ! Also worth noting that many of the nD-> conversion also assumes so there many be other issues here isize
************************************************************************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 mpp_error(FATAL, 'MPP_TRANSMIT:you cannot transmit to ANY_PE using MPI.') else if(to_pe.NE.NULL_PE) then !no other valid cases except NULL_PE call mpp_error(FATAL
************************************************************************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 READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this case
logical function received(this, seqno)
#define LONG_KIND
************************************************************************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 READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> tlevel if(PRESENT(start_in) .AND. PRESENT(axsiz_in)) then if(size(start(! the data domain and compute domain must refer to the subdomain being passed ! In this ! since that attempts to gather all data on PE size(field%axes(:)) axsiz(i)
************************************************************************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 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=> dimension(MAX_DOMAIN_FIELDS)
type(domaincommunicator2d), dimension(:), allocatable, target, save d_comm
*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 jsize
l_size ! loop over number of fields ke do je do ie pos
subroutine, public some(xmap, some_arr, grid_id)
Definition: xgrid.F90:3421
integer debug_update_level