7 use mpp_domains_mod,
only : center, corner, north, east
8 use data_override_mod,
only : data_override_init, data_override
18 use astronomy_mod,
only : orbital_time, diurnal_solar, daily_mean_solar
25 implicit none ;
private
39 #include "MOM_memory.h"
40 #include "version_variable.h"
49 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
51 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
53 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
55 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
56 intent(inout) :: h_new
59 integer :: i, j, k, m, is, ie, js, je, nz
61 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
64 do i=is-1,ie+1 ;
do j=js-1,je+1
66 h_new(i,j,k) = max(0.0, g%US%L_to_m**2*g%areaT(i,j)*h_pre(i,j,k) + &
67 ((uhtr(i-1,j,k) - uhtr(i,j,k)) + (vhtr(i,j-1,k) - vhtr(i,j,k))))
72 h_new(i,j,k) = h_new(i,j,k) + &
73 max(gv%Angstrom_H, 1.0e-13*h_new(i,j,k) - g%US%L_to_m**2*g%areaT(i,j)*h_pre(i,j,k))
76 h_new(i,j,k) = h_new(i,j,k) / (g%US%L_to_m**2*g%areaT(i,j))
87 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
90 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
93 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
96 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
97 intent(inout) :: h_new
100 integer :: i, j, k, m, is, ie, js, je, nz
102 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
109 h_new(i,j,1) = max(0.0, h_pre(i,j,1) + (eb(i,j,1) - ea(i,j,2) + ea(i,j,1) ))
110 h_new(i,j,1) = h_new(i,j,1) + &
111 max(0.0, 1.0e-13*h_new(i,j,1) - h_pre(i,j,1))
115 h_new(i,j,nz) = max(0.0, h_pre(i,j,nz) + (ea(i,j,nz) - eb(i,j,nz-1)+eb(i,j,nz)))
116 h_new(i,j,nz) = h_new(i,j,nz) + &
117 max(0.0, 1.0e-13*h_new(i,j,nz) - h_pre(i,j,nz))
122 do k=2,nz-1 ;
do i=is-1,ie+1
124 h_new(i,j,k) = max(0.0, h_pre(i,j,k) + ((ea(i,j,k) - eb(i,j,k-1)) + &
125 (eb(i,j,k) - ea(i,j,k+1))))
126 h_new(i,j,k) = h_new(i,j,k) + &
127 max(0.0, 1.0e-13*h_new(i,j,k) - h_pre(i,j,k))
140 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
142 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
144 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
147 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
150 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
155 integer :: i, j, k, m, is, ie, js, je, nz
156 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)) :: top_flux, bottom_flux
157 real :: pos_flux, hvol, h_neglect, scale_factor, max_off_cfl
166 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
171 do j=js-1,je+1 ;
do i=is-1,ie+1
172 top_flux(i,j,k) = -ea(i,j,k)
173 bottom_flux(i,j,k) = -(eb(i,j,k)-ea(i,j,k+1))
176 do k=2, nz-1 ;
do j=js-1,je+1 ;
do i=is-1,ie+1
177 top_flux(i,j,k) = -(ea(i,j,k)-eb(i,j,k-1))
178 bottom_flux(i,j,k) = -(eb(i,j,k)-ea(i,j,k+1))
179 enddo ;
enddo ;
enddo
182 do j=js-1,je+1 ;
do i=is-1,ie+1
183 top_flux(i,j,k) = -(ea(i,j,k)-eb(i,j,k-1))
184 bottom_flux(i,j,k) = -eb(i,j,k)
190 do k = 1, nz ;
do j=js-1,je+1 ;
do i=is-1,ie+1
192 hvol = h_pre(i,j,k)*g%US%L_to_m**2*g%areaT(i,j)
193 pos_flux = max(0.0,-uh(i-1,j,k)) + max(0.0, -vh(i,j-1,k)) + &
194 max(0.0, uh(i,j,k)) + max(0.0, vh(i,j,k)) + &
195 max(0.0, top_flux(i,j,k)*g%US%L_to_m**2*g%areaT(i,j)) + max(0.0, bottom_flux(i,j,k)*g%US%L_to_m**2*g%areaT(i,j))
197 if (pos_flux>hvol .and. pos_flux>0.0)
then
198 scale_factor = ( hvol )/pos_flux*max_off_cfl
204 if (-uh(i-1,j,k)>0) uh(i-1,j,k) = uh(i-1,j,k)*scale_factor
205 if (uh(i,j,k)>0) uh(i,j,k) = uh(i,j,k)*scale_factor
206 if (-vh(i,j-1,k)>0) vh(i,j-1,k) = vh(i,j-1,k)*scale_factor
207 if (vh(i,j,k)>0) vh(i,j,k) = vh(i,j,k)*scale_factor
209 if (k>1 .and. k<nz)
then
211 if (top_flux(i,j,k)>0.0)
then
212 ea(i,j,k) = ea(i,j,k)*scale_factor
213 eb(i,j,k-1) = eb(i,j,k-1)*scale_factor
215 if (bottom_flux(i,j,k)>0.0)
then
216 eb(i,j,k) = eb(i,j,k)*scale_factor
217 ea(i,j,k+1) = ea(i,j,k+1)*scale_factor
221 if (top_flux(i,j,k)>0.0) ea(i,j,k) = ea(i,j,k)*scale_factor
222 if (bottom_flux(i,j,k)>0.0)
then
223 eb(i,j,k) = eb(i,j,k)*scale_factor
224 ea(i,j,k+1) = ea(i,j,k+1)*scale_factor
228 if (top_flux(i,j,k)>0.0)
then
229 ea(i,j,k) = ea(i,j,k)*scale_factor
230 eb(i,j,k-1) = eb(i,j,k-1)*scale_factor
232 if (bottom_flux(i,j,k)>0.0) eb(i,j,k)=eb(i,j,k)*scale_factor
234 enddo ;
enddo ;
enddo
243 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
246 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
249 real,
dimension(SZIB_(G),SZK_(G)) :: uh2d
250 real,
dimension(SZIB_(G)) :: uh2d_sum
251 real,
dimension(SZI_(G),SZK_(G)) :: h2d
252 real,
dimension(SZI_(G)) :: h2d_sum
254 integer :: i, j, k, m, is, ie, js, je, nz
258 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
263 do k=1,nz ;
do i=is-1,ie
264 uh2d(i,k) = uh(i,j,k)
265 uh2d_sum(i) = uh2d_sum(i) + uh2d(i,k)
270 do k=1,nz ;
do i=is-1,ie+1
271 h2d(i,k) = hvol(i,j,k)
272 if (hvol(i,j,k)>0.)
then
273 h2d_sum(i) = h2d_sum(i) + h2d(i,k)
275 h2d(i,k) = gv%H_subroundoff
282 if ( uh2d_sum(i)>0.0 )
then
284 uh2d(i,k) = uh2d_sum(i)*(h2d(i,k)/h2d_sum(i))
286 elseif (uh2d_sum(i)<0.0)
then
288 uh2d(i,k) = uh2d_sum(i)*(h2d(i+1,k)/h2d_sum(i+1))
297 uh_neglect = gv%Angstrom_H*g%US%L_to_m**2 * min(g%areaT(i,j), g%areaT(i+1,j))
298 if ( abs(sum(uh2d(i,:))-uh2d_sum(i)) > uh_neglect) &
299 call mom_error(warning,
"Column integral of uh does not match after "//&
300 "barotropic redistribution")
303 do k=1,nz ;
do i=is-1,ie
304 uh(i,j,k) = uh2d(i,k)
314 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
317 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
320 real,
dimension(SZJB_(G),SZK_(G)) :: vh2d
321 real,
dimension(SZJB_(G)) :: vh2d_sum
322 real,
dimension(SZJ_(G),SZK_(G)) :: h2d
323 real,
dimension(SZJ_(G)) :: h2d_sum
325 integer :: i, j, k, m, is, ie, js, je, nz
329 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
334 do k=1,nz ;
do j=js-1,je
335 vh2d(j,k) = vh(i,j,k)
336 vh2d_sum(j) = vh2d_sum(j) + vh2d(j,k)
341 do k=1,nz ;
do j=js-1,je+1
342 h2d(j,k) = hvol(i,j,k)
343 if (hvol(i,j,k)>0.)
then
344 h2d_sum(j) = h2d_sum(j) + h2d(j,k)
346 h2d(j,k) = gv%H_subroundoff
352 if ( vh2d_sum(j)>0.0 )
then
354 vh2d(j,k) = vh2d_sum(j)*(h2d(j,k)/h2d_sum(j))
356 elseif (vh2d_sum(j)<0.0)
then
358 vh2d(j,k) = vh2d_sum(j)*(h2d(j+1,k)/h2d_sum(j+1))
367 vh_neglect = gv%Angstrom_H*g%US%L_to_m**2 * min(g%areaT(i,j), g%areaT(i,j+1))
368 if ( abs(sum(vh2d(j,:))-vh2d_sum(j)) > vh_neglect)
then
369 call mom_error(warning,
"Column integral of vh does not match after "//&
370 "barotropic redistribution")
375 do k=1,nz ;
do j=js-1,je
376 vh(i,j,k) = vh2d(j,k)
387 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
390 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
393 real,
dimension(SZIB_(G),SZK_(G)) :: uh2d
394 real,
dimension(SZI_(G),SZK_(G)) :: h2d
396 real :: uh_neglect, uh_remain, uh_add, uh_sum, uh_col, uh_max
397 real :: hup, hdown, hlos, min_h
398 integer :: i, j, k, m, is, ie, js, je, nz, k_rev
401 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
403 min_h = gv%Angstrom_H*0.1
407 do k=1,nz ;
do i=is-2,ie+1
408 uh2d(i,k) = uh(i,j,k)
410 do k=1,nz ;
do i=is-1,ie+1
412 h2d(i,k) = hvol(i,j,k)-min_h*g%US%L_to_m**2*g%areaT(i,j)
416 uh_col = sum(uh2d(i,:))
418 uh_remain = uh2d(i,k)
420 if (abs(uh_remain)>0.0)
then
422 uh_sum = uh_remain + uh2d(i,k_rev)
425 hlos = max(0.0,uh2d(i+1,k_rev))
426 if ((((hup - hlos) + uh_sum) < 0.0) .and. &
427 ((0.5*hup + uh_sum) < 0.0))
then
428 uh2d(i,k_rev) = min(-0.5*hup,-hup+hlos,0.0)
429 uh_remain = uh_sum - uh2d(i,k_rev)
431 uh2d(i,k_rev) = uh_sum
437 hlos = max(0.0,-uh2d(i-1,k_rev))
438 if ((((hup - hlos) - uh_sum) < 0.0) .and. &
439 ((0.5*hup - uh_sum) < 0.0))
then
440 uh2d(i,k_rev) = max(0.5*hup,hup-hlos,0.0)
441 uh_remain = uh_sum - uh2d(i,k_rev)
443 uh2d(i,k_rev) = uh_sum
451 if (abs(uh_remain)>0.0)
then
453 uh2d(i,k+1) = uh2d(i,k+1) + uh_remain
455 uh2d(i,k) = uh2d(i,k) + uh_remain
456 call mom_error(warning,
"Water column cannot accommodate UH redistribution. Tracer may not be conserved")
463 uh_neglect = gv%Angstrom_H*g%US%L_to_m**2 * min(g%areaT(i,j), g%areaT(i+1,j))
464 if (abs(uh_col - sum(uh2d(i,:)))>uh_neglect)
then
465 call mom_error(warning,
"Column integral of uh does not match after "//&
466 "upwards redistribution")
471 do k=1,nz ;
do i=is-1,ie
472 uh(i,j,k) = uh2d(i,k)
483 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
486 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
489 real,
dimension(SZJB_(G),SZK_(G)) :: vh2d
490 real,
dimension(SZJB_(G)) :: vh2d_sum
491 real,
dimension(SZJ_(G),SZK_(G)) :: h2d
492 real,
dimension(SZJ_(G)) :: h2d_sum
494 real :: vh_neglect, vh_remain, vh_col, vh_sum
495 real :: hup, hlos, min_h
496 integer :: i, j, k, m, is, ie, js, je, nz, k_rev
499 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
501 min_h = 0.1*gv%Angstrom_H
505 do k=1,nz ;
do j=js-2,je+1
506 vh2d(j,k) = vh(i,j,k)
508 do k=1,nz ;
do j=js-1,je+1
509 h2d(j,k) = hvol(i,j,k)-min_h*g%US%L_to_m**2*g%areaT(i,j)
513 vh_col = sum(vh2d(j,:))
515 vh_remain = vh2d(j,k)
517 if (abs(vh_remain)>0.0)
then
519 vh_sum = vh_remain + vh2d(j,k_rev)
522 hlos = max(0.0,vh2d(j+1,k_rev))
523 if ((((hup - hlos) + vh_sum) < 0.0) .and. &
524 ((0.5*hup + vh_sum) < 0.0))
then
525 vh2d(j,k_rev) = min(-0.5*hup,-hup+hlos,0.0)
526 vh_remain = vh_sum - vh2d(j,k_rev)
528 vh2d(j,k_rev) = vh_sum
534 hlos = max(0.0,-vh2d(j-1,k_rev))
535 if ((((hup - hlos) - vh_sum) < 0.0) .and. &
536 ((0.5*hup - vh_sum) < 0.0))
then
537 vh2d(j,k_rev) = max(0.5*hup,hup-hlos,0.0)
538 vh_remain = vh_sum - vh2d(j,k_rev)
540 vh2d(j,k_rev) = vh_sum
549 if (abs(vh_remain)>0.0)
then
551 vh2d(j,k+1) = vh2d(j,k+1) + vh_remain
553 vh2d(j,k) = vh2d(j,k) + vh_remain
554 call mom_error(warning,
"Water column cannot accommodate VH redistribution. Tracer will not be conserved")
561 vh_neglect = gv%Angstrom_H*g%US%L_to_m**2 * min(g%areaT(i,j), g%areaT(i,j+1))
562 if ( abs(vh_col-sum(vh2d(j,:))) > vh_neglect)
then
563 call mom_error(warning,
"Column integral of vh does not match after "//&
564 "upwards redistribution")
568 do k=1,nz ;
do j=js-1,je
569 vh(i,j,k) = vh2d(j,k)
580 type(time_type),
intent(in) :: time_start
581 type(time_type),
intent(in) :: time_end
583 real :: diurnal_factor, time_since_ae, rad
584 real :: fracday_dt, fracday_day
585 real :: cosz_day, cosz_dt, rrsun_day, rrsun_dt
586 type(time_type) :: dt_here
588 integer :: i, j, k, i2, j2, isc, iec, jsc, jec, i_off, j_off
590 isc = g%isc ; iec = g%iec ; jsc = g%jsc ; jec = g%jec
591 i_off = lbound(fluxes%sens,1) - g%isc ; j_off = lbound(fluxes%sens,2) - g%jsc
595 time_since_ae = orbital_time(time_start)
596 dt_here = time_end - time_start
603 do j=jsc,jec ;
do i=isc,iec
610 call diurnal_solar(g%geoLatT(i,j)*rad, g%geoLonT(i,j)*rad, time_start, cosz=cosz_dt, &
611 fracday=fracday_dt, rrsun=rrsun_dt, dt_time=dt_here)
612 call daily_mean_solar(g%geoLatT(i,j)*rad, time_since_ae, cosz_day, fracday_day, rrsun_day)
613 diurnal_factor = cosz_dt*fracday_dt*rrsun_dt / &
614 max(1e-30, cosz_day*fracday_day*rrsun_day)
616 i2 = i+i_off ; j2 = j+j_off
617 fluxes%sw(i2,j2) = fluxes%sw(i2,j2) * diurnal_factor
618 fluxes%sw_vis_dir(i2,j2) = fluxes%sw_vis_dir(i2,j2) * diurnal_factor
619 fluxes%sw_vis_dif(i2,j2) = fluxes%sw_vis_dif(i2,j2) * diurnal_factor
620 fluxes%sw_nir_dir(i2,j2) = fluxes%sw_nir_dir(i2,j2) * diurnal_factor
621 fluxes%sw_nir_dif(i2,j2) = fluxes%sw_nir_dif(i2,j2) * diurnal_factor
629 uhtr, vhtr, temp_mean, salt_mean, mld, Kd, fluxes, ridx_sum, ridx_snap, read_mld, read_sw, &
630 read_ts_uvh, do_ale_in)
634 integer,
intent(in ) :: nk_input
635 character(len=*),
intent(in ) :: mean_file
636 character(len=*),
intent(in ) :: sum_file
637 character(len=*),
intent(in ) :: snap_file
638 character(len=*),
intent(in ) :: surf_file
639 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
640 intent(inout) :: uhtr
641 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
642 intent(inout) :: vhtr
643 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
644 intent(inout) :: h_end
645 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
646 intent(inout) :: temp_mean
647 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
648 intent(inout) :: salt_mean
649 real,
dimension(SZI_(G),SZJ_(G)), &
651 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)+1), &
653 type(
forcing),
intent(inout) :: fluxes
654 integer,
intent(in ) :: ridx_sum
655 integer,
intent(in ) :: ridx_snap
656 logical,
intent(in ) :: read_mld
657 logical,
intent(in ) :: read_sw
658 logical,
intent(in ) :: read_ts_uvh
659 logical,
optional,
intent(in ) :: do_ale_in
662 integer :: i, j, k, is, ie, js, je, nz
666 if (
present(do_ale_in) ) do_ale = do_ale_in
668 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
671 if (read_ts_uvh)
then
673 temp_mean(:,:,:) = 0.0
674 salt_mean(:,:,:) = 0.0
678 call mom_read_vector(sum_file,
'uhtr_sum',
'vhtr_sum', uhtr(:,:,1:nk_input), &
679 vhtr(:,:,1:nk_input), g%Domain, timelevel=ridx_sum)
680 call mom_read_data(snap_file,
'h_end', h_end(:,:,1:nk_input), g%Domain, &
681 timelevel=ridx_snap,position=center)
682 call mom_read_data(mean_file,
'temp', temp_mean(:,:,1:nk_input), g%Domain, &
683 timelevel=ridx_sum,position=center)
684 call mom_read_data(mean_file,
'salt', salt_mean(:,:,1:nk_input), g%Domain, &
685 timelevel=ridx_sum,position=center)
688 do j=js,je ;
do i=is,ie
689 if (g%mask2dT(i,j)>0.)
then
690 temp_mean(:,:,nk_input:nz) = temp_mean(i,j,nk_input)
691 salt_mean(:,:,nk_input:nz) = salt_mean(i,j,nk_input)
696 call mom_read_data( mean_file,
'Kd_interface', kd(:,:,1:nk_input+1), g%Domain, &
697 timelevel=ridx_sum,position=center)
702 if (.not.
associated(fluxes%netMassOut))
then
703 allocate(fluxes%netMassOut(g%isd:g%ied,g%jsd:g%jed))
704 fluxes%netMassOut(:,:) = 0.0
706 if (.not.
associated(fluxes%netMassIn))
then
707 allocate(fluxes%netMassIn(g%isd:g%ied,g%jsd:g%jed))
708 fluxes%netMassIn(:,:) = 0.0
711 fluxes%netMassOut(:,:) = 0.0
712 fluxes%netMassIn(:,:) = 0.0
713 call mom_read_data(surf_file,
'massout_flux_sum',fluxes%netMassOut, g%Domain, &
715 call mom_read_data(surf_file,
'massin_flux_sum', fluxes%netMassIn, g%Domain, &
718 do j=js,je ;
do i=is,ie
719 if (g%mask2dT(i,j)<1.0)
then
720 fluxes%netMassOut(i,j) = 0.0
721 fluxes%netMassIn(i,j) = 0.0
728 call mom_read_data(surf_file,
'ePBL_h_ML', mld, g%Domain, timelevel=ridx_sum)
736 call mom_read_data(mean_file,
'sw_vis',fluxes%sw_vis_dir, g%Domain, &
738 call mom_read_data(mean_file,
'sw_nir',fluxes%sw_nir_dir, g%Domain, &
740 fluxes%sw_vis_dir(:,:) = fluxes%sw_vis_dir(:,:)*0.5
741 fluxes%sw_vis_dif(:,:) = fluxes%sw_vis_dir
742 fluxes%sw_nir_dir(:,:) = fluxes%sw_nir_dir(:,:)*0.5
743 fluxes%sw_nir_dif(:,:) = fluxes%sw_nir_dir
744 fluxes%sw = fluxes%sw_vis_dir + fluxes%sw_vis_dif + fluxes%sw_nir_dir + fluxes%sw_nir_dif
745 do j=js,je ;
do i=is,ie
746 if (g%mask2dT(i,j)<1.0)
then
748 fluxes%sw_vis_dir(i,j) = 0.0
749 fluxes%sw_nir_dir(i,j) = 0.0
750 fluxes%sw_vis_dif(i,j) = 0.0
751 fluxes%sw_nir_dif(i,j) = 0.0
755 call pass_var(fluxes%sw_vis_dir,g%Domain)
756 call pass_var(fluxes%sw_vis_dif,g%Domain)
757 call pass_var(fluxes%sw_nir_dir,g%Domain)
758 call pass_var(fluxes%sw_nir_dif,g%Domain)
765 hend, uhtr_all, vhtr_all, hend_all, temp, salt, temp_all, salt_all )
768 integer,
intent(in ) :: nk_input
769 integer,
intent(in ) :: ridx_sum
770 character(len=200),
intent(in ) :: mean_file
771 character(len=200),
intent(in ) :: sum_file
772 character(len=200),
intent(in ) :: snap_file
773 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)),
intent(inout) :: uhtr
774 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)),
intent(inout) :: vhtr
775 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(inout) :: hend
776 real,
dimension(:,:,:,:),
allocatable,
intent(inout) :: uhtr_all
777 real,
dimension(:,:,:,:),
allocatable,
intent(inout) :: vhtr_all
778 real,
dimension(:,:,:,:),
allocatable,
intent(inout) :: hend_all
779 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(inout) :: temp
780 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)),
intent(inout) :: salt
781 real,
dimension(:,:,:,:),
allocatable,
intent(inout) :: temp_all
782 real,
dimension(:,:,:,:),
allocatable,
intent(inout) :: salt_all
784 integer :: i, j, k, is, ie, js, je, nz
785 real,
parameter :: fill_value = 0.
786 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = gv%ke
789 if (.not.
allocated(uhtr_all)) &
790 call mom_error(fatal,
"uhtr_all not allocated before call to update_transport_from_arrays")
791 if (.not.
allocated(vhtr_all)) &
792 call mom_error(fatal,
"vhtr_all not allocated before call to update_transport_from_arrays")
793 if (.not.
allocated(hend_all)) &
794 call mom_error(fatal,
"hend_all not allocated before call to update_transport_from_arrays")
795 if (.not.
allocated(temp_all)) &
796 call mom_error(fatal,
"temp_all not allocated before call to update_transport_from_arrays")
797 if (.not.
allocated(salt_all)) &
798 call mom_error(fatal,
"salt_all not allocated before call to update_transport_from_arrays")
801 do k=1,nk_input ;
do j=js,je ;
do i=is,ie
802 uhtr(i,j,k) = uhtr_all(i,j,k,ridx_sum)
803 vhtr(i,j,k) = vhtr_all(i,j,k,ridx_sum)
804 hend(i,j,k) = hend_all(i,j,k,ridx_sum)
805 temp(i,j,k) = temp_all(i,j,k,ridx_sum)
806 salt(i,j,k) = salt_all(i,j,k,ridx_sum)
807 enddo ;
enddo ;
enddo
810 do k=nk_input+1,nz ;
do j=js,je ;
do i=is,ie
811 uhtr(i,j,k) = fill_value
812 vhtr(i,j,k) = fill_value
813 hend(i,j,k) = fill_value
814 temp(i,j,k) = fill_value
815 salt(i,j,k) = fill_value
816 enddo ;
enddo ;
enddo
827 integer :: read_index
832 read_index = mod(inidx+1,numtime)
833 if (read_index < 0) read_index = inidx-read_index
834 if (read_index == 0) read_index = numtime