From a45b8208f56b7a75357c9b43549d99aa694ad42d Mon Sep 17 00:00:00 2001 From: Till Rasmussen <> Date: Thu, 12 Nov 2026 10:04:54 +0100 Subject: [PATCH 1/6] history: accumulate products without building them first Seventy-two calls to accum_hist_field pass a product as the actual argument -- aice(:,:,iblk)*trcr(:,:,nt_alvl,iblk) in mechred, sk_l*trcr(:,:,nt_bgc_N(n),iblk) in bgc, and so on. Each makes the compiler evaluate the product into a temporary over the whole block, nx_block by ny_block, pass it, and discard it. accum_hist_field_2D reads only ilo:ihi by jlo:jhi under tmask, so most of that temporary is computed and never read: for a 10x12 block with nghost=2 it is 224 products to produce 120. The waste is the ghost region, and it is paid once per field per block per history step. Three specifics are added to the generic instead, taking the factors and combining them in the loop that was already running: accum_hist_field_2D_prod two fields a(i,j)*b(i,j) accum_hist_field_2D_mul field by a scalar a(i,j)*s accum_hist_field_2D_smul scalar by a field s*a(i,j) The third exists so that converting a caller whose scale is on the left is still a one-character change and a reviewer never has to check that a reordering was safe. Its dummies are named sfac/afld rather than s/a because two specifics differing only in argument ORDER are ambiguous for keyword calls, which is a compile error and not a silent one. BIT-FOR-BIT, AND WHY Nothing is reordered: the operands and the sequence multiply-then-add are identical before and after. The only mechanism that could move a bit is FMA contraction -- fusing the multiply and the add into one rounding -- which becomes possible once the two are in the same loop body rather than in separate procedures either side of an array temporary. That cannot happen on any shipped configuration. Of the 84 Macros, 25 carry an FMA-capable arch flag (-xHost, -xCORE-AVX*, -march=) and every one of those also carries -fp-model precise, source or strict, which suppresses contraction -- verified with ifx 2025.3: -O2 -xHost emits vfmadd, -O2 -xHost -fp-model precise does not. The remaining 59 set no FMA-capable arch flag, so the instruction is not available to begin with. Zero are exposed. Even where a custom build did enable contraction, it could not reach the model. a2D is referenced only in cicecore/cicedyn/analysis/ice_history* and the three io/*/ice_history_write.F90; no dynamics module, ice_state or ice_flux reads it, and nothing feeds it back into the prognostic state. The trajectory and the restart file are unaffected; only history output could differ, and only in the last bits. Verified bit-for-bit against unmodified upstream on gx3, both gfortran and ifx: every restart and history data file identical, only the history header creation stamp differs. --- cicecore/cicedyn/analysis/ice_history.F90 | 88 ++++----- cicecore/cicedyn/analysis/ice_history_bgc.F90 | 38 ++-- .../cicedyn/analysis/ice_history_mechred.F90 | 12 +- .../cicedyn/analysis/ice_history_pond.F90 | 6 +- .../cicedyn/analysis/ice_history_shared.F90 | 182 +++++++++++++++++- 5 files changed, 252 insertions(+), 74 deletions(-) diff --git a/cicecore/cicedyn/analysis/ice_history.F90 b/cicecore/cicedyn/analysis/ice_history.F90 index 83bf66110..cf885e607 100644 --- a/cicecore/cicedyn/analysis/ice_history.F90 +++ b/cicecore/cicedyn/analysis/ice_history.F90 @@ -2504,11 +2504,11 @@ subroutine accum_hist (dt) if (f_snow (1:1) /= 'x') & call accum_hist_field(n_snow, iblk, fsnow(:,:,iblk), a2D) if (f_snow_ai(1:1) /= 'x') & - call accum_hist_field(n_snow_ai,iblk, fsnow(:,:,iblk)*workb(:,:), a2D) + call accum_hist_field(n_snow_ai,iblk, fsnow(:,:,iblk),workb(:,:), a2D) if (f_rain (1:1) /= 'x') & call accum_hist_field(n_rain, iblk, frain(:,:,iblk), a2D) if (f_rain_ai(1:1) /= 'x') & - call accum_hist_field(n_rain_ai,iblk, frain(:,:,iblk)*workb(:,:), a2D) + call accum_hist_field(n_rain_ai,iblk, frain(:,:,iblk),workb(:,:), a2D) if (f_sst (1:1) /= 'x') & call accum_hist_field(n_sst, iblk, sst(:,:,iblk), a2D) @@ -2549,7 +2549,7 @@ subroutine accum_hist (dt) call accum_hist_field(n_fswint_ai, iblk, fswint_ai(:,:,iblk), a2D) if (f_fswabs_ai(1:1)/= 'x') & - call accum_hist_field(n_fswabs_ai, iblk, fswabs(:,:,iblk)*aice(:,:,iblk), a2D) + call accum_hist_field(n_fswabs_ai, iblk, fswabs(:,:,iblk),aice(:,:,iblk), a2D) if (f_albsni(1:1) /= 'x') then call accum_hist_field(n_albsni, iblk, & @@ -2588,19 +2588,19 @@ subroutine accum_hist (dt) if (f_flat (1:1) /= 'x') & call accum_hist_field(n_flat, iblk, flat(:,:,iblk), a2D) if (f_flat_ai(1:1) /= 'x') & - call accum_hist_field(n_flat_ai,iblk, flat(:,:,iblk)*aice(:,:,iblk), a2D) + call accum_hist_field(n_flat_ai,iblk, flat(:,:,iblk),aice(:,:,iblk), a2D) if (f_fsens (1:1) /= 'x') & call accum_hist_field(n_fsens, iblk, fsens(:,:,iblk), a2D) if (f_fsens_ai(1:1)/= 'x') & - call accum_hist_field(n_fsens_ai,iblk, fsens(:,:,iblk)*aice(:,:,iblk), a2D) + call accum_hist_field(n_fsens_ai,iblk, fsens(:,:,iblk),aice(:,:,iblk), a2D) if (f_flwup (1:1) /= 'x') & call accum_hist_field(n_flwup, iblk, flwout(:,:,iblk), a2D) if (f_flwup_ai(1:1)/= 'x') & - call accum_hist_field(n_flwup_ai,iblk, flwout(:,:,iblk)*aice(:,:,iblk), a2D) + call accum_hist_field(n_flwup_ai,iblk, flwout(:,:,iblk),aice(:,:,iblk), a2D) if (f_evap (1:1) /= 'x') & call accum_hist_field(n_evap, iblk, evap(:,:,iblk), a2D) if (f_evap_ai(1:1) /= 'x') & - call accum_hist_field(n_evap_ai,iblk, evap(:,:,iblk)*aice(:,:,iblk), a2D) + call accum_hist_field(n_evap_ai,iblk, evap(:,:,iblk),aice(:,:,iblk), a2D) if (f_Tair (1:1) /= 'x') & call accum_hist_field(n_Tair, iblk, Tair(:,:,iblk), a2D) @@ -2654,7 +2654,7 @@ subroutine accum_hist (dt) if (f_strtlty(1:1) /= 'x') & call accum_hist_field(n_strtlty, iblk, strtltyU(:,:,iblk), a2D) if (f_strcorx(1:1) /= 'x') & - call accum_hist_field(n_strcorx, iblk, fmU(:,:,iblk)*vvel(:,:,iblk), a2D) + call accum_hist_field(n_strcorx, iblk, fmU(:,:,iblk),vvel(:,:,iblk), a2D) if (f_strcory(1:1) /= 'x') & call accum_hist_field(n_strcory, iblk,-fmU(:,:,iblk)*uvel(:,:,iblk), a2D) if (f_strocnx(1:1) /= 'x') & @@ -2686,11 +2686,11 @@ subroutine accum_hist (dt) if (f_strtltyE(1:1) /= 'x') & call accum_hist_field(n_strtltyE, iblk, strtltyE(:,:,iblk), a2D) if (f_strcorxN(1:1) /= 'x') & - call accum_hist_field(n_strcorxN, iblk, fmN(:,:,iblk)*vvelN(:,:,iblk), a2D) + call accum_hist_field(n_strcorxN, iblk, fmN(:,:,iblk),vvelN(:,:,iblk), a2D) if (f_strcoryN(1:1) /= 'x') & call accum_hist_field(n_strcoryN, iblk,-fmN(:,:,iblk)*uvelN(:,:,iblk), a2D) if (f_strcorxE(1:1) /= 'x') & - call accum_hist_field(n_strcorxE, iblk, fmE(:,:,iblk)*vvelE(:,:,iblk), a2D) + call accum_hist_field(n_strcorxE, iblk, fmE(:,:,iblk),vvelE(:,:,iblk), a2D) if (f_strcoryE(1:1) /= 'x') & call accum_hist_field(n_strcoryE, iblk,-fmE(:,:,iblk)*uvelE(:,:,iblk), a2D) if (f_strocnxN(1:1) /= 'x') & @@ -2751,10 +2751,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_dagedtd, iblk, dagedtd(:,:,iblk), a2D) if (f_fsurf_ai(1:1)/= 'x') & - call accum_hist_field(n_fsurf_ai,iblk, fsurf(:,:,iblk)*aice(:,:,iblk), a2D) + call accum_hist_field(n_fsurf_ai,iblk, fsurf(:,:,iblk),aice(:,:,iblk), a2D) if (f_fcondtop_ai(1:1)/= 'x') & call accum_hist_field(n_fcondtop_ai, iblk, & - fcondtop(:,:,iblk)*aice(:,:,iblk), a2D) + fcondtop(:,:,iblk),aice(:,:,iblk), a2D) if (f_icepresent(1:1) /= 'x') then worka(:,:) = c0 @@ -2800,7 +2800,7 @@ subroutine accum_hist (dt) endif if (f_simass(1:1) /= 'x') then - call accum_hist_field(n_simass, iblk, rho_ice(:,:)*vice(:,:,iblk), a2D) + call accum_hist_field(n_simass, iblk, rho_ice(:,:),vice(:,:,iblk), a2D) endif if (f_sisaltmass(1:1) /= 'x') then @@ -2808,7 +2808,7 @@ subroutine accum_hist (dt) endif if (f_sisali(1:1) /= 'x') then - call accum_hist_field(n_sisali, iblk, aice(:,:,iblk)*sal_ice(:,:), a2D) + call accum_hist_field(n_sisali, iblk, aice(:,:,iblk),sal_ice(:,:), a2D) endif if (f_siconc(1:1) /= 'x') then @@ -2820,11 +2820,11 @@ subroutine accum_hist (dt) endif if (f_sisnmass(1:1) /= 'x') then - call accum_hist_field(n_sisnmass, iblk, rhos*vsno(:,:,iblk), a2D) + call accum_hist_field(n_sisnmass, iblk, rhos,vsno(:,:,iblk), a2D) endif if (f_siage(1:1) /= 'x') then - call accum_hist_field(n_siage, iblk, aice(:,:,iblk)*trcr(:,:,nt_iage,iblk), a2D) + call accum_hist_field(n_siage, iblk, aice(:,:,iblk),trcr(:,:,nt_iage,iblk), a2D) endif if (f_sisnthick(1:1) /= 'x') then @@ -2832,7 +2832,7 @@ subroutine accum_hist (dt) endif if (f_sitemptop(1:1) /= 'x') then - call accum_hist_field(n_sitemptop, iblk, aice(:,:,iblk)*trcr(:,:,nt_Tsfc,iblk), a2D) + call accum_hist_field(n_sitemptop, iblk, aice(:,:,iblk),trcr(:,:,nt_Tsfc,iblk), a2D) endif ! Tsnice is already multiplied by aicen in icepack. @@ -2841,15 +2841,15 @@ subroutine accum_hist (dt) endif if (f_sitempbot(1:1) /= 'x') then - call accum_hist_field(n_sitempbot, iblk, aice_init(:,:,iblk)*Tbot(:,:,iblk), a2D) + call accum_hist_field(n_sitempbot, iblk, aice_init(:,:,iblk),Tbot(:,:,iblk), a2D) endif if (f_siu(1:1) /= 'x') then - call accum_hist_field(n_siu, iblk, aice(:,:,iblk)*uvel(:,:,iblk), a2D) + call accum_hist_field(n_siu, iblk, aice(:,:,iblk),uvel(:,:,iblk), a2D) endif if (f_siv(1:1) /= 'x') then - call accum_hist_field(n_siv, iblk, aice(:,:,iblk)*vvel(:,:,iblk), a2D) + call accum_hist_field(n_siv, iblk, aice(:,:,iblk),vvel(:,:,iblk), a2D) endif if (f_sispeed(1:1) /= 'x') then @@ -2904,23 +2904,23 @@ subroutine accum_hist (dt) endif if (f_sistrxdtop(1:1) /= 'x') then - call accum_hist_field(n_sistrxdtop, iblk, aice(:,:,iblk)*strairxU(:,:,iblk), a2D) + call accum_hist_field(n_sistrxdtop, iblk, aice(:,:,iblk),strairxU(:,:,iblk), a2D) endif if (f_sistrydtop(1:1) /= 'x') then - call accum_hist_field(n_sistrydtop, iblk, aice(:,:,iblk)*strairyU(:,:,iblk), a2D) + call accum_hist_field(n_sistrydtop, iblk, aice(:,:,iblk),strairyU(:,:,iblk), a2D) endif if (f_sistrxubot(1:1) /= 'x') then - call accum_hist_field(n_sistrxubot, iblk, aice(:,:,iblk)*strocnxU(:,:,iblk), a2D) + call accum_hist_field(n_sistrxubot, iblk, aice(:,:,iblk),strocnxU(:,:,iblk), a2D) endif if (f_sistryubot(1:1) /= 'x') then - call accum_hist_field(n_sistryubot, iblk, aice(:,:,iblk)*strocnyU(:,:,iblk), a2D) + call accum_hist_field(n_sistryubot, iblk, aice(:,:,iblk),strocnyU(:,:,iblk), a2D) endif if (f_sicompstren(1:1) /= 'x') then - call accum_hist_field(n_sicompstren, iblk, aice(:,:,iblk)*strength(:,:,iblk), a2D) + call accum_hist_field(n_sicompstren, iblk, aice(:,:,iblk),strength(:,:,iblk), a2D) endif if (f_sihc(1:1) /= 'x') then @@ -2956,11 +2956,11 @@ subroutine accum_hist (dt) endif if (f_sidmassth(1:1) /= 'x') then - call accum_hist_field(n_sidmassth, iblk, rho_ice(:,:)*dvidtt(:,:,iblk), a2D) + call accum_hist_field(n_sidmassth, iblk, rho_ice(:,:),dvidtt(:,:,iblk), a2D) endif if (f_sidmassdyn(1:1) /= 'x') then - call accum_hist_field(n_sidmassdyn, iblk, rho_ice(:,:)*dvidtd(:,:,iblk), a2D) + call accum_hist_field(n_sidmassdyn, iblk, rho_ice(:,:),dvidtd(:,:,iblk), a2D) endif if (f_sidmassgrowthwat(1:1) /= 'x') then @@ -2980,7 +2980,7 @@ subroutine accum_hist (dt) endif if (f_sidmassevapsubl(1:1) /= 'x') then - call accum_hist_field(n_sidmassevapsubl, iblk, rho_ice(:,:)*evapi(:,:,iblk), a2D) + call accum_hist_field(n_sidmassevapsubl, iblk, rho_ice(:,:),evapi(:,:,iblk), a2D) endif if (f_sidmassmelttop(1:1) /= 'x') then @@ -3008,11 +3008,11 @@ subroutine accum_hist (dt) endif if (f_sisndmassdyn(1:1) /= 'x') then - call accum_hist_field(n_sisndmassdyn, iblk, dvsdtd(:,:,iblk)*rhos, a2D) + call accum_hist_field(n_sisndmassdyn, iblk, dvsdtd(:,:,iblk),rhos, a2D) endif if (f_siflswdtop(1:1) /= 'x') then - call accum_hist_field(n_siflswdtop, iblk, aice_init(:,:,iblk)*fsw(:,:,iblk), a2D) + call accum_hist_field(n_siflswdtop, iblk, aice_init(:,:,iblk),fsw(:,:,iblk), a2D) endif if (f_siflswutop(1:1) /= 'x') then @@ -3020,15 +3020,15 @@ subroutine accum_hist (dt) endif if (f_siflswdbot(1:1) /= 'x') then - call accum_hist_field(n_siflswdbot, iblk, aice_init(:,:,iblk)*fswthru(:,:,iblk), a2D) + call accum_hist_field(n_siflswdbot, iblk, aice_init(:,:,iblk),fswthru(:,:,iblk), a2D) endif if (f_sifllwdtop(1:1) /= 'x') then - call accum_hist_field(n_sifllwdtop, iblk, aice_init(:,:,iblk)*flw(:,:,iblk), a2D) + call accum_hist_field(n_sifllwdtop, iblk, aice_init(:,:,iblk),flw(:,:,iblk), a2D) endif if (f_sifllwutop(1:1) /= 'x') then - call accum_hist_field(n_sifllwutop, iblk, aice(:,:,iblk)*flwout(:,:,iblk), a2D) + call accum_hist_field(n_sifllwutop, iblk, aice(:,:,iblk),flwout(:,:,iblk), a2D) endif if (f_siflsenstop(1:1) /= 'x') then @@ -3038,23 +3038,23 @@ subroutine accum_hist (dt) worka(i,j) = aice(i,j,iblk)*fsens(i,j,iblk) enddo enddo - call accum_hist_field(n_siflsenstop, iblk, aice(:,:,iblk)*fsens(:,:,iblk), a2D) + call accum_hist_field(n_siflsenstop, iblk, aice(:,:,iblk),fsens(:,:,iblk), a2D) endif if (f_siflsensbot(1:1) /= 'x') then - call accum_hist_field(n_siflsensbot, iblk, aice(:,:,iblk)*fhocn(:,:,iblk), a2D) + call accum_hist_field(n_siflsensbot, iblk, aice(:,:,iblk),fhocn(:,:,iblk), a2D) endif if (f_sifllattop(1:1) /= 'x') then - call accum_hist_field(n_sifllattop, iblk, aice(:,:,iblk)*flat(:,:,iblk), a2D) + call accum_hist_field(n_sifllattop, iblk, aice(:,:,iblk),flat(:,:,iblk), a2D) endif if (f_siflcondtop(1:1) /= 'x') then - call accum_hist_field(n_siflcondtop, iblk, aice(:,:,iblk)*fcondtop(:,:,iblk), a2D) + call accum_hist_field(n_siflcondtop, iblk, aice(:,:,iblk),fcondtop(:,:,iblk), a2D) endif if (f_siflcondbot(1:1) /= 'x') then - call accum_hist_field(n_siflcondbot, iblk, aice(:,:,iblk)*fcondbot(:,:,iblk), a2D) + call accum_hist_field(n_siflcondbot, iblk, aice(:,:,iblk),fcondbot(:,:,iblk), a2D) endif if (f_sipr(1:1) /= 'x') then @@ -3137,19 +3137,19 @@ subroutine accum_hist (dt) endif if (f_sidragtop(1:1) /= 'x') then - call accum_hist_field(n_sidragtop, iblk, aice_init(:,:,iblk)*Cdn_atm(:,:,iblk), a2D) + call accum_hist_field(n_sidragtop, iblk, aice_init(:,:,iblk),Cdn_atm(:,:,iblk), a2D) endif if (f_sidragbot(1:1) /= 'x') then - call accum_hist_field(n_sidragbot, iblk, aice_init(:,:,iblk)*Cdn_ocn(:,:,iblk), a2D) + call accum_hist_field(n_sidragbot, iblk, aice_init(:,:,iblk),Cdn_ocn(:,:,iblk), a2D) endif if (f_siforcetiltx(1:1) /= 'x') then - call accum_hist_field(n_siforcetiltx, iblk, aice_init(:,:,iblk)*strtltxU(:,:,iblk), a2D) + call accum_hist_field(n_siforcetiltx, iblk, aice_init(:,:,iblk),strtltxU(:,:,iblk), a2D) endif if (f_siforcetilty(1:1) /= 'x') then - call accum_hist_field(n_siforcetilty, iblk, aice_init(:,:,iblk)*strtltyU(:,:,iblk), a2D) + call accum_hist_field(n_siforcetilty, iblk, aice_init(:,:,iblk),strtltyU(:,:,iblk), a2D) endif if (f_siforcecoriolx(1:1) /= 'x') then @@ -3173,11 +3173,11 @@ subroutine accum_hist (dt) endif if (f_siforceintstrx(1:1) /= 'x') then - call accum_hist_field(n_siforceintstrx, iblk, aice(:,:,iblk)*strintxU(:,:,iblk), a2D) + call accum_hist_field(n_siforceintstrx, iblk, aice(:,:,iblk),strintxU(:,:,iblk), a2D) endif if (f_siforceintstry(1:1) /= 'x') then - call accum_hist_field(n_siforceintstry, iblk, aice(:,:,iblk)*strintyU(:,:,iblk), a2D) + call accum_hist_field(n_siforceintstry, iblk, aice(:,:,iblk),strintyU(:,:,iblk), a2D) endif endif ! if (allocated(a2D)) diff --git a/cicecore/cicedyn/analysis/ice_history_bgc.F90 b/cicecore/cicedyn/analysis/ice_history_bgc.F90 index 85b8c4821..5322261fd 100644 --- a/cicecore/cicedyn/analysis/ice_history_bgc.F90 +++ b/cicecore/cicedyn/analysis/ice_history_bgc.F90 @@ -2032,7 +2032,7 @@ subroutine accum_hist_bgc (iblk) if (f_bgc_N(1:1)/= 'x') then do n=1,n_algae call accum_hist_field(n_bgc_N(n,:), iblk, & - sk_l*trcr(:,:,nt_bgc_N(n), iblk), a2D) + sk_l,trcr(:,:,nt_bgc_N(n), iblk), a2D) enddo endif if (f_bgc_C(1:1)/= 'x') then @@ -2044,63 +2044,63 @@ subroutine accum_hist_bgc (iblk) if (f_bgc_DOC(1:1)/= 'x') then do n=1,n_doc call accum_hist_field(n_bgc_DOC(n,:), iblk, & - sk_l*trcr(:,:,nt_bgc_DOC(n), iblk), a2D) + sk_l,trcr(:,:,nt_bgc_DOC(n), iblk), a2D) enddo endif if (f_bgc_DIC(1:1)/= 'x') then do n=1,n_dic call accum_hist_field(n_bgc_DIC(n,:), iblk, & - sk_l*trcr(:,:,nt_bgc_DIC(n), iblk), a2D) + sk_l,trcr(:,:,nt_bgc_DIC(n), iblk), a2D) enddo endif if (f_bgc_DON(1:1)/= 'x') then do n=1,n_don call accum_hist_field(n_bgc_DON(n,:), iblk, & - sk_l*trcr(:,:,nt_bgc_DON(n), iblk), a2D) + sk_l,trcr(:,:,nt_bgc_DON(n), iblk), a2D) enddo endif if (f_bgc_Fed (1:1)/= 'x') then do n=1,n_fed call accum_hist_field(n_bgc_Fed (n,:), iblk, & - sk_l*trcr(:,:,nt_bgc_Fed (n), iblk), a2D) + sk_l,trcr(:,:,nt_bgc_Fed (n), iblk), a2D) enddo endif if (f_bgc_Fep (1:1)/= 'x') then do n=1,n_fep call accum_hist_field(n_bgc_Fep (n,:), iblk, & - sk_l*trcr(:,:,nt_bgc_Fep (n), iblk), a2D) + sk_l,trcr(:,:,nt_bgc_Fep (n), iblk), a2D) enddo endif if (f_bgc_chl(1:1)/= 'x') then do n=1,n_algae call accum_hist_field(n_bgc_chl(n,:), iblk, & - sk_l*trcr(:,:,nt_bgc_chl(n), iblk), a2D) + sk_l,trcr(:,:,nt_bgc_chl(n), iblk), a2D) enddo endif if (f_bgc_Nit(1:1)/= 'x') & call accum_hist_field(n_bgc_Nit, iblk, & - sk_l*trcr(:,:,nt_bgc_Nit, iblk), a2D) + sk_l,trcr(:,:,nt_bgc_Nit, iblk), a2D) if (f_bgc_Am(1:1)/= 'x') & call accum_hist_field(n_bgc_Am, iblk, & - sk_l*trcr(:,:,nt_bgc_Am, iblk), a2D) + sk_l,trcr(:,:,nt_bgc_Am, iblk), a2D) if (f_bgc_Sil(1:1)/= 'x') & call accum_hist_field(n_bgc_Sil, iblk, & - sk_l*trcr(:,:,nt_bgc_Sil, iblk), a2D) + sk_l,trcr(:,:,nt_bgc_Sil, iblk), a2D) if (f_bgc_hum(1:1)/= 'x') & call accum_hist_field(n_bgc_hum, iblk, & - sk_l*trcr(:,:,nt_bgc_hum, iblk), a2D) + sk_l,trcr(:,:,nt_bgc_hum, iblk), a2D) if (f_bgc_PON(1:1)/= 'x') & call accum_hist_field(n_bgc_PON, iblk, & - sk_l*trcr(:,:,nt_bgc_PON, iblk), a2D) + sk_l,trcr(:,:,nt_bgc_PON, iblk), a2D) if (f_bgc_DMSPp(1:1)/= 'x') & call accum_hist_field(n_bgc_DMSPp,iblk, & - sk_l*trcr(:,:,nt_bgc_DMSPp,iblk), a2D) + sk_l,trcr(:,:,nt_bgc_DMSPp,iblk), a2D) if (f_bgc_DMSPd(1:1)/= 'x') & call accum_hist_field(n_bgc_DMSPd,iblk, & - sk_l*trcr(:,:,nt_bgc_DMSPd,iblk), a2D) + sk_l,trcr(:,:,nt_bgc_DMSPd,iblk), a2D) if (f_bgc_DMS(1:1)/= 'x') & call accum_hist_field(n_bgc_DMS, iblk, & - sk_l*trcr(:,:,nt_bgc_DMS, iblk), a2D) + sk_l,trcr(:,:,nt_bgc_DMS, iblk), a2D) endif !skl_bgc @@ -2348,7 +2348,7 @@ subroutine accum_hist_bgc (iblk) if (f_chlnet (1:1) /= 'x') then do n=1,n_algae call accum_hist_field(n_chlnet(n,:), iblk, & - R_chl2N(n)*ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + R_chl2N(n),ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) enddo endif !f_chlnet if (f_Nnet (1:1) /= 'x') then @@ -2360,7 +2360,7 @@ subroutine accum_hist_bgc (iblk) if (f_Cnet (1:1) /= 'x') then do n=1,n_algae call accum_hist_field(n_Cnet(n,:), iblk, & - R_C2N(n) *ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + R_C2N(n) ,ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) enddo endif !f_Cnet if (f_DOCnet (1:1) /= 'x') then @@ -2430,7 +2430,7 @@ subroutine accum_hist_bgc (iblk) if (f_chlsnow (1:1) /= 'x') then do n=1,n_algae call accum_hist_field(n_chlsnow(n,:), iblk, & - R_chl2N(n)*snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + R_chl2N(n),snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) enddo endif !f_chlsnow if (f_Nsnow (1:1) /= 'x') then @@ -2442,7 +2442,7 @@ subroutine accum_hist_bgc (iblk) if (f_Csnow (1:1) /= 'x') then do n=1,n_algae call accum_hist_field(n_Csnow(n,:), iblk, & - R_C2N(n)*snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + R_C2N(n),snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) enddo endif !f_Csnow if (f_DOCsnow (1:1) /= 'x') then diff --git a/cicecore/cicedyn/analysis/ice_history_mechred.F90 b/cicecore/cicedyn/analysis/ice_history_mechred.F90 index 71e148c91..19069ef81 100644 --- a/cicecore/cicedyn/analysis/ice_history_mechred.F90 +++ b/cicecore/cicedyn/analysis/ice_history_mechred.F90 @@ -388,16 +388,16 @@ subroutine accum_hist_mechred (iblk) if (f_alvl(1:1)/= 'x') & call accum_hist_field(n_alvl, iblk, & - aice(:,:,iblk) * trcr(:,:,nt_alvl,iblk), a2D) + aice(:,:,iblk) , trcr(:,:,nt_alvl,iblk), a2D) if (f_vlvl(1:1)/= 'x') & call accum_hist_field(n_vlvl, iblk, & - vice(:,:,iblk) * trcr(:,:,nt_vlvl,iblk), a2D) + vice(:,:,iblk) , trcr(:,:,nt_vlvl,iblk), a2D) if (f_ardg(1:1)/= 'x') & call accum_hist_field(n_ardg, iblk, & - aice(:,:,iblk) * (c1 - trcr(:,:,nt_alvl,iblk)), a2D) + aice(:,:,iblk) , (c1 - trcr(:,:,nt_alvl,iblk)), a2D) if (f_vrdg(1:1)/= 'x') & call accum_hist_field(n_vrdg, iblk, & - vice(:,:,iblk) * (c1 - trcr(:,:,nt_vlvl,iblk)), a2D) + vice(:,:,iblk) , (c1 - trcr(:,:,nt_vlvl,iblk)), a2D) if (f_dardg1dt(1:1)/= 'x') & call accum_hist_field(n_dardg1dt,iblk, dardg1dt(:,:,iblk), a2D) if (f_dardg2dt(1:1)/= 'x') & @@ -409,11 +409,11 @@ subroutine accum_hist_mechred (iblk) if (f_sirdgconc(1:1)/= 'x') & call accum_hist_field(n_sirdgconc, iblk, & - aice(:,:,iblk) * (c1 - trcr(:,:,nt_alvl,iblk)), a2D) + aice(:,:,iblk) , (c1 - trcr(:,:,nt_alvl,iblk)), a2D) if (f_sirdgthick(1:1)/= 'x') then call accum_hist_field(n_sirdgthick, iblk, & - vice(:,:,iblk) * (c1 - trcr(:,:,nt_vlvl,iblk)), a2D) + vice(:,:,iblk) , (c1 - trcr(:,:,nt_vlvl,iblk)), a2D) endif endif ! allocated(a2D) diff --git a/cicecore/cicedyn/analysis/ice_history_pond.F90 b/cicecore/cicedyn/analysis/ice_history_pond.F90 index 17d1c50b3..0b4f52ff8 100644 --- a/cicecore/cicedyn/analysis/ice_history_pond.F90 +++ b/cicecore/cicedyn/analysis/ice_history_pond.F90 @@ -516,13 +516,13 @@ subroutine accum_hist_pond (iblk) if (f_apond(1:1)/= 'x') & call accum_hist_field(n_apond, iblk, worka(:,:), a2D) if (f_apond_ai(1:1)/= 'x') & - call accum_hist_field(n_apond_ai, iblk, aice_init(:,:,iblk)*worka(:,:), a2D) + call accum_hist_field(n_apond_ai, iblk, aice_init(:,:,iblk),worka(:,:), a2D) if (f_hpond(1:1)/= 'x') & - call accum_hist_field(n_hpond, iblk, worka(:,:)*trcr(:,:,nt_hpnd,iblk), a2D) + call accum_hist_field(n_hpond, iblk, worka(:,:),trcr(:,:,nt_hpnd,iblk), a2D) if (f_hpond_ai(1:1)/= 'x') & call accum_hist_field(n_hpond_ai, iblk, aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_hpnd,iblk), a2D) if (f_ipond(1:1)/= 'x') & - call accum_hist_field(n_ipond, iblk, worka(:,:)*trcr(:,:,nt_ipnd,iblk), a2D) + call accum_hist_field(n_ipond, iblk, worka(:,:),trcr(:,:,nt_ipnd,iblk), a2D) if (f_ipond_ai(1:1)/= 'x') & call accum_hist_field(n_ipond_ai, iblk, aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_ipnd,iblk), a2D) diff --git a/cicecore/cicedyn/analysis/ice_history_shared.F90 b/cicecore/cicedyn/analysis/ice_history_shared.F90 index 6b6661b0d..f6c145c02 100644 --- a/cicecore/cicedyn/analysis/ice_history_shared.F90 +++ b/cicecore/cicedyn/analysis/ice_history_shared.F90 @@ -766,8 +766,11 @@ module ice_history_shared n_yieldstress22 interface accum_hist_field ! generic interface - module procedure accum_hist_field_2D, & - accum_hist_field_3D, & + module procedure accum_hist_field_2D, & + accum_hist_field_2D_prod, & + accum_hist_field_2D_mul, & + accum_hist_field_2D_smul, & + accum_hist_field_3D, & accum_hist_field_4D end interface @@ -1119,6 +1122,181 @@ end subroutine accum_hist_field_2D ! 2009 Created by D. Bailey following POP ! 2010 Generalized dimension of variables by N. Jeffery, E. Hunke +! Accumulate the product of two fields without building it first. +! +! Writing the product as an actual argument -- accum_hist_field(n, iblk, +! a(:,:,iblk)*b(:,:,iblk), a2D) -- makes the compiler evaluate it into a +! temporary over the WHOLE block, nx_block by ny_block, pass that, and +! discard it. The loop below reads only ilo:ihi by jlo:jhi under tmask, so +! most of that temporary is computed and never used: for a 10x12 block with +! nghost=2 it is 224 products to read 120. +! +! Taking the two factors instead costs one extra argument and removes the +! temporary, the fill loop and the wasted ghost-region arithmetic. + + subroutine accum_hist_field_2D_prod(id, iblk, a, b, field) + + use ice_blocks, only: block, get_block + use ice_calendar, only: nstreams + use ice_domain, only: blocks_ice + use ice_grid, only: tmask + + integer (int_kind), dimension(:), intent(in) :: & ! max_nstrm + id ! location in avail_fields array + + integer (kind=int_kind), intent(in) :: iblk + + real (kind=dbl_kind), intent(in) :: & + a(:,:), b(:,:) ! the two factors, block shaped + + real (kind=dbl_kind), intent(inout) :: & + field(:,:,:,:) + + type (block) :: & + this_block ! block information for current block + + integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns + + character(len=*), parameter :: subname = '(accum_hist_field_2D_prod)' + + do ns = 1, nstreams + idns = id(ns) + if (idns > 0) then + + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + + do j = jlo, jhi + do i = ilo, ihi + if (tmask(i,j,iblk)) then + field(i,j,idns, iblk) = field(i,j,idns, iblk) + a(i,j)*b(i,j) + endif + enddo + enddo + + endif + enddo + + end subroutine accum_hist_field_2D_prod + +!======================================================================= +! +! The same for a field scaled by a constant. Distinguished from the +! two-field form by the rank of the second factor. + + subroutine accum_hist_field_2D_mul(id, iblk, a, s, field) + + use ice_blocks, only: block, get_block + use ice_calendar, only: nstreams + use ice_domain, only: blocks_ice + use ice_grid, only: tmask + + integer (int_kind), dimension(:), intent(in) :: & ! max_nstrm + id ! location in avail_fields array + + integer (kind=int_kind), intent(in) :: iblk + + real (kind=dbl_kind), intent(in) :: & + a(:,:) ! the field, block shaped + + real (kind=dbl_kind), intent(in) :: & + s ! the scale + + real (kind=dbl_kind), intent(inout) :: & + field(:,:,:,:) + + type (block) :: & + this_block ! block information for current block + + integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns + + character(len=*), parameter :: subname = '(accum_hist_field_2D_mul)' + + do ns = 1, nstreams + idns = id(ns) + if (idns > 0) then + + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + + do j = jlo, jhi + do i = ilo, ihi + if (tmask(i,j,iblk)) then + field(i,j,idns, iblk) = field(i,j,idns, iblk) + a(i,j)*s + endif + enddo + enddo + + endif + enddo + + end subroutine accum_hist_field_2D_mul + +!======================================================================= + +! The scale on the left. A separate specific rather than swapping the +! arguments at the call site, so that converting a caller is a one-character +! change and a reviewer never has to check that a reordering was safe. + + subroutine accum_hist_field_2D_smul(id, iblk, sfac, afld, field) + + use ice_blocks, only: block, get_block + use ice_calendar, only: nstreams + use ice_domain, only: blocks_ice + use ice_grid, only: tmask + + integer (int_kind), dimension(:), intent(in) :: & ! max_nstrm + id ! location in avail_fields array + + integer (kind=int_kind), intent(in) :: iblk + + real (kind=dbl_kind), intent(in) :: & + sfac ! the scale + + real (kind=dbl_kind), intent(in) :: & + afld(:,:) ! the field, block shaped + + real (kind=dbl_kind), intent(inout) :: & + field(:,:,:,:) + + type (block) :: & + this_block ! block information for current block + + integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns + + character(len=*), parameter :: subname = '(accum_hist_field_2D_smul)' + + do ns = 1, nstreams + idns = id(ns) + if (idns > 0) then + + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + + do j = jlo, jhi + do i = ilo, ihi + if (tmask(i,j,iblk)) then + field(i,j,idns, iblk) = field(i,j,idns, iblk) + sfac*afld(i,j) + endif + enddo + enddo + + endif + enddo + + end subroutine accum_hist_field_2D_smul + +!======================================================================= + subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field) use ice_blocks, only: block, get_block From e1e50ceefc0adbecc0ca485c518fc3c1ea75097e Mon Sep 17 00:00:00 2001 From: Till Rasmussen <> Date: Fri, 13 Nov 2026 01:12:27 +0100 Subject: [PATCH 2/6] history: build compound accumulator arguments in a work array The accumulator's specific forms cover a field and a field scaled by a constant. Anything more involved -- a product of three factors, a difference, a quotient by dt, a sign flip -- would need a variant per operator combination, so those callers now compute into a work array and pass it plain. That is already the idiom in ice_history_snow, which needs no change here because every one of its callers is in this form. The scalar-first specific is gone. Callers whose scale sat on the left swap their two actuals instead, which is bit-for-bit: floating multiplication is commutative and exactly rounded. Work arrays added where the routine had none, and workc joins the OMP PRIVATE clause in accum_hist -- it is declared in the routine that carries the directive, unlike the locals of the accum_hist_* routines called from inside the loop, which are private by construction. Verified against the unmodified base on gfortran and ifx, bit-for-bit over history and restart alike. The standard templates could not have shown this: they run ktherm=-1 with ponds, FSD, BGC, aerosols and isotopes off, so they exercise almost none of the fields touched here. The check used a configuration with every tracer on and all 279 history fields enabled. --- cicecore/cicedyn/analysis/ice_history.F90 | 128 ++++++++------- cicecore/cicedyn/analysis/ice_history_bgc.F90 | 153 ++++++++---------- cicecore/cicedyn/analysis/ice_history_fsd.F90 | 35 ++-- .../cicedyn/analysis/ice_history_mechred.F90 | 21 ++- .../cicedyn/analysis/ice_history_pond.F90 | 36 +++-- .../cicedyn/analysis/ice_history_shared.F90 | 65 +------- 6 files changed, 204 insertions(+), 234 deletions(-) diff --git a/cicecore/cicedyn/analysis/ice_history.F90 b/cicecore/cicedyn/analysis/ice_history.F90 index cf885e607..32486db58 100644 --- a/cicecore/cicedyn/analysis/ice_history.F90 +++ b/cicecore/cicedyn/analysis/ice_history.F90 @@ -2269,7 +2269,7 @@ subroutine accum_hist (dt) worka, workb, ravgip, ravgip_init, ravgip_pond, ravgip_ridge, rho_ice, rho_ocn, sal_ice real (kind=dbl_kind), dimension (nx_block,ny_block,ncat_hist) :: & - ravgipn + ravgipn, workc real (kind=dbl_kind) :: awtvdr, awtidr, awtvdf, awtidf, puny, secday, rad_to_deg real (kind=dbl_kind) :: Tffresh, rhoi, rhos, rhow, ice_ref_salinity @@ -2378,7 +2378,7 @@ subroutine accum_hist (dt) #ifndef __INTEL_LLVM_COMPILER !$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block, & !$OMP k,n,qn,ns,sn,rho_ocn,rho_ice,sal_ice,dfresh,dfsalt,sicen, & - !$OMP worka,workb,Tinz4d,Sinz4d,Tsnz4d) + !$OMP worka,workb,workc,Tinz4d,Sinz4d,Tsnz4d) #endif do iblk = 1, nblocks @@ -2410,10 +2410,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_uvel, iblk, uvel(:,:,iblk), a2D) if (f_vvel (1:1) /= 'x') & call accum_hist_field(n_vvel, iblk, vvel(:,:,iblk), a2D) - if (f_icespd (1:1) /= 'x') & - call accum_hist_field(n_icespd, iblk, sqrt( & - (uvel(:,:,iblk)*uvel(:,:,iblk)) + & - (vvel(:,:,iblk)*vvel(:,:,iblk))), a2D) + if (f_icespd (1:1) /= 'x') then + worka(:,:) = sqrt( (uvel(:,:,iblk)*uvel(:,:,iblk)) + (vvel(:,:,iblk)*vvel(:,:,iblk))) + call accum_hist_field(n_icespd, iblk, worka, a2D) + endif if (f_icedir(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi @@ -2429,10 +2429,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_uvelN, iblk, uvelN(:,:,iblk), a2D) if (f_vvelN (1:1) /= 'x') & call accum_hist_field(n_vvelN, iblk, vvelN(:,:,iblk), a2D) - if (f_icespdN (1:1) /= 'x') & - call accum_hist_field(n_icespdN, iblk, sqrt( & - (uvelN(:,:,iblk)*uvelN(:,:,iblk)) + & - (vvelN(:,:,iblk)*vvelN(:,:,iblk))), a2D) + if (f_icespdN (1:1) /= 'x') then + worka(:,:) = sqrt( (uvelN(:,:,iblk)*uvelN(:,:,iblk)) + (vvelN(:,:,iblk)*vvelN(:,:,iblk))) + call accum_hist_field(n_icespdN, iblk, worka, a2D) + endif if (f_icedirN(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi @@ -2448,10 +2448,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_uvelE, iblk, uvelE(:,:,iblk), a2D) if (f_vvelE (1:1) /= 'x') & call accum_hist_field(n_vvelE, iblk, vvelE(:,:,iblk), a2D) - if (f_icespdE (1:1) /= 'x') & - call accum_hist_field(n_icespdE, iblk, sqrt( & - (uvelE(:,:,iblk)*uvelE(:,:,iblk)) + & - (vvelE(:,:,iblk)*vvelE(:,:,iblk))), a2D) + if (f_icespdE (1:1) /= 'x') then + worka(:,:) = sqrt( (uvelE(:,:,iblk)*uvelE(:,:,iblk)) + (vvelE(:,:,iblk)*vvelE(:,:,iblk))) + call accum_hist_field(n_icespdE, iblk, worka, a2D) + endif if (f_icedirE(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi @@ -2467,10 +2467,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_uatm, iblk, uatm(:,:,iblk), a2D) if (f_vatm (1:1) /= 'x') & call accum_hist_field(n_vatm, iblk, vatm(:,:,iblk), a2D) - if (f_atmspd (1:1) /= 'x') & - call accum_hist_field(n_atmspd, iblk, sqrt( & - (uatm(:,:,iblk)*uatm(:,:,iblk)) + & - (vatm(:,:,iblk)*vatm(:,:,iblk))), a2D) + if (f_atmspd (1:1) /= 'x') then + worka(:,:) = sqrt( (uatm(:,:,iblk)*uatm(:,:,iblk)) + (vatm(:,:,iblk)*vatm(:,:,iblk))) + call accum_hist_field(n_atmspd, iblk, worka, a2D) + endif if (f_atmdir(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi @@ -2518,10 +2518,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_uocn, iblk, uocn(:,:,iblk), a2D) if (f_vocn (1:1) /= 'x') & call accum_hist_field(n_vocn, iblk, vocn(:,:,iblk), a2D) - if (f_ocnspd (1:1) /= 'x') & - call accum_hist_field(n_ocnspd, iblk, sqrt( & - (uocn(:,:,iblk)*uocn(:,:,iblk)) + & - (vocn(:,:,iblk)*vocn(:,:,iblk))), a2D) + if (f_ocnspd (1:1) /= 'x') then + worka(:,:) = sqrt( (uocn(:,:,iblk)*uocn(:,:,iblk)) + (vocn(:,:,iblk)*vocn(:,:,iblk))) + call accum_hist_field(n_ocnspd, iblk, worka, a2D) + endif if (f_ocndir(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi @@ -2655,8 +2655,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_strtlty, iblk, strtltyU(:,:,iblk), a2D) if (f_strcorx(1:1) /= 'x') & call accum_hist_field(n_strcorx, iblk, fmU(:,:,iblk),vvel(:,:,iblk), a2D) - if (f_strcory(1:1) /= 'x') & - call accum_hist_field(n_strcory, iblk,-fmU(:,:,iblk)*uvel(:,:,iblk), a2D) + if (f_strcory(1:1) /= 'x') then + worka(:,:) = -fmU(:,:,iblk)*uvel(:,:,iblk) + call accum_hist_field(n_strcory, iblk, worka, a2D) + endif if (f_strocnx(1:1) /= 'x') & call accum_hist_field(n_strocnx, iblk, strocnxU(:,:,iblk), a2D) if (f_strocny(1:1) /= 'x') & @@ -2687,12 +2689,16 @@ subroutine accum_hist (dt) call accum_hist_field(n_strtltyE, iblk, strtltyE(:,:,iblk), a2D) if (f_strcorxN(1:1) /= 'x') & call accum_hist_field(n_strcorxN, iblk, fmN(:,:,iblk),vvelN(:,:,iblk), a2D) - if (f_strcoryN(1:1) /= 'x') & - call accum_hist_field(n_strcoryN, iblk,-fmN(:,:,iblk)*uvelN(:,:,iblk), a2D) + if (f_strcoryN(1:1) /= 'x') then + worka(:,:) = -fmN(:,:,iblk)*uvelN(:,:,iblk) + call accum_hist_field(n_strcoryN, iblk, worka, a2D) + endif if (f_strcorxE(1:1) /= 'x') & call accum_hist_field(n_strcorxE, iblk, fmE(:,:,iblk),vvelE(:,:,iblk), a2D) - if (f_strcoryE(1:1) /= 'x') & - call accum_hist_field(n_strcoryE, iblk,-fmE(:,:,iblk)*uvelE(:,:,iblk), a2D) + if (f_strcoryE(1:1) /= 'x') then + worka(:,:) = -fmE(:,:,iblk)*uvelE(:,:,iblk) + call accum_hist_field(n_strcoryE, iblk, worka, a2D) + endif if (f_strocnxN(1:1) /= 'x') & call accum_hist_field(n_strocnxN, iblk, strocnxN(:,:,iblk), a2D) if (f_strocnyN(1:1) /= 'x') & @@ -2804,7 +2810,8 @@ subroutine accum_hist (dt) endif if (f_sisaltmass(1:1) /= 'x') then - call accum_hist_field(n_sisaltmass, iblk, rho_ice(:,:)*sal_ice(:,:)*vice(:,:,iblk), a2D) + worka(:,:) = rho_ice(:,:)*sal_ice(:,:)*vice(:,:,iblk) + call accum_hist_field(n_sisaltmass, iblk, worka, a2D) endif if (f_sisali(1:1) /= 'x') then @@ -2820,7 +2827,7 @@ subroutine accum_hist (dt) endif if (f_sisnmass(1:1) /= 'x') then - call accum_hist_field(n_sisnmass, iblk, rhos,vsno(:,:,iblk), a2D) + call accum_hist_field(n_sisnmass, iblk, vsno(:,:,iblk), rhos, a2D) endif if (f_siage(1:1) /= 'x') then @@ -2964,19 +2971,23 @@ subroutine accum_hist (dt) endif if (f_sidmassgrowthwat(1:1) /= 'x') then - call accum_hist_field(n_sidmassgrowthwat, iblk, rho_ice(:,:)*frazil(:,:,iblk)/dt, a2D) + worka(:,:) = rho_ice(:,:)*frazil(:,:,iblk)/dt + call accum_hist_field(n_sidmassgrowthwat, iblk, worka, a2D) endif if (f_sidmassgrowthbot(1:1) /= 'x') then - call accum_hist_field(n_sidmassgrowthbot, iblk, rho_ice(:,:)*congel(:,:,iblk)/dt, a2D) + worka(:,:) = rho_ice(:,:)*congel(:,:,iblk)/dt + call accum_hist_field(n_sidmassgrowthbot, iblk, worka, a2D) endif if (f_sidmassgrowthsi(1:1) /= 'x') then - call accum_hist_field(n_sidmassgrowthsi, iblk, rho_ice(:,:)*snoice(:,:,iblk)/dt, a2D) + worka(:,:) = rho_ice(:,:)*snoice(:,:,iblk)/dt + call accum_hist_field(n_sidmassgrowthsi, iblk, worka, a2D) endif if (f_sisndmasssi(1:1) /= 'x') then - call accum_hist_field(n_sisndmasssi, iblk, -snoice(:,:,iblk)*rhos/dt, a2D) + worka(:,:) = -snoice(:,:,iblk)*rhos/dt + call accum_hist_field(n_sisndmasssi, iblk, worka, a2D) endif if (f_sidmassevapsubl(1:1) /= 'x') then @@ -2984,15 +2995,18 @@ subroutine accum_hist (dt) endif if (f_sidmassmelttop(1:1) /= 'x') then - call accum_hist_field(n_sidmassmelttop, iblk, -rho_ice(:,:)*meltt(:,:,iblk)/dt, a2D) + worka(:,:) = -rho_ice(:,:)*meltt(:,:,iblk)/dt + call accum_hist_field(n_sidmassmelttop, iblk, worka, a2D) endif if (f_sidmassmeltbot(1:1) /= 'x') then - call accum_hist_field(n_sidmassmeltbot, iblk, -rho_ice(:,:)*meltb(:,:,iblk)/dt, a2D) + worka(:,:) = -rho_ice(:,:)*meltb(:,:,iblk)/dt + call accum_hist_field(n_sidmassmeltbot, iblk, worka, a2D) endif if (f_sidmassmeltlat(1:1) /= 'x') then - call accum_hist_field(n_sidmassmeltlat, iblk, -rho_ice(:,:)*meltl(:,:,iblk)/dt, a2D) + worka(:,:) = -rho_ice(:,:)*meltl(:,:,iblk)/dt + call accum_hist_field(n_sidmassmeltlat, iblk, worka, a2D) endif if (f_sisndmasssubl(1:1) /= 'x') then @@ -3004,7 +3018,8 @@ subroutine accum_hist (dt) endif if (f_sisndmassmelt(1:1) /= 'x') then - call accum_hist_field(n_sisndmassmelt, iblk, -melts(:,:,iblk)*rhos/dt, a2D) + worka(:,:) = -melts(:,:,iblk)*rhos/dt + call accum_hist_field(n_sisndmassmelt, iblk, worka, a2D) endif if (f_sisndmassdyn(1:1) /= 'x') then @@ -3203,24 +3218,29 @@ subroutine accum_hist (dt) if (f_keffn_top (1:1) /= 'x') & call accum_hist_field(n_keffn_top-n2D, iblk, ncat_hist, & keffn_top(:,:,1:ncat_hist,iblk), a3Dc) - if (f_fsurfn_ai (1:1) /= 'x') & - call accum_hist_field(n_fsurfn_ai-n2D, iblk, ncat_hist, & - fsurfn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk), a3Dc) - if (f_fcondtopn_ai (1:1) /= 'x') & - call accum_hist_field(n_fcondtopn_ai-n2D, iblk, ncat_hist, & - fcondtopn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk), a3Dc) - if (f_flatn_ai (1:1) /= 'x') & - call accum_hist_field(n_flatn_ai-n2D, iblk, ncat_hist, & - flatn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk), a3Dc) - if (f_fsensn_ai (1:1) /= 'x') & - call accum_hist_field(n_fsensn_ai-n2D, iblk, ncat_hist, & - fsensn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk), a3Dc) + if (f_fsurfn_ai (1:1) /= 'x') then + workc(:,:,1:ncat_hist) = fsurfn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) + call accum_hist_field(n_fsurfn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + endif + if (f_fcondtopn_ai (1:1) /= 'x') then + workc(:,:,1:ncat_hist) = fcondtopn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) + call accum_hist_field(n_fcondtopn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + endif + if (f_flatn_ai (1:1) /= 'x') then + workc(:,:,1:ncat_hist) = flatn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) + call accum_hist_field(n_flatn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + endif + if (f_fsensn_ai (1:1) /= 'x') then + workc(:,:,1:ncat_hist) = fsensn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) + call accum_hist_field(n_fsensn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + endif ! Calculate surface heat flux that causes melt (calculated by the ! atmos in HadGEM3 so needed for checking purposes) - if (f_fmelttn_ai (1:1) /= 'x') & - call accum_hist_field(n_fmelttn_ai-n2D, iblk, ncat_hist, & - max(fsurfn(:,:,1:ncat_hist,iblk) - fcondtopn(:,:,1:ncat_hist,iblk),c0) & - *aicen_init(:,:,1:ncat_hist,iblk), a3Dc) + if (f_fmelttn_ai (1:1) /= 'x') then + workc(:,:,1:ncat_hist) = max(fsurfn(:,:,1:ncat_hist,iblk) - fcondtopn(:,:,1:ncat_hist,iblk),c0) & + *aicen_init(:,:,1:ncat_hist,iblk) + call accum_hist_field(n_fmelttn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + endif if (f_siitdconc (1:1) /= 'x') then call accum_hist_field(n_siitdconc-n2D, iblk, ncat_hist, aicen(:,:,:,iblk), a3Dc) diff --git a/cicecore/cicedyn/analysis/ice_history_bgc.F90 b/cicecore/cicedyn/analysis/ice_history_bgc.F90 index 5322261fd..8c4586353 100644 --- a/cicecore/cicedyn/analysis/ice_history_bgc.F90 +++ b/cicecore/cicedyn/analysis/ice_history_bgc.F90 @@ -1926,6 +1926,8 @@ subroutine accum_hist_bgc (iblk) type (block) :: & this_block ! block information for current block + real (kind=dbl_kind), dimension(nx_block,ny_block) :: worka + character(len=*), parameter :: subname = '(accum_hist_bgc)' call icepack_query_parameters(rhos_out=rhos, rhoi_out=rhoi, & @@ -1992,10 +1994,10 @@ subroutine accum_hist_bgc (iblk) endif if (f_iso(1:1) /= 'x') then do n=1,n_iso - call accum_hist_field(n_isosno(n,:), iblk, & - trcr(:,:,nt_isosno+n-1,iblk)/rhos, a2D) - call accum_hist_field(n_isoice(n,:), iblk, & - trcr(:,:,nt_isoice+n-1,iblk)/rhos, a2D) + worka(:,:) = trcr(:,:,nt_isosno+n-1,iblk)/rhos + call accum_hist_field(n_isosno(n,:), iblk, worka, a2D) + worka(:,:) = trcr(:,:,nt_isoice+n-1,iblk)/rhos + call accum_hist_field(n_isoice(n,:), iblk, worka, a2D) enddo endif @@ -2014,14 +2016,14 @@ subroutine accum_hist_bgc (iblk) endif if (f_aero(1:1) /= 'x') then do n=1,n_aero - call accum_hist_field(n_aerosn1(n,:), iblk, & - trcr(:,:,nt_aero +4*(n-1),iblk)/rhos, a2D) - call accum_hist_field(n_aerosn2(n,:), iblk, & - trcr(:,:,nt_aero+1+4*(n-1),iblk)/rhos, a2D) - call accum_hist_field(n_aeroic1(n,:), iblk, & - trcr(:,:,nt_aero+2+4*(n-1),iblk)/rhoi, a2D) - call accum_hist_field(n_aeroic2(n,:), iblk, & - trcr(:,:,nt_aero+3+4*(n-1),iblk)/rhoi, a2D) + worka(:,:) = trcr(:,:,nt_aero +4*(n-1),iblk)/rhos + call accum_hist_field(n_aerosn1(n,:), iblk, worka, a2D) + worka(:,:) = trcr(:,:,nt_aero+1+4*(n-1),iblk)/rhos + call accum_hist_field(n_aerosn2(n,:), iblk, worka, a2D) + worka(:,:) = trcr(:,:,nt_aero+2+4*(n-1),iblk)/rhoi + call accum_hist_field(n_aeroic1(n,:), iblk, worka, a2D) + worka(:,:) = trcr(:,:,nt_aero+3+4*(n-1),iblk)/rhoi + call accum_hist_field(n_aeroic2(n,:), iblk, worka, a2D) enddo endif @@ -2031,76 +2033,61 @@ subroutine accum_hist_bgc (iblk) if (f_bgc_N(1:1)/= 'x') then do n=1,n_algae - call accum_hist_field(n_bgc_N(n,:), iblk, & - sk_l,trcr(:,:,nt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_bgc_N(n,:), iblk, trcr(:,:,nt_bgc_N(n), iblk), sk_l, a2D) enddo endif if (f_bgc_C(1:1)/= 'x') then do n=1,n_algae - call accum_hist_field(n_bgc_C(n,:), iblk, & - sk_l*R_C2N(n)*trcr(:,:,nt_bgc_N(n), iblk), a2D) + worka(:,:) = sk_l*R_C2N(n)*trcr(:,:,nt_bgc_N(n), iblk) + call accum_hist_field(n_bgc_C(n,:), iblk, worka, a2D) enddo endif if (f_bgc_DOC(1:1)/= 'x') then do n=1,n_doc - call accum_hist_field(n_bgc_DOC(n,:), iblk, & - sk_l,trcr(:,:,nt_bgc_DOC(n), iblk), a2D) + call accum_hist_field(n_bgc_DOC(n,:), iblk, trcr(:,:,nt_bgc_DOC(n), iblk), sk_l, a2D) enddo endif if (f_bgc_DIC(1:1)/= 'x') then do n=1,n_dic - call accum_hist_field(n_bgc_DIC(n,:), iblk, & - sk_l,trcr(:,:,nt_bgc_DIC(n), iblk), a2D) + call accum_hist_field(n_bgc_DIC(n,:), iblk, trcr(:,:,nt_bgc_DIC(n), iblk), sk_l, a2D) enddo endif if (f_bgc_DON(1:1)/= 'x') then do n=1,n_don - call accum_hist_field(n_bgc_DON(n,:), iblk, & - sk_l,trcr(:,:,nt_bgc_DON(n), iblk), a2D) + call accum_hist_field(n_bgc_DON(n,:), iblk, trcr(:,:,nt_bgc_DON(n), iblk), sk_l, a2D) enddo endif if (f_bgc_Fed (1:1)/= 'x') then do n=1,n_fed - call accum_hist_field(n_bgc_Fed (n,:), iblk, & - sk_l,trcr(:,:,nt_bgc_Fed (n), iblk), a2D) + call accum_hist_field(n_bgc_Fed (n,:), iblk, trcr(:,:,nt_bgc_Fed (n), iblk), sk_l, a2D) enddo endif if (f_bgc_Fep (1:1)/= 'x') then do n=1,n_fep - call accum_hist_field(n_bgc_Fep (n,:), iblk, & - sk_l,trcr(:,:,nt_bgc_Fep (n), iblk), a2D) + call accum_hist_field(n_bgc_Fep (n,:), iblk, trcr(:,:,nt_bgc_Fep (n), iblk), sk_l, a2D) enddo endif if (f_bgc_chl(1:1)/= 'x') then do n=1,n_algae - call accum_hist_field(n_bgc_chl(n,:), iblk, & - sk_l,trcr(:,:,nt_bgc_chl(n), iblk), a2D) + call accum_hist_field(n_bgc_chl(n,:), iblk, trcr(:,:,nt_bgc_chl(n), iblk), sk_l, a2D) enddo endif if (f_bgc_Nit(1:1)/= 'x') & - call accum_hist_field(n_bgc_Nit, iblk, & - sk_l,trcr(:,:,nt_bgc_Nit, iblk), a2D) + call accum_hist_field(n_bgc_Nit, iblk, trcr(:,:,nt_bgc_Nit, iblk), sk_l, a2D) if (f_bgc_Am(1:1)/= 'x') & - call accum_hist_field(n_bgc_Am, iblk, & - sk_l,trcr(:,:,nt_bgc_Am, iblk), a2D) + call accum_hist_field(n_bgc_Am, iblk, trcr(:,:,nt_bgc_Am, iblk), sk_l, a2D) if (f_bgc_Sil(1:1)/= 'x') & - call accum_hist_field(n_bgc_Sil, iblk, & - sk_l,trcr(:,:,nt_bgc_Sil, iblk), a2D) + call accum_hist_field(n_bgc_Sil, iblk, trcr(:,:,nt_bgc_Sil, iblk), sk_l, a2D) if (f_bgc_hum(1:1)/= 'x') & - call accum_hist_field(n_bgc_hum, iblk, & - sk_l,trcr(:,:,nt_bgc_hum, iblk), a2D) + call accum_hist_field(n_bgc_hum, iblk, trcr(:,:,nt_bgc_hum, iblk), sk_l, a2D) if (f_bgc_PON(1:1)/= 'x') & - call accum_hist_field(n_bgc_PON, iblk, & - sk_l,trcr(:,:,nt_bgc_PON, iblk), a2D) + call accum_hist_field(n_bgc_PON, iblk, trcr(:,:,nt_bgc_PON, iblk), sk_l, a2D) if (f_bgc_DMSPp(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMSPp,iblk, & - sk_l,trcr(:,:,nt_bgc_DMSPp,iblk), a2D) + call accum_hist_field(n_bgc_DMSPp,iblk, trcr(:,:,nt_bgc_DMSPp,iblk), sk_l, a2D) if (f_bgc_DMSPd(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMSPd,iblk, & - sk_l,trcr(:,:,nt_bgc_DMSPd,iblk), a2D) + call accum_hist_field(n_bgc_DMSPd,iblk, trcr(:,:,nt_bgc_DMSPd,iblk), sk_l, a2D) if (f_bgc_DMS(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMS, iblk, & - sk_l,trcr(:,:,nt_bgc_DMS, iblk), a2D) + call accum_hist_field(n_bgc_DMS, iblk, trcr(:,:,nt_bgc_DMS, iblk), sk_l, a2D) endif !skl_bgc @@ -2109,169 +2096,169 @@ subroutine accum_hist_bgc (iblk) if (f_bgc_DOC_ml(1:1)/= 'x') then do n=1,n_doc call accum_hist_field(n_bgc_DOC_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_DOC(n), iblk), a2D) + ocean_bio(:,:,nlt_bgc_DOC(n), iblk), a2D) enddo endif if (f_bgc_DIC_ml(1:1)/= 'x') then do n=1,n_dic call accum_hist_field(n_bgc_DIC_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_DIC(n), iblk), a2D) + ocean_bio(:,:,nlt_bgc_DIC(n), iblk), a2D) enddo endif if (f_bgc_DON_ml(1:1)/= 'x') then do n=1,n_don call accum_hist_field(n_bgc_DON_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_DON(n), iblk), a2D) + ocean_bio(:,:,nlt_bgc_DON(n), iblk), a2D) enddo endif if (f_bgc_Fed_ml (1:1)/= 'x') then do n=1,n_fed call accum_hist_field(n_bgc_Fed_ml (n,:), iblk, & - ocean_bio(:,:,nlt_bgc_Fed (n), iblk), a2D) + ocean_bio(:,:,nlt_bgc_Fed (n), iblk), a2D) enddo endif if (f_bgc_Fep_ml (1:1)/= 'x') then do n=1,n_fep call accum_hist_field(n_bgc_Fep_ml (n,:), iblk, & - ocean_bio(:,:,nlt_bgc_Fep (n), iblk), a2D) + ocean_bio(:,:,nlt_bgc_Fep (n), iblk), a2D) enddo endif if (f_bgc_N_ml(1:1)/= 'x') then do n=1,n_algae call accum_hist_field(n_bgc_N_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_N(n), iblk), a2D) + ocean_bio(:,:,nlt_bgc_N(n), iblk), a2D) enddo endif if (f_bgc_Nit_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_Nit_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Nit, iblk), a2D) + ocean_bio(:,:,nlt_bgc_Nit, iblk), a2D) if (f_bgc_Am_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_Am_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Am, iblk), a2D) + ocean_bio(:,:,nlt_bgc_Am, iblk), a2D) if (f_bgc_Sil_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_Sil_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Sil, iblk), a2D) + ocean_bio(:,:,nlt_bgc_Sil, iblk), a2D) if (f_bgc_hum_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_hum_ml, iblk, & - ocean_bio(:,:,nlt_bgc_hum, iblk), a2D) + ocean_bio(:,:,nlt_bgc_hum, iblk), a2D) if (f_bgc_DMSP_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_DMSP_ml, iblk, & - ocean_bio(:,:,nlt_bgc_DMSPd, iblk), a2D) + ocean_bio(:,:,nlt_bgc_DMSPd, iblk), a2D) if (f_bgc_DMS_ml(1:1)/= 'x') & call accum_hist_field(n_bgc_DMS_ml, iblk, & - ocean_bio(:,:,nlt_bgc_DMS, iblk), a2D) + ocean_bio(:,:,nlt_bgc_DMS, iblk), a2D) if (f_fNit (1:1) /= 'x') & - call accum_hist_field(n_fNit, iblk, & + call accum_hist_field(n_fNit, iblk, & flux_bio(:,:,nlt_bgc_Nit,iblk), a2D) if (f_fNit_ai(1:1)/= 'x') & - call accum_hist_field(n_fNit_ai, iblk, & + call accum_hist_field(n_fNit_ai, iblk, & flux_bio_ai(:,:,nlt_bgc_Nit,iblk), a2D) if (f_fAm (1:1) /= 'x') & - call accum_hist_field(n_fAm, iblk, & + call accum_hist_field(n_fAm, iblk, & flux_bio(:,:,nlt_bgc_Am,iblk), a2D) if (f_fAm_ai(1:1)/= 'x') & - call accum_hist_field(n_fAm_ai, iblk, & + call accum_hist_field(n_fAm_ai, iblk, & flux_bio_ai(:,:,nlt_bgc_Am,iblk), a2D) if (f_fN(1:1)/= 'x') then do n=1,n_algae - call accum_hist_field(n_fN(n,:), iblk, & + call accum_hist_field(n_fN(n,:), iblk, & flux_bio(:,:,nlt_bgc_N(n),iblk), a2D) enddo endif if (f_fN_ai(1:1)/= 'x') then do n=1,n_algae - call accum_hist_field(n_fN_ai(n,:), iblk, & + call accum_hist_field(n_fN_ai(n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_N(n),iblk), a2D) enddo endif if (f_fDOC(1:1)/= 'x') then do n=1,n_doc - call accum_hist_field(n_fDOC(n,:), iblk, & + call accum_hist_field(n_fDOC(n,:), iblk, & flux_bio(:,:,nlt_bgc_DOC(n),iblk), a2D) enddo endif if (f_fDOC_ai(1:1)/= 'x') then do n=1,n_doc - call accum_hist_field(n_fDOC_ai(n,:), iblk, & + call accum_hist_field(n_fDOC_ai(n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_DOC(n),iblk), a2D) enddo endif if (f_fDIC(1:1)/= 'x') then do n=1,n_dic - call accum_hist_field(n_fDIC(n,:), iblk, & + call accum_hist_field(n_fDIC(n,:), iblk, & flux_bio(:,:,nlt_bgc_DIC(n),iblk), a2D) enddo endif if (f_fDIC_ai(1:1)/= 'x') then do n=1,n_dic - call accum_hist_field(n_fDIC_ai(n,:), iblk, & + call accum_hist_field(n_fDIC_ai(n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_DIC(n),iblk), a2D) enddo endif if (f_fDON(1:1)/= 'x') then do n=1,n_don - call accum_hist_field(n_fDON(n,:), iblk, & + call accum_hist_field(n_fDON(n,:), iblk, & flux_bio(:,:,nlt_bgc_DON(n),iblk), a2D) enddo endif if (f_fDON_ai(1:1)/= 'x') then do n=1,n_don - call accum_hist_field(n_fDON_ai(n,:), iblk, & + call accum_hist_field(n_fDON_ai(n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_DON(n),iblk), a2D) enddo endif if (f_fFed (1:1)/= 'x') then do n=1,n_fed - call accum_hist_field(n_fFed (n,:), iblk, & + call accum_hist_field(n_fFed (n,:), iblk, & flux_bio(:,:,nlt_bgc_Fed (n),iblk), a2D) enddo endif if (f_fFed_ai (1:1)/= 'x') then do n=1,n_fed - call accum_hist_field(n_fFed_ai (n,:), iblk, & + call accum_hist_field(n_fFed_ai (n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_Fed (n),iblk), a2D) enddo endif if (f_fFep (1:1)/= 'x') then do n=1,n_fep - call accum_hist_field(n_fFep (n,:), iblk, & + call accum_hist_field(n_fFep (n,:), iblk, & flux_bio(:,:,nlt_bgc_Fep (n),iblk), a2D) enddo endif if (f_fFep_ai (1:1)/= 'x') then do n=1,n_fep - call accum_hist_field(n_fFep_ai (n,:), iblk, & + call accum_hist_field(n_fFep_ai (n,:), iblk, & flux_bio_ai(:,:,nlt_bgc_Fep (n),iblk), a2D) enddo endif if (f_fSil (1:1) /= 'x') & - call accum_hist_field(n_fSil, iblk, & + call accum_hist_field(n_fSil, iblk, & flux_bio(:,:,nlt_bgc_Sil,iblk), a2D) if (f_fSil_ai(1:1)/= 'x') & call accum_hist_field(n_fSil_ai, iblk, & flux_bio_ai(:,:,nlt_bgc_Sil,iblk), a2D) if (f_fhum (1:1) /= 'x') & - call accum_hist_field(n_fhum, iblk, & + call accum_hist_field(n_fhum, iblk, & flux_bio(:,:,nlt_bgc_hum,iblk), a2D) if (f_fhum_ai(1:1)/= 'x') & call accum_hist_field(n_fhum_ai, iblk, & flux_bio_ai(:,:,nlt_bgc_hum,iblk), a2D) if (f_fPON (1:1) /= 'x') & - call accum_hist_field(n_fPON, iblk, & + call accum_hist_field(n_fPON, iblk, & flux_bio(:,:,nlt_bgc_PON,iblk), a2D) if (f_fPON_ai(1:1)/= 'x') & call accum_hist_field(n_fPON_ai, iblk, & flux_bio_ai(:,:,nlt_bgc_PON,iblk), a2D) if (f_fDMS (1:1) /= 'x') & - call accum_hist_field(n_fDMS, iblk, & + call accum_hist_field(n_fDMS, iblk, & flux_bio(:,:,nlt_bgc_DMS,iblk), a2D) if (f_fDMS_ai(1:1)/= 'x') & call accum_hist_field(n_fDMS_ai, iblk, & flux_bio_ai(:,:,nlt_bgc_DMS,iblk), a2D) if (f_fDMSPd (1:1) /= 'x') & - call accum_hist_field(n_fDMSPd, iblk, & + call accum_hist_field(n_fDMSPd, iblk, & flux_bio(:,:,nlt_bgc_DMSPd,iblk), a2D) if (f_fDMSPd_ai(1:1)/= 'x') & call accum_hist_field(n_fDMSPd_ai, iblk, & @@ -2347,8 +2334,7 @@ subroutine accum_hist_bgc (iblk) endif !f_zaeronet if (f_chlnet (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_chlnet(n,:), iblk, & - R_chl2N(n),ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_chlnet(n,:), iblk, ice_bio_net(:,:,nlt_bgc_N(n), iblk), R_chl2N(n), a2D) enddo endif !f_chlnet if (f_Nnet (1:1) /= 'x') then @@ -2359,8 +2345,7 @@ subroutine accum_hist_bgc (iblk) endif !f_Nnet if (f_Cnet (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_Cnet(n,:), iblk, & - R_C2N(n) ,ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_Cnet(n,:), iblk, ice_bio_net(:,:,nlt_bgc_N(n), iblk), R_C2N(n), a2D) enddo endif !f_Cnet if (f_DOCnet (1:1) /= 'x') then @@ -2429,8 +2414,7 @@ subroutine accum_hist_bgc (iblk) endif !f_zaerosnow if (f_chlsnow (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_chlsnow(n,:), iblk, & - R_chl2N(n),snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_chlsnow(n,:), iblk, snow_bio_net(:,:,nlt_bgc_N(n), iblk), R_chl2N(n), a2D) enddo endif !f_chlsnow if (f_Nsnow (1:1) /= 'x') then @@ -2441,8 +2425,7 @@ subroutine accum_hist_bgc (iblk) endif !f_Nsnow if (f_Csnow (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_Csnow(n,:), iblk, & - R_C2N(n),snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_Csnow(n,:), iblk, snow_bio_net(:,:,nlt_bgc_N(n), iblk), R_C2N(n), a2D) enddo endif !f_Csnow if (f_DOCsnow (1:1) /= 'x') then diff --git a/cicecore/cicedyn/analysis/ice_history_fsd.F90 b/cicecore/cicedyn/analysis/ice_history_fsd.F90 index 610f56608..6379233e5 100644 --- a/cicecore/cicedyn/analysis/ice_history_fsd.F90 +++ b/cicecore/cicedyn/analysis/ice_history_fsd.F90 @@ -471,21 +471,26 @@ subroutine accum_hist_fsd (dt, iblk) call accum_hist_field(n_afsd-n3Dacum, iblk, nfsd_hist, worke, a3Df) endif - if (f_dafsd_newi(1:1)/= 'x') & - call accum_hist_field(n_dafsd_newi-n3Dacum, iblk, nfsd_hist, & - d_afsd_newi(:,:,1:nfsd_hist,iblk)/dt, a3Df) - if (f_dafsd_latg(1:1)/= 'x') & - call accum_hist_field(n_dafsd_latg-n3Dacum, iblk, nfsd_hist, & - d_afsd_latg(:,:,1:nfsd_hist,iblk)/dt, a3Df) - if (f_dafsd_latm(1:1)/= 'x') & - call accum_hist_field(n_dafsd_latm-n3Dacum, iblk, nfsd_hist, & - d_afsd_latm(:,:,1:nfsd_hist,iblk)/dt, a3Df) - if (f_dafsd_wave(1:1)/= 'x') & - call accum_hist_field(n_dafsd_wave-n3Dacum, iblk, nfsd_hist, & - d_afsd_wave(:,:,1:nfsd_hist,iblk)/dt, a3Df) - if (f_dafsd_weld(1:1)/= 'x') & - call accum_hist_field(n_dafsd_weld-n3Dacum, iblk, nfsd_hist, & - d_afsd_weld(:,:,1:nfsd_hist,iblk)/dt, a3Df) + if (f_dafsd_newi(1:1)/= 'x') then + worke(:,:,1:nfsd_hist) = d_afsd_newi(:,:,1:nfsd_hist,iblk)/dt + call accum_hist_field(n_dafsd_newi-n3Dacum, iblk, nfsd_hist, worke, a3Df) + endif + if (f_dafsd_latg(1:1)/= 'x') then + worke(:,:,1:nfsd_hist) = d_afsd_latg(:,:,1:nfsd_hist,iblk)/dt + call accum_hist_field(n_dafsd_latg-n3Dacum, iblk, nfsd_hist, worke, a3Df) + endif + if (f_dafsd_latm(1:1)/= 'x') then + worke(:,:,1:nfsd_hist) = d_afsd_latm(:,:,1:nfsd_hist,iblk)/dt + call accum_hist_field(n_dafsd_latm-n3Dacum, iblk, nfsd_hist, worke, a3Df) + endif + if (f_dafsd_wave(1:1)/= 'x') then + worke(:,:,1:nfsd_hist) = d_afsd_wave(:,:,1:nfsd_hist,iblk)/dt + call accum_hist_field(n_dafsd_wave-n3Dacum, iblk, nfsd_hist, worke, a3Df) + endif + if (f_dafsd_weld(1:1)/= 'x') then + worke(:,:,1:nfsd_hist) = d_afsd_weld(:,:,1:nfsd_hist,iblk)/dt + call accum_hist_field(n_dafsd_weld-n3Dacum, iblk, nfsd_hist, worke, a3Df) + endif endif ! a3Df allocated ! 4D floe size, thickness category fields diff --git a/cicecore/cicedyn/analysis/ice_history_mechred.F90 b/cicecore/cicedyn/analysis/ice_history_mechred.F90 index 19069ef81..5e44e6511 100644 --- a/cicecore/cicedyn/analysis/ice_history_mechred.F90 +++ b/cicecore/cicedyn/analysis/ice_history_mechred.F90 @@ -358,6 +358,7 @@ end subroutine init_hist_mechred_3Dc subroutine accum_hist_mechred (iblk) + use ice_blocks, only: nx_block, ny_block use ice_history_shared, only: n2D, a2D, a3Dc, ncat_hist, & accum_hist_field use ice_state, only: aice, vice, trcr, aicen, vicen, trcrn @@ -372,6 +373,8 @@ subroutine accum_hist_mechred (iblk) integer (kind=int_kind) :: & nt_alvl, nt_vlvl + real (kind=dbl_kind), dimension(nx_block,ny_block,ncat_hist) :: workc + character(len=*), parameter :: subname = '(accum_hist_mechred)' call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl) @@ -421,14 +424,16 @@ subroutine accum_hist_mechred (iblk) ! 3D category fields if (allocated(a3Dc)) then - if (f_ardgn(1:1)/= 'x') & - call accum_hist_field(n_ardgn-n2D, iblk, ncat_hist, & - aicen(:,:,1:ncat_hist,iblk) & - * (c1 - trcrn(:,:,nt_alvl,1:ncat_hist,iblk)), a3Dc) - if (f_vrdgn(1:1)/= 'x') & - call accum_hist_field(n_vrdgn-n2D, iblk, ncat_hist, & - vicen(:,:,1:ncat_hist,iblk) & - * (c1 - trcrn(:,:,nt_vlvl,1:ncat_hist,iblk)), a3Dc) + if (f_ardgn(1:1)/= 'x') then + workc(:,:,1:ncat_hist) = aicen(:,:,1:ncat_hist,iblk) & + * (c1 - trcrn(:,:,nt_alvl,1:ncat_hist,iblk)) + call accum_hist_field(n_ardgn-n2D, iblk, ncat_hist, workc, a3Dc) + endif + if (f_vrdgn(1:1)/= 'x') then + workc(:,:,1:ncat_hist) = vicen(:,:,1:ncat_hist,iblk) & + * (c1 - trcrn(:,:,nt_vlvl,1:ncat_hist,iblk)) + call accum_hist_field(n_vrdgn-n2D, iblk, ncat_hist, workc, a3Dc) + endif if (f_dardg1ndt(1:1)/= 'x') & call accum_hist_field(n_dardg1ndt-n2D, iblk, ncat_hist, & dardg1ndt(:,:,1:ncat_hist,iblk), a3Dc) diff --git a/cicecore/cicedyn/analysis/ice_history_pond.F90 b/cicecore/cicedyn/analysis/ice_history_pond.F90 index 0b4f52ff8..25a578b2f 100644 --- a/cicecore/cicedyn/analysis/ice_history_pond.F90 +++ b/cicecore/cicedyn/analysis/ice_history_pond.F90 @@ -489,6 +489,9 @@ subroutine accum_hist_pond (iblk) type (block) :: & this_block ! block information for current block + real (kind=dbl_kind), dimension(nx_block,ny_block) :: workb + real (kind=dbl_kind), dimension(nx_block,ny_block,ncat_hist) :: workc + character(len=*), parameter :: subname = '(accum_hist_pond)' !--------------------------------------------------------------- @@ -519,12 +522,16 @@ subroutine accum_hist_pond (iblk) call accum_hist_field(n_apond_ai, iblk, aice_init(:,:,iblk),worka(:,:), a2D) if (f_hpond(1:1)/= 'x') & call accum_hist_field(n_hpond, iblk, worka(:,:),trcr(:,:,nt_hpnd,iblk), a2D) - if (f_hpond_ai(1:1)/= 'x') & - call accum_hist_field(n_hpond_ai, iblk, aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_hpnd,iblk), a2D) + if (f_hpond_ai(1:1)/= 'x') then + workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_hpnd,iblk) + call accum_hist_field(n_hpond_ai, iblk, workb, a2D) + endif if (f_ipond(1:1)/= 'x') & call accum_hist_field(n_ipond, iblk, worka(:,:),trcr(:,:,nt_ipnd,iblk), a2D) - if (f_ipond_ai(1:1)/= 'x') & - call accum_hist_field(n_ipond_ai, iblk, aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_ipnd,iblk), a2D) + if (f_ipond_ai(1:1)/= 'x') then + workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_ipnd,iblk) + call accum_hist_field(n_ipond_ai, iblk, workb, a2D) + endif ! CMIP pond related variables if (f_simpeffconc (1:1) /= 'x') & @@ -533,11 +540,15 @@ subroutine accum_hist_pond (iblk) if (f_simpconc(1:1)/= 'x') & call accum_hist_field(n_simpconc, iblk, worka(:,:), a2D) - if (f_simpthick(1:1)/= 'x') & - call accum_hist_field(n_simpthick, iblk, aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_hpnd,iblk), a2D) + if (f_simpthick(1:1)/= 'x') then + workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_hpnd,iblk) + call accum_hist_field(n_simpthick, iblk, workb, a2D) + endif - if (f_simprefrozen(1:1)/= 'x') & - call accum_hist_field(n_simprefrozen, iblk, aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_ipnd,iblk), a2D) + if (f_simprefrozen(1:1)/= 'x') then + workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_ipnd,iblk) + call accum_hist_field(n_simprefrozen, iblk, workb, a2D) + endif this_block = get_block(blocks_ice(iblk),iblk) ilo = this_block%ilo @@ -583,10 +594,11 @@ subroutine accum_hist_pond (iblk) if (f_apeffn (1:1) /= 'x') & call accum_hist_field(n_apeffn-n2D, iblk, ncat_hist, & apeffn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_hpondn (1:1) /= 'x') & - call accum_hist_field(n_hpondn-n2D, iblk, ncat_hist, & - trcrn(:,:,nt_apnd,1:ncat_hist,iblk) & - * trcrn(:,:,nt_hpnd,1:ncat_hist,iblk), a3Dc) + if (f_hpondn (1:1) /= 'x') then + workc(:,:,1:ncat_hist) = trcrn(:,:,nt_apnd,1:ncat_hist,iblk) & + * trcrn(:,:,nt_hpnd,1:ncat_hist,iblk) + call accum_hist_field(n_hpondn-n2D, iblk, ncat_hist, workc, a3Dc) + endif if (f_dpnd_flushn (1:1) /= 'x') & call accum_hist_field(n_dpnd_flushn-n2D , iblk, ncat_hist, dpnd_flushn (:,:,1:ncat_hist,iblk), a3Dc) diff --git a/cicecore/cicedyn/analysis/ice_history_shared.F90 b/cicecore/cicedyn/analysis/ice_history_shared.F90 index f6c145c02..edc4d87d2 100644 --- a/cicecore/cicedyn/analysis/ice_history_shared.F90 +++ b/cicecore/cicedyn/analysis/ice_history_shared.F90 @@ -769,7 +769,6 @@ module ice_history_shared module procedure accum_hist_field_2D, & accum_hist_field_2D_prod, & accum_hist_field_2D_mul, & - accum_hist_field_2D_smul, & accum_hist_field_3D, & accum_hist_field_4D end interface @@ -1184,8 +1183,11 @@ end subroutine accum_hist_field_2D_prod !======================================================================= ! -! The same for a field scaled by a constant. Distinguished from the -! two-field form by the rank of the second factor. +! The same for a field scaled by a constant, distinguished from the +! two-field form by the rank of the second factor. There is deliberately +! no mirror form taking the scale first: a caller whose scale is on the +! left swaps its two actuals, which is bit-for-bit because floating +! multiplication is commutative and exactly rounded. subroutine accum_hist_field_2D_mul(id, iblk, a, s, field) @@ -1238,63 +1240,6 @@ subroutine accum_hist_field_2D_mul(id, iblk, a, s, field) end subroutine accum_hist_field_2D_mul -!======================================================================= - -! The scale on the left. A separate specific rather than swapping the -! arguments at the call site, so that converting a caller is a one-character -! change and a reviewer never has to check that a reordering was safe. - - subroutine accum_hist_field_2D_smul(id, iblk, sfac, afld, field) - - use ice_blocks, only: block, get_block - use ice_calendar, only: nstreams - use ice_domain, only: blocks_ice - use ice_grid, only: tmask - - integer (int_kind), dimension(:), intent(in) :: & ! max_nstrm - id ! location in avail_fields array - - integer (kind=int_kind), intent(in) :: iblk - - real (kind=dbl_kind), intent(in) :: & - sfac ! the scale - - real (kind=dbl_kind), intent(in) :: & - afld(:,:) ! the field, block shaped - - real (kind=dbl_kind), intent(inout) :: & - field(:,:,:,:) - - type (block) :: & - this_block ! block information for current block - - integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns - - character(len=*), parameter :: subname = '(accum_hist_field_2D_smul)' - - do ns = 1, nstreams - idns = id(ns) - if (idns > 0) then - - this_block = get_block(blocks_ice(iblk),iblk) - ilo = this_block%ilo - ihi = this_block%ihi - jlo = this_block%jlo - jhi = this_block%jhi - - do j = jlo, jhi - do i = ilo, ihi - if (tmask(i,j,iblk)) then - field(i,j,idns, iblk) = field(i,j,idns, iblk) + sfac*afld(i,j) - endif - enddo - enddo - - endif - enddo - - end subroutine accum_hist_field_2D_smul - !======================================================================= subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field) From 570d1aa21a54788e059b6225a65665b6c56a5e79 Mon Sep 17 00:00:00 2001 From: Till Rasmussen <> Date: Fri, 13 Nov 2026 11:18:59 +0100 Subject: [PATCH 3/6] history: the compound callers a parenthesised expression hid Five callers were missed: f_albsni, whose argument is a four-term weighted sum, and the four ridge fields whose second factor is (c1 - trcr(...)). They were missed because the scan that found the others stripped anything inside parentheses before looking for operators -- so it would not mistake a subscript for arithmetic -- and an expression wrapped in its own parentheses then looks like one subscript and comes back operator-free. The scan also only examined the argument before the accumulator, which is the second factor only in the two-field form. Peeling one layer of wrapping parentheses and checking EVERY field argument finds all five and reports none remaining. albsni builds its sum in a work array. The ridge fields keep the two-field specific -- that is what it is for -- and only the (c1 - trcr) factor moves to a work array, so no anonymous temporary is built for it. Verified against the unmodified base on gfortran, bit-for-bit over all five history files and all 36 restart files, with every tracer enabled and all 279 history fields on. --- cicecore/cicedyn/analysis/ice_history.F90 | 10 +++++----- .../cicedyn/analysis/ice_history_mechred.F90 | 17 +++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/cicecore/cicedyn/analysis/ice_history.F90 b/cicecore/cicedyn/analysis/ice_history.F90 index 32486db58..0c669a1ac 100644 --- a/cicecore/cicedyn/analysis/ice_history.F90 +++ b/cicecore/cicedyn/analysis/ice_history.F90 @@ -2552,11 +2552,11 @@ subroutine accum_hist (dt) call accum_hist_field(n_fswabs_ai, iblk, fswabs(:,:,iblk),aice(:,:,iblk), a2D) if (f_albsni(1:1) /= 'x') then - call accum_hist_field(n_albsni, iblk, & - (awtvdr*alvdr_ai(:,:,iblk) & - + awtidr*alidr_ai(:,:,iblk) & - + awtvdf*alvdf_ai(:,:,iblk) & - + awtidf*alidf_ai(:,:,iblk)), a2D) + worka(:,:) = awtvdr*alvdr_ai(:,:,iblk) & + + awtidr*alidr_ai(:,:,iblk) & + + awtvdf*alvdf_ai(:,:,iblk) & + + awtidf*alidf_ai(:,:,iblk) + call accum_hist_field(n_albsni, iblk, worka, a2D) endif if (f_alvdr (1:1) /= 'x') & diff --git a/cicecore/cicedyn/analysis/ice_history_mechred.F90 b/cicecore/cicedyn/analysis/ice_history_mechred.F90 index 5e44e6511..28930e834 100644 --- a/cicecore/cicedyn/analysis/ice_history_mechred.F90 +++ b/cicecore/cicedyn/analysis/ice_history_mechred.F90 @@ -373,6 +373,7 @@ subroutine accum_hist_mechred (iblk) integer (kind=int_kind) :: & nt_alvl, nt_vlvl + real (kind=dbl_kind), dimension(nx_block,ny_block) :: worka real (kind=dbl_kind), dimension(nx_block,ny_block,ncat_hist) :: workc character(len=*), parameter :: subname = '(accum_hist_mechred)' @@ -396,11 +397,11 @@ subroutine accum_hist_mechred (iblk) call accum_hist_field(n_vlvl, iblk, & vice(:,:,iblk) , trcr(:,:,nt_vlvl,iblk), a2D) if (f_ardg(1:1)/= 'x') & - call accum_hist_field(n_ardg, iblk, & - aice(:,:,iblk) , (c1 - trcr(:,:,nt_alvl,iblk)), a2D) + worka(:,:) = c1 - trcr(:,:,nt_alvl,iblk) + call accum_hist_field(n_ardg, iblk, aice(:,:,iblk), worka, a2D) if (f_vrdg(1:1)/= 'x') & - call accum_hist_field(n_vrdg, iblk, & - vice(:,:,iblk) , (c1 - trcr(:,:,nt_vlvl,iblk)), a2D) + worka(:,:) = c1 - trcr(:,:,nt_vlvl,iblk) + call accum_hist_field(n_vrdg, iblk, vice(:,:,iblk), worka, a2D) if (f_dardg1dt(1:1)/= 'x') & call accum_hist_field(n_dardg1dt,iblk, dardg1dt(:,:,iblk), a2D) if (f_dardg2dt(1:1)/= 'x') & @@ -411,12 +412,12 @@ subroutine accum_hist_mechred (iblk) call accum_hist_field(n_opening, iblk, opening(:,:,iblk), a2D) if (f_sirdgconc(1:1)/= 'x') & - call accum_hist_field(n_sirdgconc, iblk, & - aice(:,:,iblk) , (c1 - trcr(:,:,nt_alvl,iblk)), a2D) + worka(:,:) = c1 - trcr(:,:,nt_alvl,iblk) + call accum_hist_field(n_sirdgconc, iblk, aice(:,:,iblk), worka, a2D) if (f_sirdgthick(1:1)/= 'x') then - call accum_hist_field(n_sirdgthick, iblk, & - vice(:,:,iblk) , (c1 - trcr(:,:,nt_vlvl,iblk)), a2D) + worka(:,:) = c1 - trcr(:,:,nt_vlvl,iblk) + call accum_hist_field(n_sirdgthick, iblk, vice(:,:,iblk), worka, a2D) endif endif ! allocated(a2D) From f59da26352724da0628a84df3433af7ce2cb2cec Mon Sep 17 00:00:00 2001 From: Till Rasmussen <> Date: Fri, 13 Nov 2026 11:51:37 +0100 Subject: [PATCH 4/6] history: compute the work arrays over the physical domain only Every work-array expression ran over the whole block, halo included. The accumulators read jlo..jhi x ilo..ihi and nothing else, so the halo result was built and discarded -- 13% of each assignment on a gx3 block. The waste is not the reason to change it. A full-array expression EVALUATES across the halo, where a value may be uninitialised; with -finit-real=snan that is a floating-point trap on a result nobody wanted. In ice_history the operands are state arrays the halo updates keep defined, so this was latent rather than live, but it is the wrong default. All 74 statements now run ilo:ihi, jlo:jhi. That is 41 which predate this branch -- the split is upstream's, not new here: when upstream uses a work array it writes the full array, and when it needs per-cell logic it writes a scoped loop. The explicit loops are left alone; they exist where a per-cell condition needs them and are already scoped. accum_hist_snow and accum_hist_mechred had no block geometry at all and now take this_block and the four bounds. In accum_hist_pond the bounds existed but were set BELOW the work arrays, so scoping them alone gave ilo = 0 and an index-zero abort; the block moves above its first use. Bit-for-bit against the unmodified base: all five history files and all 36 restart files, every tracer on, all 279 history fields. --- cicecore/cicedyn/analysis/ice_history.F90 | 86 +++++++++---------- cicecore/cicedyn/analysis/ice_history_bgc.F90 | 14 +-- .../cicedyn/analysis/ice_history_mechred.F90 | 26 ++++-- .../cicedyn/analysis/ice_history_pond.F90 | 29 ++++--- .../cicedyn/analysis/ice_history_snow.F90 | 60 ++++++++----- 5 files changed, 125 insertions(+), 90 deletions(-) diff --git a/cicecore/cicedyn/analysis/ice_history.F90 b/cicecore/cicedyn/analysis/ice_history.F90 index 0c669a1ac..00fceaf13 100644 --- a/cicecore/cicedyn/analysis/ice_history.F90 +++ b/cicecore/cicedyn/analysis/ice_history.F90 @@ -2390,7 +2390,7 @@ subroutine accum_hist (dt) if (allocated(a2D)) then - workb(:,:) = aice_init(:,:,iblk) + workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk) ! if (f_example(1:1) /= 'x') & ! call accum_hist_field(n_example,iblk, vice(:,:,iblk), a2D) @@ -2411,11 +2411,11 @@ subroutine accum_hist (dt) if (f_vvel (1:1) /= 'x') & call accum_hist_field(n_vvel, iblk, vvel(:,:,iblk), a2D) if (f_icespd (1:1) /= 'x') then - worka(:,:) = sqrt( (uvel(:,:,iblk)*uvel(:,:,iblk)) + (vvel(:,:,iblk)*vvel(:,:,iblk))) + worka(ilo:ihi,jlo:jhi) = sqrt( (uvel(ilo:ihi,jlo:jhi,iblk)*uvel(ilo:ihi,jlo:jhi,iblk)) + (vvel(ilo:ihi,jlo:jhi,iblk)*vvel(ilo:ihi,jlo:jhi,iblk))) call accum_hist_field(n_icespd, iblk, worka, a2D) endif if (f_icedir(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uvel(i,j,iblk)) > puny .or. abs(vvel(i,j,iblk)) > puny) & @@ -2430,11 +2430,11 @@ subroutine accum_hist (dt) if (f_vvelN (1:1) /= 'x') & call accum_hist_field(n_vvelN, iblk, vvelN(:,:,iblk), a2D) if (f_icespdN (1:1) /= 'x') then - worka(:,:) = sqrt( (uvelN(:,:,iblk)*uvelN(:,:,iblk)) + (vvelN(:,:,iblk)*vvelN(:,:,iblk))) + worka(ilo:ihi,jlo:jhi) = sqrt( (uvelN(ilo:ihi,jlo:jhi,iblk)*uvelN(ilo:ihi,jlo:jhi,iblk)) + (vvelN(ilo:ihi,jlo:jhi,iblk)*vvelN(ilo:ihi,jlo:jhi,iblk))) call accum_hist_field(n_icespdN, iblk, worka, a2D) endif if (f_icedirN(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uvelN(i,j,iblk)) > puny .or. abs(vvelN(i,j,iblk)) > puny) & @@ -2449,11 +2449,11 @@ subroutine accum_hist (dt) if (f_vvelE (1:1) /= 'x') & call accum_hist_field(n_vvelE, iblk, vvelE(:,:,iblk), a2D) if (f_icespdE (1:1) /= 'x') then - worka(:,:) = sqrt( (uvelE(:,:,iblk)*uvelE(:,:,iblk)) + (vvelE(:,:,iblk)*vvelE(:,:,iblk))) + worka(ilo:ihi,jlo:jhi) = sqrt( (uvelE(ilo:ihi,jlo:jhi,iblk)*uvelE(ilo:ihi,jlo:jhi,iblk)) + (vvelE(ilo:ihi,jlo:jhi,iblk)*vvelE(ilo:ihi,jlo:jhi,iblk))) call accum_hist_field(n_icespdE, iblk, worka, a2D) endif if (f_icedirE(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uvelE(i,j,iblk)) > puny .or. abs(vvelE(i,j,iblk)) > puny) & @@ -2468,11 +2468,11 @@ subroutine accum_hist (dt) if (f_vatm (1:1) /= 'x') & call accum_hist_field(n_vatm, iblk, vatm(:,:,iblk), a2D) if (f_atmspd (1:1) /= 'x') then - worka(:,:) = sqrt( (uatm(:,:,iblk)*uatm(:,:,iblk)) + (vatm(:,:,iblk)*vatm(:,:,iblk))) + worka(ilo:ihi,jlo:jhi) = sqrt( (uatm(ilo:ihi,jlo:jhi,iblk)*uatm(ilo:ihi,jlo:jhi,iblk)) + (vatm(ilo:ihi,jlo:jhi,iblk)*vatm(ilo:ihi,jlo:jhi,iblk))) call accum_hist_field(n_atmspd, iblk, worka, a2D) endif if (f_atmdir(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uatm(i,j,iblk)) > puny .or. abs(vatm(i,j,iblk)) > puny) & @@ -2519,11 +2519,11 @@ subroutine accum_hist (dt) if (f_vocn (1:1) /= 'x') & call accum_hist_field(n_vocn, iblk, vocn(:,:,iblk), a2D) if (f_ocnspd (1:1) /= 'x') then - worka(:,:) = sqrt( (uocn(:,:,iblk)*uocn(:,:,iblk)) + (vocn(:,:,iblk)*vocn(:,:,iblk))) + worka(ilo:ihi,jlo:jhi) = sqrt( (uocn(ilo:ihi,jlo:jhi,iblk)*uocn(ilo:ihi,jlo:jhi,iblk)) + (vocn(ilo:ihi,jlo:jhi,iblk)*vocn(ilo:ihi,jlo:jhi,iblk))) call accum_hist_field(n_ocnspd, iblk, worka, a2D) endif if (f_ocndir(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uocn(i,j,iblk)) > puny .or. abs(vocn(i,j,iblk)) > puny) & @@ -2552,10 +2552,10 @@ subroutine accum_hist (dt) call accum_hist_field(n_fswabs_ai, iblk, fswabs(:,:,iblk),aice(:,:,iblk), a2D) if (f_albsni(1:1) /= 'x') then - worka(:,:) = awtvdr*alvdr_ai(:,:,iblk) & - + awtidr*alidr_ai(:,:,iblk) & - + awtvdf*alvdf_ai(:,:,iblk) & - + awtidf*alidf_ai(:,:,iblk) + worka(ilo:ihi,jlo:jhi) = awtvdr*alvdr_ai(ilo:ihi,jlo:jhi,iblk) & + + awtidr*alidr_ai(ilo:ihi,jlo:jhi,iblk) & + + awtvdf*alvdf_ai(ilo:ihi,jlo:jhi,iblk) & + + awtidf*alidf_ai(ilo:ihi,jlo:jhi,iblk) call accum_hist_field(n_albsni, iblk, worka, a2D) endif @@ -2656,7 +2656,7 @@ subroutine accum_hist (dt) if (f_strcorx(1:1) /= 'x') & call accum_hist_field(n_strcorx, iblk, fmU(:,:,iblk),vvel(:,:,iblk), a2D) if (f_strcory(1:1) /= 'x') then - worka(:,:) = -fmU(:,:,iblk)*uvel(:,:,iblk) + worka(ilo:ihi,jlo:jhi) = -fmU(ilo:ihi,jlo:jhi,iblk)*uvel(ilo:ihi,jlo:jhi,iblk) call accum_hist_field(n_strcory, iblk, worka, a2D) endif if (f_strocnx(1:1) /= 'x') & @@ -2690,13 +2690,13 @@ subroutine accum_hist (dt) if (f_strcorxN(1:1) /= 'x') & call accum_hist_field(n_strcorxN, iblk, fmN(:,:,iblk),vvelN(:,:,iblk), a2D) if (f_strcoryN(1:1) /= 'x') then - worka(:,:) = -fmN(:,:,iblk)*uvelN(:,:,iblk) + worka(ilo:ihi,jlo:jhi) = -fmN(ilo:ihi,jlo:jhi,iblk)*uvelN(ilo:ihi,jlo:jhi,iblk) call accum_hist_field(n_strcoryN, iblk, worka, a2D) endif if (f_strcorxE(1:1) /= 'x') & call accum_hist_field(n_strcorxE, iblk, fmE(:,:,iblk),vvelE(:,:,iblk), a2D) if (f_strcoryE(1:1) /= 'x') then - worka(:,:) = -fmE(:,:,iblk)*uvelE(:,:,iblk) + worka(ilo:ihi,jlo:jhi) = -fmE(ilo:ihi,jlo:jhi,iblk)*uvelE(ilo:ihi,jlo:jhi,iblk) call accum_hist_field(n_strcoryE, iblk, worka, a2D) endif if (f_strocnxN(1:1) /= 'x') & @@ -2763,7 +2763,7 @@ subroutine accum_hist (dt) fcondtop(:,:,iblk),aice(:,:,iblk), a2D) if (f_icepresent(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) worka(i,j) = c1 @@ -2775,7 +2775,7 @@ subroutine accum_hist (dt) ! 2D CMIP fields if (f_sitimefrac(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) worka(i,j) = c1 @@ -2810,7 +2810,7 @@ subroutine accum_hist (dt) endif if (f_sisaltmass(1:1) /= 'x') then - worka(:,:) = rho_ice(:,:)*sal_ice(:,:)*vice(:,:,iblk) + worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*sal_ice(ilo:ihi,jlo:jhi)*vice(ilo:ihi,jlo:jhi,iblk) call accum_hist_field(n_sisaltmass, iblk, worka, a2D) endif @@ -2860,7 +2860,7 @@ subroutine accum_hist (dt) endif if (f_sispeed(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk) & @@ -2887,7 +2887,7 @@ subroutine accum_hist (dt) ! endif if (f_sidmasstranx(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = (rho_ice(i,j)*p5*(vice(i+1,j,iblk)+vice(i,j,iblk))*dyU(i,j,iblk) & @@ -2899,7 +2899,7 @@ subroutine accum_hist (dt) endif if (f_sidmasstrany(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = (rho_ice(i,j)*p5*(vice(i,j+1,iblk)+vice(i,j,iblk))*dxU(i,j,iblk) & @@ -2931,7 +2931,7 @@ subroutine accum_hist (dt) endif if (f_sihc(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do k = 1,nzilyr do j = jlo, jhi do i = ilo, ihi @@ -2943,7 +2943,7 @@ subroutine accum_hist (dt) endif if (f_sisnhc(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do k = 1,nzslyr do j = jlo, jhi do i = ilo, ihi @@ -2971,22 +2971,22 @@ subroutine accum_hist (dt) endif if (f_sidmassgrowthwat(1:1) /= 'x') then - worka(:,:) = rho_ice(:,:)*frazil(:,:,iblk)/dt + worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*frazil(ilo:ihi,jlo:jhi,iblk)/dt call accum_hist_field(n_sidmassgrowthwat, iblk, worka, a2D) endif if (f_sidmassgrowthbot(1:1) /= 'x') then - worka(:,:) = rho_ice(:,:)*congel(:,:,iblk)/dt + worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*congel(ilo:ihi,jlo:jhi,iblk)/dt call accum_hist_field(n_sidmassgrowthbot, iblk, worka, a2D) endif if (f_sidmassgrowthsi(1:1) /= 'x') then - worka(:,:) = rho_ice(:,:)*snoice(:,:,iblk)/dt + worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*snoice(ilo:ihi,jlo:jhi,iblk)/dt call accum_hist_field(n_sidmassgrowthsi, iblk, worka, a2D) endif if (f_sisndmasssi(1:1) /= 'x') then - worka(:,:) = -snoice(:,:,iblk)*rhos/dt + worka(ilo:ihi,jlo:jhi) = -snoice(ilo:ihi,jlo:jhi,iblk)*rhos/dt call accum_hist_field(n_sisndmasssi, iblk, worka, a2D) endif @@ -2995,17 +2995,17 @@ subroutine accum_hist (dt) endif if (f_sidmassmelttop(1:1) /= 'x') then - worka(:,:) = -rho_ice(:,:)*meltt(:,:,iblk)/dt + worka(ilo:ihi,jlo:jhi) = -rho_ice(ilo:ihi,jlo:jhi)*meltt(ilo:ihi,jlo:jhi,iblk)/dt call accum_hist_field(n_sidmassmelttop, iblk, worka, a2D) endif if (f_sidmassmeltbot(1:1) /= 'x') then - worka(:,:) = -rho_ice(:,:)*meltb(:,:,iblk)/dt + worka(ilo:ihi,jlo:jhi) = -rho_ice(ilo:ihi,jlo:jhi)*meltb(ilo:ihi,jlo:jhi,iblk)/dt call accum_hist_field(n_sidmassmeltbot, iblk, worka, a2D) endif if (f_sidmassmeltlat(1:1) /= 'x') then - worka(:,:) = -rho_ice(:,:)*meltl(:,:,iblk)/dt + worka(ilo:ihi,jlo:jhi) = -rho_ice(ilo:ihi,jlo:jhi)*meltl(ilo:ihi,jlo:jhi,iblk)/dt call accum_hist_field(n_sidmassmeltlat, iblk, worka, a2D) endif @@ -3018,7 +3018,7 @@ subroutine accum_hist (dt) endif if (f_sisndmassmelt(1:1) /= 'x') then - worka(:,:) = -melts(:,:,iblk)*rhos/dt + worka(ilo:ihi,jlo:jhi) = -melts(ilo:ihi,jlo:jhi,iblk)*rhos/dt call accum_hist_field(n_sisndmassmelt, iblk, worka, a2D) endif @@ -3047,7 +3047,7 @@ subroutine accum_hist (dt) endif if (f_siflsenstop(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk)*fsens(i,j,iblk) @@ -3073,13 +3073,13 @@ subroutine accum_hist (dt) endif if (f_sipr(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 if (tr_pond_topo) worka(:,:) = aice_init(:,:,iblk)*frain(:,:,iblk) call accum_hist_field(n_sipr, iblk, worka(:,:), a2D) endif if (f_sifb(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) then @@ -3092,7 +3092,7 @@ subroutine accum_hist (dt) endif if (f_siflsaltbot(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) then @@ -3122,7 +3122,7 @@ subroutine accum_hist (dt) endif if (f_siflfwbot(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) then @@ -3142,7 +3142,7 @@ subroutine accum_hist (dt) endif if (f_siflfwdrain(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk)*(melts(i,j,iblk)+meltt(i,j,iblk)) @@ -3168,7 +3168,7 @@ subroutine accum_hist (dt) endif if (f_siforcecoriolx(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk)*fmU(i,j,iblk)*vvel(i,j,iblk) @@ -3178,7 +3178,7 @@ subroutine accum_hist (dt) endif if (f_siforcecorioly(1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = -aice(i,j,iblk)*fmU(i,j,iblk)*uvel(i,j,iblk) @@ -3327,7 +3327,7 @@ subroutine accum_hist (dt) if (f_fmeltt_ai(1:1) /= 'x') then do ns = 1, nstreams if (n_fmeltt_ai(ns) /= 0) then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (tmask(i,j,iblk)) then diff --git a/cicecore/cicedyn/analysis/ice_history_bgc.F90 b/cicecore/cicedyn/analysis/ice_history_bgc.F90 index 8c4586353..be92e9590 100644 --- a/cicecore/cicedyn/analysis/ice_history_bgc.F90 +++ b/cicecore/cicedyn/analysis/ice_history_bgc.F90 @@ -1994,9 +1994,9 @@ subroutine accum_hist_bgc (iblk) endif if (f_iso(1:1) /= 'x') then do n=1,n_iso - worka(:,:) = trcr(:,:,nt_isosno+n-1,iblk)/rhos + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_isosno+n-1,iblk)/rhos call accum_hist_field(n_isosno(n,:), iblk, worka, a2D) - worka(:,:) = trcr(:,:,nt_isoice+n-1,iblk)/rhos + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_isoice+n-1,iblk)/rhos call accum_hist_field(n_isoice(n,:), iblk, worka, a2D) enddo endif @@ -2016,13 +2016,13 @@ subroutine accum_hist_bgc (iblk) endif if (f_aero(1:1) /= 'x') then do n=1,n_aero - worka(:,:) = trcr(:,:,nt_aero +4*(n-1),iblk)/rhos + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero +4*(n-1),iblk)/rhos call accum_hist_field(n_aerosn1(n,:), iblk, worka, a2D) - worka(:,:) = trcr(:,:,nt_aero+1+4*(n-1),iblk)/rhos + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+1+4*(n-1),iblk)/rhos call accum_hist_field(n_aerosn2(n,:), iblk, worka, a2D) - worka(:,:) = trcr(:,:,nt_aero+2+4*(n-1),iblk)/rhoi + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+2+4*(n-1),iblk)/rhoi call accum_hist_field(n_aeroic1(n,:), iblk, worka, a2D) - worka(:,:) = trcr(:,:,nt_aero+3+4*(n-1),iblk)/rhoi + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+3+4*(n-1),iblk)/rhoi call accum_hist_field(n_aeroic2(n,:), iblk, worka, a2D) enddo endif @@ -2038,7 +2038,7 @@ subroutine accum_hist_bgc (iblk) endif if (f_bgc_C(1:1)/= 'x') then do n=1,n_algae - worka(:,:) = sk_l*R_C2N(n)*trcr(:,:,nt_bgc_N(n), iblk) + worka(ilo:ihi,jlo:jhi) = sk_l*R_C2N(n)*trcr(ilo:ihi,jlo:jhi,nt_bgc_N(n), iblk) call accum_hist_field(n_bgc_C(n,:), iblk, worka, a2D) enddo endif diff --git a/cicecore/cicedyn/analysis/ice_history_mechred.F90 b/cicecore/cicedyn/analysis/ice_history_mechred.F90 index 28930e834..57abe50e0 100644 --- a/cicecore/cicedyn/analysis/ice_history_mechred.F90 +++ b/cicecore/cicedyn/analysis/ice_history_mechred.F90 @@ -358,7 +358,8 @@ end subroutine init_hist_mechred_3Dc subroutine accum_hist_mechred (iblk) - use ice_blocks, only: nx_block, ny_block + use ice_blocks, only: block, get_block, nx_block, ny_block + use ice_domain, only: blocks_ice use ice_history_shared, only: n2D, a2D, a3Dc, ncat_hist, & accum_hist_field use ice_state, only: aice, vice, trcr, aicen, vicen, trcrn @@ -376,8 +377,23 @@ subroutine accum_hist_mechred (iblk) real (kind=dbl_kind), dimension(nx_block,ny_block) :: worka real (kind=dbl_kind), dimension(nx_block,ny_block,ncat_hist) :: workc + type (block) :: & + this_block ! block information for current block + + integer (kind=int_kind) :: & + ilo, ihi, jlo, jhi ! physical domain of this block + character(len=*), parameter :: subname = '(accum_hist_mechred)' + ! ⚠ Compute over the PHYSICAL domain only. A full-array expression + ! evaluates across the halo, where a value may be uninitialised -- + ! and the accumulators read jlo..jhi x ilo..ihi regardless. + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & @@ -397,10 +413,10 @@ subroutine accum_hist_mechred (iblk) call accum_hist_field(n_vlvl, iblk, & vice(:,:,iblk) , trcr(:,:,nt_vlvl,iblk), a2D) if (f_ardg(1:1)/= 'x') & - worka(:,:) = c1 - trcr(:,:,nt_alvl,iblk) + worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_alvl,iblk) call accum_hist_field(n_ardg, iblk, aice(:,:,iblk), worka, a2D) if (f_vrdg(1:1)/= 'x') & - worka(:,:) = c1 - trcr(:,:,nt_vlvl,iblk) + worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_vlvl,iblk) call accum_hist_field(n_vrdg, iblk, vice(:,:,iblk), worka, a2D) if (f_dardg1dt(1:1)/= 'x') & call accum_hist_field(n_dardg1dt,iblk, dardg1dt(:,:,iblk), a2D) @@ -412,11 +428,11 @@ subroutine accum_hist_mechred (iblk) call accum_hist_field(n_opening, iblk, opening(:,:,iblk), a2D) if (f_sirdgconc(1:1)/= 'x') & - worka(:,:) = c1 - trcr(:,:,nt_alvl,iblk) + worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_alvl,iblk) call accum_hist_field(n_sirdgconc, iblk, aice(:,:,iblk), worka, a2D) if (f_sirdgthick(1:1)/= 'x') then - worka(:,:) = c1 - trcr(:,:,nt_vlvl,iblk) + worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_vlvl,iblk) call accum_hist_field(n_sirdgthick, iblk, vice(:,:,iblk), worka, a2D) endif diff --git a/cicecore/cicedyn/analysis/ice_history_pond.F90 b/cicecore/cicedyn/analysis/ice_history_pond.F90 index 25a578b2f..19927353c 100644 --- a/cicecore/cicedyn/analysis/ice_history_pond.F90 +++ b/cicecore/cicedyn/analysis/ice_history_pond.F90 @@ -509,11 +509,19 @@ subroutine accum_hist_pond (iblk) if (allocated(a2D)) then - worka(:,:) = c0 + ! ⚠ Bounds BEFORE first use: the work arrays below are scoped to the + ! physical domain, so these must be set first. + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + + worka(ilo:ihi,jlo:jhi) = c0 if (tr_pond_lvl) then - worka(:,:) = trcr(:,:,nt_alvl,iblk) * trcr(:,:,nt_apnd,iblk) + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_alvl,iblk) * trcr(ilo:ihi,jlo:jhi,nt_apnd,iblk) elseif (tr_pond_sealvl .or. tr_pond_topo) then - worka(:,:) = trcr(:,:,nt_apnd,iblk) + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_apnd,iblk) endif if (f_apond(1:1)/= 'x') & @@ -523,13 +531,13 @@ subroutine accum_hist_pond (iblk) if (f_hpond(1:1)/= 'x') & call accum_hist_field(n_hpond, iblk, worka(:,:),trcr(:,:,nt_hpnd,iblk), a2D) if (f_hpond_ai(1:1)/= 'x') then - workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_hpnd,iblk) + workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_hpnd,iblk) call accum_hist_field(n_hpond_ai, iblk, workb, a2D) endif if (f_ipond(1:1)/= 'x') & call accum_hist_field(n_ipond, iblk, worka(:,:),trcr(:,:,nt_ipnd,iblk), a2D) if (f_ipond_ai(1:1)/= 'x') then - workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_ipnd,iblk) + workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_ipnd,iblk) call accum_hist_field(n_ipond_ai, iblk, workb, a2D) endif @@ -541,23 +549,18 @@ subroutine accum_hist_pond (iblk) call accum_hist_field(n_simpconc, iblk, worka(:,:), a2D) if (f_simpthick(1:1)/= 'x') then - workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_hpnd,iblk) + workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_hpnd,iblk) call accum_hist_field(n_simpthick, iblk, workb, a2D) endif if (f_simprefrozen(1:1)/= 'x') then - workb(:,:) = aice_init(:,:,iblk)*worka(:,:)*trcr(:,:,nt_ipnd,iblk) + workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_ipnd,iblk) call accum_hist_field(n_simprefrozen, iblk, workb, a2D) endif - this_block = get_block(blocks_ice(iblk),iblk) - ilo = this_block%ilo - ihi = this_block%ihi - jlo = this_block%jlo - jhi = this_block%jhi if (f_apeff (1:1) /= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) worka(i,j) = apeff_ai(i,j,iblk) & diff --git a/cicecore/cicedyn/analysis/ice_history_snow.F90 b/cicecore/cicedyn/analysis/ice_history_snow.F90 index bb702defa..e8a73cf17 100644 --- a/cicecore/cicedyn/analysis/ice_history_snow.F90 +++ b/cicecore/cicedyn/analysis/ice_history_snow.F90 @@ -298,7 +298,8 @@ end subroutine init_hist_snow_3Dc subroutine accum_hist_snow (iblk) use ice_arrays_column, only: meltsliq - use ice_blocks, only: block, nx_block, ny_block + use ice_blocks, only: block, get_block, nx_block, ny_block + use ice_domain, only: blocks_ice use ice_flux, only: fsloss use ice_history_shared, only: n2D, a2D, a3Dc, ncat_hist, & accum_hist_field, nzslyr @@ -323,8 +324,23 @@ subroutine accum_hist_snow (iblk) real (kind=dbl_kind), dimension (nx_block,ny_block,ncat_hist) :: & workb + type (block) :: & + this_block ! block information for current block + + integer (kind=int_kind) :: & + ilo, ihi, jlo, jhi ! physical domain of this block + character(len=*), parameter :: subname = '(accum_hist_snow)' + ! ⚠ Compute over the PHYSICAL domain only. A full-array expression + ! evaluates across the halo, where a value may be uninitialised -- + ! and the accumulators read jlo..jhi x ilo..ihi regardless. + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + !--------------------------------------------------------------- ! increment field !--------------------------------------------------------------- @@ -340,49 +356,49 @@ subroutine accum_hist_snow (iblk) if (tr_snow) then if (f_smassice(1:1)/= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do k = 1, nzslyr - worka(:,:) = worka(:,:) & - + trcr(:,:,nt_smice+k-1,iblk) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + + trcr(ilo:ihi,jlo:jhi,nt_smice+k-1,iblk) enddo - worka(:,:) = worka(:,:) * vsno(:,:,iblk) / real(nslyr,kind=dbl_kind) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) * vsno(ilo:ihi,jlo:jhi,iblk) / real(nslyr,kind=dbl_kind) call accum_hist_field(n_smassice, iblk, worka, a2D) endif if (f_smassliq(1:1)/= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do k = 1, nzslyr - worka(:,:) = worka(:,:) & - + trcr(:,:,nt_smliq+k-1,iblk) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + + trcr(ilo:ihi,jlo:jhi,nt_smliq+k-1,iblk) enddo - worka(:,:) = worka(:,:) * vsno(:,:,iblk) / real(nslyr,kind=dbl_kind) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) * vsno(ilo:ihi,jlo:jhi,iblk) / real(nslyr,kind=dbl_kind) call accum_hist_field(n_smassliq, iblk, worka, a2D) endif if (f_rhos_cmp(1:1)/= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do k = 1, nzslyr - worka(:,:) = worka(:,:) & - + trcr(:,:,nt_rhos+k-1,iblk) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + + trcr(ilo:ihi,jlo:jhi,nt_rhos+k-1,iblk) enddo - worka(:,:) = worka(:,:) / real(nslyr,kind=dbl_kind) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) / real(nslyr,kind=dbl_kind) call accum_hist_field(n_rhos_cmp, iblk, worka, a2D) endif if (f_rhos_cnt(1:1)/= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do k = 1, nzslyr - worka(:,:) = worka(:,:) & - + trcr(:,:,nt_smice+k-1,iblk) & - + trcr(:,:,nt_smliq+k-1,iblk) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + + trcr(ilo:ihi,jlo:jhi,nt_smice+k-1,iblk) & + + trcr(ilo:ihi,jlo:jhi,nt_smliq+k-1,iblk) enddo - worka(:,:) = worka(:,:) / real(nslyr,kind=dbl_kind) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) / real(nslyr,kind=dbl_kind) call accum_hist_field(n_rhos_cnt, iblk, worka, a2D) endif if (f_rsnw(1:1)/= 'x') then - worka(:,:) = c0 + worka(ilo:ihi,jlo:jhi) = c0 do k = 1, nzslyr - worka(:,:) = worka(:,:) & - + trcr(:,:,nt_rsnw+k-1,iblk) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + + trcr(ilo:ihi,jlo:jhi,nt_rsnw+k-1,iblk) enddo - worka(:,:) = worka(:,:) / real(nslyr,kind=dbl_kind) + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) / real(nslyr,kind=dbl_kind) call accum_hist_field(n_rsnw, iblk, worka, a2D) endif if (f_meltsliq(1:1)/= 'x') & From 8c51f3ef74394d7c13d2b8e511ecb7f00bb1aa6c Mon Sep 17 00:00:00 2001 From: Till Rasmussen <> Date: Wed, 18 Nov 2026 02:10:34 +0100 Subject: [PATCH 5/6] history: one routine for speed, an optional mask, and defined work arrays Five fields computed sqrt(a*a + b*b) inline over the physical domain, each with its own loop. accum_hist_field_2D_speed takes the two components and does it once; icespd, icespdN, icespdE, atmspd and ocnspd now call it. It is public by name rather than through the generic interface: its signature is indistinguishable from the _prod accumulator, which takes two fields and multiplies them. All six 2D accumulators gain an optional mask. Absent, they fall back to tmask exactly as before, so every existing call is unchanged; the predicate is hoisted out of the i loop. The work arrays were left undefined outside the physical domain, holding whatever the previous field had put there. They are now zeroed once per block, after the bounds are taken and before first use. The zero is a constant store over the whole array; the computations stay scoped to ilo:ihi, jlo:jhi, because a full-array expression would evaluate across the halo where an operand may be uninitialised -- with -finit-real=snan that is a trap on a result nobody wanted. That is the rule the previous commit established and this one keeps. Zeroing once per block rather than per use costs one pass instead of thirteen, and the branch in accum_hist_pond that could leave worka unset carries the zero in its else arm instead. workc needed nothing: every assignment already spans its full extent. Verified against upstream d92f18a on gx3, history output identical in every configuration tried: histall, fsdww, hist3d, bgc, restore5 and evpCD, and a 309-field all-tracer case covering ice_history_snow, _fsd and _pond together. --- cicecore/cicedyn/analysis/ice_history.F90 | 65 ++++---- .../cicedyn/analysis/ice_history_pond.F90 | 5 +- .../cicedyn/analysis/ice_history_shared.F90 | 152 ++++++++++++++++-- .../cicedyn/analysis/ice_history_snow.F90 | 10 +- 4 files changed, 184 insertions(+), 48 deletions(-) diff --git a/cicecore/cicedyn/analysis/ice_history.F90 b/cicecore/cicedyn/analysis/ice_history.F90 index 00fceaf13..8efaa2153 100644 --- a/cicecore/cicedyn/analysis/ice_history.F90 +++ b/cicecore/cicedyn/analysis/ice_history.F90 @@ -2388,6 +2388,9 @@ subroutine accum_hist (dt) jlo = this_block%jlo jhi = this_block%jhi + worka(:,:) = c0 + workb(:,:) = c0 + if (allocated(a2D)) then workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk) @@ -2411,11 +2414,11 @@ subroutine accum_hist (dt) if (f_vvel (1:1) /= 'x') & call accum_hist_field(n_vvel, iblk, vvel(:,:,iblk), a2D) if (f_icespd (1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = sqrt( (uvel(ilo:ihi,jlo:jhi,iblk)*uvel(ilo:ihi,jlo:jhi,iblk)) + (vvel(ilo:ihi,jlo:jhi,iblk)*vvel(ilo:ihi,jlo:jhi,iblk))) - call accum_hist_field(n_icespd, iblk, worka, a2D) + call accum_hist_field_2D_speed(n_icespd, iblk, & + uvel(:,:,iblk), vvel(:,:,iblk), a2D) endif if (f_icedir(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uvel(i,j,iblk)) > puny .or. abs(vvel(i,j,iblk)) > puny) & @@ -2430,11 +2433,11 @@ subroutine accum_hist (dt) if (f_vvelN (1:1) /= 'x') & call accum_hist_field(n_vvelN, iblk, vvelN(:,:,iblk), a2D) if (f_icespdN (1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = sqrt( (uvelN(ilo:ihi,jlo:jhi,iblk)*uvelN(ilo:ihi,jlo:jhi,iblk)) + (vvelN(ilo:ihi,jlo:jhi,iblk)*vvelN(ilo:ihi,jlo:jhi,iblk))) - call accum_hist_field(n_icespdN, iblk, worka, a2D) + call accum_hist_field_2D_speed(n_icespdN, iblk, & + uvelN(:,:,iblk), vvelN(:,:,iblk), a2D) endif if (f_icedirN(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uvelN(i,j,iblk)) > puny .or. abs(vvelN(i,j,iblk)) > puny) & @@ -2449,11 +2452,11 @@ subroutine accum_hist (dt) if (f_vvelE (1:1) /= 'x') & call accum_hist_field(n_vvelE, iblk, vvelE(:,:,iblk), a2D) if (f_icespdE (1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = sqrt( (uvelE(ilo:ihi,jlo:jhi,iblk)*uvelE(ilo:ihi,jlo:jhi,iblk)) + (vvelE(ilo:ihi,jlo:jhi,iblk)*vvelE(ilo:ihi,jlo:jhi,iblk))) - call accum_hist_field(n_icespdE, iblk, worka, a2D) + call accum_hist_field_2D_speed(n_icespdE, iblk, & + uvelE(:,:,iblk), vvelE(:,:,iblk), a2D) endif if (f_icedirE(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uvelE(i,j,iblk)) > puny .or. abs(vvelE(i,j,iblk)) > puny) & @@ -2468,11 +2471,11 @@ subroutine accum_hist (dt) if (f_vatm (1:1) /= 'x') & call accum_hist_field(n_vatm, iblk, vatm(:,:,iblk), a2D) if (f_atmspd (1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = sqrt( (uatm(ilo:ihi,jlo:jhi,iblk)*uatm(ilo:ihi,jlo:jhi,iblk)) + (vatm(ilo:ihi,jlo:jhi,iblk)*vatm(ilo:ihi,jlo:jhi,iblk))) - call accum_hist_field(n_atmspd, iblk, worka, a2D) + call accum_hist_field_2D_speed(n_atmspd, iblk, & + uatm(:,:,iblk), vatm(:,:,iblk), a2D) endif if (f_atmdir(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uatm(i,j,iblk)) > puny .or. abs(vatm(i,j,iblk)) > puny) & @@ -2519,11 +2522,11 @@ subroutine accum_hist (dt) if (f_vocn (1:1) /= 'x') & call accum_hist_field(n_vocn, iblk, vocn(:,:,iblk), a2D) if (f_ocnspd (1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = sqrt( (uocn(ilo:ihi,jlo:jhi,iblk)*uocn(ilo:ihi,jlo:jhi,iblk)) + (vocn(ilo:ihi,jlo:jhi,iblk)*vocn(ilo:ihi,jlo:jhi,iblk))) - call accum_hist_field(n_ocnspd, iblk, worka, a2D) + call accum_hist_field_2D_speed(n_ocnspd, iblk, & + uocn(:,:,iblk), vocn(:,:,iblk), a2D) endif if (f_ocndir(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (abs(uocn(i,j,iblk)) > puny .or. abs(vocn(i,j,iblk)) > puny) & @@ -2763,7 +2766,7 @@ subroutine accum_hist (dt) fcondtop(:,:,iblk),aice(:,:,iblk), a2D) if (f_icepresent(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) worka(i,j) = c1 @@ -2775,7 +2778,7 @@ subroutine accum_hist (dt) ! 2D CMIP fields if (f_sitimefrac(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) worka(i,j) = c1 @@ -2860,7 +2863,7 @@ subroutine accum_hist (dt) endif if (f_sispeed(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk) & @@ -2887,7 +2890,7 @@ subroutine accum_hist (dt) ! endif if (f_sidmasstranx(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = (rho_ice(i,j)*p5*(vice(i+1,j,iblk)+vice(i,j,iblk))*dyU(i,j,iblk) & @@ -2899,7 +2902,7 @@ subroutine accum_hist (dt) endif if (f_sidmasstrany(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = (rho_ice(i,j)*p5*(vice(i,j+1,iblk)+vice(i,j,iblk))*dxU(i,j,iblk) & @@ -2931,7 +2934,7 @@ subroutine accum_hist (dt) endif if (f_sihc(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do k = 1,nzilyr do j = jlo, jhi do i = ilo, ihi @@ -2943,7 +2946,7 @@ subroutine accum_hist (dt) endif if (f_sisnhc(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do k = 1,nzslyr do j = jlo, jhi do i = ilo, ihi @@ -3047,7 +3050,7 @@ subroutine accum_hist (dt) endif if (f_siflsenstop(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk)*fsens(i,j,iblk) @@ -3073,13 +3076,13 @@ subroutine accum_hist (dt) endif if (f_sipr(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 if (tr_pond_topo) worka(:,:) = aice_init(:,:,iblk)*frain(:,:,iblk) call accum_hist_field(n_sipr, iblk, worka(:,:), a2D) endif if (f_sifb(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) then @@ -3092,7 +3095,7 @@ subroutine accum_hist (dt) endif if (f_siflsaltbot(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) then @@ -3122,7 +3125,7 @@ subroutine accum_hist (dt) endif if (f_siflfwbot(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) then @@ -3142,7 +3145,7 @@ subroutine accum_hist (dt) endif if (f_siflfwdrain(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk)*(melts(i,j,iblk)+meltt(i,j,iblk)) @@ -3168,7 +3171,7 @@ subroutine accum_hist (dt) endif if (f_siforcecoriolx(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk)*fmU(i,j,iblk)*vvel(i,j,iblk) @@ -3178,7 +3181,7 @@ subroutine accum_hist (dt) endif if (f_siforcecorioly(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = -aice(i,j,iblk)*fmU(i,j,iblk)*uvel(i,j,iblk) @@ -3327,7 +3330,7 @@ subroutine accum_hist (dt) if (f_fmeltt_ai(1:1) /= 'x') then do ns = 1, nstreams if (n_fmeltt_ai(ns) /= 0) then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (tmask(i,j,iblk)) then diff --git a/cicecore/cicedyn/analysis/ice_history_pond.F90 b/cicecore/cicedyn/analysis/ice_history_pond.F90 index 19927353c..85a8a19ff 100644 --- a/cicecore/cicedyn/analysis/ice_history_pond.F90 +++ b/cicecore/cicedyn/analysis/ice_history_pond.F90 @@ -517,7 +517,8 @@ subroutine accum_hist_pond (iblk) jlo = this_block%jlo jhi = this_block%jhi - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 + workb(:,:) = c0 if (tr_pond_lvl) then worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_alvl,iblk) * trcr(ilo:ihi,jlo:jhi,nt_apnd,iblk) elseif (tr_pond_sealvl .or. tr_pond_topo) then @@ -560,7 +561,7 @@ subroutine accum_hist_pond (iblk) if (f_apeff (1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi if (aice(i,j,iblk) > puny) worka(i,j) = apeff_ai(i,j,iblk) & diff --git a/cicecore/cicedyn/analysis/ice_history_shared.F90 b/cicecore/cicedyn/analysis/ice_history_shared.F90 index edc4d87d2..c337ac28c 100644 --- a/cicecore/cicedyn/analysis/ice_history_shared.F90 +++ b/cicecore/cicedyn/analysis/ice_history_shared.F90 @@ -35,6 +35,9 @@ module ice_history_shared private public :: define_hist_field, accum_hist_field, icefields_nml, construct_filename, ice_brine_density + ! ⚠ by name, not through the generic interface: its argument list is the + ! same shape as accum_hist_field_2D_prod's and the two cannot be resolved apart + public :: accum_hist_field_2D_speed integer (kind=int_kind), public :: history_precision @@ -1061,7 +1064,7 @@ end subroutine define_hist_field ! 2009 Created by D. Bailey following POP ! 2010 Generalized dimension of variables by N. Jeffery, E. Hunke - subroutine accum_hist_field_2D(id, iblk, field_accum, field) + subroutine accum_hist_field_2D(id, iblk, field_accum, field, mask) use ice_blocks, only: block, get_block use ice_calendar, only: nstreams @@ -1085,6 +1088,13 @@ subroutine accum_hist_field_2D(id, iblk, field_accum, field) integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns + logical (kind=log_kind) :: wet + + ! Where to accumulate. Absent means tmask, which is what every caller + ! wanted before this argument existed. + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) + character(len=*), parameter :: subname = '(accum_hist_field_2D)' !--------------------------------------------------------------- @@ -1103,7 +1113,12 @@ subroutine accum_hist_field_2D(id, iblk, field_accum, field) do j = jlo, jhi do i = ilo, ihi - if (tmask(i,j,iblk)) then + if (present(mask)) then + wet = mask(i,j) + else + wet = tmask(i,j,iblk) + endif + if (wet) then field(i,j,idns, iblk) = field(i,j,idns, iblk) + field_accum(i,j) endif enddo @@ -1133,7 +1148,7 @@ end subroutine accum_hist_field_2D ! Taking the two factors instead costs one extra argument and removes the ! temporary, the fill loop and the wasted ghost-region arithmetic. - subroutine accum_hist_field_2D_prod(id, iblk, a, b, field) + subroutine accum_hist_field_2D_prod(id, iblk, a, b, field, mask) use ice_blocks, only: block, get_block use ice_calendar, only: nstreams @@ -1156,6 +1171,13 @@ subroutine accum_hist_field_2D_prod(id, iblk, a, b, field) integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns + logical (kind=log_kind) :: wet + + ! Where to accumulate. Absent means tmask, which is what every caller + ! wanted before this argument existed. + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) + character(len=*), parameter :: subname = '(accum_hist_field_2D_prod)' do ns = 1, nstreams @@ -1170,7 +1192,12 @@ subroutine accum_hist_field_2D_prod(id, iblk, a, b, field) do j = jlo, jhi do i = ilo, ihi - if (tmask(i,j,iblk)) then + if (present(mask)) then + wet = mask(i,j) + else + wet = tmask(i,j,iblk) + endif + if (wet) then field(i,j,idns, iblk) = field(i,j,idns, iblk) + a(i,j)*b(i,j) endif enddo @@ -1189,7 +1216,76 @@ end subroutine accum_hist_field_2D_prod ! left swaps its two actuals, which is bit-for-bit because floating ! multiplication is commutative and exactly rounded. - subroutine accum_hist_field_2D_mul(id, iblk, a, s, field) + subroutine accum_hist_field_2D_speed(id, iblk, a, b, field, mask) + + ! sqrt(a*a + b*b), accumulated without building it first. + ! + ! ⚠ NOT in the generic interface: the argument list is the same shape as + ! accum_hist_field_2D_prod's, so the two cannot be resolved apart. Call + ! it by name. + + use ice_blocks, only: block, get_block + use ice_calendar, only: nstreams + use ice_domain, only: blocks_ice + use ice_grid, only: tmask + + integer (int_kind), dimension(:), intent(in) :: & ! max_nstrm + id ! location in avail_fields array + + integer (kind=int_kind), intent(in) :: iblk + + real (kind=dbl_kind), intent(in) :: & + a(:,:), b(:,:) ! the two components, block shaped + + real (kind=dbl_kind), intent(inout) :: & + field(:,:,:,:) + + ! Where to accumulate. Absent means tmask, which is what every caller + ! wanted before this argument existed. + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) + + type (block) :: & + this_block ! block information for current block + + integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns + + logical (kind=log_kind) :: wet + + character(len=*), parameter :: subname = '(accum_hist_field_2D_speed)' + + do ns = 1, nstreams + idns = id(ns) + if (idns > 0) then + + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + + do j = jlo, jhi + do i = ilo, ihi + if (present(mask)) then + wet = mask(i,j) + else + wet = tmask(i,j,iblk) + endif + if (wet) then + field(i,j,idns, iblk) = field(i,j,idns, iblk) + & + sqrt((a(i,j)*a(i,j)) + (b(i,j)*b(i,j))) + endif + enddo + enddo + + endif + enddo + + end subroutine accum_hist_field_2D_speed + +!======================================================================= + + subroutine accum_hist_field_2D_mul(id, iblk, a, s, field, mask) use ice_blocks, only: block, get_block use ice_calendar, only: nstreams @@ -1215,6 +1311,13 @@ subroutine accum_hist_field_2D_mul(id, iblk, a, s, field) integer (kind=int_kind) :: i,j, ilo, ihi, jlo, jhi, ns, idns + logical (kind=log_kind) :: wet + + ! Where to accumulate. Absent means tmask, which is what every caller + ! wanted before this argument existed. + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) + character(len=*), parameter :: subname = '(accum_hist_field_2D_mul)' do ns = 1, nstreams @@ -1229,7 +1332,12 @@ subroutine accum_hist_field_2D_mul(id, iblk, a, s, field) do j = jlo, jhi do i = ilo, ihi - if (tmask(i,j,iblk)) then + if (present(mask)) then + wet = mask(i,j) + else + wet = tmask(i,j,iblk) + endif + if (wet) then field(i,j,idns, iblk) = field(i,j,idns, iblk) + a(i,j)*s endif enddo @@ -1242,7 +1350,7 @@ end subroutine accum_hist_field_2D_mul !======================================================================= - subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field) + subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field, mask) use ice_blocks, only: block, get_block use ice_calendar, only: nstreams @@ -1269,6 +1377,13 @@ subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field) integer (kind=int_kind) :: i,j,k, ilo, ihi, jlo, jhi, ns, idns + logical (kind=log_kind) :: wet + + ! Where to accumulate. Absent means tmask, which is what every caller + ! wanted before this argument existed. + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) + character(len=*), parameter :: subname = '(accum_hist_field_3D)' !--------------------------------------------------------------- @@ -1288,7 +1403,12 @@ subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field) do k = 1, ndim do j = jlo, jhi do i = ilo, ihi - if (tmask(i,j,iblk)) then + if (present(mask)) then + wet = mask(i,j) + else + wet = tmask(i,j,iblk) + endif + if (wet) then field(i,j,k,idns,iblk) = field(i,j,k,idns,iblk) + field_accum(i,j,k) endif enddo @@ -1307,7 +1427,7 @@ end subroutine accum_hist_field_3D ! 2009 Created by D. Bailey following POP ! 2010 Generalized dimension of variables by N. Jeffery, E. Hunke - subroutine accum_hist_field_4D(id, iblk, ndim3, ndim4, field_accum, field) + subroutine accum_hist_field_4D(id, iblk, ndim3, ndim4, field_accum, field, mask) use ice_blocks, only: block, get_block use ice_calendar, only: nstreams @@ -1335,6 +1455,13 @@ subroutine accum_hist_field_4D(id, iblk, ndim3, ndim4, field_accum, field) integer (kind=int_kind) :: i,j,k,n,ilo, ihi, jlo, jhi, ns, idns + logical (kind=log_kind) :: wet + + ! Where to accumulate. Absent means tmask, which is what every caller + ! wanted before this argument existed. + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) + character(len=*), parameter :: subname = '(accum_hist_field_4D)' !--------------------------------------------------------------- @@ -1355,7 +1482,12 @@ subroutine accum_hist_field_4D(id, iblk, ndim3, ndim4, field_accum, field) do n = 1, ndim3 do j = jlo, jhi do i = ilo, ihi - if (tmask(i,j,iblk)) then + if (present(mask)) then + wet = mask(i,j) + else + wet = tmask(i,j,iblk) + endif + if (wet) then field(i,j,n,k,idns,iblk) = field(i,j,n,k,idns,iblk) + field_accum(i,j,n,k) endif enddo diff --git a/cicecore/cicedyn/analysis/ice_history_snow.F90 b/cicecore/cicedyn/analysis/ice_history_snow.F90 index e8a73cf17..a2937f8e3 100644 --- a/cicecore/cicedyn/analysis/ice_history_snow.F90 +++ b/cicecore/cicedyn/analysis/ice_history_snow.F90 @@ -356,7 +356,7 @@ subroutine accum_hist_snow (iblk) if (tr_snow) then if (f_smassice(1:1)/= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do k = 1, nzslyr worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_smice+k-1,iblk) @@ -365,7 +365,7 @@ subroutine accum_hist_snow (iblk) call accum_hist_field(n_smassice, iblk, worka, a2D) endif if (f_smassliq(1:1)/= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do k = 1, nzslyr worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_smliq+k-1,iblk) @@ -374,7 +374,7 @@ subroutine accum_hist_snow (iblk) call accum_hist_field(n_smassliq, iblk, worka, a2D) endif if (f_rhos_cmp(1:1)/= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do k = 1, nzslyr worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_rhos+k-1,iblk) @@ -383,7 +383,7 @@ subroutine accum_hist_snow (iblk) call accum_hist_field(n_rhos_cmp, iblk, worka, a2D) endif if (f_rhos_cnt(1:1)/= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do k = 1, nzslyr worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_smice+k-1,iblk) & @@ -393,7 +393,7 @@ subroutine accum_hist_snow (iblk) call accum_hist_field(n_rhos_cnt, iblk, worka, a2D) endif if (f_rsnw(1:1)/= 'x') then - worka(ilo:ihi,jlo:jhi) = c0 + worka(:,:) = c0 do k = 1, nzslyr worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_rsnw+k-1,iblk) From bb57194c0c88cd797a692d12e26f9a9b4ab5cbb9 Mon Sep 17 00:00:00 2001 From: Till Rasmussen <> Date: Thu, 19 Nov 2026 14:48:24 +0100 Subject: [PATCH 6/6] history: align the accumulator calls, zero the work arrays first Pad the field and index names in the accum_hist_field calls so the commas line up, and join the two-line calls that no longer need to wrap. Where a single call sat under if (...) then / endif, it becomes the one-statement if (...) & form. The work arrays are now zeroed over the whole block before use and computed over the physical domain only, which is the convention settled with upstream: worka(:,:) = c0 first, then worka(ilo:ihi,jlo:jhi) = ... The zeroing moves ahead of the loop rather than sitting inside it. accum_hist_fsd had no block geometry at all -- it looped over nx_block and ny_block -- so it gains the ilo/ihi/jlo/jhi bounds, the this_block lookup and the imports they need, placed before first use. Four defects found while building it: - five j loops in ice_history_fsd bounded by ihi rather than jhi - one i loop bounded by a truncated 'ih' - ilo/ihi/jlo/jhi used in accum_hist_fsd without being declared - two endifs left behind where if/then/endif became the one-statement form, after f_sivol and f_sisnthick. Each silently closed the outer if (allocated(a2D)) block, so the compiler reported the error several hundred lines later at an unrelated endif. Bit-for-bit against upstream d92f18a on gfortran and ifx: histall, fsdww, hist3d, bgc, restore5, evpCD and a 309-field all-tracer case covering ice_history_snow, _fsd and _pond. --- cicecore/cicedyn/analysis/ice_history.F90 | 949 ++++++++---------- cicecore/cicedyn/analysis/ice_history_bgc.F90 | 755 ++++++-------- .../cicedyn/analysis/ice_history_drag.F90 | 42 +- cicecore/cicedyn/analysis/ice_history_fsd.F90 | 112 ++- .../cicedyn/analysis/ice_history_mechred.F90 | 67 +- .../cicedyn/analysis/ice_history_pond.F90 | 62 +- .../cicedyn/analysis/ice_history_shared.F90 | 65 +- .../cicedyn/analysis/ice_history_snow.F90 | 23 +- 8 files changed, 911 insertions(+), 1164 deletions(-) diff --git a/cicecore/cicedyn/analysis/ice_history.F90 b/cicecore/cicedyn/analysis/ice_history.F90 index 8efaa2153..3676258f9 100644 --- a/cicecore/cicedyn/analysis/ice_history.F90 +++ b/cicecore/cicedyn/analysis/ice_history.F90 @@ -2397,134 +2397,130 @@ subroutine accum_hist (dt) ! if (f_example(1:1) /= 'x') & ! call accum_hist_field(n_example,iblk, vice(:,:,iblk), a2D) - if (f_hi (1:1) /= 'x') & - call accum_hist_field(n_hi, iblk, vice(:,:,iblk), a2D) - if (f_hs (1:1) /= 'x') & - call accum_hist_field(n_hs, iblk, vsno(:,:,iblk), a2D) - if (f_snowfrac(1:1) /= 'x') & - call accum_hist_field(n_snowfrac, iblk, snowfrac(:,:,iblk), a2D) - if (f_Tsfc (1:1) /= 'x') & - call accum_hist_field(n_Tsfc, iblk, trcr(:,:,nt_Tsfc,iblk), a2D) - if (f_aice (1:1) /= 'x') & - call accum_hist_field(n_aice, iblk, aice(:,:,iblk), a2D) - if (f_aice_init (1:1) /= 'x') & - call accum_hist_field(n_aice_init, iblk, aice_init(:,:,iblk), a2D) - if (f_uvel (1:1) /= 'x') & - call accum_hist_field(n_uvel, iblk, uvel(:,:,iblk), a2D) - if (f_vvel (1:1) /= 'x') & - call accum_hist_field(n_vvel, iblk, vvel(:,:,iblk), a2D) - if (f_icespd (1:1) /= 'x') then - call accum_hist_field_2D_speed(n_icespd, iblk, & - uvel(:,:,iblk), vvel(:,:,iblk), a2D) - endif + if (f_hi (1:1) /= 'x') & + call accum_hist_field(n_hi , iblk, vice (:,:,iblk) , a2D) + if (f_hs (1:1) /= 'x') & + call accum_hist_field(n_hs , iblk, vsno (:,:,iblk) , a2D) + if (f_snowfrac (1:1) /= 'x') & + call accum_hist_field(n_snowfrac , iblk, snowfrac (:,:,iblk) , a2D) + if (f_Tsfc (1:1) /= 'x') & + call accum_hist_field(n_Tsfc , iblk, trcr (:,:,nt_Tsfc,iblk), a2D) + if (f_aice (1:1) /= 'x') & + call accum_hist_field(n_aice , iblk, aice (:,:,iblk) , a2D) + if (f_aice_init(1:1) /= 'x') & + call accum_hist_field(n_aice_init, iblk, aice_init(:,:,iblk) , a2D) + if (f_uvel (1:1) /= 'x') & + call accum_hist_field(n_uvel , iblk, uvel (:,:,iblk) , a2D) + if (f_vvel (1:1) /= 'x') & + call accum_hist_field(n_vvel , iblk, vvel (:,:,iblk) , a2D) + + if (f_icespd (1:1) /= 'x') & + call accum_hist_field_2D_speed(n_icespd, iblk, uvel(:,:,iblk), vvel(:,:,iblk), a2D) + if (f_icedir(1:1) /= 'x') then - worka(:,:) = c0 - do j = jlo, jhi - do i = ilo, ihi - if (abs(uvel(i,j,iblk)) > puny .or. abs(vvel(i,j,iblk)) > puny) & - worka(i,j) = atan2(uvel(i,j,iblk),vvel(i,j,iblk))*rad_to_deg - worka(i,j) = worka(i,j) + c180 - enddo - enddo - call accum_hist_field(n_icedir, iblk, worka(:,:), a2D) + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + if (abs(uvel(i,j,iblk)) > puny .or. abs(vvel(i,j,iblk)) > puny) & + worka(i,j) = atan2(uvel(i,j,iblk),vvel(i,j,iblk))*rad_to_deg + worka(i,j) = worka(i,j) + c180 + enddo + enddo + call accum_hist_field(n_icedir, iblk, worka(:,:) , a2D) endif if (f_uvelN (1:1) /= 'x') & - call accum_hist_field(n_uvelN, iblk, uvelN(:,:,iblk), a2D) + call accum_hist_field(n_uvelN , iblk, uvelN(:,:,iblk), a2D) if (f_vvelN (1:1) /= 'x') & - call accum_hist_field(n_vvelN, iblk, vvelN(:,:,iblk), a2D) - if (f_icespdN (1:1) /= 'x') then - call accum_hist_field_2D_speed(n_icespdN, iblk, & - uvelN(:,:,iblk), vvelN(:,:,iblk), a2D) - endif + call accum_hist_field(n_vvelN , iblk, vvelN(:,:,iblk), a2D) + if (f_icespdN (1:1) /= 'x') & + call accum_hist_field_2D_speed(n_icespdN, iblk, uvelN(:,:,iblk), vvelN(:,:,iblk), a2D) + if (f_icedirN(1:1) /= 'x') then - worka(:,:) = c0 - do j = jlo, jhi - do i = ilo, ihi - if (abs(uvelN(i,j,iblk)) > puny .or. abs(vvelN(i,j,iblk)) > puny) & - worka(i,j) = atan2(uvelN(i,j,iblk),vvelN(i,j,iblk))*rad_to_deg - worka(i,j) = worka(i,j) + c180 - enddo - enddo - call accum_hist_field(n_icedirN, iblk, worka(:,:), a2D) + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + if (abs(uvelN(i,j,iblk)) > puny .or. abs(vvelN(i,j,iblk)) > puny) & + worka(i,j) = atan2(uvelN(i,j,iblk),vvelN(i,j,iblk))*rad_to_deg + worka(i,j) = worka(i,j) + c180 + enddo + enddo + call accum_hist_field(n_icedirN, iblk, worka(:,:) , a2D) endif if (f_uvelE (1:1) /= 'x') & - call accum_hist_field(n_uvelE, iblk, uvelE(:,:,iblk), a2D) + call accum_hist_field(n_uvelE , iblk, uvelE(:,:,iblk), a2D) if (f_vvelE (1:1) /= 'x') & - call accum_hist_field(n_vvelE, iblk, vvelE(:,:,iblk), a2D) - if (f_icespdE (1:1) /= 'x') then - call accum_hist_field_2D_speed(n_icespdE, iblk, & - uvelE(:,:,iblk), vvelE(:,:,iblk), a2D) - endif + call accum_hist_field(n_vvelE , iblk, vvelE(:,:,iblk), a2D) + if (f_icespdE (1:1) /= 'x') & + call accum_hist_field_2D_speed(n_icespdE, iblk, uvelE(:,:,iblk), vvelE(:,:,iblk), a2D) + if (f_icedirE(1:1) /= 'x') then - worka(:,:) = c0 - do j = jlo, jhi - do i = ilo, ihi - if (abs(uvelE(i,j,iblk)) > puny .or. abs(vvelE(i,j,iblk)) > puny) & - worka(i,j) = atan2(uvelE(i,j,iblk),vvelE(i,j,iblk))*rad_to_deg - worka(i,j) = worka(i,j) + c180 - enddo - enddo - call accum_hist_field(n_icedirE, iblk, worka(:,:), a2D) - endif - if (f_uatm (1:1) /= 'x') & - call accum_hist_field(n_uatm, iblk, uatm(:,:,iblk), a2D) - if (f_vatm (1:1) /= 'x') & - call accum_hist_field(n_vatm, iblk, vatm(:,:,iblk), a2D) - if (f_atmspd (1:1) /= 'x') then - call accum_hist_field_2D_speed(n_atmspd, iblk, & - uatm(:,:,iblk), vatm(:,:,iblk), a2D) + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + if (abs(uvelE(i,j,iblk)) > puny .or. abs(vvelE(i,j,iblk)) > puny) & + worka(i,j) = atan2(uvelE(i,j,iblk),vvelE(i,j,iblk))*rad_to_deg + worka(i,j) = worka(i,j) + c180 + enddo + enddo + call accum_hist_field(n_icedirE , iblk, worka(:,:) , a2D) endif + if (f_uatm (1:1) /= 'x') & + call accum_hist_field(n_uatm , iblk, uatm(:,:,iblk), a2D) + if (f_vatm (1:1) /= 'x') & + call accum_hist_field(n_vatm , iblk, vatm(:,:,iblk), a2D) + if (f_atmspd (1:1) /= 'x') & + call accum_hist_field_2D_speed(n_atmspd, iblk, uatm(:,:,iblk), vatm(:,:,iblk), a2D) + if (f_atmdir(1:1) /= 'x') then - worka(:,:) = c0 - do j = jlo, jhi - do i = ilo, ihi - if (abs(uatm(i,j,iblk)) > puny .or. abs(vatm(i,j,iblk)) > puny) & - worka(i,j) = atan2(uatm(i,j,iblk),vatm(i,j,iblk))*rad_to_deg - worka(i,j) = worka(i,j) + c180 - enddo - enddo - call accum_hist_field(n_atmdir, iblk, worka(:,:), a2D) + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + if (abs(uatm(i,j,iblk)) > puny .or. abs(vatm(i,j,iblk)) > puny) & + worka(i,j) = atan2(uatm(i,j,iblk),vatm(i,j,iblk))*rad_to_deg + worka(i,j) = worka(i,j) + c180 + enddo + enddo + call accum_hist_field(n_atmdir , iblk, worka(:,:) , a2D) endif if (f_sice (1:1) /= 'x') then - do j = jlo, jhi - do i = ilo, ihi - worka(i,j) = c0 - do k = 1, nzilyr - worka(i,j) = worka(i,j) + trcr(i,j,nt_sice+k-1,iblk) - enddo - worka(i,j) = worka(i,j) / nzilyr - enddo - enddo - call accum_hist_field(n_sice, iblk, worka(:,:), a2D) + do j = jlo, jhi + do i = ilo, ihi + worka(i,j) = c0 + do k = 1, nzilyr + worka(i,j) = worka(i,j) + trcr(i,j,nt_sice+k-1,iblk) + enddo + worka(i,j) = worka(i,j) / nzilyr + enddo + enddo + call accum_hist_field(n_sice , iblk, worka(:,:) , a2D) endif - if (f_fswup(1:1) /= 'x') & - call accum_hist_field(n_fswup, iblk, fswup(:,:,iblk), a2D) + if (f_fswup(1:1) /= 'x') & + call accum_hist_field(n_fswup , iblk, fswup(:,:,iblk) , a2D) if (f_fswdn (1:1) /= 'x') & - call accum_hist_field(n_fswdn, iblk, fsw(:,:,iblk), a2D) + call accum_hist_field(n_fswdn , iblk, fsw (:,:,iblk) , a2D) if (f_flwdn (1:1) /= 'x') & - call accum_hist_field(n_flwdn, iblk, flw(:,:,iblk), a2D) + call accum_hist_field(n_flwdn , iblk, flw (:,:,iblk) , a2D) if (f_snow (1:1) /= 'x') & - call accum_hist_field(n_snow, iblk, fsnow(:,:,iblk), a2D) + call accum_hist_field(n_snow , iblk, fsnow(:,:,iblk) , a2D) if (f_snow_ai(1:1) /= 'x') & - call accum_hist_field(n_snow_ai,iblk, fsnow(:,:,iblk),workb(:,:), a2D) + call accum_hist_field(n_snow_ai, iblk, fsnow(:,:,iblk),workb(:,:), a2D) if (f_rain (1:1) /= 'x') & - call accum_hist_field(n_rain, iblk, frain(:,:,iblk), a2D) + call accum_hist_field(n_rain , iblk, frain(:,:,iblk) , a2D) if (f_rain_ai(1:1) /= 'x') & - call accum_hist_field(n_rain_ai,iblk, frain(:,:,iblk),workb(:,:), a2D) + call accum_hist_field(n_rain_ai, iblk, frain(:,:,iblk),workb(:,:), a2D) if (f_sst (1:1) /= 'x') & - call accum_hist_field(n_sst, iblk, sst(:,:,iblk), a2D) + call accum_hist_field(n_sst , iblk, sst(:,:,iblk) , a2D) if (f_sss (1:1) /= 'x') & - call accum_hist_field(n_sss, iblk, sss(:,:,iblk), a2D) + call accum_hist_field(n_sss , iblk, sss(:,:,iblk) , a2D) if (f_uocn (1:1) /= 'x') & - call accum_hist_field(n_uocn, iblk, uocn(:,:,iblk), a2D) + call accum_hist_field(n_uocn , iblk, uocn(:,:,iblk) , a2D) if (f_vocn (1:1) /= 'x') & - call accum_hist_field(n_vocn, iblk, vocn(:,:,iblk), a2D) - if (f_ocnspd (1:1) /= 'x') then - call accum_hist_field_2D_speed(n_ocnspd, iblk, & - uocn(:,:,iblk), vocn(:,:,iblk), a2D) - endif + call accum_hist_field(n_vocn , iblk, vocn(:,:,iblk) , a2D) + if (f_ocnspd (1:1) /= 'x') & + call accum_hist_field_2D_speed(n_ocnspd, iblk, uocn(:,:,iblk), vocn(:,:,iblk), a2D) + if (f_ocndir(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi @@ -2538,196 +2534,188 @@ subroutine accum_hist (dt) endif enddo enddo - call accum_hist_field(n_ocndir, iblk, worka(:,:), a2D) - endif - if (f_frzmlt (1:1) /= 'x') & - call accum_hist_field(n_frzmlt, iblk, frzmlt_init(:,:,iblk), a2D) - - if (f_fswfac (1:1) /= 'x') & - call accum_hist_field(n_fswfac, iblk, scale_factor(:,:,iblk), a2D) - if (f_fswabs (1:1) /= 'x') & - call accum_hist_field(n_fswabs, iblk, fswabs(:,:,iblk), a2D) - + call accum_hist_field(n_ocndir , iblk, worka (:,:) , a2D) + endif + if (f_frzmlt (1:1) /= 'x') & + call accum_hist_field(n_frzmlt , iblk, frzmlt_init(:,:,iblk) , a2D) + if (f_fswfac (1:1) /= 'x') & + call accum_hist_field(n_fswfac , iblk, scale_factor(:,:,iblk) , a2D) + if (f_fswabs (1:1) /= 'x') & + call accum_hist_field(n_fswabs , iblk, fswabs(:,:,iblk) , a2D) if (f_fswint_ai (1:1) /= 'x') & - call accum_hist_field(n_fswint_ai, iblk, fswint_ai(:,:,iblk), a2D) + call accum_hist_field(n_fswint_ai, iblk, fswint_ai(:,:,iblk) , a2D) - if (f_fswabs_ai(1:1)/= 'x') & - call accum_hist_field(n_fswabs_ai, iblk, fswabs(:,:,iblk),aice(:,:,iblk), a2D) + if (f_fswabs_ai (1:1)/= 'x') & + call accum_hist_field(n_fswabs_ai, iblk, fswabs(:,:,iblk), aice(:,:,iblk), a2D) if (f_albsni(1:1) /= 'x') then worka(ilo:ihi,jlo:jhi) = awtvdr*alvdr_ai(ilo:ihi,jlo:jhi,iblk) & - + awtidr*alidr_ai(ilo:ihi,jlo:jhi,iblk) & - + awtvdf*alvdf_ai(ilo:ihi,jlo:jhi,iblk) & + + awtidr*alidr_ai(ilo:ihi,jlo:jhi,iblk) & + + awtvdf*alvdf_ai(ilo:ihi,jlo:jhi,iblk) & + awtidf*alidf_ai(ilo:ihi,jlo:jhi,iblk) call accum_hist_field(n_albsni, iblk, worka, a2D) endif - if (f_alvdr (1:1) /= 'x') & - call accum_hist_field(n_alvdr, iblk, alvdr(:,:,iblk), a2D) - if (f_alidr (1:1) /= 'x') & - call accum_hist_field(n_alidr, iblk, alidr(:,:,iblk), a2D) - if (f_alvdf (1:1) /= 'x') & - call accum_hist_field(n_alvdf, iblk, alvdf(:,:,iblk), a2D) - if (f_alidf (1:1) /= 'x') & - call accum_hist_field(n_alidf, iblk, alidf(:,:,iblk), a2D) + if (f_alvdr (1:1) /= 'x') & + call accum_hist_field(n_alvdr , iblk, alvdr (:,:,iblk), a2D) + if (f_alidr (1:1) /= 'x') & + call accum_hist_field(n_alidr , iblk, alidr (:,:,iblk), a2D) + if (f_alvdf (1:1) /= 'x') & + call accum_hist_field(n_alvdf , iblk, alvdf (:,:,iblk), a2D) + if (f_alidf (1:1) /= 'x') & + call accum_hist_field(n_alidf , iblk, alidf (:,:,iblk), a2D) if (f_alvdr_ai (1:1) /= 'x') & - call accum_hist_field(n_alvdr_ai, iblk, alvdr_ai(:,:,iblk), a2D) + call accum_hist_field(n_alvdr_ai , iblk, alvdr_ai(:,:,iblk), a2D) if (f_alidr_ai (1:1) /= 'x') & - call accum_hist_field(n_alidr_ai, iblk, alidr_ai(:,:,iblk), a2D) + call accum_hist_field(n_alidr_ai , iblk, alidr_ai(:,:,iblk), a2D) if (f_alvdf_ai (1:1) /= 'x') & - call accum_hist_field(n_alvdf_ai, iblk, alvdf_ai(:,:,iblk), a2D) + call accum_hist_field(n_alvdf_ai , iblk, alvdf_ai(:,:,iblk), a2D) if (f_alidf_ai (1:1) /= 'x') & - call accum_hist_field(n_alidf_ai, iblk, alidf_ai(:,:,iblk), a2D) - - if (f_albice (1:1) /= 'x') & - call accum_hist_field(n_albice, iblk, albice(:,:,iblk), a2D) - if (f_albsno (1:1) /= 'x') & - call accum_hist_field(n_albsno, iblk, albsno(:,:,iblk), a2D) - if (f_albpnd (1:1) /= 'x') & - call accum_hist_field(n_albpnd, iblk, albpnd(:,:,iblk), a2D) - if (f_coszen (1:1) /= 'x') & - call accum_hist_field(n_coszen, iblk, coszen(:,:,iblk), a2D) - - if (f_flat (1:1) /= 'x') & - call accum_hist_field(n_flat, iblk, flat(:,:,iblk), a2D) - if (f_flat_ai(1:1) /= 'x') & - call accum_hist_field(n_flat_ai,iblk, flat(:,:,iblk),aice(:,:,iblk), a2D) - if (f_fsens (1:1) /= 'x') & - call accum_hist_field(n_fsens, iblk, fsens(:,:,iblk), a2D) - if (f_fsens_ai(1:1)/= 'x') & - call accum_hist_field(n_fsens_ai,iblk, fsens(:,:,iblk),aice(:,:,iblk), a2D) - if (f_flwup (1:1) /= 'x') & - call accum_hist_field(n_flwup, iblk, flwout(:,:,iblk), a2D) - if (f_flwup_ai(1:1)/= 'x') & - call accum_hist_field(n_flwup_ai,iblk, flwout(:,:,iblk),aice(:,:,iblk), a2D) - if (f_evap (1:1) /= 'x') & - call accum_hist_field(n_evap, iblk, evap(:,:,iblk), a2D) - if (f_evap_ai(1:1) /= 'x') & - call accum_hist_field(n_evap_ai,iblk, evap(:,:,iblk),aice(:,:,iblk), a2D) - - if (f_Tair (1:1) /= 'x') & - call accum_hist_field(n_Tair, iblk, Tair(:,:,iblk), a2D) - if (f_Tref (1:1) /= 'x') & - call accum_hist_field(n_Tref, iblk, Tref(:,:,iblk), a2D) - if (f_Qref (1:1) /= 'x') & - call accum_hist_field(n_Qref, iblk, Qref(:,:,iblk), a2D) - if (f_congel (1:1) /= 'x') & - call accum_hist_field(n_congel, iblk, congel(:,:,iblk), a2D) - if (f_frazil (1:1) /= 'x') & - call accum_hist_field(n_frazil, iblk, frazil(:,:,iblk), a2D) - if (f_snoice (1:1) /= 'x') & - call accum_hist_field(n_snoice, iblk, snoice(:,:,iblk), a2D) - if (f_dsnow (1:1) /= 'x') & - call accum_hist_field(n_dsnow, iblk, dsnow(:,:,iblk), a2D) - if (f_meltt (1:1) /= 'x') & - call accum_hist_field(n_meltt, iblk, meltt(:,:,iblk), a2D) - if (f_melts (1:1) /= 'x') & - call accum_hist_field(n_melts, iblk, melts(:,:,iblk), a2D) - if (f_meltb (1:1) /= 'x') & - call accum_hist_field(n_meltb, iblk, meltb(:,:,iblk), a2D) - if (f_meltl (1:1) /= 'x') & - call accum_hist_field(n_meltl, iblk, meltl(:,:,iblk), a2D) - - if (f_fresh (1:1) /= 'x') & - call accum_hist_field(n_fresh, iblk, fresh(:,:,iblk), a2D) - if (f_fresh_ai(1:1)/= 'x') & - call accum_hist_field(n_fresh_ai,iblk, fresh_ai(:,:,iblk), a2D) - if (f_fsalt (1:1) /= 'x') & - call accum_hist_field(n_fsalt, iblk, fsalt(:,:,iblk), a2D) - if (f_fsalt_ai(1:1)/= 'x') & - call accum_hist_field(n_fsalt_ai,iblk, fsalt_ai(:,:,iblk), a2D) - - if (f_fbot(1:1)/= 'x') & - call accum_hist_field(n_fbot,iblk, fbot(:,:,iblk), a2D) - if (f_fhocn (1:1) /= 'x') & - call accum_hist_field(n_fhocn, iblk, fhocn(:,:,iblk), a2D) - if (f_fhocn_ai(1:1)/= 'x') & - call accum_hist_field(n_fhocn_ai,iblk, fhocn_ai(:,:,iblk), a2D) - if (f_fswthru(1:1) /= 'x') & - call accum_hist_field(n_fswthru, iblk, fswthru(:,:,iblk), a2D) - if (f_fswthru_ai(1:1)/= 'x') & - call accum_hist_field(n_fswthru_ai,iblk, fswthru_ai(:,:,iblk), a2D) - - if (f_strairx(1:1) /= 'x') & - call accum_hist_field(n_strairx, iblk, strairxU(:,:,iblk), a2D) - if (f_strairy(1:1) /= 'x') & - call accum_hist_field(n_strairy, iblk, strairyU(:,:,iblk), a2D) - if (f_strtltx(1:1) /= 'x') & - call accum_hist_field(n_strtltx, iblk, strtltxU(:,:,iblk), a2D) - if (f_strtlty(1:1) /= 'x') & - call accum_hist_field(n_strtlty, iblk, strtltyU(:,:,iblk), a2D) - if (f_strcorx(1:1) /= 'x') & - call accum_hist_field(n_strcorx, iblk, fmU(:,:,iblk),vvel(:,:,iblk), a2D) - if (f_strcory(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = -fmU(ilo:ihi,jlo:jhi,iblk)*uvel(ilo:ihi,jlo:jhi,iblk) - call accum_hist_field(n_strcory, iblk, worka, a2D) - endif - if (f_strocnx(1:1) /= 'x') & - call accum_hist_field(n_strocnx, iblk, strocnxU(:,:,iblk), a2D) - if (f_strocny(1:1) /= 'x') & - call accum_hist_field(n_strocny, iblk, strocnyU(:,:,iblk), a2D) - if (f_strintx(1:1) /= 'x') & - call accum_hist_field(n_strintx, iblk, strintxU(:,:,iblk), a2D) - if (f_strinty(1:1) /= 'x') & - call accum_hist_field(n_strinty, iblk, strintyU(:,:,iblk), a2D) - if (f_taubx(1:1) /= 'x') & - call accum_hist_field(n_taubx, iblk, taubxU(:,:,iblk), a2D) - if (f_tauby(1:1) /= 'x') & - call accum_hist_field(n_tauby, iblk, taubyU(:,:,iblk), a2D) - if (f_strairxN(1:1) /= 'x') & - call accum_hist_field(n_strairxN, iblk, strairxN(:,:,iblk), a2D) - if (f_strairyN(1:1) /= 'x') & - call accum_hist_field(n_strairyN, iblk, strairyN(:,:,iblk), a2D) - if (f_strairxE(1:1) /= 'x') & - call accum_hist_field(n_strairxE, iblk, strairxE(:,:,iblk), a2D) - if (f_strairyE(1:1) /= 'x') & - call accum_hist_field(n_strairyE, iblk, strairyE(:,:,iblk), a2D) - if (f_strtltxN(1:1) /= 'x') & - call accum_hist_field(n_strtltxN, iblk, strtltxN(:,:,iblk), a2D) - if (f_strtltyN(1:1) /= 'x') & - call accum_hist_field(n_strtltyN, iblk, strtltyN(:,:,iblk), a2D) - if (f_strtltxE(1:1) /= 'x') & - call accum_hist_field(n_strtltxE, iblk, strtltxE(:,:,iblk), a2D) - if (f_strtltyE(1:1) /= 'x') & - call accum_hist_field(n_strtltyE, iblk, strtltyE(:,:,iblk), a2D) - if (f_strcorxN(1:1) /= 'x') & - call accum_hist_field(n_strcorxN, iblk, fmN(:,:,iblk),vvelN(:,:,iblk), a2D) - if (f_strcoryN(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = -fmN(ilo:ihi,jlo:jhi,iblk)*uvelN(ilo:ihi,jlo:jhi,iblk) - call accum_hist_field(n_strcoryN, iblk, worka, a2D) - endif - if (f_strcorxE(1:1) /= 'x') & - call accum_hist_field(n_strcorxE, iblk, fmE(:,:,iblk),vvelE(:,:,iblk), a2D) - if (f_strcoryE(1:1) /= 'x') then - worka(ilo:ihi,jlo:jhi) = -fmE(ilo:ihi,jlo:jhi,iblk)*uvelE(ilo:ihi,jlo:jhi,iblk) - call accum_hist_field(n_strcoryE, iblk, worka, a2D) - endif - if (f_strocnxN(1:1) /= 'x') & - call accum_hist_field(n_strocnxN, iblk, strocnxN(:,:,iblk), a2D) - if (f_strocnyN(1:1) /= 'x') & - call accum_hist_field(n_strocnyN, iblk, strocnyN(:,:,iblk), a2D) - if (f_strocnxE(1:1) /= 'x') & - call accum_hist_field(n_strocnxE, iblk, strocnxE(:,:,iblk), a2D) - if (f_strocnyE(1:1) /= 'x') & - call accum_hist_field(n_strocnyE, iblk, strocnyE(:,:,iblk), a2D) - if (f_strintxN(1:1) /= 'x') & - call accum_hist_field(n_strintxN, iblk, strintxN(:,:,iblk), a2D) - if (f_strintyN(1:1) /= 'x') & - call accum_hist_field(n_strintyN, iblk, strintyN(:,:,iblk), a2D) - if (f_strintxE(1:1) /= 'x') & - call accum_hist_field(n_strintxE, iblk, strintxE(:,:,iblk), a2D) - if (f_strintyE(1:1) /= 'x') & - call accum_hist_field(n_strintyE, iblk, strintyE(:,:,iblk), a2D) - if (f_taubxN(1:1) /= 'x') & - call accum_hist_field(n_taubxN, iblk, taubxN(:,:,iblk), a2D) - if (f_taubyN(1:1) /= 'x') & - call accum_hist_field(n_taubyN, iblk, taubyN(:,:,iblk), a2D) - if (f_taubxE(1:1) /= 'x') & - call accum_hist_field(n_taubxE, iblk, taubxE(:,:,iblk), a2D) - if (f_taubyE(1:1) /= 'x') & - call accum_hist_field(n_taubyE, iblk, taubyE(:,:,iblk), a2D) - if (f_strength(1:1)/= 'x') & - call accum_hist_field(n_strength,iblk, strength(:,:,iblk), a2D) + call accum_hist_field(n_alidf_ai , iblk, alidf_ai(:,:,iblk), a2D) + + if (f_albice (1:1) /= 'x') & + call accum_hist_field(n_albice , iblk, albice (:,:,iblk), a2D) + if (f_albsno (1:1) /= 'x') & + call accum_hist_field(n_albsno , iblk, albsno (:,:,iblk), a2D) + if (f_albpnd (1:1) /= 'x') & + call accum_hist_field(n_albpnd , iblk, albpnd (:,:,iblk), a2D) + if (f_coszen (1:1) /= 'x') & + call accum_hist_field(n_coszen , iblk, coszen (:,:,iblk), a2D) + + if (f_flat (1:1) /= 'x') & + call accum_hist_field(n_flat , iblk, flat (:,:,iblk) , a2D) + if (f_flat_ai (1:1) /= 'x') & + call accum_hist_field(n_flat_ai , iblk, flat (:,:,iblk), aice(:,:,iblk), a2D) + if (f_fsens (1:1) /= 'x') & + call accum_hist_field(n_fsens , iblk, fsens (:,:,iblk) , a2D) + if (f_fsens_ai (1:1) /= 'x') & + call accum_hist_field(n_fsens_ai , iblk, fsens (:,:,iblk), aice(:,:,iblk), a2D) + if (f_flwup (1:1) /= 'x') & + call accum_hist_field(n_flwup , iblk, flwout (:,:,iblk) , a2D) + if (f_flwup_ai (1:1) /= 'x') & + call accum_hist_field(n_flwup_ai , iblk, flwout (:,:,iblk), aice(:,:,iblk), a2D) + if (f_evap (1:1) /= 'x') & + call accum_hist_field(n_evap , iblk, evap (:,:,iblk) , a2D) + if (f_evap_ai (1:1) /= 'x') & + call accum_hist_field(n_evap_ai , iblk, evap (:,:,iblk), aice(:,:,iblk), a2D) + + if (f_Tair (1:1) /= 'x') & + call accum_hist_field(n_Tair , iblk, Tair (:,:,iblk) , a2D) + if (f_Tref (1:1) /= 'x') & + call accum_hist_field(n_Tref , iblk, Tref (:,:,iblk) , a2D) + if (f_Qref (1:1) /= 'x') & + call accum_hist_field(n_Qref , iblk, Qref (:,:,iblk) , a2D) + if (f_congel (1:1) /= 'x') & + call accum_hist_field(n_congel , iblk, congel (:,:,iblk) , a2D) + if (f_frazil (1:1) /= 'x') & + call accum_hist_field(n_frazil , iblk, frazil (:,:,iblk) , a2D) + if (f_snoice (1:1) /= 'x') & + call accum_hist_field(n_snoice , iblk, snoice (:,:,iblk) , a2D) + if (f_dsnow (1:1) /= 'x') & + call accum_hist_field(n_dsnow , iblk, dsnow (:,:,iblk) , a2D) + if (f_meltt (1:1) /= 'x') & + call accum_hist_field(n_meltt , iblk, meltt (:,:,iblk) , a2D) + if (f_melts (1:1) /= 'x') & + call accum_hist_field(n_melts , iblk, melts (:,:,iblk) , a2D) + if (f_meltb (1:1) /= 'x') & + call accum_hist_field(n_meltb , iblk, meltb (:,:,iblk) , a2D) + if (f_meltl (1:1) /= 'x') & + call accum_hist_field(n_meltl , iblk, meltl (:,:,iblk) , a2D) + + if (f_fresh (1:1) /= 'x') & + call accum_hist_field(n_fresh , iblk, fresh (:,:,iblk) , a2D) + if (f_fresh_ai (1:1) /= 'x') & + call accum_hist_field(n_fresh_ai , iblk, fresh_ai(:,:,iblk) , a2D) + if (f_fsalt (1:1) /= 'x') & + call accum_hist_field(n_fsalt , iblk, fsalt (:,:,iblk) , a2D) + if (f_fsalt_ai (1:1) /= 'x') & + call accum_hist_field(n_fsalt_ai , iblk, fsalt_ai(:,:,iblk) , a2D) + + if (f_fbot (1:1) /= 'x') & + call accum_hist_field(n_fbot , iblk, fbot (:,:,iblk) , a2D) + if (f_fhocn (1:1) /= 'x') & + call accum_hist_field(n_fhocn , iblk, fhocn (:,:,iblk) , a2D) + if (f_fhocn_ai (1:1) /= 'x') & + call accum_hist_field(n_fhocn_ai , iblk, fhocn_ai (:,:,iblk) , a2D) + if (f_fswthru (1:1) /= 'x') & + call accum_hist_field(n_fswthru , iblk, fswthru (:,:,iblk) , a2D) + if (f_fswthru_ai(1:1) /= 'x') & + call accum_hist_field(n_fswthru_ai, iblk, fswthru_ai(:,:,iblk) , a2D) + + if (f_strairx (1:1) /= 'x') & + call accum_hist_field(n_strairx , iblk, strairxU (:,:,iblk) , a2D) + if (f_strairy (1:1) /= 'x') & + call accum_hist_field(n_strairy , iblk, strairyU (:,:,iblk) , a2D) + if (f_strtltx (1:1) /= 'x') & + call accum_hist_field(n_strtltx , iblk, strtltxU (:,:,iblk) , a2D) + if (f_strtlty (1:1) /= 'x') & + call accum_hist_field(n_strtlty , iblk, strtltyU (:,:,iblk) , a2D) + if (f_strcorx (1:1) /= 'x') & + call accum_hist_field(n_strcorx , iblk, fmU (:,:,iblk), vvel(:,:,iblk), a2D) + if (f_strcory (1:1) /= 'x') & + call accum_hist_field(n_strcory , iblk, -fmu (:,:,iblk), uvel(:,:,iblk), a2D) + if (f_strocnx (1:1) /= 'x') & + call accum_hist_field(n_strocnx , iblk, strocnxU (:,:,iblk) , a2D) + if (f_strocny (1:1) /= 'x') & + call accum_hist_field(n_strocny , iblk, strocnyU (:,:,iblk) , a2D) + if (f_strintx (1:1) /= 'x') & + call accum_hist_field(n_strintx , iblk, strintxU (:,:,iblk) , a2D) + if (f_strinty (1:1) /= 'x') & + call accum_hist_field(n_strinty , iblk, strintyU (:,:,iblk) , a2D) + if (f_taubx (1:1) /= 'x') & + call accum_hist_field(n_taubx , iblk, taubxU (:,:,iblk) , a2D) + if (f_tauby (1:1) /= 'x') & + call accum_hist_field(n_tauby , iblk, taubyU (:,:,iblk) , a2D) + if (f_strairxN (1:1) /= 'x') & + call accum_hist_field(n_strairxN , iblk, strairxN (:,:,iblk) , a2D) + if (f_strairyN (1:1) /= 'x') & + call accum_hist_field(n_strairyN , iblk, strairyN (:,:,iblk) , a2D) + if (f_strairxE (1:1) /= 'x') & + call accum_hist_field(n_strairxE , iblk, strairxE (:,:,iblk) , a2D) + if (f_strairyE (1:1) /= 'x') & + call accum_hist_field(n_strairyE , iblk, strairyE (:,:,iblk) , a2D) + if (f_strtltxN (1:1) /= 'x') & + call accum_hist_field(n_strtltxN , iblk, strtltxN (:,:,iblk) , a2D) + if (f_strtltyN (1:1) /= 'x') & + call accum_hist_field(n_strtltyN , iblk, strtltyN (:,:,iblk) , a2D) + if (f_strtltxE (1:1) /= 'x') & + call accum_hist_field(n_strtltxE , iblk, strtltxE (:,:,iblk) , a2D) + if (f_strtltyE (1:1) /= 'x') & + call accum_hist_field(n_strtltyE , iblk, strtltyE (:,:,iblk) , a2D) + if (f_strcorxN (1:1) /= 'x') & + call accum_hist_field(n_strcorxN , iblk, fmN (:,:,iblk),vvelN(:,:,iblk), a2D) + if (f_strcoryN (1:1) /= 'x') & + call accum_hist_field(n_strcoryN , iblk, -fmN (:,:,iblk),uvelN(:,:,iblk), a2D) + if (f_strcorxE (1:1) /= 'x') & + call accum_hist_field(n_strcorxE , iblk, fmE (:,:,iblk),vvelE(:,:,iblk), a2D) + if (f_strcoryE (1:1) /= 'x') & + call accum_hist_field(n_strcoryE , iblk, -fmE (:,:,iblk),uvelE(:,:,iblk), a2D) + if (f_strocnxN (1:1) /= 'x') & + call accum_hist_field(n_strocnxN , iblk, strocnxN (:,:,iblk) , a2D) + if (f_strocnyN (1:1) /= 'x') & + call accum_hist_field(n_strocnyN , iblk, strocnyN (:,:,iblk) , a2D) + if (f_strocnxE (1:1) /= 'x') & + call accum_hist_field(n_strocnxE , iblk, strocnxE (:,:,iblk) , a2D) + if (f_strocnyE (1:1) /= 'x') & + call accum_hist_field(n_strocnyE , iblk, strocnyE (:,:,iblk) , a2D) + if (f_strintxN (1:1) /= 'x') & + call accum_hist_field(n_strintxN , iblk, strintxN (:,:,iblk) , a2D) + if (f_strintyN (1:1) /= 'x') & + call accum_hist_field(n_strintyN , iblk, strintyN (:,:,iblk) , a2D) + if (f_strintxE (1:1) /= 'x') & + call accum_hist_field(n_strintxE , iblk, strintxE (:,:,iblk) , a2D) + if (f_strintyE (1:1) /= 'x') & + call accum_hist_field(n_strintyE , iblk, strintyE (:,:,iblk) , a2D) + if (f_taubxN (1:1) /= 'x') & + call accum_hist_field(n_taubxN , iblk, taubxN (:,:,iblk) , a2D) + if (f_taubyN (1:1) /= 'x') & + call accum_hist_field(n_taubyN , iblk, taubyN (:,:,iblk) , a2D) + if (f_taubxE (1:1) /= 'x') & + call accum_hist_field(n_taubxE , iblk, taubxE (:,:,iblk) , a2D) + if (f_taubyE (1:1) /= 'x') & + call accum_hist_field(n_taubyE , iblk, taubyE (:,:,iblk) , a2D) + if (f_strength (1:1) /= 'x') & + call accum_hist_field(n_strength , iblk, strength (:,:,iblk) , a2D) ! The following fields (divu, shear, vort, sig1, and sig2) will be smeared ! if averaged over more than a few days. @@ -2746,54 +2734,51 @@ subroutine accum_hist (dt) ! if (f_trsig (1:1) /= 'x') & ! call accum_hist_field(n_trsig, iblk, trsig(:,:,iblk), a2D) - if (f_dvidtt (1:1) /= 'x') & - call accum_hist_field(n_dvidtt, iblk, dvidtt(:,:,iblk), a2D) - if (f_dvidtd (1:1) /= 'x') & - call accum_hist_field(n_dvidtd, iblk, dvidtd(:,:,iblk), a2D) - if (f_daidtt (1:1) /= 'x') & - call accum_hist_field(n_daidtt, iblk, daidtt(:,:,iblk), a2D) - if (f_daidtd (1:1) /= 'x') & - call accum_hist_field(n_daidtd, iblk, daidtd(:,:,iblk), a2D) - if (f_dagedtt (1:1) /= 'x') & - call accum_hist_field(n_dagedtt, iblk, dagedtt(:,:,iblk), a2D) - if (f_dagedtd (1:1) /= 'x') & - call accum_hist_field(n_dagedtd, iblk, dagedtd(:,:,iblk), a2D) - - if (f_fsurf_ai(1:1)/= 'x') & - call accum_hist_field(n_fsurf_ai,iblk, fsurf(:,:,iblk),aice(:,:,iblk), a2D) + if (f_dvidtt (1:1) /= 'x') & + call accum_hist_field(n_dvidtt , iblk, dvidtt (:,:,iblk) , a2D) + if (f_dvidtd (1:1) /= 'x') & + call accum_hist_field(n_dvidtd , iblk, dvidtd (:,:,iblk) , a2D) + if (f_daidtt (1:1) /= 'x') & + call accum_hist_field(n_daidtt , iblk, daidtt (:,:,iblk) , a2D) + if (f_daidtd (1:1) /= 'x') & + call accum_hist_field(n_daidtd , iblk, daidtd (:,:,iblk) , a2D) + if (f_dagedtt (1:1) /= 'x') & + call accum_hist_field(n_dagedtt , iblk, dagedtt (:,:,iblk) , a2D) + if (f_dagedtd (1:1) /= 'x') & + call accum_hist_field(n_dagedtd , iblk, dagedtd (:,:,iblk) , a2D) + + if (f_fsurf_ai (1:1) /= 'x') & + call accum_hist_field(n_fsurf_ai , iblk, fsurf (:,:,iblk), aice(:,:,iblk), a2D) if (f_fcondtop_ai(1:1)/= 'x') & - call accum_hist_field(n_fcondtop_ai, iblk, & - fcondtop(:,:,iblk),aice(:,:,iblk), a2D) + call accum_hist_field(n_fcondtop_ai,iblk, fcondtop (:,:,iblk), aice(:,:,iblk), a2D) if (f_icepresent(1:1) /= 'x') then - worka(:,:) = c0 - do j = jlo, jhi - do i = ilo, ihi - if (aice(i,j,iblk) > puny) worka(i,j) = c1 - enddo - enddo - call accum_hist_field(n_icepresent, iblk, worka(:,:), a2D) + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + if (aice(i,j,iblk) > puny) worka(i,j) = c1 + enddo + enddo + call accum_hist_field(n_icepresent, iblk, worka (:,:) , a2D) endif ! 2D CMIP fields if (f_sitimefrac(1:1) /= 'x') then - worka(:,:) = c0 - do j = jlo, jhi - do i = ilo, ihi - if (aice(i,j,iblk) > puny) worka(i,j) = c1 - enddo - enddo - call accum_hist_field(n_sitimefrac, iblk, worka(:,:), a2D) + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + if (aice(i,j,iblk) > puny) worka(i,j) = c1 + enddo + enddo + call accum_hist_field(n_sitimefrac, iblk, worka(:,:) , a2D) endif - if (f_sithick(1:1) /= 'x') then - call accum_hist_field(n_sithick, iblk, vice(:,:,iblk), a2D) - endif + if (f_sithick(1:1) /= 'x') & + call accum_hist_field(n_sithick , iblk, vice(:,:,iblk), a2D) - if (f_sivol(1:1) /= 'x') then - call accum_hist_field(n_sivol, iblk, vice(:,:,iblk), a2D) - endif + if (f_sivol(1:1) /= 'x') & + call accum_hist_field(n_sivol , iblk, vice(:,:,iblk), a2D) rho_ice(:,:) = rhoi rho_ocn(:,:) = rhow @@ -2808,69 +2793,57 @@ subroutine accum_hist (dt) enddo endif - if (f_simass(1:1) /= 'x') then - call accum_hist_field(n_simass, iblk, rho_ice(:,:),vice(:,:,iblk), a2D) - endif + if (f_simass (1:1) /= 'x') & + call accum_hist_field(n_simass , iblk, rho_ice (:,:) , vice(:,:,iblk) , a2D) if (f_sisaltmass(1:1) /= 'x') then worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*sal_ice(ilo:ihi,jlo:jhi)*vice(ilo:ihi,jlo:jhi,iblk) call accum_hist_field(n_sisaltmass, iblk, worka, a2D) endif - if (f_sisali(1:1) /= 'x') then - call accum_hist_field(n_sisali, iblk, aice(:,:,iblk),sal_ice(:,:), a2D) - endif + if (f_sisali (1:1) /= 'x') & + call accum_hist_field(n_sisali , iblk, aice (:,:,iblk), sal_ice , a2D) - if (f_siconc(1:1) /= 'x') then - call accum_hist_field(n_siconc, iblk, aice(:,:,iblk), a2D) - endif + if (f_siconc (1:1) /= 'x') & + call accum_hist_field(n_siconc , iblk, aice (:,:,iblk) , a2D) - if (f_sisnconc(1:1) /= 'x') then - call accum_hist_field(n_sisnconc, iblk, snowfrac(:,:,iblk), a2D) - endif + if (f_sisnconc (1:1) /= 'x') & + call accum_hist_field(n_sisnconc , iblk, snowfrac(:,:,iblk) , a2D) - if (f_sisnmass(1:1) /= 'x') then - call accum_hist_field(n_sisnmass, iblk, vsno(:,:,iblk), rhos, a2D) - endif + if (f_sisnmass (1:1) /= 'x') & + call accum_hist_field(n_sisnmass , iblk, vsno (:,:,iblk), rhos , a2D) - if (f_siage(1:1) /= 'x') then - call accum_hist_field(n_siage, iblk, aice(:,:,iblk),trcr(:,:,nt_iage,iblk), a2D) - endif + if (f_siage (1:1) /= 'x') & + call accum_hist_field(n_siage , iblk, aice (:,:,iblk), trcr(:,:,nt_iage,iblk), a2D) - if (f_sisnthick(1:1) /= 'x') then - call accum_hist_field(n_sisnthick, iblk, vsno(:,:,iblk), a2D) - endif + if (f_sisnthick (1:1) /= 'x') & + call accum_hist_field(n_sisnthick , iblk, vsno (:,:,iblk) , a2D) - if (f_sitemptop(1:1) /= 'x') then - call accum_hist_field(n_sitemptop, iblk, aice(:,:,iblk),trcr(:,:,nt_Tsfc,iblk), a2D) - endif + if (f_sitemptop (1:1) /= 'x') & + call accum_hist_field(n_sitemptop , iblk, aice (:,:,iblk), trcr(:,:,nt_Tsfc,iblk), a2D) ! Tsnice is already multiplied by aicen in icepack. - if (f_sitempsnic(1:1) /= 'x') then - call accum_hist_field(n_sitempsnic, iblk, Tsnice(:,:,iblk), a2D) - endif + if (f_sitempsnic(1:1) /= 'x') & + call accum_hist_field(n_sitempsnic, iblk, Tsnice (:,:,iblk) , a2D) - if (f_sitempbot(1:1) /= 'x') then - call accum_hist_field(n_sitempbot, iblk, aice_init(:,:,iblk),Tbot(:,:,iblk), a2D) - endif + if (f_sitempbot (1:1) /= 'x') & + call accum_hist_field(n_sitempbot , iblk,aice_init(:,:,iblk), Tbot(:,:,iblk) , a2D) - if (f_siu(1:1) /= 'x') then - call accum_hist_field(n_siu, iblk, aice(:,:,iblk),uvel(:,:,iblk), a2D) - endif + if (f_siu (1:1) /= 'x') & + call accum_hist_field(n_siu , iblk, aice (:,:,iblk), uvel(:,:,iblk) , a2D) - if (f_siv(1:1) /= 'x') then - call accum_hist_field(n_siv, iblk, aice(:,:,iblk),vvel(:,:,iblk), a2D) - endif + if (f_siv (1:1) /= 'x') & + call accum_hist_field(n_siv , iblk, aice (:,:,iblk), vvel(:,:,iblk) , a2D) if (f_sispeed(1:1) /= 'x') then worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi worka(i,j) = aice(i,j,iblk) & - * sqrt(uvel(i,j,iblk)*uvel(i,j,iblk)+vvel(i,j,iblk)*vvel(i,j,iblk)) + * sqrt(uvel(i,j,iblk)*uvel(i,j,iblk)+vvel(i,j,iblk)*vvel(i,j,iblk)) enddo enddo - call accum_hist_field(n_sispeed, iblk, worka(:,:), a2D) + call accum_hist_field(n_sispeed , iblk, worka (:,:) , a2D) endif ! if (f_sidir(1:1) /= 'x') then @@ -2910,39 +2883,34 @@ subroutine accum_hist (dt) * p5*(vvel(i-1,j,iblk)+vvel(i,j,iblk)) enddo enddo - call accum_hist_field(n_sidmasstrany, iblk, worka(:,:), a2D) + call accum_hist_field(n_sidmasstrany, iblk, worka(:,:) , a2D) endif - if (f_sistrxdtop(1:1) /= 'x') then - call accum_hist_field(n_sistrxdtop, iblk, aice(:,:,iblk),strairxU(:,:,iblk), a2D) - endif + if (f_sistrxdtop (1:1) /= 'x') & + call accum_hist_field(n_sistrxdtop , iblk, aice (:,:,iblk),strairxU(:,:,iblk), a2D) - if (f_sistrydtop(1:1) /= 'x') then - call accum_hist_field(n_sistrydtop, iblk, aice(:,:,iblk),strairyU(:,:,iblk), a2D) - endif + if (f_sistrydtop (1:1) /= 'x') & + call accum_hist_field(n_sistrydtop , iblk, aice (:,:,iblk),strairyU(:,:,iblk), a2D) - if (f_sistrxubot(1:1) /= 'x') then - call accum_hist_field(n_sistrxubot, iblk, aice(:,:,iblk),strocnxU(:,:,iblk), a2D) - endif + if (f_sistrxubot (1:1) /= 'x') & + call accum_hist_field(n_sistrxubot , iblk, aice (:,:,iblk),strocnxU(:,:,iblk), a2D) - if (f_sistryubot(1:1) /= 'x') then - call accum_hist_field(n_sistryubot, iblk, aice(:,:,iblk),strocnyU(:,:,iblk), a2D) - endif + if (f_sistryubot (1:1) /= 'x') & + call accum_hist_field(n_sistryubot , iblk, aice (:,:,iblk),strocnyU(:,:,iblk), a2D) - if (f_sicompstren(1:1) /= 'x') then - call accum_hist_field(n_sicompstren, iblk, aice(:,:,iblk),strength(:,:,iblk), a2D) - endif + if (f_sicompstren(1:1) /= 'x') & + call accum_hist_field(n_sicompstren , iblk, aice (:,:,iblk),strength(:,:,iblk), a2D) if (f_sihc(1:1) /= 'x') then - worka(:,:) = c0 - do k = 1,nzilyr - do j = jlo, jhi + worka(:,:) = c0 + do k = 1,nzilyr + do j = jlo, jhi do i = ilo, ihi worka(i,j) = worka(i,j) + trcr(i,j,nt_qice+k-1,iblk)*vice(i,j,iblk)/real(nzilyr,kind=dbl_kind) enddo enddo enddo - call accum_hist_field(n_sihc, iblk, worka(:,:), a2D) + call accum_hist_field(n_sihc , iblk, worka(:,:) , a2D) endif if (f_sisnhc(1:1) /= 'x') then @@ -2954,131 +2922,102 @@ subroutine accum_hist (dt) enddo enddo enddo - call accum_hist_field(n_sisnhc, iblk, worka(:,:), a2D) + call accum_hist_field(n_sisnhc, iblk, worka(:,:) , a2D) endif - if (f_sidconcth(1:1) /= 'x') then - call accum_hist_field(n_sidconcth, iblk, daidtt(:,:,iblk), a2D) - endif + if (f_sidconcth (1:1) /= 'x') & + call accum_hist_field(n_sidconcth , iblk, daidtt(:,:,iblk) , a2D) - if (f_sidconcdyn(1:1) /= 'x') then - call accum_hist_field(n_sidconcdyn, iblk, daidtd(:,:,iblk), a2D) - endif + if (f_sidconcdyn (1:1) /= 'x') & + call accum_hist_field(n_sidconcdyn , iblk, daidtd(:,:,iblk) , a2D) - if (f_sidmassth(1:1) /= 'x') then - call accum_hist_field(n_sidmassth, iblk, rho_ice(:,:),dvidtt(:,:,iblk), a2D) - endif + if (f_sidmassth (1:1) /= 'x') & + call accum_hist_field(n_sidmassth , iblk, rho_ice(:,:),dvidtt(:,:,iblk), a2D) - if (f_sidmassdyn(1:1) /= 'x') then - call accum_hist_field(n_sidmassdyn, iblk, rho_ice(:,:),dvidtd(:,:,iblk), a2D) - endif + if (f_sidmassdyn (1:1) /= 'x') & + call accum_hist_field(n_sidmassdyn , iblk, rho_ice(:,:),dvidtd(:,:,iblk), a2D) - if (f_sidmassgrowthwat(1:1) /= 'x') then + if (f_sidmassgrowthwat(1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*frazil(ilo:ihi,jlo:jhi,iblk)/dt - call accum_hist_field(n_sidmassgrowthwat, iblk, worka, a2D) - endif + call accum_hist_field(n_sidmassgrowthwat, iblk, worka , a2D) - if (f_sidmassgrowthbot(1:1) /= 'x') then + if (f_sidmassgrowthbot(1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*congel(ilo:ihi,jlo:jhi,iblk)/dt - call accum_hist_field(n_sidmassgrowthbot, iblk, worka, a2D) - endif + call accum_hist_field(n_sidmassgrowthbot, iblk, worka , a2D) - if (f_sidmassgrowthsi(1:1) /= 'x') then + if (f_sidmassgrowthsi (1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = rho_ice(ilo:ihi,jlo:jhi)*snoice(ilo:ihi,jlo:jhi,iblk)/dt - call accum_hist_field(n_sidmassgrowthsi, iblk, worka, a2D) - endif + call accum_hist_field(n_sidmassgrowthsi , iblk, worka , a2D) - if (f_sisndmasssi(1:1) /= 'x') then + if (f_sisndmasssi (1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = -snoice(ilo:ihi,jlo:jhi,iblk)*rhos/dt - call accum_hist_field(n_sisndmasssi, iblk, worka, a2D) - endif + call accum_hist_field(n_sisndmasssi , iblk, worka , a2D) - if (f_sidmassevapsubl(1:1) /= 'x') then - call accum_hist_field(n_sidmassevapsubl, iblk, rho_ice(:,:),evapi(:,:,iblk), a2D) - endif + if (f_sidmassevapsubl (1:1) /= 'x') & + call accum_hist_field(n_sidmassevapsubl , iblk, rho_ice(:,:),evapi(:,:,iblk) , a2D) - if (f_sidmassmelttop(1:1) /= 'x') then + if (f_sidmassmelttop (1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = -rho_ice(ilo:ihi,jlo:jhi)*meltt(ilo:ihi,jlo:jhi,iblk)/dt - call accum_hist_field(n_sidmassmelttop, iblk, worka, a2D) - endif + call accum_hist_field(n_sidmassmelttop , iblk, worka , a2D) - if (f_sidmassmeltbot(1:1) /= 'x') then + if (f_sidmassmeltbot (1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = -rho_ice(ilo:ihi,jlo:jhi)*meltb(ilo:ihi,jlo:jhi,iblk)/dt - call accum_hist_field(n_sidmassmeltbot, iblk, worka, a2D) - endif + call accum_hist_field(n_sidmassmeltbot, iblk, worka , a2D) - if (f_sidmassmeltlat(1:1) /= 'x') then + if (f_sidmassmeltlat (1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = -rho_ice(ilo:ihi,jlo:jhi)*meltl(ilo:ihi,jlo:jhi,iblk)/dt - call accum_hist_field(n_sidmassmeltlat, iblk, worka, a2D) - endif + call accum_hist_field(n_sidmassmeltlat, iblk, worka , a2D) - if (f_sisndmasssubl(1:1) /= 'x') then - call accum_hist_field(n_sisndmasssubl, iblk, evaps(:,:,iblk), a2D) - endif + if (f_sisndmasssubl (1:1) /= 'x') & + call accum_hist_field(n_sisndmasssubl , iblk, evaps(:,:,iblk) , a2D) - if (f_sisndmasssnf(1:1) /= 'x') then - call accum_hist_field(n_sisndmasssnf, iblk, fsnow(:,:,iblk), a2D) - endif + if (f_sisndmasssnf (1:1) /= 'x') & + call accum_hist_field(n_sisndmasssnf , iblk, fsnow(:,:,iblk) , a2D) - if (f_sisndmassmelt(1:1) /= 'x') then + if (f_sisndmassmelt (1:1) /= 'x') & worka(ilo:ihi,jlo:jhi) = -melts(ilo:ihi,jlo:jhi,iblk)*rhos/dt - call accum_hist_field(n_sisndmassmelt, iblk, worka, a2D) - endif + call accum_hist_field(n_sisndmassmelt , iblk, worka , a2D) - if (f_sisndmassdyn(1:1) /= 'x') then - call accum_hist_field(n_sisndmassdyn, iblk, dvsdtd(:,:,iblk),rhos, a2D) - endif + if (f_sisndmassdyn (1:1) /= 'x') & + call accum_hist_field(n_sisndmassdyn , iblk, dvsdtd(:,:,iblk), rhos , a2D) - if (f_siflswdtop(1:1) /= 'x') then - call accum_hist_field(n_siflswdtop, iblk, aice_init(:,:,iblk),fsw(:,:,iblk), a2D) - endif + if (f_siflswdtop (1:1) /= 'x') & + call accum_hist_field(n_siflswdtop , iblk, aice_init(:,:,iblk),fsw(:,:,iblk), a2D) - if (f_siflswutop(1:1) /= 'x') then + if (f_siflswutop (1:1) /= 'x') & call accum_hist_field(n_siflswutop, iblk, fswup(:,:,iblk), a2D) - endif - if (f_siflswdbot(1:1) /= 'x') then - call accum_hist_field(n_siflswdbot, iblk, aice_init(:,:,iblk),fswthru(:,:,iblk), a2D) - endif + if (f_siflswdbot (1:1) /= 'x') & + call accum_hist_field(n_siflswdbot, iblk, aice_init(:,:,iblk),fswthru(:,:,iblk) , a2D) - if (f_sifllwdtop(1:1) /= 'x') then - call accum_hist_field(n_sifllwdtop, iblk, aice_init(:,:,iblk),flw(:,:,iblk), a2D) - endif + if (f_sifllwdtop (1:1) /= 'x') & + call accum_hist_field(n_sifllwdtop, iblk, aice_init(:,:,iblk),flw(:,:,iblk) , a2D) - if (f_sifllwutop(1:1) /= 'x') then - call accum_hist_field(n_sifllwutop, iblk, aice(:,:,iblk),flwout(:,:,iblk), a2D) - endif + if (f_sifllwutop (1:1) /= 'x') & + call accum_hist_field(n_sifllwutop, iblk, aice(:,:,iblk) , flwout(:,:,iblk) , a2D) - if (f_siflsenstop(1:1) /= 'x') then - worka(:,:) = c0 - do j = jlo, jhi - do i = ilo, ihi - worka(i,j) = aice(i,j,iblk)*fsens(i,j,iblk) - enddo - enddo - call accum_hist_field(n_siflsenstop, iblk, aice(:,:,iblk),fsens(:,:,iblk), a2D) - endif + if (f_siflsenstop (1:1) /= 'x') & + call accum_hist_field(n_siflsenstop,iblk, aice(:,:,iblk) , fsens(:,:,iblk) , a2D) - if (f_siflsensbot(1:1) /= 'x') then - call accum_hist_field(n_siflsensbot, iblk, aice(:,:,iblk),fhocn(:,:,iblk), a2D) - endif + if (f_siflsensbot (1:1) /= 'x') & + call accum_hist_field(n_siflsensbot,iblk, aice(:,:,iblk) , fhocn(:,:,iblk) , a2D) - if (f_sifllattop(1:1) /= 'x') then - call accum_hist_field(n_sifllattop, iblk, aice(:,:,iblk),flat(:,:,iblk), a2D) - endif + if (f_sifllattop (1:1) /= 'x') & + call accum_hist_field(n_sifllattop, iblk, aice(:,:,iblk) , flat(:,:,iblk) , a2D) - if (f_siflcondtop(1:1) /= 'x') then - call accum_hist_field(n_siflcondtop, iblk, aice(:,:,iblk),fcondtop(:,:,iblk), a2D) - endif + if (f_siflcondtop (1:1) /= 'x') & + call accum_hist_field(n_siflcondtop,iblk, aice(:,:,iblk) ,fcondtop(:,:,iblk), a2D) - if (f_siflcondbot(1:1) /= 'x') then - call accum_hist_field(n_siflcondbot, iblk, aice(:,:,iblk),fcondbot(:,:,iblk), a2D) - endif + if (f_siflcondbot (1:1) /= 'x') & + call accum_hist_field(n_siflcondbot,iblk, aice(:,:,iblk) ,fcondbot(:,:,iblk), a2D) if (f_sipr(1:1) /= 'x') then - worka(:,:) = c0 - if (tr_pond_topo) worka(:,:) = aice_init(:,:,iblk)*frain(:,:,iblk) - call accum_hist_field(n_sipr, iblk, worka(:,:), a2D) + if (tr_pond_topo) then + call accum_hist_field(n_sipr , iblk, aice_init(:,:,iblk),frain (:,:,iblk), a2D) + else + worka(:,:) = c0 + call accum_hist_field(n_sipr , iblk, worka , a2D) + endif endif if (f_sifb(1:1) /= 'x') then @@ -3154,21 +3093,17 @@ subroutine accum_hist (dt) call accum_hist_field(n_siflfwdrain, iblk, worka(:,:), a2D) endif - if (f_sidragtop(1:1) /= 'x') then - call accum_hist_field(n_sidragtop, iblk, aice_init(:,:,iblk),Cdn_atm(:,:,iblk), a2D) - endif + if (f_sidragtop (1:1) /= 'x') & + call accum_hist_field(n_sidragtop , iblk, aice_init(:,:,iblk), Cdn_atm(:,:,iblk), a2D) - if (f_sidragbot(1:1) /= 'x') then - call accum_hist_field(n_sidragbot, iblk, aice_init(:,:,iblk),Cdn_ocn(:,:,iblk), a2D) - endif + if (f_sidragbot (1:1) /= 'x') & + call accum_hist_field(n_sidragbot , iblk, aice_init(:,:,iblk), Cdn_ocn(:,:,iblk), a2D) - if (f_siforcetiltx(1:1) /= 'x') then - call accum_hist_field(n_siforcetiltx, iblk, aice_init(:,:,iblk),strtltxU(:,:,iblk), a2D) - endif + if (f_siforcetiltx(1:1) /= 'x') & + call accum_hist_field(n_siforcetiltx, iblk, aice_init(:,:,iblk), strtltxU(:,:,iblk), a2D) - if (f_siforcetilty(1:1) /= 'x') then - call accum_hist_field(n_siforcetilty, iblk, aice_init(:,:,iblk),strtltyU(:,:,iblk), a2D) - endif + if (f_siforcetilty(1:1) /= 'x') & + call accum_hist_field(n_siforcetilty, iblk, aice_init(:,:,iblk), strtltyU(:,:,iblk), a2D) if (f_siforcecoriolx(1:1) /= 'x') then worka(:,:) = c0 @@ -3190,76 +3125,64 @@ subroutine accum_hist (dt) call accum_hist_field(n_siforcecorioly, iblk, worka(:,:), a2D) endif - if (f_siforceintstrx(1:1) /= 'x') then + if (f_siforceintstrx(1:1) /= 'x') & call accum_hist_field(n_siforceintstrx, iblk, aice(:,:,iblk),strintxU(:,:,iblk), a2D) - endif - if (f_siforceintstry(1:1) /= 'x') then + if (f_siforceintstry(1:1) /= 'x') & call accum_hist_field(n_siforceintstry, iblk, aice(:,:,iblk),strintyU(:,:,iblk), a2D) - endif endif ! if (allocated(a2D)) if (allocated(a3Dc)) then ! 3D category fields - if (f_aicen (1:1) /= 'x') & - call accum_hist_field(n_aicen-n2D, iblk, ncat_hist, & - aicen(:,:,1:ncat_hist,iblk), a3Dc) - if (f_vicen (1:1) /= 'x') & - call accum_hist_field(n_vicen-n2D, iblk, ncat_hist, & - vicen(:,:,1:ncat_hist,iblk), a3Dc) - if (f_vsnon (1:1) /= 'x') & - call accum_hist_field(n_vsnon-n2D, iblk, ncat_hist, & - vsnon(:,:,1:ncat_hist,iblk), a3Dc) + if (f_aicen (1:1) /= 'x') & + call accum_hist_field(n_aicen-n2D , iblk, ncat_hist, aicen (:,:,1:ncat_hist,iblk), a3Dc) + if (f_vicen (1:1) /= 'x') & + call accum_hist_field(n_vicen-n2D , iblk, ncat_hist, vicen (:,:,1:ncat_hist,iblk), a3Dc) + if (f_vsnon (1:1) /= 'x') & + call accum_hist_field(n_vsnon-n2D , iblk, ncat_hist, vsnon (:,:,1:ncat_hist,iblk), a3Dc) if (f_snowfracn(1:1) /= 'x') & - call accum_hist_field(n_snowfracn-n2D, iblk, ncat_hist, & - snowfracn(:,:,1:ncat_hist,iblk), a3Dc) + call accum_hist_field(n_snowfracn-n2D , iblk, ncat_hist, snowfracn(:,:,1:ncat_hist,iblk), a3Dc) if (f_snowfracn(1:1) /= 'x') & - call accum_hist_field(n_snowfracn-n2D, iblk, ncat_hist, & - snowfracn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_keffn_top (1:1) /= 'x') & - call accum_hist_field(n_keffn_top-n2D, iblk, ncat_hist, & - keffn_top(:,:,1:ncat_hist,iblk), a3Dc) + call accum_hist_field(n_snowfracn-n2D , iblk, ncat_hist, snowfracn(:,:,1:ncat_hist,iblk), a3Dc) + if (f_keffn_top(1:1) /= 'x') & + call accum_hist_field(n_keffn_top-n2D , iblk, ncat_hist, keffn_top(:,:,1:ncat_hist,iblk), a3Dc) if (f_fsurfn_ai (1:1) /= 'x') then workc(:,:,1:ncat_hist) = fsurfn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) - call accum_hist_field(n_fsurfn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + call accum_hist_field(n_fsurfn_ai-n2D , iblk, ncat_hist, workc , a3Dc) endif - if (f_fcondtopn_ai (1:1) /= 'x') then + if (f_fcondtopn_ai(1:1) /= 'x') then workc(:,:,1:ncat_hist) = fcondtopn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) - call accum_hist_field(n_fcondtopn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + call accum_hist_field(n_fcondtopn_ai-n2D, iblk, ncat_hist, workc , a3Dc) endif - if (f_flatn_ai (1:1) /= 'x') then + if (f_flatn_ai (1:1) /= 'x') then workc(:,:,1:ncat_hist) = flatn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) - call accum_hist_field(n_flatn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + call accum_hist_field(n_flatn_ai-n2D , iblk, ncat_hist, workc , a3Dc) endif if (f_fsensn_ai (1:1) /= 'x') then workc(:,:,1:ncat_hist) = fsensn(:,:,1:ncat_hist,iblk)*aicen_init(:,:,1:ncat_hist,iblk) - call accum_hist_field(n_fsensn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + call accum_hist_field(n_fsensn_ai-n2D , iblk, ncat_hist, workc , a3Dc) endif ! Calculate surface heat flux that causes melt (calculated by the ! atmos in HadGEM3 so needed for checking purposes) if (f_fmelttn_ai (1:1) /= 'x') then workc(:,:,1:ncat_hist) = max(fsurfn(:,:,1:ncat_hist,iblk) - fcondtopn(:,:,1:ncat_hist,iblk),c0) & - *aicen_init(:,:,1:ncat_hist,iblk) - call accum_hist_field(n_fmelttn_ai-n2D, iblk, ncat_hist, workc, a3Dc) + *aicen_init(:,:,1:ncat_hist,iblk) + call accum_hist_field(n_fmelttn_ai-n2D , iblk, ncat_hist, workc , a3Dc) endif - if (f_siitdconc (1:1) /= 'x') then - call accum_hist_field(n_siitdconc-n2D, iblk, ncat_hist, aicen(:,:,:,iblk), a3Dc) - endif + if (f_siitdconc (1:1) /= 'x') & + call accum_hist_field(n_siitdconc-n2D , iblk, ncat_hist, aicen (:,:,:,iblk) , a3Dc) - if (f_siitdsnconc (1:1) /= 'x') then - call accum_hist_field(n_siitdsnconc-n2D, iblk, ncat_hist, snowfracn(:,:,:,iblk), a3Dc) - endif + if (f_siitdsnconc (1:1) /= 'x') & + call accum_hist_field(n_siitdsnconc-n2D , iblk, ncat_hist, snowfracn (:,:,:,iblk) , a3Dc) - if (f_siitdthick (1:1) /= 'x') then - call accum_hist_field(n_siitdthick-n2D, iblk, ncat_hist, vicen(:,:,:,iblk), a3Dc) - endif + if (f_siitdthick (1:1) /= 'x') & + call accum_hist_field(n_siitdthick-n2D , iblk, ncat_hist, vicen (:,:,:,iblk) , a3Dc) - if (f_siitdsnthick (1:1) /= 'x') then - call accum_hist_field(n_siitdsnthick-n2D, iblk, ncat_hist, vsnon(:,:,:,iblk), a3Dc) - endif + if (f_siitdsnthick (1:1) /= 'x') & + call accum_hist_field(n_siitdsnthick-n2D , iblk, ncat_hist, vsnon (:,:,:,iblk) , a3Dc) endif ! if (allocated(a3Dc)) diff --git a/cicecore/cicedyn/analysis/ice_history_bgc.F90 b/cicecore/cicedyn/analysis/ice_history_bgc.F90 index be92e9590..440128b33 100644 --- a/cicecore/cicedyn/analysis/ice_history_bgc.F90 +++ b/cicecore/cicedyn/analysis/ice_history_bgc.F90 @@ -1976,311 +1976,263 @@ subroutine accum_hist_bgc (iblk) ! 2d bgc fields if (allocated(a2D)) then - - if (tr_iso .or. tr_aero .or. tr_brine .or. skl_bgc) then - - ! isotopes - if (f_fiso_atm(1:1) /= 'x') then - do n=1,n_iso - call accum_hist_field(n_fiso_atm(n,:),iblk, & - fiso_atm(:,:,n,iblk), a2D) - enddo - endif - if (f_fiso_ocn(1:1) /= 'x') then - do n=1,n_iso - call accum_hist_field(n_fiso_ocn(n,:),iblk, & - fiso_ocn(:,:,n,iblk), a2D) - enddo - endif - if (f_iso(1:1) /= 'x') then - do n=1,n_iso - worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_isosno+n-1,iblk)/rhos - call accum_hist_field(n_isosno(n,:), iblk, worka, a2D) - worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_isoice+n-1,iblk)/rhos - call accum_hist_field(n_isoice(n,:), iblk, worka, a2D) - enddo - endif - - ! Aerosols - if (f_faero_atm(1:1) /= 'x') then - do n=1,n_aero - call accum_hist_field(n_faero_atm(n,:),iblk, & - faero_atm(:,:,n,iblk), a2D) - enddo - endif - if (f_faero_ocn(1:1) /= 'x') then - do n=1,n_aero - call accum_hist_field(n_faero_ocn(n,:),iblk, & - faero_ocn(:,:,n,iblk), a2D) - enddo - endif - if (f_aero(1:1) /= 'x') then - do n=1,n_aero - worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero +4*(n-1),iblk)/rhos - call accum_hist_field(n_aerosn1(n,:), iblk, worka, a2D) - worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+1+4*(n-1),iblk)/rhos - call accum_hist_field(n_aerosn2(n,:), iblk, worka, a2D) - worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+2+4*(n-1),iblk)/rhoi - call accum_hist_field(n_aeroic1(n,:), iblk, worka, a2D) - worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+3+4*(n-1),iblk)/rhoi - call accum_hist_field(n_aeroic2(n,:), iblk, worka, a2D) - enddo - endif - - if (skl_bgc) then - - ! skeletal layer bgc - - if (f_bgc_N(1:1)/= 'x') then - do n=1,n_algae - call accum_hist_field(n_bgc_N(n,:), iblk, trcr(:,:,nt_bgc_N(n), iblk), sk_l, a2D) - enddo - endif - if (f_bgc_C(1:1)/= 'x') then - do n=1,n_algae - worka(ilo:ihi,jlo:jhi) = sk_l*R_C2N(n)*trcr(ilo:ihi,jlo:jhi,nt_bgc_N(n), iblk) - call accum_hist_field(n_bgc_C(n,:), iblk, worka, a2D) - enddo - endif - if (f_bgc_DOC(1:1)/= 'x') then - do n=1,n_doc - call accum_hist_field(n_bgc_DOC(n,:), iblk, trcr(:,:,nt_bgc_DOC(n), iblk), sk_l, a2D) - enddo - endif - if (f_bgc_DIC(1:1)/= 'x') then - do n=1,n_dic - call accum_hist_field(n_bgc_DIC(n,:), iblk, trcr(:,:,nt_bgc_DIC(n), iblk), sk_l, a2D) - enddo - endif - if (f_bgc_DON(1:1)/= 'x') then - do n=1,n_don - call accum_hist_field(n_bgc_DON(n,:), iblk, trcr(:,:,nt_bgc_DON(n), iblk), sk_l, a2D) - enddo - endif - if (f_bgc_Fed (1:1)/= 'x') then - do n=1,n_fed - call accum_hist_field(n_bgc_Fed (n,:), iblk, trcr(:,:,nt_bgc_Fed (n), iblk), sk_l, a2D) - enddo - endif - if (f_bgc_Fep (1:1)/= 'x') then - do n=1,n_fep - call accum_hist_field(n_bgc_Fep (n,:), iblk, trcr(:,:,nt_bgc_Fep (n), iblk), sk_l, a2D) - enddo - endif - if (f_bgc_chl(1:1)/= 'x') then - do n=1,n_algae - call accum_hist_field(n_bgc_chl(n,:), iblk, trcr(:,:,nt_bgc_chl(n), iblk), sk_l, a2D) - enddo - endif - if (f_bgc_Nit(1:1)/= 'x') & - call accum_hist_field(n_bgc_Nit, iblk, trcr(:,:,nt_bgc_Nit, iblk), sk_l, a2D) - if (f_bgc_Am(1:1)/= 'x') & - call accum_hist_field(n_bgc_Am, iblk, trcr(:,:,nt_bgc_Am, iblk), sk_l, a2D) - if (f_bgc_Sil(1:1)/= 'x') & - call accum_hist_field(n_bgc_Sil, iblk, trcr(:,:,nt_bgc_Sil, iblk), sk_l, a2D) - if (f_bgc_hum(1:1)/= 'x') & - call accum_hist_field(n_bgc_hum, iblk, trcr(:,:,nt_bgc_hum, iblk), sk_l, a2D) - if (f_bgc_PON(1:1)/= 'x') & - call accum_hist_field(n_bgc_PON, iblk, trcr(:,:,nt_bgc_PON, iblk), sk_l, a2D) - if (f_bgc_DMSPp(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMSPp,iblk, trcr(:,:,nt_bgc_DMSPp,iblk), sk_l, a2D) - if (f_bgc_DMSPd(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMSPd,iblk, trcr(:,:,nt_bgc_DMSPd,iblk), sk_l, a2D) - if (f_bgc_DMS(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMS, iblk, trcr(:,:,nt_bgc_DMS, iblk), sk_l, a2D) - - endif !skl_bgc + worka(:,:) = c0 + if (tr_iso .or. tr_aero .or. tr_brine .or. skl_bgc) then + + ! isotopes + if (f_fiso_atm(1:1) /= 'x') then + do n=1,n_iso + call accum_hist_field(n_fiso_atm(n,:),iblk, fiso_atm(:,:,n,iblk), a2D) + enddo + endif + if (f_fiso_ocn(1:1) /= 'x') then + do n=1,n_iso + call accum_hist_field(n_fiso_ocn(n,:),iblk, fiso_ocn(:,:,n,iblk), a2D) + enddo + endif + if (f_iso(1:1) /= 'x') then + do n=1,n_iso + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_isosno+n-1,iblk)/rhos + call accum_hist_field(n_isosno(n,:), iblk, worka, a2D) + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_isoice+n-1,iblk)/rhos + call accum_hist_field(n_isoice(n,:), iblk, worka, a2D) + enddo + endif + + ! Aerosols + if (f_faero_atm(1:1) /= 'x') then + do n=1,n_aero + call accum_hist_field(n_faero_atm(n,:),iblk, faero_atm(:,:,n,iblk), a2D) + enddo + endif + if (f_faero_ocn(1:1) /= 'x') then + do n=1,n_aero + call accum_hist_field(n_faero_ocn(n,:),iblk, faero_ocn(:,:,n,iblk), a2D) + enddo + endif + if (f_aero(1:1) /= 'x') then + do n=1,n_aero + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero +4*(n-1),iblk)/rhos + call accum_hist_field(n_aerosn1(n,:), iblk, worka, a2D) + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+1+4*(n-1),iblk)/rhos + call accum_hist_field(n_aerosn2(n,:), iblk, worka, a2D) + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+2+4*(n-1),iblk)/rhoi + call accum_hist_field(n_aeroic1(n,:), iblk, worka, a2D) + worka(ilo:ihi,jlo:jhi) = trcr(ilo:ihi,jlo:jhi,nt_aero+3+4*(n-1),iblk)/rhoi + call accum_hist_field(n_aeroic2(n,:), iblk, worka, a2D) + enddo + endif + + if (skl_bgc) then + + ! skeletal layer bgc + + if (f_bgc_N(1:1)/= 'x') then + do n=1,n_algae + call accum_hist_field(n_bgc_N(n,:) , iblk, trcr(:,:,nt_bgc_N(n), iblk) , sk_l, a2D) + enddo + endif + if (f_bgc_C(1:1)/= 'x') then + do n=1,n_algae + worka(ilo:ihi,jlo:jhi) = sk_l*R_C2N(n)*trcr(ilo:ihi,jlo:jhi,nt_bgc_N(n), iblk) + call accum_hist_field(n_bgc_C(n,:) , iblk, worka , a2D) + enddo + endif + if (f_bgc_DOC(1:1)/= 'x') then + do n=1,n_doc + call accum_hist_field(n_bgc_DOC(n,:), iblk, trcr(:,:,nt_bgc_DOC(n), iblk), sk_l, a2D) + enddo + endif + if (f_bgc_DIC(1:1)/= 'x') then + do n=1,n_dic + call accum_hist_field(n_bgc_DIC(n,:), iblk, trcr(:,:,nt_bgc_DIC(n), iblk), sk_l, a2D) + enddo + endif + if (f_bgc_DON(1:1)/= 'x') then + do n=1,n_don + call accum_hist_field(n_bgc_DON(n,:), iblk, trcr(:,:,nt_bgc_DON(n), iblk), sk_l, a2D) + enddo + endif + if (f_bgc_Fed (1:1)/= 'x') then + do n=1,n_fed + call accum_hist_field(n_bgc_Fed (n,:),iblk, trcr(:,:,nt_bgc_Fed(n), iblk), sk_l, a2D) + enddo + endif + if (f_bgc_Fep (1:1)/= 'x') then + do n=1,n_fep + call accum_hist_field(n_bgc_Fep (n,:),iblk, trcr(:,:,nt_bgc_Fep(n), iblk), sk_l, a2D) + enddo + endif + if (f_bgc_chl(1:1)/= 'x') then + do n=1,n_algae + call accum_hist_field(n_bgc_chl(n,:),iblk, trcr(:,:,nt_bgc_chl (n), iblk), sk_l, a2D) + enddo + endif + if (f_bgc_Nit(1:1)/= 'x') & + call accum_hist_field(n_bgc_Nit , iblk, trcr(:,:,nt_bgc_Nit, iblk) , sk_l, a2D) + if (f_bgc_Am(1:1)/= 'x') & + call accum_hist_field(n_bgc_Am , iblk, trcr(:,:,nt_bgc_Am, iblk) , sk_l, a2D) + if (f_bgc_Sil(1:1)/= 'x') & + call accum_hist_field(n_bgc_Sil , iblk, trcr(:,:,nt_bgc_Sil, iblk) , sk_l, a2D) + if (f_bgc_hum(1:1)/= 'x') & + call accum_hist_field(n_bgc_hum , iblk, trcr(:,:,nt_bgc_hum, iblk) , sk_l, a2D) + if (f_bgc_PON(1:1)/= 'x') & + call accum_hist_field(n_bgc_PON , iblk, trcr(:,:,nt_bgc_PON, iblk) , sk_l, a2D) + if (f_bgc_DMSPp(1:1)/= 'x') & + call accum_hist_field(n_bgc_DMSPp, iblk, trcr(:,:,nt_bgc_DMSPp, iblk), sk_l, a2D) + if (f_bgc_DMSPd(1:1)/= 'x') & + call accum_hist_field(n_bgc_DMSPd, iblk, trcr(:,:,nt_bgc_DMSPd, iblk), sk_l, a2D) + if (f_bgc_DMS(1:1)/= 'x') & + call accum_hist_field(n_bgc_DMS , iblk, trcr(:,:,nt_bgc_DMS, iblk) , sk_l, a2D) + + endif !skl_bgc ! skeletal layer and vertical bgc if (f_bgc_DOC_ml(1:1)/= 'x') then do n=1,n_doc - call accum_hist_field(n_bgc_DOC_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_DOC(n), iblk), a2D) + call accum_hist_field(n_bgc_DOC_ml(n,:), iblk, ocean_bio(:,:,nlt_bgc_DOC(n), iblk), a2D) enddo endif if (f_bgc_DIC_ml(1:1)/= 'x') then do n=1,n_dic - call accum_hist_field(n_bgc_DIC_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_DIC(n), iblk), a2D) + call accum_hist_field(n_bgc_DIC_ml(n,:), iblk, ocean_bio(:,:,nlt_bgc_DIC(n), iblk), a2D) enddo endif if (f_bgc_DON_ml(1:1)/= 'x') then do n=1,n_don - call accum_hist_field(n_bgc_DON_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_DON(n), iblk), a2D) + call accum_hist_field(n_bgc_DON_ml(n,:), iblk, ocean_bio(:,:,nlt_bgc_DON(n), iblk), a2D) enddo endif - if (f_bgc_Fed_ml (1:1)/= 'x') then + if (f_bgc_Fed_ml(1:1)/= 'x') then do n=1,n_fed - call accum_hist_field(n_bgc_Fed_ml (n,:), iblk, & - ocean_bio(:,:,nlt_bgc_Fed (n), iblk), a2D) + call accum_hist_field(n_bgc_Fed_ml(n,:), iblk, ocean_bio(:,:,nlt_bgc_Fed(n), iblk), a2D) enddo endif - if (f_bgc_Fep_ml (1:1)/= 'x') then + if (f_bgc_Fep_ml(1:1)/= 'x') then do n=1,n_fep - call accum_hist_field(n_bgc_Fep_ml (n,:), iblk, & - ocean_bio(:,:,nlt_bgc_Fep (n), iblk), a2D) + call accum_hist_field(n_bgc_Fep_ml(n,:), iblk, ocean_bio(:,:,nlt_bgc_Fep(n), iblk), a2D) enddo endif - if (f_bgc_N_ml(1:1)/= 'x') then + if (f_bgc_N_ml (1:1)/= 'x') then do n=1,n_algae - call accum_hist_field(n_bgc_N_ml(n,:), iblk, & - ocean_bio(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_bgc_N_ml (n,:), iblk, ocean_bio(:,:,nlt_bgc_N (n), iblk), a2D) enddo endif - if (f_bgc_Nit_ml(1:1)/= 'x') & - call accum_hist_field(n_bgc_Nit_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Nit, iblk), a2D) - if (f_bgc_Am_ml(1:1)/= 'x') & - call accum_hist_field(n_bgc_Am_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Am, iblk), a2D) - if (f_bgc_Sil_ml(1:1)/= 'x') & - call accum_hist_field(n_bgc_Sil_ml, iblk, & - ocean_bio(:,:,nlt_bgc_Sil, iblk), a2D) - if (f_bgc_hum_ml(1:1)/= 'x') & - call accum_hist_field(n_bgc_hum_ml, iblk, & - ocean_bio(:,:,nlt_bgc_hum, iblk), a2D) - if (f_bgc_DMSP_ml(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMSP_ml, iblk, & - ocean_bio(:,:,nlt_bgc_DMSPd, iblk), a2D) - if (f_bgc_DMS_ml(1:1)/= 'x') & - call accum_hist_field(n_bgc_DMS_ml, iblk, & - ocean_bio(:,:,nlt_bgc_DMS, iblk), a2D) - - if (f_fNit (1:1) /= 'x') & - call accum_hist_field(n_fNit, iblk, & - flux_bio(:,:,nlt_bgc_Nit,iblk), a2D) - if (f_fNit_ai(1:1)/= 'x') & - call accum_hist_field(n_fNit_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_Nit,iblk), a2D) - - if (f_fAm (1:1) /= 'x') & - call accum_hist_field(n_fAm, iblk, & - flux_bio(:,:,nlt_bgc_Am,iblk), a2D) - if (f_fAm_ai(1:1)/= 'x') & - call accum_hist_field(n_fAm_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_Am,iblk), a2D) - if (f_fN(1:1)/= 'x') then + if (f_bgc_Nit_ml (1:1) /= 'x') & + call accum_hist_field(n_bgc_Nit_ml , iblk, ocean_bio(:,:,nlt_bgc_Nit , iblk), a2D) + if (f_bgc_Am_ml (1:1) /= 'x') & + call accum_hist_field(n_bgc_Am_ml , iblk, ocean_bio(:,:,nlt_bgc_Am , iblk), a2D) + if (f_bgc_Sil_ml (1:1) /= 'x') & + call accum_hist_field(n_bgc_Sil_ml , iblk, ocean_bio(:,:,nlt_bgc_Sil , iblk), a2D) + if (f_bgc_hum_ml (1:1) /= 'x') & + call accum_hist_field(n_bgc_hum_ml , iblk, ocean_bio(:,:,nlt_bgc_hum , iblk), a2D) + if (f_bgc_DMSP_ml(1:1) /= 'x') & + call accum_hist_field(n_bgc_DMSP_ml, iblk, ocean_bio(:,:,nlt_bgc_DMSPd, iblk), a2D) + if (f_bgc_DMS_ml (1:1) /= 'x') & + call accum_hist_field(n_bgc_DMS_ml , iblk, ocean_bio(:,:,nlt_bgc_DMS , iblk), a2D) + + if (f_fNit (1:1) /= 'x') & + call accum_hist_field(n_fNit , iblk, flux_bio (:,:,nlt_bgc_Nit,iblk), a2D) + if (f_fNit_ai(1:1) /= 'x') & + call accum_hist_field(n_fNit_ai, iblk, flux_bio_ai(:,:,nlt_bgc_Nit,iblk), a2D) + + if (f_fAm (1:1) /= 'x') & + call accum_hist_field(n_fAm , iblk, flux_bio (:,:,nlt_bgc_Am ,iblk), a2D) + if (f_fAm_ai (1:1) /= 'x') & + call accum_hist_field(n_fAm_ai , iblk, flux_bio_ai(:,:,nlt_bgc_Am ,iblk), a2D) + if (f_fN (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_fN(n,:), iblk, & - flux_bio(:,:,nlt_bgc_N(n),iblk), a2D) + call accum_hist_field(n_fN (n,:), iblk, flux_bio (:,:,nlt_bgc_N (n), iblk), a2D) enddo endif - if (f_fN_ai(1:1)/= 'x') then + if (f_fN_ai (1:1)/= 'x') then do n=1,n_algae - call accum_hist_field(n_fN_ai(n,:), iblk, & - flux_bio_ai(:,:,nlt_bgc_N(n),iblk), a2D) + call accum_hist_field(n_fN_ai (n,:), iblk, flux_bio_ai(:,:,nlt_bgc_N (n), iblk), a2D) enddo endif - if (f_fDOC(1:1)/= 'x') then + if (f_fDOC (1:1)/= 'x') then do n=1,n_doc - call accum_hist_field(n_fDOC(n,:), iblk, & - flux_bio(:,:,nlt_bgc_DOC(n),iblk), a2D) + call accum_hist_field(n_fDOC (n,:), iblk, flux_bio (:,:,nlt_bgc_DOC(n), iblk), a2D) enddo endif if (f_fDOC_ai(1:1)/= 'x') then do n=1,n_doc - call accum_hist_field(n_fDOC_ai(n,:), iblk, & - flux_bio_ai(:,:,nlt_bgc_DOC(n),iblk), a2D) + call accum_hist_field(n_fDOC_ai(n,:), iblk, flux_bio_ai(:,:,nlt_bgc_DOC(n), iblk), a2D) enddo endif - if (f_fDIC(1:1)/= 'x') then + if (f_fDIC (1:1)/= 'x') then do n=1,n_dic - call accum_hist_field(n_fDIC(n,:), iblk, & - flux_bio(:,:,nlt_bgc_DIC(n),iblk), a2D) + call accum_hist_field(n_fDIC (n,:), iblk, flux_bio(:,:,nlt_bgc_DIC (n), iblk), a2D) enddo endif if (f_fDIC_ai(1:1)/= 'x') then do n=1,n_dic - call accum_hist_field(n_fDIC_ai(n,:), iblk, & - flux_bio_ai(:,:,nlt_bgc_DIC(n),iblk), a2D) + call accum_hist_field(n_fDIC_ai(n,:), iblk, flux_bio_ai(:,:,nlt_bgc_DIC(n), iblk), a2D) enddo endif - if (f_fDON(1:1)/= 'x') then + if (f_fDON (1:1)/= 'x') then do n=1,n_don - call accum_hist_field(n_fDON(n,:), iblk, & - flux_bio(:,:,nlt_bgc_DON(n),iblk), a2D) + call accum_hist_field(n_fDON (n,:), iblk, flux_bio (:,:,nlt_bgc_DON(n), iblk), a2D) enddo endif if (f_fDON_ai(1:1)/= 'x') then do n=1,n_don - call accum_hist_field(n_fDON_ai(n,:), iblk, & - flux_bio_ai(:,:,nlt_bgc_DON(n),iblk), a2D) + call accum_hist_field(n_fDON_ai(n,:), iblk, flux_bio_ai(:,:,nlt_bgc_DON(n), iblk), a2D) enddo endif - if (f_fFed (1:1)/= 'x') then + if (f_fFed (1:1)/= 'x') then do n=1,n_fed - call accum_hist_field(n_fFed (n,:), iblk, & - flux_bio(:,:,nlt_bgc_Fed (n),iblk), a2D) + call accum_hist_field(n_fFed (n,:), iblk, flux_bio (:,:,nlt_bgc_Fed(n), iblk), a2D) enddo endif - if (f_fFed_ai (1:1)/= 'x') then + if (f_fFed_ai(1:1)/= 'x') then do n=1,n_fed - call accum_hist_field(n_fFed_ai (n,:), iblk, & - flux_bio_ai(:,:,nlt_bgc_Fed (n),iblk), a2D) + call accum_hist_field(n_fFed_ai(n,:), iblk,flux_bio_ai(:,:,nlt_bgc_Fed (n), iblk), a2D) enddo endif - if (f_fFep (1:1)/= 'x') then + if (f_fFep (1:1)/= 'x') then do n=1,n_fep - call accum_hist_field(n_fFep (n,:), iblk, & - flux_bio(:,:,nlt_bgc_Fep (n),iblk), a2D) + call accum_hist_field(n_fFep (n,:), iblk, flux_bio (:,:,nlt_bgc_Fep (n),iblk) , a2D) enddo endif - if (f_fFep_ai (1:1)/= 'x') then + if (f_fFep_ai(1:1)/= 'x') then do n=1,n_fep - call accum_hist_field(n_fFep_ai (n,:), iblk, & - flux_bio_ai(:,:,nlt_bgc_Fep (n),iblk), a2D) + call accum_hist_field(n_fFep_ai (n,:), iblk,flux_bio_ai(:,:,nlt_bgc_Fep (n),iblk), a2D) enddo endif - if (f_fSil (1:1) /= 'x') & - call accum_hist_field(n_fSil, iblk, & - flux_bio(:,:,nlt_bgc_Sil,iblk), a2D) - if (f_fSil_ai(1:1)/= 'x') & - call accum_hist_field(n_fSil_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_Sil,iblk), a2D) - if (f_fhum (1:1) /= 'x') & - call accum_hist_field(n_fhum, iblk, & - flux_bio(:,:,nlt_bgc_hum,iblk), a2D) - if (f_fhum_ai(1:1)/= 'x') & - call accum_hist_field(n_fhum_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_hum,iblk), a2D) - if (f_fPON (1:1) /= 'x') & - call accum_hist_field(n_fPON, iblk, & - flux_bio(:,:,nlt_bgc_PON,iblk), a2D) - if (f_fPON_ai(1:1)/= 'x') & - call accum_hist_field(n_fPON_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_PON,iblk), a2D) - if (f_fDMS (1:1) /= 'x') & - call accum_hist_field(n_fDMS, iblk, & - flux_bio(:,:,nlt_bgc_DMS,iblk), a2D) - if (f_fDMS_ai(1:1)/= 'x') & - call accum_hist_field(n_fDMS_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_DMS,iblk), a2D) - if (f_fDMSPd (1:1) /= 'x') & - call accum_hist_field(n_fDMSPd, iblk, & - flux_bio(:,:,nlt_bgc_DMSPd,iblk), a2D) - if (f_fDMSPd_ai(1:1)/= 'x') & - call accum_hist_field(n_fDMSPd_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_DMSPd,iblk), a2D) - if (f_fDMSPp (1:1) /= 'x') & - call accum_hist_field(n_fDMSPp, iblk, & - flux_bio(:,:,nlt_bgc_DMSPp,iblk), a2D) - if (f_fDMSPp_ai(1:1)/= 'x') & - call accum_hist_field(n_fDMSPp_ai, iblk, & - flux_bio_ai(:,:,nlt_bgc_DMSPp,iblk), a2D) - if (f_PPnet (1:1) /= 'x') & - call accum_hist_field(n_PPnet, iblk, & - PP_net(:,:,iblk), a2D) + if (f_fSil (1:1) /= 'x') & + call accum_hist_field(n_fSil , iblk, flux_bio (:,:,nlt_bgc_Sil,iblk) , a2D) + if (f_fSil_ai (1:1) /= 'x') & + call accum_hist_field(n_fSil_ai , iblk, flux_bio_ai(:,:,nlt_bgc_Sil,iblk) , a2D) + if (f_fhum (1:1) /= 'x') & + call accum_hist_field(n_fhum , iblk, flux_bio (:,:,nlt_bgc_hum,iblk) , a2D) + if (f_fhum_ai (1:1) /= 'x') & + call accum_hist_field(n_fhum_ai , iblk, flux_bio_ai(:,:,nlt_bgc_hum,iblk) , a2D) + if (f_fPON (1:1) /= 'x') & + call accum_hist_field(n_fPON , iblk, flux_bio (:,:,nlt_bgc_PON,iblk) , a2D) + if (f_fPON_ai (1:1) /= 'x') & + call accum_hist_field(n_fPON_ai , iblk, flux_bio_ai(:,:,nlt_bgc_PON,iblk) , a2D) + if (f_fDMS (1:1) /= 'x') & + call accum_hist_field(n_fDMS , iblk, flux_bio (:,:,nlt_bgc_DMS,iblk) , a2D) + if (f_fDMS_ai (1:1) /= 'x') & + call accum_hist_field(n_fDMS_ai , iblk, flux_bio_ai(:,:,nlt_bgc_DMS,iblk) , a2D) + if (f_fDMSPd (1:1) /= 'x') & + call accum_hist_field(n_fDMSPd , iblk, flux_bio (:,:,nlt_bgc_DMSPd,iblk), a2D) + if (f_fDMSPd_ai(1:1) /= 'x') & + call accum_hist_field(n_fDMSPd_ai, iblk, flux_bio_ai(:,:,nlt_bgc_DMSPd,iblk), a2D) + if (f_fDMSPp (1:1) /= 'x') & + call accum_hist_field(n_fDMSPp , iblk, flux_bio (:,:,nlt_bgc_DMSPp,iblk), a2D) + if (f_fDMSPp_ai(1:1) /= 'x') & + call accum_hist_field(n_fDMSPp_ai, iblk, flux_bio_ai(:,:,nlt_bgc_DMSPp,iblk), a2D) + if (f_PPnet (1:1) /= 'x') & + call accum_hist_field(n_PPnet , iblk, PP_net (:,:,iblk) , a2D) if (f_grownet (1:1) /= 'x') & - call accum_hist_field(n_grownet, iblk, & - grow_net(:,:,iblk), a2D) - if (f_upNO (1:1) /= 'x') & - call accum_hist_field(n_upNO, iblk, & - upNO(:,:,iblk), a2D) - if (f_upNH (1:1) /= 'x') & - call accum_hist_field(n_upNH, iblk, & - upNH(:,:,iblk), a2D) + call accum_hist_field(n_grownet , iblk, grow_net (:,:,iblk) , a2D) + if (f_upNO (1:1) /= 'x') & + call accum_hist_field(n_upNO , iblk, upNO (:,:,iblk) , a2D) + if (f_upNH (1:1) /= 'x') & + call accum_hist_field(n_upNH , iblk, upNH (:,:,iblk) , a2D) ! vertical biogeochemistry @@ -2288,14 +2240,12 @@ subroutine accum_hist_bgc (iblk) if (f_fzaero(1:1)/= 'x') then do n=1,n_zaero - call accum_hist_field(n_fzaero(n,:), iblk, & - flux_bio(:,:,nlt_zaero(n),iblk), a2D) + call accum_hist_field(n_fzaero (n,:), iblk, flux_bio (:,:,nlt_zaero(n), iblk), a2D) enddo endif if (f_fzaero_ai(1:1)/= 'x') then do n=1,n_zaero - call accum_hist_field(n_fzaero_ai(n,:), iblk, & - flux_bio_ai(:,:,nlt_zaero(n),iblk), a2D) + call accum_hist_field(n_fzaero_ai(n,:), iblk, flux_bio_ai(:,:,nlt_zaero(n), iblk), a2D) enddo endif if (f_algalpeak (1:1) /= 'x') then @@ -2316,10 +2266,8 @@ subroutine accum_hist_bgc (iblk) worknj(i,j) = maxv enddo ! i enddo ! j - call accum_hist_field(n_algalpeak(n,:), iblk, & - workni(:,:), a2D) - call accum_hist_field(n_peakval(n,:), iblk, & - worknj(:,:), a2D) + call accum_hist_field(n_algalpeak(n,:), iblk, workni(:,:), a2D) + call accum_hist_field(n_peakval (n,:), iblk, worknj(:,:), a2D) enddo ! n endif !f_algalpeak @@ -2328,177 +2276,145 @@ subroutine accum_hist_bgc (iblk) ! if (f_zaeronet (1:1) /= 'x') then do n=1,n_zaero - call accum_hist_field(n_zaeronet(n,:), iblk, & - ice_bio_net(:,:,nlt_zaero(n), iblk), a2D) + call accum_hist_field(n_zaeronet(n,:), iblk, ice_bio_net(:,:,nlt_zaero (n), iblk) , a2D) enddo endif !f_zaeronet - if (f_chlnet (1:1) /= 'x') then + if (f_chlnet (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_chlnet(n,:), iblk, ice_bio_net(:,:,nlt_bgc_N(n), iblk), R_chl2N(n), a2D) + call accum_hist_field(n_chlnet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_N (n), iblk), R_chl2N(n), a2D) enddo endif !f_chlnet - if (f_Nnet (1:1) /= 'x') then + if (f_Nnet (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_Nnet(n,:), iblk, & - ice_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_Nnet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_N (n), iblk) , a2D) enddo endif !f_Nnet - if (f_Cnet (1:1) /= 'x') then + if (f_Cnet (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_Cnet(n,:), iblk, ice_bio_net(:,:,nlt_bgc_N(n), iblk), R_C2N(n), a2D) + call accum_hist_field(n_Cnet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_N (n), iblk), R_C2N (n), a2D) enddo endif !f_Cnet - if (f_DOCnet (1:1) /= 'x') then + if (f_DOCnet (1:1) /= 'x') then do n=1,n_doc - call accum_hist_field(n_DOCnet(n,:), iblk, & - ice_bio_net(:,:,nlt_bgc_DOC(n), iblk), a2D) + call accum_hist_field(n_DOCnet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_DOC(n), iblk) , a2D) enddo endif !f_DOCnet - if (f_DICnet (1:1) /= 'x') then + if (f_DICnet (1:1) /= 'x') then do n=1,n_dic - call accum_hist_field(n_DICnet(n,:), iblk, & - ice_bio_net(:,:,nlt_bgc_DIC(n), iblk), a2D) + call accum_hist_field(n_DICnet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_DIC(n), iblk) , a2D) enddo endif !f_DICnet - if (f_DONnet (1:1) /= 'x') then + if (f_DONnet (1:1) /= 'x') then do n=1,n_don - call accum_hist_field(n_DONnet(n,:), iblk, & - ice_bio_net(:,:,nlt_bgc_DON(n), iblk), a2D) + call accum_hist_field(n_DONnet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_DON(n), iblk) , a2D) enddo endif !f_DONnet if (f_Fednet (1:1) /= 'x') then do n=1,n_fed - call accum_hist_field(n_Fednet (n,:), iblk, & - ice_bio_net(:,:,nlt_bgc_Fed (n), iblk), a2D) + call accum_hist_field(n_Fednet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_Fed(n), iblk) , a2D) enddo endif !f_Fednet if (f_Fepnet (1:1) /= 'x') then do n=1,n_fep - call accum_hist_field(n_Fepnet (n,:), iblk, & - ice_bio_net(:,:,nlt_bgc_Fep (n), iblk), a2D) + call accum_hist_field(n_Fepnet (n,:), iblk, ice_bio_net(:,:,nlt_bgc_Fep(n), iblk) , a2D) enddo endif !f_Fepnet - if (f_Nitnet (1:1) /= 'x') & - call accum_hist_field(n_Nitnet, iblk, & - ice_bio_net(:,:,nlt_bgc_Nit, iblk), a2D) - if (f_Amnet (1:1) /= 'x') & - call accum_hist_field(n_Amnet, iblk, & - ice_bio_net(:,:,nlt_bgc_Am, iblk), a2D) - if (f_Silnet (1:1) /= 'x') & - call accum_hist_field(n_Silnet, iblk, & - ice_bio_net(:,:,nlt_bgc_Sil, iblk), a2D) - if (f_humnet (1:1) /= 'x') & - call accum_hist_field(n_humnet, iblk, & - ice_bio_net(:,:,nlt_bgc_hum, iblk), a2D) + if (f_Nitnet (1:1) /= 'x') & + call accum_hist_field(n_Nitnet , iblk, ice_bio_net(:,:,nlt_bgc_Nit , iblk), a2D) + if (f_Amnet (1:1) /= 'x') & + call accum_hist_field(n_Amnet , iblk, ice_bio_net(:,:,nlt_bgc_Am , iblk), a2D) + if (f_Silnet (1:1) /= 'x') & + call accum_hist_field(n_Silnet , iblk, ice_bio_net(:,:,nlt_bgc_Sil , iblk), a2D) + if (f_humnet (1:1) /= 'x') & + call accum_hist_field(n_humnet , iblk, ice_bio_net(:,:,nlt_bgc_hum , iblk), a2D) if (f_DMSPpnet (1:1) /= 'x') & - call accum_hist_field(n_DMSPpnet, iblk, & - ice_bio_net(:,:,nlt_bgc_DMSPp, iblk), a2D) + call accum_hist_field(n_DMSPpnet, iblk, ice_bio_net(:,:,nlt_bgc_DMSPp, iblk), a2D) if (f_DMSPdnet (1:1) /= 'x') & - call accum_hist_field(n_DMSPdnet, iblk, & - ice_bio_net(:,:,nlt_bgc_DMSPd, iblk), a2D) - if (f_DMSnet (1:1) /= 'x') & - call accum_hist_field(n_DMSnet, iblk, & - ice_bio_net(:,:,nlt_bgc_DMS, iblk), a2D) - if (f_PONnet (1:1) /= 'x') & - call accum_hist_field(n_PONnet, iblk, & - ice_bio_net(:,:,nlt_bgc_PON, iblk), a2D) + call accum_hist_field(n_DMSPdnet, iblk, ice_bio_net(:,:,nlt_bgc_DMSPd, iblk), a2D) + if (f_DMSnet (1:1) /= 'x') & + call accum_hist_field(n_DMSnet , iblk, ice_bio_net(:,:,nlt_bgc_DMS , iblk), a2D) + if (f_PONnet (1:1) /= 'x') & + call accum_hist_field(n_PONnet , iblk, ice_bio_net(:,:,nlt_bgc_PON , iblk), a2D) ! ! snow_bio_net ! if (f_zaerosnow (1:1) /= 'x') then do n=1,n_zaero - call accum_hist_field(n_zaerosnow(n,:), iblk, & - snow_bio_net(:,:,nlt_zaero(n), iblk), a2D) + call accum_hist_field(n_zaerosnow(n,:), iblk, snow_bio_net(:,:,nlt_zaero(n) , iblk) , a2D) enddo endif !f_zaerosnow - if (f_chlsnow (1:1) /= 'x') then + if (f_chlsnow (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_chlsnow(n,:), iblk, snow_bio_net(:,:,nlt_bgc_N(n), iblk), R_chl2N(n), a2D) + call accum_hist_field(n_chlsnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_N(n) , iblk), R_chl2N(n), a2D) enddo endif !f_chlsnow - if (f_Nsnow (1:1) /= 'x') then + if (f_Nsnow (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_Nsnow(n,:), iblk, & - snow_bio_net(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_Nsnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_N(n) , iblk) , a2D) enddo endif !f_Nsnow - if (f_Csnow (1:1) /= 'x') then + if (f_Csnow (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_Csnow(n,:), iblk, snow_bio_net(:,:,nlt_bgc_N(n), iblk), R_C2N(n), a2D) + call accum_hist_field(n_Csnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_N(n) , iblk), R_C2N (n), a2D) enddo endif !f_Csnow - if (f_DOCsnow (1:1) /= 'x') then + if (f_DOCsnow (1:1) /= 'x') then do n=1,n_doc - call accum_hist_field(n_DOCsnow(n,:), iblk, & - snow_bio_net(:,:,nlt_bgc_DOC(n), iblk), a2D) + call accum_hist_field(n_DOCsnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_DOC(n), iblk) , a2D) enddo endif !f_DOCsnow - if (f_DICsnow (1:1) /= 'x') then + if (f_DICsnow (1:1) /= 'x') then do n=1,n_dic - call accum_hist_field(n_DICsnow(n,:), iblk, & - snow_bio_net(:,:,nlt_bgc_DIC(n), iblk), a2D) + call accum_hist_field(n_DICsnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_DIC(n), iblk) , a2D) enddo endif !f_DICsnow - if (f_DONsnow (1:1) /= 'x') then + if (f_DONsnow (1:1) /= 'x') then do n=1,n_don - call accum_hist_field(n_DONsnow(n,:), iblk, & - snow_bio_net(:,:,nlt_bgc_DON(n), iblk), a2D) + call accum_hist_field(n_DONsnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_DON(n), iblk) , a2D) enddo endif !f_DONsnow if (f_Fedsnow (1:1) /= 'x') then do n=1,n_fed - call accum_hist_field(n_Fedsnow (n,:), iblk, & - snow_bio_net(:,:,nlt_bgc_Fed (n), iblk), a2D) + call accum_hist_field(n_Fedsnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_Fed(n), iblk) , a2D) enddo endif !f_Fedsnow if (f_Fepsnow (1:1) /= 'x') then do n=1,n_fep - call accum_hist_field(n_Fepsnow (n,:), iblk, & - snow_bio_net(:,:,nlt_bgc_Fep (n), iblk), a2D) + call accum_hist_field(n_Fepsnow (n,:), iblk, snow_bio_net(:,:,nlt_bgc_Fep (n), iblk) , a2D) enddo endif !f_Fepsnow if (f_Nitsnow (1:1) /= 'x') & - call accum_hist_field(n_Nitsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_Nit, iblk), a2D) - if (f_Amsnow (1:1) /= 'x') & - call accum_hist_field(n_Amsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_Am, iblk), a2D) + call accum_hist_field(n_Nitsnow , iblk, snow_bio_net(:,:,nlt_bgc_Nit , iblk), a2D) + if (f_Amsnow (1:1) /= 'x') & + call accum_hist_field(n_Amsnow , iblk, snow_bio_net(:,:,nlt_bgc_Am , iblk), a2D) if (f_Silsnow (1:1) /= 'x') & - call accum_hist_field(n_Silsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_Sil, iblk), a2D) + call accum_hist_field(n_Silsnow , iblk, snow_bio_net(:,:,nlt_bgc_Sil , iblk), a2D) if (f_humsnow (1:1) /= 'x') & - call accum_hist_field(n_humsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_hum, iblk), a2D) - if (f_DMSPpsnow (1:1) /= 'x') & - call accum_hist_field(n_DMSPpsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_DMSPp, iblk), a2D) - if (f_DMSPdsnow (1:1) /= 'x') & - call accum_hist_field(n_DMSPdsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_DMSPd, iblk), a2D) + call accum_hist_field(n_humsnow , iblk, snow_bio_net(:,:,nlt_bgc_hum , iblk), a2D) + if (f_DMSPpsnow(1:1) /= 'x') & + call accum_hist_field(n_DMSPpsnow, iblk, snow_bio_net(:,:,nlt_bgc_DMSPp, iblk), a2D) + if (f_DMSPdsnow(1:1) /= 'x') & + call accum_hist_field(n_DMSPdsnow, iblk, snow_bio_net(:,:,nlt_bgc_DMSPd, iblk), a2D) if (f_DMSsnow (1:1) /= 'x') & - call accum_hist_field(n_DMSsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_DMS, iblk), a2D) + call accum_hist_field(n_DMSsnow , iblk, snow_bio_net(:,:,nlt_bgc_DMS , iblk), a2D) if (f_PONsnow (1:1) /= 'x') & - call accum_hist_field(n_PONsnow, iblk, & - snow_bio_net(:,:,nlt_bgc_PON, iblk), a2D) + call accum_hist_field(n_PONsnow , iblk, snow_bio_net(:,:,nlt_bgc_PON , iblk), a2D) ! ! mobile frac ! - if (f_zaerofrac (1:1) /= 'x') then + if (f_zaerofrac(1:1) /= 'x') then do n=1,n_zaero - call accum_hist_field(n_zaerofrac(n,:), iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_zaero(n), iblk), a2D) + call accum_hist_field(n_zaerofrac(n,:), iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_zaero(n), iblk), a2D) enddo endif !f_zaerofrac if (f_chlfrac (1:1) /= 'x') then do n=1,n_algae - call accum_hist_field(n_chlfrac(n,:), iblk, & - trcr(:,:,nlt_bgc_N(n), iblk), a2D) + call accum_hist_field(n_chlfrac(n,:), iblk, trcr(:,:,nlt_bgc_N(n), iblk), a2D) enddo endif !f_chlfrac - if (f_Nfrac (1:1) /= 'x') then + if (f_Nfrac (1:1) /= 'x') then do n=1,n_algae call accum_hist_field(n_Nfrac(n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_N(n), iblk), a2D) @@ -2522,13 +2438,13 @@ subroutine accum_hist_bgc (iblk) trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DON(n), iblk), a2D) enddo endif !f_DONfrac - if (f_Fedfrac (1:1) /= 'x') then + if (f_Fedfrac (1:1) /= 'x') then do n=1,n_fed call accum_hist_field(n_Fedfrac (n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Fed (n), iblk), a2D) enddo endif !f_Fedfrac - if (f_Fepfrac (1:1) /= 'x') then + if (f_Fepfrac (1:1) /= 'x') then do n=1,n_fep call accum_hist_field(n_Fepfrac (n,:), iblk, & trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Fep (n), iblk), a2D) @@ -2536,36 +2452,27 @@ subroutine accum_hist_bgc (iblk) endif !f_Fepfrac if (f_Nitfrac (1:1) /= 'x') & - call accum_hist_field(n_Nitfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Nit, iblk), a2D) - if (f_Amfrac (1:1) /= 'x') & - call accum_hist_field(n_Amfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Am, iblk), a2D) + call accum_hist_field(n_Nitfrac , iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Nit , iblk), a2D) + if (f_Amfrac (1:1) /= 'x') & + call accum_hist_field(n_Amfrac , iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Am , iblk), a2D) if (f_Silfrac (1:1) /= 'x') & - call accum_hist_field(n_Silfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Sil, iblk), a2D) + call accum_hist_field(n_Silfrac , iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_Sil , iblk), a2D) if (f_humfrac (1:1) /= 'x') & - call accum_hist_field(n_humfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_hum, iblk), a2D) - if (f_DMSPpfrac (1:1) /= 'x') & - call accum_hist_field(n_DMSPpfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMSPp, iblk), a2D) + call accum_hist_field(n_humfrac , iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_hum , iblk), a2D) + if (f_DMSPpfrac(1:1) /= 'x') & + call accum_hist_field(n_DMSPpfrac, iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMSPp, iblk), a2D) if (f_DMSPdfrac (1:1) /= 'x') & - call accum_hist_field(n_DMSPdfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMSPd, iblk), a2D) + call accum_hist_field(n_DMSPdfrac, iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMSPd, iblk), a2D) if (f_DMSfrac (1:1) /= 'x') & - call accum_hist_field(n_DMSfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMS, iblk), a2D) + call accum_hist_field(n_DMSfrac , iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_DMS , iblk), a2D) if (f_PONfrac (1:1) /= 'x') & - call accum_hist_field(n_PONfrac, iblk, & - trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_PON, iblk), a2D) + call accum_hist_field(n_PONfrac , iblk, trcr(:,:,nt_zbgc_frac - 1 + nlt_bgc_PON , iblk), a2D) endif ! z_tracers ! brine if (f_hbri (1:1) /= 'x') & - call accum_hist_field(n_hbri, iblk, & - hbri(:,:,iblk), a2D) + call accum_hist_field(n_hbri, iblk, hbri(:,:,iblk), a2D) endif ! 2d bgc tracers, tr_aero, tr_brine, skl_bgc endif ! allocated(a2D) @@ -2577,8 +2484,7 @@ subroutine accum_hist_bgc (iblk) ! 3Dc bgc category fields if (f_fbri (1:1) /= 'x') & - call accum_hist_field(n_fbri-n2D, iblk, ncat_hist, & - trcrn(:,:,nt_fbri,1:ncat_hist,iblk), a3Dc) + call accum_hist_field(n_fbri-n2D, iblk, ncat_hist, trcrn(:,:,nt_fbri,1:ncat_hist,iblk), a3Dc) endif endif ! allocated(a3Dc) @@ -2592,14 +2498,13 @@ subroutine accum_hist_bgc (iblk) do j = jlo, jhi do i = ilo, ihi if (aicen(i,j,n,iblk) > c0) then - workz(i,j,1:nzblyr) = workz(i,j,1:nzblyr) + bTiz(i,j,1:nzblyr,n,iblk)*& - aicen(i,j,n,iblk) + workz(i,j,1:nzblyr) = workz(i,j,1:nzblyr) + bTiz(i,j,1:nzblyr,n,iblk) & + * aicen(i,j,n,iblk) endif enddo ! i enddo ! j enddo ! n - call accum_hist_field(n_bTin-n3Dzcum, iblk, nzblyr, & - workz(:,:,1:nzblyr), a3Db) + call accum_hist_field(n_bTin-n3Dzcum, iblk, nzblyr, workz(:,:,1:nzblyr), a3Db) endif if (f_bphi (1:1) /= 'x') then @@ -2608,14 +2513,13 @@ subroutine accum_hist_bgc (iblk) do j = jlo, jhi do i = ilo, ihi if (aicen(i,j,n,iblk) > c0) then - workz(i,j,1:nzblyr) = workz(i,j,1:nzblyr) + bphi(i,j,1:nzblyr,n,iblk)*& - aicen(i,j,n,iblk) + workz(i,j,1:nzblyr) = workz(i,j,1:nzblyr) + bphi(i,j,1:nzblyr,n,iblk) & + * aicen(i,j,n,iblk) endif enddo ! i enddo ! j enddo ! n - call accum_hist_field(n_bphi-n3Dzcum, iblk, nzblyr, & - workz(:,:,1:nzblyr), a3Db) + call accum_hist_field(n_bphi-n3Dzcum, iblk, nzblyr, workz(:,:,1:nzblyr), a3Db) endif if (f_zfswin (1:1) /= 'x') then @@ -2624,16 +2528,15 @@ subroutine accum_hist_bgc (iblk) do j = jlo, jhi do i = ilo, ihi if (aicen(i,j,n,iblk) > c0) then - workz(i,j,1:nblyr+1) = workz(i,j,1:nblyr+1)+ zfswin(i,j,1:nblyr+1,n,iblk)*& - aicen(i,j,n,iblk) - workz(i,j,nzblyr) = workz(i,j,nzblyr) + zfswin(i,j,nblyr+1,n,iblk)*& - aicen(i,j,n,iblk) + workz(i,j,1:nblyr+1) = workz(i,j,1:nblyr+1)+ zfswin(i,j,1:nblyr+1,n,iblk) & + * aicen(i,j,n,iblk) + workz(i,j,nzblyr) = workz(i,j,nzblyr) + zfswin(i,j,nblyr+1,n,iblk) & + * aicen(i,j,n,iblk) endif enddo ! i enddo ! j enddo ! n - call accum_hist_field(n_zfswin-n3Dzcum, iblk, nzblyr, & - workz(:,:,1:nzblyr), a3Db) + call accum_hist_field(n_zfswin-n3Dzcum, iblk, nzblyr, workz(:,:,1:nzblyr), a3Db) endif if (f_iDi (1:1) /= 'x') then @@ -2650,8 +2553,7 @@ subroutine accum_hist_bgc (iblk) enddo ! j enddo ! k enddo ! n - call accum_hist_field(n_iDi-n3Dzcum, iblk, nzblyr, & - workz(:,:,1:nzblyr), a3Db) + call accum_hist_field(n_iDi-n3Dzcum, iblk, nzblyr, workz(:,:,1:nzblyr), a3Db) endif if (f_iki (1:1) /= 'x') then @@ -2670,8 +2572,7 @@ subroutine accum_hist_bgc (iblk) enddo ! j enddo ! k enddo ! n - call accum_hist_field(n_iki-n3Dzcum, iblk, nzblyr, & - workz(:,:,1:nzblyr), a3Db) + call accum_hist_field(n_iki-n3Dzcum, iblk, nzblyr, workz(:,:,1:nzblyr), a3Db) endif endif ! 3Db fields @@ -2695,8 +2596,7 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_zaeros(k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_zaeros(k,:)-n3Dbcum, iblk, nzalyr, workz(:,:,1:nzalyr), a3Da) enddo !k endif !f_zaero if (f_bgc_N (1:1) /= 'x') then @@ -2721,10 +2621,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_N(k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_N_cat1(k,:)-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_N(k,:)-n3Dbcum, iblk, nzalyr, workz(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_N_cat1(k,:)-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_N if (f_bgc_C (1:1) /= 'x') then @@ -2741,8 +2639,7 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_C(k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_C(k,:)-n3Dbcum, iblk, nzalyr, workz(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_C if (f_bgc_DOC (1:1) /= 'x') then @@ -2767,10 +2664,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_DOC(k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_DOC_cat1(k,:)-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DOC (k,:)-n3Dbcum, iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DOC_cat1(k,:)-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_DOC if (f_bgc_DIC (1:1) /= 'x') then @@ -2795,10 +2690,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_DIC(k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_DIC_cat1(k,:)-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DIC (k,:)-n3Dbcum, iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DIC_cat1(k,:)-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_DIC if (f_bgc_DON (1:1) /= 'x') then @@ -2823,10 +2716,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_DON(k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_DON_cat1(k,:)-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DON (k,:)-n3Dbcum, iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DON_cat1(k,:)-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_DON if (f_bgc_Fed (1:1) /= 'x') then @@ -2851,10 +2742,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_Fed (k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_Fed_cat1 (k,:)-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Fed (k,:)-n3Dbcum, iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Fed_cat1 (k,:)-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_Fed if (f_bgc_Fep (1:1) /= 'x') then @@ -2879,10 +2768,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_Fep (k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_Fep_cat1 (k,:)-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Fep (k,:)-n3Dbcum, iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Fep_cat1 (k,:)-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_Fep if (f_bgc_chl (1:1) /= 'x') then @@ -2899,8 +2786,7 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_chl(k,:)-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_chl(k,:)-n3Dbcum, iblk, nzalyr, workz(:,:,1:nzalyr), a3Da) enddo !k endif !f_bgc_chl @@ -2925,10 +2811,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_Nit-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_Nit_cat1-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Nit-n3Dbcum , iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Nit_cat1-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) endif if (f_bgc_Am (1:1) /= 'x') then @@ -2952,10 +2836,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_Am-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_Am_cat1-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Am-n3Dbcum , iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Am_cat1-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) endif if (f_bgc_Sil (1:1) /= 'x') then @@ -2979,10 +2861,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_Sil-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_Sil_cat1-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Sil-n3Dbcum , iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_Sil_cat1-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) endif @@ -3007,10 +2887,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_hum-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_hum_cat1-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_hum-n3Dbcum , iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_hum_cat1-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) endif if (f_bgc_DMSPd (1:1) /= 'x') then @@ -3034,10 +2912,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_DMSPd-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_DMSPd_cat1-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DMSPd-n3Dbcum , iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DMSPd_cat1-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) endif if (f_bgc_DMSPp (1:1) /= 'x') then @@ -3053,8 +2929,7 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_DMSPp-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DMSPp-n3Dbcum, iblk, nzalyr, workz(:,:,1:nzalyr), a3Da) endif if (f_bgc_DMS (1:1) /= 'x') then @@ -3078,10 +2953,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_DMS-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_DMS_cat1-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DMS-n3Dbcum , iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_DMS_cat1-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) endif if (f_bgc_PON (1:1) /= 'x') then @@ -3105,10 +2978,8 @@ subroutine accum_hist_bgc (iblk) endif enddo ! i enddo ! j - call accum_hist_field(n_bgc_PON-n3Dbcum, iblk, nzalyr, & - workz(:,:,1:nzalyr), a3Da) - call accum_hist_field(n_bgc_PON_cat1-n3Dbcum, iblk, nzalyr, & - workz2(:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_PON-n3Dbcum , iblk, nzalyr, workz (:,:,1:nzalyr), a3Da) + call accum_hist_field(n_bgc_PON_cat1-n3Dbcum, iblk, nzalyr, workz2(:,:,1:nzalyr), a3Da) endif endif ! z_tracers, 3Da tracers diff --git a/cicecore/cicedyn/analysis/ice_history_drag.F90 b/cicecore/cicedyn/analysis/ice_history_drag.F90 index dd9e3cb59..ef17f7ca2 100644 --- a/cicecore/cicedyn/analysis/ice_history_drag.F90 +++ b/cicecore/cicedyn/analysis/ice_history_drag.F90 @@ -289,31 +289,23 @@ subroutine accum_hist_drag (iblk) call accum_hist_field(n_Cdn_atm, iblk, Cdn_atm(:,:,iblk), a2D) if (f_Cdn_ocn (1:1) /= 'x') & call accum_hist_field(n_Cdn_ocn, iblk, Cdn_ocn(:,:,iblk), a2D) - if (f_drag (1:1) /= 'x') then - call accum_hist_field(n_hfreebd, iblk, hfreebd(:,:,iblk), a2D) - call accum_hist_field(n_hdraft, iblk, hdraft(:,:,iblk), a2D) - call accum_hist_field(n_hridge, iblk, hridge(:,:,iblk), a2D) - call accum_hist_field(n_distrdg, iblk, distrdg(:,:,iblk), a2D) - call accum_hist_field(n_hkeel, iblk, hkeel(:,:,iblk), a2D) - call accum_hist_field(n_dkeel, iblk, dkeel(:,:,iblk), a2D) - call accum_hist_field(n_lfloe, iblk, lfloe(:,:,iblk), a2D) - call accum_hist_field(n_dfloe, iblk, dfloe(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_atm_rdg, & - iblk, Cdn_atm_rdg(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_atm_floe, & - iblk, Cdn_atm_floe(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_atm_pond, & - iblk, Cdn_atm_pond(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_atm_skin, & - iblk, Cdn_atm_skin(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_atm_ratio, & - iblk, Cdn_atm_ratio(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_ocn_keel, & - iblk, Cdn_ocn_keel(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_ocn_floe, & - iblk, Cdn_ocn_floe(:,:,iblk), a2D) - call accum_hist_field(n_Cdn_ocn_skin, & - iblk, Cdn_ocn_skin(:,:,iblk), a2D) + if (f_drag (1:1) /= 'x') then + call accum_hist_field(n_hfreebd , iblk, hfreebd (:,:,iblk), a2D) + call accum_hist_field(n_hdraft , iblk, hdraft (:,:,iblk), a2D) + call accum_hist_field(n_hridge , iblk, hridge (:,:,iblk), a2D) + call accum_hist_field(n_distrdg , iblk, distrdg (:,:,iblk), a2D) + call accum_hist_field(n_hkeel , iblk, hkeel (:,:,iblk), a2D) + call accum_hist_field(n_dkeel , iblk, dkeel (:,:,iblk), a2D) + call accum_hist_field(n_lfloe , iblk, lfloe (:,:,iblk), a2D) + call accum_hist_field(n_dfloe , iblk, dfloe (:,:,iblk), a2D) + call accum_hist_field(n_Cdn_atm_rdg , iblk, Cdn_atm_rdg (:,:,iblk), a2D) + call accum_hist_field(n_Cdn_atm_floe , iblk, Cdn_atm_floe (:,:,iblk), a2D) + call accum_hist_field(n_Cdn_atm_pond , iblk, Cdn_atm_pond (:,:,iblk), a2D) + call accum_hist_field(n_Cdn_atm_skin , iblk, Cdn_atm_skin (:,:,iblk), a2D) + call accum_hist_field(n_Cdn_atm_ratio, iblk, Cdn_atm_ratio(:,:,iblk), a2D) + call accum_hist_field(n_Cdn_ocn_keel , iblk, Cdn_ocn_keel (:,:,iblk), a2D) + call accum_hist_field(n_Cdn_ocn_floe , iblk, Cdn_ocn_floe (:,:,iblk), a2D) + call accum_hist_field(n_Cdn_ocn_skin , iblk, Cdn_ocn_skin (:,:,iblk), a2D) end if endif ! if(allocated(a2D)) diff --git a/cicecore/cicedyn/analysis/ice_history_fsd.F90 b/cicecore/cicedyn/analysis/ice_history_fsd.F90 index 6379233e5..8e8049f5a 100644 --- a/cicecore/cicedyn/analysis/ice_history_fsd.F90 +++ b/cicecore/cicedyn/analysis/ice_history_fsd.F90 @@ -308,8 +308,9 @@ end subroutine init_hist_fsd_4Df subroutine accum_hist_fsd (dt, iblk) - use ice_blocks, only: nx_block, ny_block + use ice_blocks, only: block, get_block, nx_block, ny_block use ice_constants, only: c0, c1, c2, c4 + use ice_domain, only: blocks_ice use ice_history_shared, only: a2D, a3Df, a4Df, nfsd_hist, & ncat_hist, accum_hist_field, n3Dacum, n4Dscum use ice_state, only: trcrn, aicen, vicen, aice @@ -326,7 +327,11 @@ subroutine accum_hist_fsd (dt, iblk) integer (kind=int_kind) :: & i, j, n, k, & ! loop indices + ilo,ihi,jlo,jhi, & ! beginning and end of physical domain nt_fsd ! fsd tracer index + + type (block) :: & + this_block ! block information for current block logical (kind=log_kind) :: tr_fsd real (kind=dbl_kind) :: floeshape, puny @@ -337,6 +342,14 @@ subroutine accum_hist_fsd (dt, iblk) character(len=*), parameter :: subname = '(accum_hist_fsd)' + ! Bounds before first use: the work arrays are zeroed over the whole + ! block but computed only over the physical domain. + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + call icepack_query_parameters(floeshape_out=floeshape, puny_out=puny) call icepack_query_tracer_flags(tr_fsd_out=tr_fsd) call icepack_query_tracer_indices(nt_fsd_out=nt_fsd) @@ -354,13 +367,12 @@ subroutine accum_hist_fsd (dt, iblk) if (allocated(a2D)) then if (f_wave_sig_ht(1:1)/= 'x') & - call accum_hist_field(n_wave_sig_ht, iblk, & - wave_sig_ht(:,:,iblk), a2D) + call accum_hist_field(n_wave_sig_ht, iblk, wave_sig_ht(:,:,iblk), a2D) if (f_aice_ww(1:1)/= 'x') then - do j = 1, ny_block - do i = 1, nx_block - worka(i,j) = c0 + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi do n = 1, ncat_hist do k = 1, nfsd_hist worka(i,j) = worka(i,j) + aicen(i,j,n,iblk)*trcrn(i,j,nt_fsd+k-1,n,iblk) @@ -368,18 +380,17 @@ subroutine accum_hist_fsd (dt, iblk) end do end do end do - call accum_hist_field(n_aice_ww, iblk, worka(:,:), a2D) + call accum_hist_field(n_aice_ww, iblk, worka(:,:), a2D) endif if (f_diam_ww (1:1) /= 'x') then - do j = 1, ny_block - do i = 1, nx_block - worka(i,j) = c0 - workb = c0 + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi + workb = c0 do n = 1, ncat_hist do k = 1, nfsd_hist - workc = aicen(i,j,n,iblk)*trcrn(i,j,nt_fsd+k-1,n,iblk) & - / (c4*floeshape*floe_rad_c(k)**2) + workc = aicen(i,j,n,iblk)*trcrn(i,j,nt_fsd+k-1,n,iblk) / (c4*floeshape*floe_rad_c(k)**2) ! number-mean radius worka(i,j) = worka(i,j) + workc * floe_rad_c(k) ! normalization factor @@ -395,9 +406,9 @@ subroutine accum_hist_fsd (dt, iblk) endif if (f_hice_ww (1:1) /= 'x') then - do j = 1, ny_block - do i = 1, nx_block - worka(i,j) = c0 + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi workb = c0 do n = 1, ncat_hist do k = 1, nfsd_hist @@ -416,17 +427,17 @@ subroutine accum_hist_fsd (dt, iblk) endif if (f_fsdrad(1:1) /= 'x') then - do j = 1, ny_block - do i = 1, nx_block - worka(i,j) = c0 + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi if (aice(i,j,iblk) > puny) then - do k = 1, nfsd_hist - do n = 1, ncat_hist - worka(i,j) = worka(i,j) & - + (trcrn(i,j,nt_fsd+k-1,n,iblk) * floe_rad_c(k) & - * aicen(i,j,n,iblk)/aice(i,j,iblk)) - end do - end do + do k = 1, nfsd_hist + do n = 1, ncat_hist + worka(i,j) = worka(i,j) & + + (trcrn(i,j,nt_fsd+k-1,n,iblk) * floe_rad_c(k) & + * aicen(i,j,n,iblk)/aice(i,j,iblk)) + end do + end do endif end do end do @@ -434,17 +445,17 @@ subroutine accum_hist_fsd (dt, iblk) endif if (f_fsdperim(1:1) /= 'x') then - do j = 1, ny_block - do i = 1, nx_block - worka(i,j) = c0 + worka(:,:) = c0 + do j = jlo, jhi + do i = ilo, ihi if (aice(i,j,iblk) > puny) then - do k = 1, nfsd_hist + do k = 1, nfsd_hist do n = 1, ncat_hist - worka(i,j) = worka(i,j) & - + (c8*floeshape*trcrn(i,j,nt_fsd+k-1,n,iblk)*floe_rad_c(k) & - *aicen(i,j,n,iblk)/(c4*floeshape*floe_rad_c(k)**2 *aice(i,j,iblk))) + worka(i,j) = worka(i,j) & + + (c8*floeshape*trcrn(i,j,nt_fsd+k-1,n,iblk)*floe_rad_c(k) & + *aicen(i,j,n,iblk)/(c4*floeshape*floe_rad_c(k)**2 *aice(i,j,iblk))) + end do end do - end do endif end do end do @@ -455,16 +466,15 @@ subroutine accum_hist_fsd (dt, iblk) ! 3D category fields if (allocated(a3Df)) then - + worke(:,:,:)=c0 if (f_afsd(1:1) /= 'x') then - do j = 1, ny_block - do i = 1, nx_block + do j = jlo, jhi + do i = ilo, ihi do k = 1, nfsd_hist - worke(i,j,k)=c0 - do n = 1, ncat_hist - worke(i,j,k) = worke(i,j,k) + (trcrn(i,j,nt_fsd+k-1,n,iblk) & - * aicen(i,j,n,iblk)/floe_binwidth(k)) - end do + do n = 1, ncat_hist + worke(i,j,k) = worke(i,j,k) + (trcrn(i,j,nt_fsd+k-1,n,iblk) & + * aicen(i,j,n,iblk)/floe_binwidth(k)) + end do end do end do end do @@ -472,23 +482,23 @@ subroutine accum_hist_fsd (dt, iblk) endif if (f_dafsd_newi(1:1)/= 'x') then - worke(:,:,1:nfsd_hist) = d_afsd_newi(:,:,1:nfsd_hist,iblk)/dt + worke(ilo:ihi,jlo:jhi,1:nfsd_hist)= d_afsd_newi(ilo:ihi,jlo:jhi,1:nfsd_hist,iblk)/dt call accum_hist_field(n_dafsd_newi-n3Dacum, iblk, nfsd_hist, worke, a3Df) endif if (f_dafsd_latg(1:1)/= 'x') then - worke(:,:,1:nfsd_hist) = d_afsd_latg(:,:,1:nfsd_hist,iblk)/dt + worke(ilo:ihi,jlo:jhi,1:nfsd_hist)= d_afsd_latg(ilo:ihi,jlo:jhi,1:nfsd_hist,iblk)/dt call accum_hist_field(n_dafsd_latg-n3Dacum, iblk, nfsd_hist, worke, a3Df) endif if (f_dafsd_latm(1:1)/= 'x') then - worke(:,:,1:nfsd_hist) = d_afsd_latm(:,:,1:nfsd_hist,iblk)/dt + worke(ilo:ihi,jlo:jhi,1:nfsd_hist)= d_afsd_latm(ilo:ihi,jlo:jhi,1:nfsd_hist,iblk)/dt call accum_hist_field(n_dafsd_latm-n3Dacum, iblk, nfsd_hist, worke, a3Df) endif if (f_dafsd_wave(1:1)/= 'x') then - worke(:,:,1:nfsd_hist) = d_afsd_wave(:,:,1:nfsd_hist,iblk)/dt + worke(ilo:ihi,jlo:jhi,1:nfsd_hist)= d_afsd_wave(ilo:ihi,jlo:jhi,1:nfsd_hist,iblk)/dt call accum_hist_field(n_dafsd_wave-n3Dacum, iblk, nfsd_hist, worke, a3Df) endif if (f_dafsd_weld(1:1)/= 'x') then - worke(:,:,1:nfsd_hist) = d_afsd_weld(:,:,1:nfsd_hist,iblk)/dt + worke(ilo:ihi,jlo:jhi,1:nfsd_hist)= d_afsd_weld(ilo:ihi,jlo:jhi,1:nfsd_hist,iblk)/dt call accum_hist_field(n_dafsd_weld-n3Dacum, iblk, nfsd_hist, worke, a3Df) endif endif ! a3Df allocated @@ -497,12 +507,12 @@ subroutine accum_hist_fsd (dt, iblk) if (allocated(a4Df)) then if (f_afsdn(1:1) /= 'x') then + workd(:,:,:,:) = c0 do n = 1, ncat_hist do k = 1, nfsd_hist - do j = 1, ny_block - do i = 1, nx_block - workd(i,j,k,n) = trcrn(i,j,nt_fsd+k-1,n,iblk) & - * aicen(i,j,n,iblk)/floe_binwidth(k) + do j = jlo, jhi + do i = ilo, ihi + workd(i,j,k,n) = trcrn(i,j,nt_fsd+k-1,n,iblk) * aicen(i,j,n,iblk)/floe_binwidth(k) end do end do end do diff --git a/cicecore/cicedyn/analysis/ice_history_mechred.F90 b/cicecore/cicedyn/analysis/ice_history_mechred.F90 index 57abe50e0..edb8f3608 100644 --- a/cicecore/cicedyn/analysis/ice_history_mechred.F90 +++ b/cicecore/cicedyn/analysis/ice_history_mechred.F90 @@ -407,29 +407,27 @@ subroutine accum_hist_mechred (iblk) if (allocated(a2D)) then if (f_alvl(1:1)/= 'x') & - call accum_hist_field(n_alvl, iblk, & - aice(:,:,iblk) , trcr(:,:,nt_alvl,iblk), a2D) + call accum_hist_field(n_alvl , iblk, aice(:,:,iblk) , trcr(:,:,nt_alvl,iblk), a2D) if (f_vlvl(1:1)/= 'x') & - call accum_hist_field(n_vlvl, iblk, & - vice(:,:,iblk) , trcr(:,:,nt_vlvl,iblk), a2D) + call accum_hist_field(n_vlvl , iblk, vice(:,:,iblk) , trcr(:,:,nt_vlvl,iblk), a2D) if (f_ardg(1:1)/= 'x') & worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_alvl,iblk) - call accum_hist_field(n_ardg, iblk, aice(:,:,iblk), worka, a2D) - if (f_vrdg(1:1)/= 'x') & + call accum_hist_field(n_ardg , iblk, aice(:,:,iblk) , worka , a2D) + if (f_vrdg(1:1)/= 'x') & worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_vlvl,iblk) - call accum_hist_field(n_vrdg, iblk, vice(:,:,iblk), worka, a2D) + call accum_hist_field(n_vrdg , iblk, vice(:,:,iblk) , worka , a2D) if (f_dardg1dt(1:1)/= 'x') & - call accum_hist_field(n_dardg1dt,iblk, dardg1dt(:,:,iblk), a2D) + call accum_hist_field(n_dardg1dt, iblk, dardg1dt(:,:,iblk) , a2D) if (f_dardg2dt(1:1)/= 'x') & - call accum_hist_field(n_dardg2dt,iblk, dardg2dt(:,:,iblk), a2D) + call accum_hist_field(n_dardg2dt, iblk, dardg2dt(:,:,iblk) , a2D) if (f_dvirdgdt(1:1)/= 'x') & - call accum_hist_field(n_dvirdgdt,iblk, dvirdgdt(:,:,iblk), a2D) + call accum_hist_field(n_dvirdgdt, iblk, dvirdgdt(:,:,iblk) , a2D) if (f_opening(1:1) /= 'x') & - call accum_hist_field(n_opening, iblk, opening(:,:,iblk), a2D) + call accum_hist_field(n_opening , iblk, opening (:,:,iblk) , a2D) if (f_sirdgconc(1:1)/= 'x') & worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_alvl,iblk) - call accum_hist_field(n_sirdgconc, iblk, aice(:,:,iblk), worka, a2D) + call accum_hist_field(n_sirdgconc , iblk, aice(:,:,iblk), worka, a2D) if (f_sirdgthick(1:1)/= 'x') then worka(ilo:ihi,jlo:jhi) = c1 - trcr(ilo:ihi,jlo:jhi,nt_vlvl,iblk) @@ -442,42 +440,31 @@ subroutine accum_hist_mechred (iblk) if (allocated(a3Dc)) then if (f_ardgn(1:1)/= 'x') then - workc(:,:,1:ncat_hist) = aicen(:,:,1:ncat_hist,iblk) & - * (c1 - trcrn(:,:,nt_alvl,1:ncat_hist,iblk)) + workc(:,:,1:ncat_hist) = aicen(:,:,1:ncat_hist,iblk) * (c1 - trcrn(:,:,nt_alvl,1:ncat_hist,iblk)) call accum_hist_field(n_ardgn-n2D, iblk, ncat_hist, workc, a3Dc) endif if (f_vrdgn(1:1)/= 'x') then - workc(:,:,1:ncat_hist) = vicen(:,:,1:ncat_hist,iblk) & - * (c1 - trcrn(:,:,nt_vlvl,1:ncat_hist,iblk)) + workc(:,:,1:ncat_hist) = vicen(:,:,1:ncat_hist,iblk) * (c1 - trcrn(:,:,nt_vlvl,1:ncat_hist,iblk)) call accum_hist_field(n_vrdgn-n2D, iblk, ncat_hist, workc, a3Dc) endif if (f_dardg1ndt(1:1)/= 'x') & - call accum_hist_field(n_dardg1ndt-n2D, iblk, ncat_hist, & - dardg1ndt(:,:,1:ncat_hist,iblk), a3Dc) + call accum_hist_field(n_dardg1ndt-n2D, iblk, ncat_hist, dardg1ndt(:,:,1:ncat_hist,iblk), a3Dc) if (f_dardg2ndt(1:1)/= 'x') & - call accum_hist_field(n_dardg2ndt-n2D, iblk, ncat_hist, & - dardg2ndt(:,:,1:ncat_hist,iblk), a3Dc) + call accum_hist_field(n_dardg2ndt-n2D, iblk, ncat_hist, dardg2ndt(:,:,1:ncat_hist,iblk), a3Dc) if (f_dvirdgndt(1:1)/= 'x') & - call accum_hist_field(n_dvirdgndt-n2D, iblk, ncat_hist, & - dvirdgndt(:,:,1:ncat_hist,iblk), a3Dc) - if (f_krdgn(1:1)/= 'x') & - call accum_hist_field(n_krdgn-n2D, iblk, ncat_hist, & - krdgn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_aparticn(1:1)/= 'x') & - call accum_hist_field(n_aparticn-n2D, iblk, ncat_hist, & - aparticn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_aredistn(1:1)/= 'x') & - call accum_hist_field(n_aredistn-n2D, iblk, ncat_hist, & - aredistn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_vredistn(1:1)/= 'x') & - call accum_hist_field(n_vredistn-n2D, iblk, ncat_hist, & - vredistn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_araftn(1:1)/= 'x') & - call accum_hist_field(n_araftn-n2D, iblk, ncat_hist, & - araftn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_vraftn(1:1)/= 'x') & - call accum_hist_field(n_vraftn-n2D, iblk, ncat_hist, & - vraftn(:,:,1:ncat_hist,iblk), a3Dc) + call accum_hist_field(n_dvirdgndt-n2D, iblk, ncat_hist, dvirdgndt(:,:,1:ncat_hist,iblk), a3Dc) + if (f_krdgn(1:1)/= 'x') & + call accum_hist_field(n_krdgn-n2D , iblk, ncat_hist, krdgn (:,:,1:ncat_hist,iblk), a3Dc) + if (f_aparticn(1:1)/= 'x') & + call accum_hist_field(n_aparticn-n2D , iblk, ncat_hist, aparticn (:,:,1:ncat_hist,iblk), a3Dc) + if (f_aredistn(1:1)/= 'x') & + call accum_hist_field(n_aredistn-n2D , iblk, ncat_hist, aredistn (:,:,1:ncat_hist,iblk), a3Dc) + if (f_vredistn(1:1)/= 'x') & + call accum_hist_field(n_vredistn-n2D , iblk, ncat_hist, vredistn (:,:,1:ncat_hist,iblk), a3Dc) + if (f_araftn(1:1)/= 'x') & + call accum_hist_field(n_araftn-n2D , iblk, ncat_hist, araftn (:,:,1:ncat_hist,iblk), a3Dc) + if (f_vraftn(1:1)/= 'x') & + call accum_hist_field(n_vraftn-n2D , iblk, ncat_hist, vraftn (:,:,1:ncat_hist,iblk), a3Dc) endif ! allocated(a3Dc) end subroutine accum_hist_mechred diff --git a/cicecore/cicedyn/analysis/ice_history_pond.F90 b/cicecore/cicedyn/analysis/ice_history_pond.F90 index 85a8a19ff..716109305 100644 --- a/cicecore/cicedyn/analysis/ice_history_pond.F90 +++ b/cicecore/cicedyn/analysis/ice_history_pond.F90 @@ -526,37 +526,37 @@ subroutine accum_hist_pond (iblk) endif if (f_apond(1:1)/= 'x') & - call accum_hist_field(n_apond, iblk, worka(:,:), a2D) + call accum_hist_field(n_apond , iblk, worka (:,:) , a2D) if (f_apond_ai(1:1)/= 'x') & - call accum_hist_field(n_apond_ai, iblk, aice_init(:,:,iblk),worka(:,:), a2D) + call accum_hist_field(n_apond_ai , iblk, aice_init(:,:,iblk), worka(:,:) , a2D) if (f_hpond(1:1)/= 'x') & - call accum_hist_field(n_hpond, iblk, worka(:,:),trcr(:,:,nt_hpnd,iblk), a2D) + call accum_hist_field(n_hpond , iblk, worka (:,:) , trcr(:,:,nt_hpnd,iblk), a2D) if (f_hpond_ai(1:1)/= 'x') then workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_hpnd,iblk) - call accum_hist_field(n_hpond_ai, iblk, workb, a2D) + call accum_hist_field(n_hpond_ai , iblk, workb (:,:) , a2D) endif if (f_ipond(1:1)/= 'x') & - call accum_hist_field(n_ipond, iblk, worka(:,:),trcr(:,:,nt_ipnd,iblk), a2D) + call accum_hist_field(n_ipond , iblk, worka (:,:) , trcr(:,:,nt_ipnd,iblk), a2D) if (f_ipond_ai(1:1)/= 'x') then workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_ipnd,iblk) - call accum_hist_field(n_ipond_ai, iblk, workb, a2D) + call accum_hist_field(n_ipond_ai , iblk, workb , a2D) endif ! CMIP pond related variables if (f_simpeffconc (1:1) /= 'x') & - call accum_hist_field(n_simpeffconc, iblk, apeff_ai(:,:,iblk), a2D) + call accum_hist_field(n_simpeffconc, iblk, apeff_ai (:,:,iblk) , a2D) if (f_simpconc(1:1)/= 'x') & - call accum_hist_field(n_simpconc, iblk, worka(:,:), a2D) + call accum_hist_field(n_simpconc , iblk, worka (:,:) , a2D) if (f_simpthick(1:1)/= 'x') then workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_hpnd,iblk) - call accum_hist_field(n_simpthick, iblk, workb, a2D) + call accum_hist_field(n_simpthick , iblk, workb , a2D) endif if (f_simprefrozen(1:1)/= 'x') then workb(ilo:ihi,jlo:jhi) = aice_init(ilo:ihi,jlo:jhi,iblk)*worka(ilo:ihi,jlo:jhi)*trcr(ilo:ihi,jlo:jhi,nt_ipnd,iblk) - call accum_hist_field(n_simprefrozen, iblk, workb, a2D) + call accum_hist_field(n_simprefrozen, iblk, workb , a2D) endif @@ -564,28 +564,27 @@ subroutine accum_hist_pond (iblk) worka(:,:) = c0 do j = jlo, jhi do i = ilo, ihi - if (aice(i,j,iblk) > puny) worka(i,j) = apeff_ai(i,j,iblk) & - / aice(i,j,iblk) + if (aice(i,j,iblk) > puny) worka(i,j) = apeff_ai(i,j,iblk) / aice(i,j,iblk) enddo enddo - call accum_hist_field(n_apeff, iblk, worka(:,:), a2D) + call accum_hist_field(n_apeff , iblk, worka (:,:) , a2D) endif - if (f_apeff_ai(1:1) /= 'x') & - call accum_hist_field(n_apeff_ai, iblk, apeff_ai(:,:,iblk), a2D) + if (f_apeff_ai (1:1) /= 'x') & + call accum_hist_field(n_apeff_ai , iblk, apeff_ai (:,:,iblk), a2D) - if (f_dpnd_flush (1:1) /= 'x') & + if (f_dpnd_flush (1:1) /= 'x') & call accum_hist_field(n_dpnd_flush , iblk, dpnd_flush (:,:,iblk), a2D) - if (f_dpnd_expon (1:1) /= 'x') & + if (f_dpnd_expon (1:1) /= 'x') & call accum_hist_field(n_dpnd_expon , iblk, dpnd_expon (:,:,iblk), a2D) if (f_dpnd_freebd (1:1) /= 'x') & call accum_hist_field(n_dpnd_freebd , iblk, dpnd_freebd (:,:,iblk), a2D) - if (f_dpnd_initial (1:1) /= 'x') & + if (f_dpnd_initial(1:1) /= 'x') & call accum_hist_field(n_dpnd_initial, iblk, dpnd_initial(:,:,iblk), a2D) - if (f_dpnd_dlid (1:1) /= 'x') & + if (f_dpnd_dlid (1:1) /= 'x') & call accum_hist_field(n_dpnd_dlid , iblk, dpnd_dlid (:,:,iblk), a2D) - if (f_dpnd_melt (1:1) /= 'x') & + if (f_dpnd_melt (1:1) /= 'x') & call accum_hist_field(n_dpnd_melt , iblk, dpnd_melt (:,:,iblk), a2D) - if (f_dpnd_ridge (1:1) /= 'x') & + if (f_dpnd_ridge (1:1) /= 'x') & call accum_hist_field(n_dpnd_ridge , iblk, dpnd_ridge (:,:,iblk), a2D) endif ! allocated(a2D) @@ -593,26 +592,23 @@ subroutine accum_hist_pond (iblk) ! 3D category fields if (allocated(a3Dc)) then if (f_apondn (1:1) /= 'x') & - call accum_hist_field(n_apondn-n2D, iblk, ncat_hist, & - trcrn(:,:,nt_apnd,1:ncat_hist,iblk), a3Dc) - if (f_apeffn (1:1) /= 'x') & - call accum_hist_field(n_apeffn-n2D, iblk, ncat_hist, & - apeffn(:,:,1:ncat_hist,iblk), a3Dc) + call accum_hist_field(n_apondn-n2D, iblk, ncat_hist, trcrn(:,:,nt_apnd,1:ncat_hist,iblk), a3Dc) + if (f_apeffn (1:1) /= 'x') & + call accum_hist_field(n_apeffn-n2D, iblk, ncat_hist, apeffn(:,:,1:ncat_hist,iblk) , a3Dc) if (f_hpondn (1:1) /= 'x') then - workc(:,:,1:ncat_hist) = trcrn(:,:,nt_apnd,1:ncat_hist,iblk) & - * trcrn(:,:,nt_hpnd,1:ncat_hist,iblk) - call accum_hist_field(n_hpondn-n2D, iblk, ncat_hist, workc, a3Dc) + workc(:,:,1:ncat_hist) = trcrn(:,:,nt_apnd,1:ncat_hist,iblk) * trcrn(:,:,nt_hpnd,1:ncat_hist,iblk) + call accum_hist_field(n_hpondn-n2D, iblk, ncat_hist, workc , a3Dc) endif - if (f_dpnd_flushn (1:1) /= 'x') & + if (f_dpnd_flushn (1:1) /= 'x') & call accum_hist_field(n_dpnd_flushn-n2D , iblk, ncat_hist, dpnd_flushn (:,:,1:ncat_hist,iblk), a3Dc) - if (f_dpnd_exponn (1:1) /= 'x') & + if (f_dpnd_exponn (1:1) /= 'x') & call accum_hist_field(n_dpnd_exponn-n2D , iblk, ncat_hist, dpnd_exponn (:,:,1:ncat_hist,iblk), a3Dc) - if (f_dpnd_freebdn (1:1) /= 'x') & + if (f_dpnd_freebdn (1:1) /= 'x') & call accum_hist_field(n_dpnd_freebdn-n2D , iblk, ncat_hist, dpnd_freebdn (:,:,1:ncat_hist,iblk), a3Dc) if (f_dpnd_initialn (1:1) /= 'x') & call accum_hist_field(n_dpnd_initialn-n2D, iblk, ncat_hist, dpnd_initialn(:,:,1:ncat_hist,iblk), a3Dc) - if (f_dpnd_dlidn (1:1) /= 'x') & + if (f_dpnd_dlidn (1:1) /= 'x') & call accum_hist_field(n_dpnd_dlidn-n2D , iblk, ncat_hist, dpnd_dlidn (:,:,1:ncat_hist,iblk), a3Dc) endif ! allocated(a3Dc) diff --git a/cicecore/cicedyn/analysis/ice_history_shared.F90 b/cicecore/cicedyn/analysis/ice_history_shared.F90 index c337ac28c..7a8829be3 100644 --- a/cicecore/cicedyn/analysis/ice_history_shared.F90 +++ b/cicecore/cicedyn/analysis/ice_history_shared.F90 @@ -1083,6 +1083,9 @@ subroutine accum_hist_field_2D(id, iblk, field_accum, field, mask) real (kind=dbl_kind), intent(inout) :: & field(:,:,:,:) + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) ! defaults to tmask + type (block) :: & this_block ! block information for current block @@ -1090,11 +1093,6 @@ subroutine accum_hist_field_2D(id, iblk, field_accum, field, mask) logical (kind=log_kind) :: wet - ! Where to accumulate. Absent means tmask, which is what every caller - ! wanted before this argument existed. - logical (kind=log_kind), intent(in), optional :: & - mask(:,:) - character(len=*), parameter :: subname = '(accum_hist_field_2D)' !--------------------------------------------------------------- @@ -1136,18 +1134,6 @@ end subroutine accum_hist_field_2D ! 2009 Created by D. Bailey following POP ! 2010 Generalized dimension of variables by N. Jeffery, E. Hunke -! Accumulate the product of two fields without building it first. -! -! Writing the product as an actual argument -- accum_hist_field(n, iblk, -! a(:,:,iblk)*b(:,:,iblk), a2D) -- makes the compiler evaluate it into a -! temporary over the WHOLE block, nx_block by ny_block, pass that, and -! discard it. The loop below reads only ilo:ihi by jlo:jhi under tmask, so -! most of that temporary is computed and never used: for a 10x12 block with -! nghost=2 it is 224 products to read 120. -! -! Taking the two factors instead costs one extra argument and removes the -! temporary, the fill loop and the wasted ghost-region arithmetic. - subroutine accum_hist_field_2D_prod(id, iblk, a, b, field, mask) use ice_blocks, only: block, get_block @@ -1166,6 +1152,9 @@ subroutine accum_hist_field_2D_prod(id, iblk, a, b, field, mask) real (kind=dbl_kind), intent(inout) :: & field(:,:,:,:) + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) ! defaults to tmask. + type (block) :: & this_block ! block information for current block @@ -1173,11 +1162,6 @@ subroutine accum_hist_field_2D_prod(id, iblk, a, b, field, mask) logical (kind=log_kind) :: wet - ! Where to accumulate. Absent means tmask, which is what every caller - ! wanted before this argument existed. - logical (kind=log_kind), intent(in), optional :: & - mask(:,:) - character(len=*), parameter :: subname = '(accum_hist_field_2D_prod)' do ns = 1, nstreams @@ -1210,19 +1194,12 @@ end subroutine accum_hist_field_2D_prod !======================================================================= ! -! The same for a field scaled by a constant, distinguished from the -! two-field form by the rank of the second factor. There is deliberately -! no mirror form taking the scale first: a caller whose scale is on the -! left swaps its two actuals, which is bit-for-bit because floating -! multiplication is commutative and exactly rounded. - subroutine accum_hist_field_2D_speed(id, iblk, a, b, field, mask) - ! sqrt(a*a + b*b), accumulated without building it first. + ! sqrt(a*a + b*b) ! - ! ⚠ NOT in the generic interface: the argument list is the same shape as - ! accum_hist_field_2D_prod's, so the two cannot be resolved apart. Call - ! it by name. + ! NOT in the generic interface: the argument list is the same shape as + ! accum_hist_field_2D_prod's use ice_blocks, only: block, get_block use ice_calendar, only: nstreams @@ -1306,6 +1283,9 @@ subroutine accum_hist_field_2D_mul(id, iblk, a, s, field, mask) real (kind=dbl_kind), intent(inout) :: & field(:,:,:,:) + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) ! Defaults to tmask + type (block) :: & this_block ! block information for current block @@ -1313,11 +1293,6 @@ subroutine accum_hist_field_2D_mul(id, iblk, a, s, field, mask) logical (kind=log_kind) :: wet - ! Where to accumulate. Absent means tmask, which is what every caller - ! wanted before this argument existed. - logical (kind=log_kind), intent(in), optional :: & - mask(:,:) - character(len=*), parameter :: subname = '(accum_hist_field_2D_mul)' do ns = 1, nstreams @@ -1372,6 +1347,9 @@ subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field, mask) real (kind=dbl_kind), intent(inout) :: & field(:,:,:,:,:) + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) ! Default to tmask + type (block) :: & this_block ! block information for current block @@ -1379,11 +1357,6 @@ subroutine accum_hist_field_3D(id, iblk, ndim, field_accum, field, mask) logical (kind=log_kind) :: wet - ! Where to accumulate. Absent means tmask, which is what every caller - ! wanted before this argument existed. - logical (kind=log_kind), intent(in), optional :: & - mask(:,:) - character(len=*), parameter :: subname = '(accum_hist_field_3D)' !--------------------------------------------------------------- @@ -1450,6 +1423,9 @@ subroutine accum_hist_field_4D(id, iblk, ndim3, ndim4, field_accum, field, mask) real (kind=dbl_kind), intent(inout) :: & field(:,:,:,:,:,:) + logical (kind=log_kind), intent(in), optional :: & + mask(:,:) ! default to tmassk + type (block) :: & this_block ! block information for current block @@ -1457,11 +1433,6 @@ subroutine accum_hist_field_4D(id, iblk, ndim3, ndim4, field_accum, field, mask) logical (kind=log_kind) :: wet - ! Where to accumulate. Absent means tmask, which is what every caller - ! wanted before this argument existed. - logical (kind=log_kind), intent(in), optional :: & - mask(:,:) - character(len=*), parameter :: subname = '(accum_hist_field_4D)' !--------------------------------------------------------------- diff --git a/cicecore/cicedyn/analysis/ice_history_snow.F90 b/cicecore/cicedyn/analysis/ice_history_snow.F90 index a2937f8e3..8fb01d4bb 100644 --- a/cicecore/cicedyn/analysis/ice_history_snow.F90 +++ b/cicecore/cicedyn/analysis/ice_history_snow.F90 @@ -358,7 +358,7 @@ subroutine accum_hist_snow (iblk) if (f_smassice(1:1)/= 'x') then worka(:,:) = c0 do k = 1, nzslyr - worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_smice+k-1,iblk) enddo worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) * vsno(ilo:ihi,jlo:jhi,iblk) / real(nslyr,kind=dbl_kind) @@ -367,7 +367,7 @@ subroutine accum_hist_snow (iblk) if (f_smassliq(1:1)/= 'x') then worka(:,:) = c0 do k = 1, nzslyr - worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_smliq+k-1,iblk) enddo worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) * vsno(ilo:ihi,jlo:jhi,iblk) / real(nslyr,kind=dbl_kind) @@ -376,7 +376,7 @@ subroutine accum_hist_snow (iblk) if (f_rhos_cmp(1:1)/= 'x') then worka(:,:) = c0 do k = 1, nzslyr - worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_rhos+k-1,iblk) enddo worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) / real(nslyr,kind=dbl_kind) @@ -385,7 +385,7 @@ subroutine accum_hist_snow (iblk) if (f_rhos_cnt(1:1)/= 'x') then worka(:,:) = c0 do k = 1, nzslyr - worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) & + trcr(ilo:ihi,jlo:jhi,nt_smice+k-1,iblk) & + trcr(ilo:ihi,jlo:jhi,nt_smliq+k-1,iblk) enddo @@ -401,16 +401,13 @@ subroutine accum_hist_snow (iblk) worka(ilo:ihi,jlo:jhi) = worka(ilo:ihi,jlo:jhi) / real(nslyr,kind=dbl_kind) call accum_hist_field(n_rsnw, iblk, worka, a2D) endif - if (f_meltsliq(1:1)/= 'x') & - call accum_hist_field(n_meltsliq, iblk, & - meltsliq(:,:,iblk), a2D) - if (f_fsloss(1:1)/= 'x') & - call accum_hist_field(n_fsloss, iblk, & - fsloss(:,:,iblk), a2D) + if (f_meltsliq (1:1)/= 'x') & + call accum_hist_field(n_meltsliq , iblk, meltsliq(:,:,iblk), a2D) + if (f_fsloss (1:1)/= 'x') & + call accum_hist_field(n_fsloss , iblk, fsloss (:,:,iblk), a2D) if (f_sisndmasswind(1:1)/= 'x') & - call accum_hist_field(n_sisndmasswind, iblk, & - fsloss(:,:,iblk), a2D) + call accum_hist_field(n_sisndmasswind, iblk, fsloss (:,:,iblk), a2D) endif ! allocated(a2D) @@ -455,7 +452,7 @@ subroutine accum_hist_snow (iblk) workb(:,:,:) = c0 do n = 1, ncat_hist do k = 1, nzslyr - workb(:,:,n) = workb(:,:,n) & + workb(:,:,n) = workb(:,:,n) & + trcrn(:,:,nt_smice+k-1,n,iblk) & + trcrn(:,:,nt_smliq+k-1,n,iblk) enddo