pass_var_2d does a halo update for a two-dimensional array.
185 real,
dimension(:,:),
intent(inout) :: array
187 type(MOM_domain_type),
intent(inout) :: MOM_dom
189 integer,
optional,
intent(in) :: sideflag
193 logical,
optional,
intent(in) :: complete
197 integer,
optional,
intent(in) :: position
200 integer,
optional,
intent(in) :: halo
202 integer,
optional,
intent(in) :: inner_halo
206 integer,
optional,
intent(in) :: clock
210 real,
allocatable,
dimension(:,:) :: tmp
211 integer :: pos, i_halo, j_halo
212 integer :: isc, iec, jsc, jec, isd, ied, jsd, jed, IscB, IecB, JscB, JecB
213 integer :: inner, i, j, isfw, iefw, isfe, iefe, jsfs, jefs, jsfn, jefn
215 logical :: block_til_complete
217 if (
present(clock))
then ;
if (clock>0)
call cpu_clock_begin(clock) ;
endif
220 if (
present(sideflag))
then ;
if (sideflag > 0) dirflag = sideflag ;
endif
221 block_til_complete = .true. ;
if (
present(complete)) block_til_complete = complete
222 pos = center ;
if (
present(position)) pos = position
224 if (
present(inner_halo))
then ;
if (inner_halo >= 0)
then
226 allocate(tmp(
size(array,1),
size(array,2)))
227 tmp(:,:) = array(:,:)
228 block_til_complete = .true.
231 if (
present(halo) .and. mom_dom%thin_halo_updates)
then
232 call mpp_update_domains(array, mom_dom%mpp_domain, flags=dirflag, &
233 complete=block_til_complete, position=position, &
234 whalo=halo, ehalo=halo, shalo=halo, nhalo=halo)
236 call mpp_update_domains(array, mom_dom%mpp_domain, flags=dirflag, &
237 complete=block_til_complete, position=position)
240 if (
present(inner_halo))
then ;
if (inner_halo >= 0)
then
241 call mpp_get_compute_domain(mom_dom%mpp_domain, isc, iec, jsc, jec)
242 call mpp_get_data_domain(mom_dom%mpp_domain, isd, ied, jsd, jed)
244 isc = isc - (isd-1) ; iec = iec - (isd-1) ; ied = ied - (isd-1) ; isd = 1
245 jsc = jsc - (jsd-1) ; jec = jec - (jsd-1) ; jed = jed - (jsd-1) ; jsd = 1
246 i_halo = min(inner_halo, isc-1) ; j_halo = min(inner_halo, jsc-1)
249 if (pos == center)
then
250 if (
size(array,1) == ied)
then
251 isfw = isc - i_halo ; iefw = isc ; isfe = iec ; iefe = iec + i_halo
252 else ;
call mom_error(fatal,
"pass_var_2d: wrong i-size for CENTER array.") ;
endif
253 if (
size(array,2) == jed)
then
254 isfw = isc - i_halo ; iefw = isc ; isfe = iec ; iefe = iec + i_halo
255 else ;
call mom_error(fatal,
"pass_var_2d: wrong j-size for CENTER array.") ;
endif
256 elseif (pos == corner)
then
257 if (
size(array,1) == ied)
then
258 isfw = max(isc - (i_halo+1), 1) ; iefw = isc ; isfe = iec ; iefe = iec + i_halo
259 elseif (
size(array,1) == ied+1)
then
260 isfw = isc - i_halo ; iefw = isc+1 ; isfe = iec+1 ; iefe = min(iec + 1 + i_halo, ied+1)
261 else ;
call mom_error(fatal,
"pass_var_2d: wrong i-size for CORNER array.") ;
endif
262 if (
size(array,2) == jed)
then
263 jsfs = max(jsc - (j_halo+1), 1) ; jefs = jsc ; jsfn = jec ; jefn = jec + j_halo
264 elseif (
size(array,2) == jed+1)
then
265 jsfs = jsc - j_halo ; jefs = jsc+1 ; jsfn = jec+1 ; jefn = min(jec + 1 + j_halo, jed+1)
266 else ;
call mom_error(fatal,
"pass_var_2d: wrong j-size for CORNER array.") ;
endif
268 call mom_error(fatal,
"pass_var_2d: Unrecognized position")
272 do j=jsfs,jefn ;
do i=isfw,iefw ; array(i,j) = tmp(i,j) ;
enddo ;
enddo
273 do j=jsfs,jefn ;
do i=isfe,iefe ; array(i,j) = tmp(i,j) ;
enddo ;
enddo
274 do j=jsfs,jefs ;
do i=isfw,iefe ; array(i,j) = tmp(i,j) ;
enddo ;
enddo
275 do j=jsfn,jefn ;
do i=isfw,iefe ; array(i,j) = tmp(i,j) ;
enddo ;
enddo
280 if (
present(clock))
then ;
if (clock>0)
call cpu_clock_end(clock) ;
endif