From 8492af9acd294368fb8ee749480165aa58b03ef1 Mon Sep 17 00:00:00 2001 From: mhrib <38077893+mhrib@users.noreply.github.com> Date: Fri, 28 Sep 2018 05:43:01 +0200 Subject: [PATCH] Alloc dyn4 (#194) * Allocatable dynamics version using namelist * Updated ice_in according to "Allocated Dynamics" * update scripts to automatically set namelist associated with grids and blocks * fix uarea initialization related to NYGLOB cpp (#1) * update pgi optimzation to address reproducibility problems (#2) * mods for nag compiler failure (#3) * Update to Consortium master bbec5d1e (#4) * update pgi compiler optimization to address reproducibility problems * Dummy and unused variables. (#180) * Remove some dummy arguments and unused variables. * Dummy variable cleanup * Cleanup * Remove icepack from commit * Reset icepack master * Fix * Fix * Update icepack * fix * Fix flush ifdef logic * Uninitialized variables. * Additional initialization * Update dummy * more dummy fixes * More hobart changes * Update Hobart Intel settings * Additional Hobart Intel changes * Update icepack * Some tweaks to dummy variables * Remove some initialization code. * Only remove istat checks in one routine. * update icepack (#188) * fix ice_abort error in ice_state.F90 (#5) --- cice.setup | 22 +- cicecore/cicedynB/dynamics/ice_dyn_eap.F90 | 39 ++- cicecore/cicedynB/dynamics/ice_dyn_shared.F90 | 23 +- cicecore/cicedynB/general/ice_flux.F90 | 241 ++++++++++++++++-- cicecore/cicedynB/general/ice_flux_bgc.F90 | 77 +++++- cicecore/cicedynB/general/ice_forcing.F90 | 61 +++-- cicecore/cicedynB/general/ice_forcing_bgc.F90 | 49 +++- cicecore/cicedynB/general/ice_init.F90 | 16 +- cicecore/cicedynB/general/ice_state.F90 | 50 +++- .../cicedynB/infrastructure/ice_blocks.F90 | 7 +- .../cicedynB/infrastructure/ice_domain.F90 | 25 +- cicecore/cicedynB/infrastructure/ice_grid.F90 | 115 +++++++-- cicecore/drivers/cesm/CICE_InitMod.F90 | 22 +- cicecore/drivers/cice/CICE_InitMod.F90 | 24 +- cicecore/drivers/hadgem3/CICE_InitMod.F90 | 24 +- cicecore/shared/ice_arrays_column.F90 | 151 ++++++++--- cicecore/shared/ice_domain_size.F90 | 16 +- configuration/scripts/cice.build | 7 +- configuration/scripts/cice.settings | 14 +- configuration/scripts/ice_in | 5 + ...settings.sh => parse_namelist_from_env.sh} | 9 +- 21 files changed, 789 insertions(+), 208 deletions(-) rename configuration/scripts/{parse_namelist_from_settings.sh => parse_namelist_from_env.sh} (61%) diff --git a/cice.setup b/cice.setup index b41d287b3..048b0fc35 100755 --- a/cice.setup +++ b/cice.setup @@ -518,7 +518,7 @@ foreach compiler ( $ncompilers ) end # from basic script dir to casescr - foreach file (parse_namelist.sh parse_settings.sh parse_namelist_from_settings.sh cice_decomp.csh cice.run.setup.csh cice.test.setup.csh) + foreach file (parse_namelist.sh parse_settings.sh parse_namelist_from_env.sh cice_decomp.csh cice.run.setup.csh cice.test.setup.csh) if !(-e ${ICE_SCRIPTS}/$file) then echo "${0}: ERROR, ${ICE_SCRIPTS}/$file not found" exit -1 @@ -603,6 +603,7 @@ foreach compiler ( $ncompilers ) echo "ICE_COMPILER = ${compiler}" echo "ICE_PES = ${task}x${thrd}" echo "ICE_GRID = ${grid} (${ICE_DECOMP_NXGLOB}x${ICE_DECOMP_NYGLOB}) blocksize=${ICE_DECOMP_BLCKX}x${ICE_DECOMP_BLCKY}x${ICE_DECOMP_MXBLCKS}" + echo "ICE_DECOMP = ${ICE_DECOMP_DECOMP} ${ICE_DECOMP_DSHAPE}" #------------------------------------------------------------ # Copy in and update cice.settings and ice_in files @@ -618,7 +619,12 @@ foreach compiler ( $ncompilers ) cat >! ${fimods} << EOF1 # cice.setup settings -nprocs = ${task} +nprocs = ${task} +nx_global = ${ICE_DECOMP_NXGLOB} +ny_global = ${ICE_DECOMP_NYGLOB} +block_size_x = ${ICE_DECOMP_BLCKX} +block_size_y = ${ICE_DECOMP_BLCKY} +max_blocks = ${ICE_DECOMP_MXBLCKS} distribution_type = '${ICE_DECOMP_DECOMP}' processor_shape = '${ICE_DECOMP_DSHAPE}' version_name = '${ICE_VERSION}' @@ -651,13 +657,13 @@ setenv ICE_COMPILER ${compiler} setenv ICE_MACHCOMP ${machcomp} setenv ICE_RUNDIR ${ICE_MACHINE_WKDIR}/${casename} setenv ICE_GRID ${grid} -setenv ICE_NXGLOB ${ICE_DECOMP_NXGLOB} -setenv ICE_NYGLOB ${ICE_DECOMP_NYGLOB} +#setenv ICE_NXGLOB ${ICE_DECOMP_NXGLOB} # moved to namelist +#setenv ICE_NYGLOB ${ICE_DECOMP_NYGLOB} # moved to namelist setenv ICE_NTASKS ${task} setenv ICE_NTHRDS ${thrd} -setenv ICE_MXBLCKS ${ICE_DECOMP_MXBLCKS} -setenv ICE_BLCKX ${ICE_DECOMP_BLCKX} -setenv ICE_BLCKY ${ICE_DECOMP_BLCKY} +#setenv ICE_MXBLCKS ${ICE_DECOMP_MXBLCKS} # moved to namelist +#setenv ICE_BLCKX ${ICE_DECOMP_BLCKX} # moved to namelist +#setenv ICE_BLCKY ${ICE_DECOMP_BLCKY} # moved to namelist setenv ICE_BASELINE ${basedir_tmp} setenv ICE_BASEGEN ${baseGen} setenv ICE_BASECOM ${baseCom} @@ -754,7 +760,7 @@ EOF2 ${casescr}/parse_namelist.sh ice_in ${fimods} source ./cice.settings source ./env.${machcomp} || exit 2 - ${casescr}/parse_namelist_from_settings.sh ice_in cice.settings + ${casescr}/parse_namelist_from_env.sh ice_in #------------------------------------------------------------ # Generate run script diff --git a/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 b/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 index e7b5bacbc..b2202369d 100644 --- a/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 +++ b/cicecore/cicedynB/dynamics/ice_dyn_eap.F90 @@ -33,7 +33,8 @@ module ice_dyn_eap implicit none private - public :: eap, init_eap, write_restart_eap, read_restart_eap + public :: eap, init_eap, write_restart_eap, read_restart_eap, & + alloc_dyn_eap ! Look-up table needed for calculating structure tensor integer (int_kind), parameter :: & @@ -44,12 +45,12 @@ module ice_dyn_eap real (kind=dbl_kind), dimension (nx_yield,ny_yield,na_yield) :: & s11r, s12r, s22r, s11s, s12s, s22s - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable :: & a11_1, a11_2, a11_3, a11_4, & ! components of a12_1, a12_2, a12_3, a12_4 ! structure tensor ! history - real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension(:,:,:), allocatable, public :: & e11 , & ! components of strain rate tensor (1/s) e12 , & e22 , & @@ -66,6 +67,38 @@ module ice_dyn_eap contains +!======================================================================= +! +! Allocate space for all variables +! + subroutine alloc_dyn_eap + + integer (int_kind) :: ierr + + allocate( a11_1 (nx_block,ny_block,max_blocks), & + a11_2 (nx_block,ny_block,max_blocks), & + a11_3 (nx_block,ny_block,max_blocks), & + a11_4 (nx_block,ny_block,max_blocks), & + a12_1 (nx_block,ny_block,max_blocks), & + a12_2 (nx_block,ny_block,max_blocks), & + a12_3 (nx_block,ny_block,max_blocks), & + a12_4 (nx_block,ny_block,max_blocks), & + e11 (nx_block,ny_block,max_blocks), & + e12 (nx_block,ny_block,max_blocks), & + e22 (nx_block,ny_block,max_blocks), & + yieldstress11(nx_block,ny_block,max_blocks), & + yieldstress12(nx_block,ny_block,max_blocks), & + yieldstress22(nx_block,ny_block,max_blocks), & + s11 (nx_block,ny_block,max_blocks), & + s12 (nx_block,ny_block,max_blocks), & + s22 (nx_block,ny_block,max_blocks), & + a11 (nx_block,ny_block,max_blocks), & + a12 (nx_block,ny_block,max_blocks), & + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_dyn_eap): Out of memory') + + end subroutine alloc_dyn_eap + !======================================================================= ! ! Elastic-anisotropic-plastic dynamics driver diff --git a/cicecore/cicedynB/dynamics/ice_dyn_shared.F90 b/cicecore/cicedynB/dynamics/ice_dyn_shared.F90 index 17ffa388d..4d962f987 100644 --- a/cicecore/cicedynB/dynamics/ice_dyn_shared.F90 +++ b/cicecore/cicedynB/dynamics/ice_dyn_shared.F90 @@ -10,6 +10,7 @@ module ice_dyn_shared use ice_kinds_mod + use ice_communicate, only: my_task, master_task use ice_constants, only: c0, c1, p01, p001 use ice_blocks, only: nx_block, ny_block use ice_domain_size, only: max_blocks @@ -21,7 +22,8 @@ module ice_dyn_shared implicit none private public :: init_evp, set_evp_parameters, stepu, principal_stress, & - dyn_prep1, dyn_prep2, dyn_finish, basal_stress_coeff + dyn_prep1, dyn_prep2, dyn_finish, basal_stress_coeff, & + alloc_dyn_shared ! namelist parameters @@ -60,7 +62,7 @@ module ice_dyn_shared real (kind=dbl_kind), allocatable, public :: & fcor_blk(:,:,:) ! Coriolis parameter (1/s) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & uvel_init, & ! x-component of velocity (m/s), beginning of timestep vvel_init ! y-component of velocity (m/s), beginning of timestep @@ -75,6 +77,22 @@ module ice_dyn_shared contains +!======================================================================= +! +! Allocate space for all variables +! + subroutine alloc_dyn_shared + + integer (int_kind) :: ierr + + allocate( & + uvel_init (nx_block,ny_block,max_blocks), & ! x-component of velocity (m/s), beginning of timestep + vvel_init (nx_block,ny_block,max_blocks), & ! y-component of velocity (m/s), beginning of timestep + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_dyn_shared): Out of memory') + + end subroutine alloc_dyn_shared + !======================================================================= ! Initialize parameters and variables needed for the evp dynamics @@ -83,7 +101,6 @@ module ice_dyn_shared subroutine init_evp (dt) use ice_blocks, only: nx_block, ny_block - use ice_communicate, only: my_task, master_task use ice_constants, only: c0, c2, omega use ice_domain, only: nblocks use ice_domain_size, only: max_blocks diff --git a/cicecore/cicedynB/general/ice_flux.F90 b/cicecore/cicedynB/general/ice_flux.F90 index dbdab39b3..2d0797ef6 100644 --- a/cicecore/cicedynB/general/ice_flux.F90 +++ b/cicecore/cicedynB/general/ice_flux.F90 @@ -26,13 +26,13 @@ module ice_flux implicit none private public :: init_coupler_flux, init_history_therm, init_history_dyn, & - init_flux_ocn, init_flux_atm, scale_fluxes + init_flux_ocn, init_flux_atm, scale_fluxes, alloc_flux !----------------------------------------------------------------- ! Dynamics component !----------------------------------------------------------------- - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & ! in from atmos (if .not.calc_strair) strax , & ! wind stress components (N/m^2) @@ -56,7 +56,7 @@ module ice_flux ! diagnostic - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & sig1 , & ! normalized principal stress component sig2 , & ! normalized principal stress component sigP , & ! internal ice pressure (N/m) @@ -79,7 +79,7 @@ module ice_flux opening ! rate of opening due to divergence/shear (1/s) real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & ! ridging diagnostics in categories dardg1ndt, & ! rate of area loss by ridging ice (1/s) dardg2ndt, & ! rate of area gain by new ridges (1/s) @@ -95,19 +95,19 @@ module ice_flux ! restart - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & ! ice stress tensor in each corner of T cell (kg/s^2) stressp_1, stressp_2, stressp_3, stressp_4 , & ! sigma11+sigma22 stressm_1, stressm_2, stressm_3, stressm_4 , & ! sigma11-sigma22 stress12_1,stress12_2,stress12_3,stress12_4 ! sigma12 logical (kind=log_kind), & - dimension (nx_block,ny_block,max_blocks), public :: & + dimension (:,:,:), allocatable, public :: & iceumask ! ice extent mask (U-cell) ! internal - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fm , & ! Coriolis param. * mass in U-cell (kg/s) Tbu ! coefficient for basal stress (N/m^2) @@ -117,7 +117,7 @@ module ice_flux ! in from atmosphere (if calc_Tsfc) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & zlvl , & ! atm level height (m) uatm , & ! wind velocity components (m/s) vatm , & @@ -138,7 +138,7 @@ module ice_flux ! not per ice area. When in standalone mode, these are per ice area. real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & fsurfn_f , & ! net flux to top surface, excluding fcondtop fcondtopn_f, & ! downward cond flux at top surface (W m-2) fsensn_f , & ! sensible heat flux (W m-2) @@ -146,13 +146,13 @@ module ice_flux ! in from atmosphere - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & frain , & ! rainfall rate (kg/m^2 s) fsnow ! snowfall rate (kg/m^2 s) ! in from ocean - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & sss , & ! sea surface salinity (ppt) sst , & ! sea surface temperature (C) frzmlt , & ! freezing/melting potential (W/m^2) @@ -166,7 +166,7 @@ module ice_flux ! out to atmosphere (if calc_Tsfc) ! note Tsfc is in ice_state.F - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fsens , & ! sensible heat flux (W/m^2) flat , & ! latent heat flux (W/m^2) fswabs , & ! shortwave flux absorbed in ice and ocean (W/m^2) @@ -180,7 +180,7 @@ module ice_flux evapi ! evaporative water flux over ice (kg/m^2/s) ! albedos aggregated over categories (if calc_Tsfc) - real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & alvdr , & ! visible, direct (fraction) alidr , & ! near-ir, direct (fraction) alvdf , & ! visible, diffuse (fraction) @@ -203,13 +203,13 @@ module ice_flux alidf_init ! near-ir, diffuse (fraction) real (kind=dbl_kind), & - dimension(nx_block,ny_block,max_blocks,max_nstrm), public :: & + dimension(:,:,:,:), allocatable, public :: & albcnt ! counter for zenith angle ! out to ocean ! (Note CICE_IN_NEMO does not use these for coupling. ! It uses fresh_ai,fsalt_ai,fhocn_ai and fswthru_ai) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fpond , & ! fresh water flux to ponds (kg/m^2/s) fresh , & ! fresh water flux to ocean (kg/m^2/s) fsalt , & ! salt flux to ocean (kg/m^2/s) @@ -218,8 +218,7 @@ module ice_flux ! internal - real (kind=dbl_kind), & - dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & scale_factor! scaling factor for shortwave components logical (kind=log_kind), public :: & @@ -227,21 +226,21 @@ module ice_flux l_mpond_fresh ! if true, include freshwater feedback from meltponds ! when running in ice-ocean or coupled configuration - real (kind=dbl_kind), dimension (nx_block,ny_block,ncat,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & meltsn , & ! snow melt in category n (m) melttn , & ! top melt in category n (m) meltbn , & ! bottom melt in category n (m) congeln , & ! congelation ice formation in category n (m) snoicen ! snow-ice formation in category n (m) - real (kind=dbl_kind), dimension (nx_block,ny_block,ncat,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & keffn_top ! effective thermal conductivity of the top ice layer ! on categories (W/m^2/K) ! quantities passed from ocean mixed layer to atmosphere ! (for running with CAM) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & strairx_ocn , & ! stress on ocean by air, x-direction strairy_ocn , & ! stress on ocean by air, y-direction fsens_ocn , & ! sensible heat flux (W/m^2) @@ -257,7 +256,7 @@ module ice_flux ! diagnostic - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fsurf , & ! net surface heat flux (excluding fcondtop)(W/m^2) fcondtop,&! top surface conductive flux (W/m^2) fcondbot,&! bottom surface conductive flux (W/m^2) @@ -280,7 +279,7 @@ module ice_flux frazil_diag ! frazil ice growth diagnostic (m/step-->cm/day) real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & fsurfn, & ! category fsurf fcondtopn,& ! category fcondtop fcondbotn,& ! category fcondbot @@ -294,14 +293,14 @@ module ice_flux ! (The others suffer from problem of incorrect values at grid boxes ! that change from an ice free state to an icy state.) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fresh_ai, & ! fresh water flux to ocean (kg/m^2/s) fsalt_ai, & ! salt flux to ocean (kg/m^2/s) fhocn_ai, & ! net heat flux to ocean (W/m^2) fswthru_ai ! shortwave penetrating to ocean (W/m^2) ! Used with data assimilation in hadgem drivers - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks) :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fresh_da, & ! fresh water flux to ocean due to data assim (kg/m^2/s) fsalt_da ! salt flux to ocean due to data assimilation(kg/m^2/s) @@ -309,14 +308,14 @@ module ice_flux ! internal !----------------------------------------------------------------- - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & rside , & ! fraction of ice that melts laterally fsw , & ! incoming shortwave radiation (W/m^2) coszen , & ! cosine solar zenith angle, < 0 for sun below horizon rdg_conv, & ! convergence term for ridging (1/s) rdg_shear ! shear term for ridging (1/s) - real (kind=dbl_kind), dimension(nx_block,ny_block,nilyr+1,max_blocks), public :: & + real (kind=dbl_kind), dimension(:,:,:,:), allocatable, public :: & salinz ,& ! initial salinity profile (ppt) Tmltz ! initial melting temperature (^oC) @@ -324,6 +323,195 @@ module ice_flux contains +!======================================================================= +! +! Allocate space for all variables +! + subroutine alloc_flux + + integer (int_kind) :: ierr + + allocate( & + strax (nx_block,ny_block,max_blocks), & ! wind stress components (N/m^2) + stray (nx_block,ny_block,max_blocks), & ! + uocn (nx_block,ny_block,max_blocks), & ! ocean current, x-direction (m/s) + vocn (nx_block,ny_block,max_blocks), & ! ocean current, y-direction (m/s) + ss_tltx (nx_block,ny_block,max_blocks), & ! sea surface slope, x-direction (m/m) + ss_tlty (nx_block,ny_block,max_blocks), & ! sea surface slope, y-direction + hwater (nx_block,ny_block,max_blocks), & ! water depth for basal stress calc (landfast ice) + strairxT (nx_block,ny_block,max_blocks), & ! stress on ice by air, x-direction + strairyT (nx_block,ny_block,max_blocks), & ! stress on ice by air, y-direction + strocnxT (nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction + strocnyT (nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction + sig1 (nx_block,ny_block,max_blocks), & ! normalized principal stress component + sig2 (nx_block,ny_block,max_blocks), & ! normalized principal stress component + sigP (nx_block,ny_block,max_blocks), & ! internal ice pressure (N/m) + taubx (nx_block,ny_block,max_blocks), & ! basal stress (x) (N/m^2) + tauby (nx_block,ny_block,max_blocks), & ! basal stress (y) (N/m^2) + strairx (nx_block,ny_block,max_blocks), & ! stress on ice by air, x-direction + strairy (nx_block,ny_block,max_blocks), & ! stress on ice by air, y-direction + strocnx (nx_block,ny_block,max_blocks), & ! ice-ocean stress, x-direction + strocny (nx_block,ny_block,max_blocks), & ! ice-ocean stress, y-direction + strtltx (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, x-direction + strtlty (nx_block,ny_block,max_blocks), & ! stress due to sea surface slope, y-direction + strintx (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, x (N/m^2) + strinty (nx_block,ny_block,max_blocks), & ! divergence of internal ice stress, y (N/m^2) + daidtd (nx_block,ny_block,max_blocks), & ! ice area tendency due to transport (1/s) + dvidtd (nx_block,ny_block,max_blocks), & ! ice volume tendency due to transport (m/s) + dagedtd (nx_block,ny_block,max_blocks), & ! ice age tendency due to transport (s/s) + dardg1dt (nx_block,ny_block,max_blocks), & ! rate of area loss by ridging ice (1/s) + dardg2dt (nx_block,ny_block,max_blocks), & ! rate of area gain by new ridges (1/s) + dvirdgdt (nx_block,ny_block,max_blocks), & ! rate of ice volume ridged (m/s) + opening (nx_block,ny_block,max_blocks), & ! rate of opening due to divergence/shear (1/s) + stressp_1 (nx_block,ny_block,max_blocks), & ! sigma11+sigma22 + stressp_2 (nx_block,ny_block,max_blocks), & ! sigma11+sigma22 + stressp_3 (nx_block,ny_block,max_blocks), & ! sigma11+sigma22 + stressp_4 (nx_block,ny_block,max_blocks), & ! sigma11+sigma22 + stressm_1 (nx_block,ny_block,max_blocks), & ! sigma11-sigma22 + stressm_2 (nx_block,ny_block,max_blocks), & ! sigma11-sigma22 + stressm_3 (nx_block,ny_block,max_blocks), & ! sigma11-sigma22 + stressm_4 (nx_block,ny_block,max_blocks), & ! sigma11-sigma22 + stress12_1 (nx_block,ny_block,max_blocks), & ! sigma12 + stress12_2 (nx_block,ny_block,max_blocks), & ! sigma12 + stress12_3 (nx_block,ny_block,max_blocks), & ! sigma12 + stress12_4 (nx_block,ny_block,max_blocks), & ! sigma12 + iceumask (nx_block,ny_block,max_blocks), & ! ice extent mask (U-cell) + fm (nx_block,ny_block,max_blocks), & ! Coriolis param. * mass in U-cell (kg/s) + Tbu (nx_block,ny_block,max_blocks), & ! coefficient for basal stress (landfast ice) + zlvl (nx_block,ny_block,max_blocks), & ! atm level height (m) + uatm (nx_block,ny_block,max_blocks), & ! wind velocity components (m/s) + vatm (nx_block,ny_block,max_blocks), & + wind (nx_block,ny_block,max_blocks), & ! wind speed (m/s) + potT (nx_block,ny_block,max_blocks), & ! air potential temperature (K) + Tair (nx_block,ny_block,max_blocks), & ! air temperature (K) + Qa (nx_block,ny_block,max_blocks), & ! specific humidity (kg/kg) + rhoa (nx_block,ny_block,max_blocks), & ! air density (kg/m^3) + swvdr (nx_block,ny_block,max_blocks), & ! sw down, visible, direct (W/m^2) + swvdf (nx_block,ny_block,max_blocks), & ! sw down, visible, diffuse (W/m^2) + swidr (nx_block,ny_block,max_blocks), & ! sw down, near IR, direct (W/m^2) + swidf (nx_block,ny_block,max_blocks), & ! sw down, near IR, diffuse (W/m^2) + flw (nx_block,ny_block,max_blocks), & ! incoming longwave radiation (W/m^2) + frain (nx_block,ny_block,max_blocks), & ! rainfall rate (kg/m^2 s) + fsnow (nx_block,ny_block,max_blocks), & ! snowfall rate (kg/m^2 s) + sss (nx_block,ny_block,max_blocks), & ! sea surface salinity (ppt) + sst (nx_block,ny_block,max_blocks), & ! sea surface temperature (C) + frzmlt (nx_block,ny_block,max_blocks), & ! freezing/melting potential (W/m^2) + frzmlt_init(nx_block,ny_block,max_blocks), & ! frzmlt used in current time step (W/m^2) + Tf (nx_block,ny_block,max_blocks), & ! freezing temperature (C) + qdp (nx_block,ny_block,max_blocks), & ! deep ocean heat flux (W/m^2), negative upward + hmix (nx_block,ny_block,max_blocks), & ! mixed layer depth (m) + daice_da (nx_block,ny_block,max_blocks), & ! data assimilation concentration increment rate (concentration s-1)(only used in hadgem drivers) + fsens (nx_block,ny_block,max_blocks), & ! sensible heat flux (W/m^2) + flat (nx_block,ny_block,max_blocks), & ! latent heat flux (W/m^2) + fswabs (nx_block,ny_block,max_blocks), & ! shortwave flux absorbed in ice and ocean (W/m^2) + fswint_ai (nx_block,ny_block,max_blocks), & ! SW absorbed in ice interior below surface (W/m^2) + flwout (nx_block,ny_block,max_blocks), & ! outgoing longwave radiation (W/m^2) + Tref (nx_block,ny_block,max_blocks), & ! 2m atm reference temperature (K) + Qref (nx_block,ny_block,max_blocks), & ! 2m atm reference spec humidity (kg/kg) + Uref (nx_block,ny_block,max_blocks), & ! 10m atm reference wind speed (m/s) + evap (nx_block,ny_block,max_blocks), & ! evaporative water flux (kg/m^2/s) + evaps (nx_block,ny_block,max_blocks), & ! evaporative water flux over snow (kg/m^2/s) + evapi (nx_block,ny_block,max_blocks), & ! evaporative water flux over ice (kg/m^2/s) + alvdr (nx_block,ny_block,max_blocks), & ! visible, direct (fraction) + alidr (nx_block,ny_block,max_blocks), & ! near-ir, direct (fraction) + alvdf (nx_block,ny_block,max_blocks), & ! visible, diffuse (fraction) + alidf (nx_block,ny_block,max_blocks), & ! near-ir, diffuse (fraction) + alvdr_ai (nx_block,ny_block,max_blocks), & ! visible, direct (fraction) + alidr_ai (nx_block,ny_block,max_blocks), & ! near-ir, direct (fraction) + alvdf_ai (nx_block,ny_block,max_blocks), & ! visible, diffuse (fraction) + alidf_ai (nx_block,ny_block,max_blocks), & ! near-ir, diffuse (fraction) + albice (nx_block,ny_block,max_blocks), & ! bare ice albedo + albsno (nx_block,ny_block,max_blocks), & ! snow albedo + albpnd (nx_block,ny_block,max_blocks), & ! melt pond albedo + apeff_ai (nx_block,ny_block,max_blocks), & ! effective pond area used for radiation calculation + snowfrac (nx_block,ny_block,max_blocks), & ! snow fraction used in radiation + alvdr_init (nx_block,ny_block,max_blocks), & ! visible, direct (fraction) + alidr_init (nx_block,ny_block,max_blocks), & ! near-ir, direct (fraction) + alvdf_init (nx_block,ny_block,max_blocks), & ! visible, diffuse (fraction) + alidf_init (nx_block,ny_block,max_blocks), & ! near-ir, diffuse (fraction) + fpond (nx_block,ny_block,max_blocks), & ! fresh water flux to ponds (kg/m^2/s) + fresh (nx_block,ny_block,max_blocks), & ! fresh water flux to ocean (kg/m^2/s) + fsalt (nx_block,ny_block,max_blocks), & ! salt flux to ocean (kg/m^2/s) + fhocn (nx_block,ny_block,max_blocks), & ! net heat flux to ocean (W/m^2) + fswthru (nx_block,ny_block,max_blocks), & ! shortwave penetrating to ocean (W/m^2) + scale_factor (nx_block,ny_block,max_blocks), & ! scaling factor for shortwave components + strairx_ocn(nx_block,ny_block,max_blocks), & ! stress on ocean by air, x-direction + strairy_ocn(nx_block,ny_block,max_blocks), & ! stress on ocean by air, y-direction + fsens_ocn (nx_block,ny_block,max_blocks), & ! sensible heat flux (W/m^2) + flat_ocn (nx_block,ny_block,max_blocks), & ! latent heat flux (W/m^2) + flwout_ocn (nx_block,ny_block,max_blocks), & ! outgoing longwave radiation (W/m^2) + evap_ocn (nx_block,ny_block,max_blocks), & ! evaporative water flux (kg/m^2/s) + alvdr_ocn (nx_block,ny_block,max_blocks), & ! visible, direct (fraction) + alidr_ocn (nx_block,ny_block,max_blocks), & ! near-ir, direct (fraction) + alvdf_ocn (nx_block,ny_block,max_blocks), & ! visible, diffuse (fraction) + alidf_ocn (nx_block,ny_block,max_blocks), & ! near-ir, diffuse (fraction) + Tref_ocn (nx_block,ny_block,max_blocks), & ! 2m atm reference temperature (K) + Qref_ocn (nx_block,ny_block,max_blocks), & ! 2m atm reference spec humidity (kg/kg) + fsurf (nx_block,ny_block,max_blocks), & ! net surface heat flux (excluding fcondtop)(W/m^2) + fcondtop (nx_block,ny_block,max_blocks), & ! top surface conductive flux (W/m^2) + fcondbot (nx_block,ny_block,max_blocks), & ! bottom surface conductive flux (W/m^2) + fbot (nx_block,ny_block,max_blocks), & ! heat flux at bottom surface of ice (excluding excess) (W/m^2) + Tbot (nx_block,ny_block,max_blocks), & ! temperature at bottom surface of ice (deg C) + Tsnice (nx_block,ny_block,max_blocks), & ! temperature at snow ice interface (deg C) + congel (nx_block,ny_block,max_blocks), & ! basal ice growth (m/step-->cm/day) + frazil (nx_block,ny_block,max_blocks), & ! frazil ice growth (m/step-->cm/day) + snoice (nx_block,ny_block,max_blocks), & ! snow-ice formation (m/step-->cm/day) + meltt (nx_block,ny_block,max_blocks), & ! top ice melt (m/step-->cm/day) + melts (nx_block,ny_block,max_blocks), & ! snow melt (m/step-->cm/day) + meltb (nx_block,ny_block,max_blocks), & ! basal ice melt (m/step-->cm/day) + meltl (nx_block,ny_block,max_blocks), & ! lateral ice melt (m/step-->cm/day) + dsnow (nx_block,ny_block,max_blocks), & ! change in snow thickness (m/step-->cm/day) + daidtt (nx_block,ny_block,max_blocks), & ! ice area tendency thermo. (s^-1) + dvidtt (nx_block,ny_block,max_blocks), & ! ice volume tendency thermo. (m/s) + dagedtt (nx_block,ny_block,max_blocks), & ! ice age tendency thermo. (s/s) + mlt_onset (nx_block,ny_block,max_blocks), & ! day of year that sfc melting begins + frz_onset (nx_block,ny_block,max_blocks), & ! day of year that freezing begins (congel or frazil) + frazil_diag(nx_block,ny_block,max_blocks), & ! frazil ice growth diagnostic (m/step-->cm/day) + fresh_ai (nx_block,ny_block,max_blocks), & ! fresh water flux to ocean (kg/m^2/s) + fsalt_ai (nx_block,ny_block,max_blocks), & ! salt flux to ocean (kg/m^2/s) + fhocn_ai (nx_block,ny_block,max_blocks), & ! net heat flux to ocean (W/m^2) + fswthru_ai (nx_block,ny_block,max_blocks), & ! shortwave penetrating to ocean (W/m^2) + fresh_da (nx_block,ny_block,max_blocks), & ! fresh water flux to ocean due to data assim (kg/m^2/s) + fsalt_da (nx_block,ny_block,max_blocks), & ! salt flux to ocean due to data assimilation(kg/m^2/s) + rside (nx_block,ny_block,max_blocks), & ! fraction of ice that melts laterally + fsw (nx_block,ny_block,max_blocks), & ! incoming shortwave radiation (W/m^2) + coszen (nx_block,ny_block,max_blocks), & ! cosine solar zenith angle, < 0 for sun below horizon + rdg_conv (nx_block,ny_block,max_blocks), & ! convergence term for ridging (1/s) + rdg_shear (nx_block,ny_block,max_blocks), & ! shear term for ridging (1/s) + dardg1ndt (nx_block,ny_block,ncat,max_blocks), & ! rate of area loss by ridging ice (1/s) + dardg2ndt (nx_block,ny_block,ncat,max_blocks), & ! rate of area gain by new ridges (1/s) + dvirdgndt (nx_block,ny_block,ncat,max_blocks), & ! rate of ice volume ridged (m/s) + aparticn (nx_block,ny_block,ncat,max_blocks), & ! participation function + krdgn (nx_block,ny_block,ncat,max_blocks), & ! mean ridge thickness/thickness of ridging ice + ardgn (nx_block,ny_block,ncat,max_blocks), & ! fractional area of ridged ice + vrdgn (nx_block,ny_block,ncat,max_blocks), & ! volume of ridged ice + araftn (nx_block,ny_block,ncat,max_blocks), & ! rafting ice area + vraftn (nx_block,ny_block,ncat,max_blocks), & ! rafting ice volume + aredistn (nx_block,ny_block,ncat,max_blocks), & ! redistribution function: fraction of new ridge area + vredistn (nx_block,ny_block,ncat,max_blocks), & ! redistribution function: fraction of new ridge volume + fsurfn_f (nx_block,ny_block,ncat,max_blocks), & ! net flux to top surface, excluding fcondtop + fcondtopn_f(nx_block,ny_block,ncat,max_blocks), & ! downward cond flux at top surface (W m-2) + fsensn_f (nx_block,ny_block,ncat,max_blocks), & ! sensible heat flux (W m-2) + flatn_f (nx_block,ny_block,ncat,max_blocks), & ! latent heat flux (W m-2) + meltsn (nx_block,ny_block,ncat,max_blocks), & ! snow melt in category n (m) + melttn (nx_block,ny_block,ncat,max_blocks), & ! top melt in category n (m) + meltbn (nx_block,ny_block,ncat,max_blocks), & ! bottom melt in category n (m) + congeln (nx_block,ny_block,ncat,max_blocks), & ! congelation ice formation in category n (m) + snoicen (nx_block,ny_block,ncat,max_blocks), & ! snow-ice formation in category n (m) + keffn_top (nx_block,ny_block,ncat,max_blocks), & ! effective thermal conductivity of the top ice layer + fsurfn (nx_block,ny_block,ncat,max_blocks), & ! category fsurf + fcondtopn (nx_block,ny_block,ncat,max_blocks), & ! category fcondtop + fcondbotn (nx_block,ny_block,ncat,max_blocks), & ! category fcondbot + fsensn (nx_block,ny_block,ncat,max_blocks), & ! category sensible heat flux + flatn (nx_block,ny_block,ncat,max_blocks), & ! category latent heat flux + albcnt (nx_block,ny_block,max_blocks,max_nstrm), & ! counter for zenith angle + salinz (nx_block,ny_block,nilyr+1,max_blocks), & ! initial salinity profile (ppt) + Tmltz (nx_block,ny_block,nilyr+1,max_blocks), & ! initial melting temperature (^oC) + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_flux): Out of memory') + + end subroutine alloc_flux + !======================================================================= ! Initialize all fluxes exchanged with flux coupler @@ -525,7 +713,6 @@ subroutine init_coupler_flux coszen (:,:,:) = c0 ! Cosine of the zenith angle fsw (:,:,:) = c0 ! shortwave radiation (W/m^2) -! fswfac (:,:,:) = c0 scale_factor(:,:,:) = c1 ! shortwave scaling factor wind (:,:,:) = sqrt(uatm(:,:,:)**2 & + vatm(:,:,:)**2) ! wind speed, (m/s) diff --git a/cicecore/cicedynB/general/ice_flux_bgc.F90 b/cicecore/cicedynB/general/ice_flux_bgc.F90 index 0254a6df3..3dc7d4146 100644 --- a/cicecore/cicedynB/general/ice_flux_bgc.F90 +++ b/cicecore/cicedynB/general/ice_flux_bgc.F90 @@ -19,32 +19,32 @@ module ice_flux_bgc implicit none private - public :: bgcflux_ice_to_ocn + public :: bgcflux_ice_to_ocn, alloc_flux_bgc ! in from atmosphere real (kind=dbl_kind), & !coupling variable for both tr_aero and tr_zaero - dimension (nx_block,ny_block,icepack_max_aero,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & faero_atm ! aerosol deposition rate (kg/m^2 s) real (kind=dbl_kind), & - dimension (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & flux_bio_atm ! all bio fluxes to ice from atmosphere ! in from ocean real (kind=dbl_kind), & - dimension (nx_block,ny_block,icepack_max_aero,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & faero_ocn ! aerosol flux to ocean (kg/m^2/s) ! out to ocean real (kind=dbl_kind), & - dimension (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & flux_bio , & ! all bio fluxes to ocean flux_bio_ai ! all bio fluxes to ocean, averaged over grid cell - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fzsal_ai, & ! salt flux to ocean from zsalinity (kg/m^2/s) fzsal_g_ai ! gravity drainage salt flux to ocean (kg/m^2/s) @@ -53,11 +53,11 @@ module ice_flux_bgc logical (kind=log_kind), public :: & cpl_bgc ! switch to couple BGC via drivers - real (kind=dbl_kind), dimension (nx_block,ny_block,ncat,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & hin_old , & ! old ice thickness dsnown ! change in snow thickness in category n (m) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & nit , & ! ocean nitrate (mmol/m^3) amm , & ! ammonia/um (mmol/m^3) sil , & ! silicate (mmol/m^3) @@ -72,33 +72,82 @@ module ice_flux_bgc fhum , & ! ice-ocean humic material carbon (mmol/m^2/s), positive to ocean fdust ! ice-ocean dust flux (kg/m^2/s), positive to ocean - real (kind=dbl_kind), dimension (nx_block,ny_block,icepack_max_algae, max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & algalN , & ! ocean algal nitrogen (mmol/m^3) (diatoms, pico, phaeo) falgalN ! ice-ocean algal nitrogen flux (mmol/m^2/s) (diatoms, pico, phaeo) - real (kind=dbl_kind), dimension (nx_block,ny_block,icepack_max_doc, max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & doc , & ! ocean doc (mmol/m^3) (saccharids, lipids, tbd ) fdoc ! ice-ocean doc flux (mmol/m^2/s) (saccharids, lipids, tbd) - real (kind=dbl_kind), dimension (nx_block,ny_block,icepack_max_don, max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & don , & ! ocean don (mmol/m^3) (proteins and amino acids) fdon ! ice-ocean don flux (mmol/m^2/s) (proteins and amino acids) - real (kind=dbl_kind), dimension (nx_block,ny_block,icepack_max_dic, max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & dic , & ! ocean dic (mmol/m^3) fdic ! ice-ocean dic flux (mmol/m^2/s) - real (kind=dbl_kind), dimension (nx_block,ny_block,icepack_max_fe, max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & fed, fep , & ! ocean dissolved and particulate fe (nM) ffed, ffep ! ice-ocean dissolved and particulate fe flux (umol/m^2/s) - real (kind=dbl_kind), dimension (nx_block,ny_block,icepack_max_aero, max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & zaeros ! ocean aerosols (mmol/m^3) !======================================================================= contains +!======================================================================= +! +! Allocate space for all variables +! + subroutine alloc_flux_bgc + + integer (int_kind) :: ierr + + allocate( & + fzsal_ai (nx_block,ny_block,max_blocks), & ! salt flux to ocean from zsalinity (kg/m^2/s) + fzsal_g_ai (nx_block,ny_block,max_blocks), & ! gravity drainage salt flux to ocean (kg/m^2/s) + nit (nx_block,ny_block,max_blocks), & ! ocean nitrate (mmol/m^3) + amm (nx_block,ny_block,max_blocks), & ! ammonia/um (mmol/m^3) + sil (nx_block,ny_block,max_blocks), & ! silicate (mmol/m^3) + dmsp (nx_block,ny_block,max_blocks), & ! dmsp (mmol/m^3) + dms (nx_block,ny_block,max_blocks), & ! dms (mmol/m^3) + hum (nx_block,ny_block,max_blocks), & ! humic material carbon (mmol/m^3) + fnit (nx_block,ny_block,max_blocks), & ! ice-ocean nitrate flux (mmol/m^2/s), positive to ocean + famm (nx_block,ny_block,max_blocks), & ! ice-ocean ammonia/um flux (mmol/m^2/s), positive to ocean + fsil (nx_block,ny_block,max_blocks), & ! ice-ocean silicate flux (mmol/m^2/s), positive to ocean + fdmsp (nx_block,ny_block,max_blocks), & ! ice-ocean dmsp (mmol/m^2/s), positive to ocean + fdms (nx_block,ny_block,max_blocks), & ! ice-ocean dms (mmol/m^2/s), positive to ocean + fhum (nx_block,ny_block,max_blocks), & ! ice-ocean humic material carbon (mmol/m^2/s), positive to ocean + fdust (nx_block,ny_block,max_blocks), & ! ice-ocean dust flux (kg/m^2/s), positive to ocean + hin_old (nx_block,ny_block,ncat,max_blocks), & ! old ice thickness + dsnown (nx_block,ny_block,ncat,max_blocks), & ! change in snow thickness in category n (m) + faero_atm (nx_block,ny_block,icepack_max_aero,max_blocks), & ! aerosol deposition rate (kg/m^2 s) + faero_ocn (nx_block,ny_block,icepack_max_aero,max_blocks), & ! aerosol flux to ocean (kg/m^2/s) + zaeros (nx_block,ny_block,icepack_max_aero,max_blocks), & ! ocean aerosols (mmol/m^3) + flux_bio_atm(nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! all bio fluxes to ice from atmosphere + flux_bio (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! all bio fluxes to ocean + flux_bio_ai (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! all bio fluxes to ocean, averaged over grid cell + algalN (nx_block,ny_block,icepack_max_algae,max_blocks), & ! ocean algal nitrogen (mmol/m^3) (diatoms, pico, phaeo) + falgalN (nx_block,ny_block,icepack_max_algae,max_blocks), & ! ice-ocean algal nitrogen flux (mmol/m^2/s) (diatoms, pico, phaeo) + doc (nx_block,ny_block,icepack_max_doc,max_blocks), & ! ocean doc (mmol/m^3) (saccharids, lipids, tbd ) + fdoc (nx_block,ny_block,icepack_max_doc,max_blocks), & ! ice-ocean doc flux (mmol/m^2/s) (saccharids, lipids, tbd) + don (nx_block,ny_block,icepack_max_don,max_blocks), & ! ocean don (mmol/m^3) (proteins and amino acids) + fdon (nx_block,ny_block,icepack_max_don,max_blocks), & ! ice-ocean don flux (mmol/m^2/s) (proteins and amino acids) + dic (nx_block,ny_block,icepack_max_dic,max_blocks), & ! ocean dic (mmol/m^3) + fdic (nx_block,ny_block,icepack_max_dic,max_blocks), & ! ice-ocean dic flux (mmol/m^2/s) + fed (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ocean dissolved fe (nM) + fep (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ocean particulate fe (nM) + ffed (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ice-ocean dissolved fe flux (umol/m^2/s) + ffep (nx_block,ny_block,icepack_max_fe, max_blocks), & ! ice-ocean particulate fe flux (umol/m^2/s) + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_flux_bgc): Out of memory') + + end subroutine alloc_flux_bgc + !======================================================================= ! Initialize some fluxes sent to coupler for use by the atm model diff --git a/cicecore/cicedynB/general/ice_forcing.F90 b/cicecore/cicedynB/general/ice_forcing.F90 index 45500791d..8db628c93 100644 --- a/cicecore/cicedynB/general/ice_forcing.F90 +++ b/cicecore/cicedynB/general/ice_forcing.F90 @@ -41,7 +41,7 @@ module ice_forcing implicit none private - public :: init_forcing_atmo, init_forcing_ocn, & + public :: init_forcing_atmo, init_forcing_ocn, alloc_forcing, & get_forcing_atmo, get_forcing_ocn, & read_clim_data, read_clim_data_nc, & interpolate_data, interp_coeff_monthly, & @@ -82,10 +82,10 @@ module ice_forcing oldrecnum = 0 , & ! old record number (save between steps) oldrecnum4X = 0 ! - real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: & + real (kind=dbl_kind), dimension(:,:,:), allocatable :: & cldf ! cloud fraction - real (kind=dbl_kind), dimension(nx_block,ny_block,2,max_blocks) :: & + real (kind=dbl_kind), dimension(:,:,:,:), allocatable :: & fsw_data, & ! field values at 2 temporal data points cldf_data, & fsnow_data, & @@ -106,7 +106,7 @@ module ice_forcing frain_data real (kind=dbl_kind), & - dimension(nx_block,ny_block,2,max_blocks,ncat) :: & + dimension(:,:,:,:,:), allocatable :: & topmelt_data, & botmelt_data @@ -136,7 +136,7 @@ module ice_forcing frcidf = 0.17_dbl_kind ! frac of incoming sw in near IR diffuse band real (kind=dbl_kind), & - dimension (nx_block,ny_block,max_blocks,nfld,12) :: & + dimension (:,:,:,:,:), allocatable :: & ocn_frc_m ! ocn data for 12 months logical (kind=log_kind), public :: & @@ -155,6 +155,41 @@ module ice_forcing contains +!======================================================================= +! +! Allocate space for all variables +! + subroutine alloc_forcing + integer (int_kind) :: ierr + + allocate ( & + cldf(nx_block,ny_block, max_blocks), & ! cloud fraction + fsw_data(nx_block,ny_block,2,max_blocks), & ! field values at 2 temporal data points + cldf_data(nx_block,ny_block,2,max_blocks), & + fsnow_data(nx_block,ny_block,2,max_blocks), & + Tair_data(nx_block,ny_block,2,max_blocks), & + uatm_data(nx_block,ny_block,2,max_blocks), & + vatm_data(nx_block,ny_block,2,max_blocks), & + wind_data(nx_block,ny_block,2,max_blocks), & + strax_data(nx_block,ny_block,2,max_blocks), & + stray_data(nx_block,ny_block,2,max_blocks), & + Qa_data(nx_block,ny_block,2,max_blocks), & + rhoa_data(nx_block,ny_block,2,max_blocks), & + flw_data(nx_block,ny_block,2,max_blocks), & + sst_data(nx_block,ny_block,2,max_blocks), & + sss_data(nx_block,ny_block,2,max_blocks), & + uocn_data(nx_block,ny_block,2,max_blocks), & + vocn_data(nx_block,ny_block,2,max_blocks), & + sublim_data(nx_block,ny_block,2,max_blocks), & + frain_data(nx_block,ny_block,2,max_blocks), & + topmelt_data(nx_block,ny_block,2,max_blocks,ncat), & + botmelt_data(nx_block,ny_block,2,max_blocks,ncat), & + ocn_frc_m(nx_block,ny_block, max_blocks,nfld,12), & ! ocn data for 12 months + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_forcing): Out of Memory') + + end subroutine alloc_forcing + !======================================================================= subroutine init_forcing_atmo @@ -164,20 +199,8 @@ subroutine init_forcing_atmo character(len=*), parameter :: subname = '(init_forcing_atmo)' -! fsw_data(:,:,:,:) = c0 -! cldf_data(:,:,:,:) = c0 -! fsnow_data(:,:,:,:) = c0 -! Tair_data(:,:,:,:) = c0 -! uatm_data(:,:,:,:) = c0 -! vatm_data(:,:,:,:) = c0 -! wind_data(:,:,:,:) = c0 -! strax_data(:,:,:,:) = c0 -! stray_data(:,:,:,:) = c0 -! Qa_data(:,:,:,:) = c0 -! rhoa_data(:,:,:,:) = c0 -! flw_data(:,:,:,:) = c0 -! sublim_data(:,:,:,:) = c0 -! frain_data(:,:,:,:) = c0 + ! Allocate forcing arrays + call alloc_forcing() fyear = fyear_init + mod(nyr-1,ycycle) ! current year fyear_final = fyear_init + ycycle - 1 ! last year in forcing cycle diff --git a/cicecore/cicedynB/general/ice_forcing_bgc.F90 b/cicecore/cicedynB/general/ice_forcing_bgc.F90 index b5041412c..d202e0b76 100644 --- a/cicecore/cicedynB/general/ice_forcing_bgc.F90 +++ b/cicecore/cicedynB/general/ice_forcing_bgc.F90 @@ -27,16 +27,42 @@ module ice_forcing_bgc implicit none private - public :: get_forcing_bgc, get_atm_bgc, fzaero_data, & + public :: get_forcing_bgc, get_atm_bgc, fzaero_data, alloc_forcing_bgc, & init_bgc_data, faero_data, faero_default, faero_optics integer (kind=int_kind) :: & bgcrecnum = 0 ! old record number (save between steps) + real (kind=dbl_kind), dimension(:,:,:), allocatable :: & + nitdat , & ! data value toward which nitrate is restored + sildat ! data value toward which silicate is restored + + real (kind=dbl_kind), dimension(:,:,:,:), allocatable, save :: & + nit_data, & ! field values at 2 temporal data points + sil_data + !======================================================================= contains +!======================================================================= +! +! Allocate space for forcing_bgc variables +! + subroutine alloc_forcing_bgc + + integer (int_kind) :: ierr + + allocate( & + nitdat (nx_block,ny_block,max_blocks), & ! data value toward which nitrate is restored + sildat (nx_block,ny_block,max_blocks), & ! data value toward which silicate is restored + nit_data(nx_block,ny_block,2,max_blocks), & ! field values at 2 temporal data points + sil_data(nx_block,ny_block,2,max_blocks), & + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_forcing_bgc): Out of memory') + + end subroutine alloc_forcing_bgc + !======================================================================= ! ! Read and interpolate annual climatologies of silicate and nitrate. @@ -71,14 +97,6 @@ subroutine get_forcing_bgc met_file, & ! netcdf filename fieldname ! field name in netcdf file - real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks) :: & - nitdat , & ! data value toward which nitrate is restored - sildat ! data value toward which silicate is restored - - real (kind=dbl_kind), dimension(nx_block,ny_block,2,max_blocks), save :: & - nit_data, & ! field values at 2 temporal data points - sil_data - real (kind=dbl_kind), dimension(2), save :: & sil_data_p , & ! field values at 2 temporal data points nit_data_p ! field values at 2 temporal data points @@ -486,7 +504,7 @@ subroutine faero_data #ifdef ncdf ! local parameters - real (kind=dbl_kind), dimension(nx_block,ny_block,2,max_blocks), & + real (kind=dbl_kind), dimension(:,:,:,:), allocatable, & save :: & aero1_data , & ! field values at 2 temporal data points aero2_data , & ! field values at 2 temporal data points @@ -506,6 +524,11 @@ subroutine faero_data character(len=*), parameter :: subname = '(faero_data)' + allocate( aero1_data(nx_block,ny_block,2,max_blocks), & + aero2_data(nx_block,ny_block,2,max_blocks), & + aero3_data(nx_block,ny_block,2,max_blocks) ) + + !------------------------------------------------------------------- ! monthly data ! @@ -562,6 +585,7 @@ subroutine faero_data where (faero_atm(:,:,:,:) > 1.e20) faero_atm(:,:,:,:) = c0 + deallocate( aero1_data, aero2_data, aero3_data ) #endif end subroutine faero_data @@ -581,7 +605,7 @@ subroutine fzaero_data #ifdef ncdf ! local parameters - real (kind=dbl_kind), dimension(nx_block,ny_block,2,max_blocks), & + real (kind=dbl_kind), dimension(:,:,:,:), allocatable, & save :: & aero_data ! field values at 2 temporal data points @@ -607,6 +631,8 @@ subroutine fzaero_data if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) + allocate( aero_data(nx_block,ny_block,2,max_blocks) ) + !------------------------------------------------------------------- ! monthly data ! @@ -653,6 +679,7 @@ subroutine fzaero_data where (faero_atm(:,:,nlt_zaero(1),:) > 1.e20) faero_atm(:,:,nlt_zaero(1),:) = c0 + deallocate( aero_data ) #endif end subroutine fzaero_data diff --git a/cicecore/cicedynB/general/ice_init.F90 b/cicecore/cicedynB/general/ice_init.F90 index 48a4926dc..330419198 100644 --- a/cicecore/cicedynB/general/ice_init.F90 +++ b/cicecore/cicedynB/general/ice_init.F90 @@ -189,9 +189,10 @@ subroutine input_data abort_flag = 0 call icepack_query_parameters(puny_out=puny) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname//'Icepack Abort0', & - file=__FILE__, line=__LINE__) +! nu_diag not yet defined +! call icepack_warnings_flush(nu_diag) +! if (icepack_warnings_aborted()) call abort_ice(error_message=subname//'Icepack Abort0', & +! file=__FILE__, line=__LINE__) days_per_year = 365 ! number of days in a year use_leap_years= .false.! if true, use leap years (Feb 29) @@ -876,7 +877,13 @@ subroutine input_data write(nu_diag,1020) ' kitd = ', kitd write(nu_diag,1020) ' kcatbound = ', & kcatbound - write(nu_diag,1020) ' kdyn = ', kdyn + if (kdyn == 1) then + write(nu_diag,1021) ' kdyn = ','evp ', kdyn + elseif (kdyn == 2) then + write(nu_diag,1021) ' kdyn = ','eap ', kdyn + else + write(nu_diag,1020) ' kdyn = ', kdyn + endif write(nu_diag,1020) ' ndtd = ', ndtd write(nu_diag,1020) ' ndte = ', ndte write(nu_diag,1010) ' revised_evp = ', & @@ -1112,6 +1119,7 @@ subroutine input_data 1005 format (a30,2x,f9.6) ! float 1010 format (a30,2x,l6) ! logical 1020 format (a30,2x,i6) ! integer + 1021 format (a30,2x,a8,i6) ! char, int 1030 format (a30, a8) ! character 1040 format (a30,2x,6i6) ! integer 1050 format (a30,2x,6a6) ! character diff --git a/cicecore/cicedynB/general/ice_state.F90 b/cicecore/cicedynB/general/ice_state.F90 index a9c8b1541..44aa16d4c 100644 --- a/cicecore/cicedynB/general/ice_state.F90 +++ b/cicecore/cicedynB/general/ice_state.F90 @@ -38,23 +38,24 @@ module ice_state use ice_kinds_mod use ice_domain_size, only: max_blocks, ncat, max_ntrcr use ice_blocks, only: nx_block, ny_block + use ice_exit, only: abort_ice implicit none private - public :: bound_state + public :: bound_state, alloc_state !----------------------------------------------------------------- ! state of the ice aggregated over all categories !----------------------------------------------------------------- - real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks), & + real (kind=dbl_kind), dimension(:,:,:), allocatable, & public :: & aice , & ! concentration of ice vice , & ! volume per unit area of ice (m) vsno ! volume per unit area of snow (m) real (kind=dbl_kind), & - dimension(nx_block,ny_block,max_ntrcr,max_blocks), public :: & + dimension(:,:,:,:), allocatable, public :: & trcr ! ice tracers ! 1: surface temperature of ice/snow (C) @@ -62,18 +63,18 @@ module ice_state ! state of the ice for each category !----------------------------------------------------------------- - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), & + real (kind=dbl_kind), dimension (:,:,:), allocatable, & public:: & aice0 ! concentration of open water real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & aicen , & ! concentration of ice vicen , & ! volume per unit area of ice (m) vsnon ! volume per unit area of snow (m) real (kind=dbl_kind), public, & - dimension (nx_block,ny_block,max_ntrcr,ncat,max_blocks) :: & + dimension (:,:,:,:,:), allocatable :: & trcrn ! tracers ! 1: surface temperature of ice/snow (C) @@ -100,7 +101,7 @@ module ice_state ! dynamic variables closely related to the state of the ice !----------------------------------------------------------------- - real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks), & + real (kind=dbl_kind), dimension(:,:,:), allocatable, & public :: & uvel , & ! x-component of velocity (m/s) vvel , & ! y-component of velocity (m/s) @@ -112,12 +113,12 @@ module ice_state ! ice state at start of time step, saved for later in the step !----------------------------------------------------------------- - real (kind=dbl_kind), dimension(nx_block,ny_block,max_blocks), & + real (kind=dbl_kind), dimension(:,:,:), allocatable, & public :: & aice_init ! initial concentration of ice, for diagnostics real (kind=dbl_kind), & - dimension(nx_block,ny_block,ncat,max_blocks), public :: & + dimension(:,:,:,:), allocatable, public :: & aicen_init , & ! initial ice concentration, for linear ITD vicen_init , & ! initial ice volume (m), for linear ITD vsnon_init ! initial snow volume (m), for aerosol @@ -126,6 +127,37 @@ module ice_state contains +!======================================================================= +! +! Allocate space for all state variables +! + subroutine alloc_state + integer (int_kind) :: ierr + + allocate ( & + aice (nx_block,ny_block,max_blocks) , & ! concentration of ice + vice (nx_block,ny_block,max_blocks) , & ! volume per unit area of ice (m) + vsno (nx_block,ny_block,max_blocks) , & ! volume per unit area of snow (m) + aice0 (nx_block,ny_block,max_blocks) , & ! concentration of open water + uvel (nx_block,ny_block,max_blocks) , & ! x-component of velocity (m/s) + vvel (nx_block,ny_block,max_blocks) , & ! y-component of velocity (m/s) + divu (nx_block,ny_block,max_blocks) , & ! strain rate I component, velocity divergence (1/s) + shear (nx_block,ny_block,max_blocks) , & ! strain rate II component (1/s) + strength (nx_block,ny_block,max_blocks) , & ! ice strength (N/m) + aice_init (nx_block,ny_block,max_blocks) , & ! initial concentration of ice, for diagnostics + aicen (nx_block,ny_block,ncat,max_blocks) , & ! concentration of ice + vicen (nx_block,ny_block,ncat,max_blocks) , & ! volume per unit area of ice (m) + vsnon (nx_block,ny_block,ncat,max_blocks) , & ! volume per unit area of snow (m) + aicen_init(nx_block,ny_block,ncat,max_blocks) , & ! initial ice concentration, for linear ITD + vicen_init(nx_block,ny_block,ncat,max_blocks) , & ! initial ice volume (m), for linear ITD + vsnon_init(nx_block,ny_block,ncat,max_blocks) , & ! initial snow volume (m), for aerosol + trcr (nx_block,ny_block,max_ntrcr,max_blocks) , & ! ice tracers: 1: surface temperature of ice/snow (C) + trcrn (nx_block,ny_block,max_ntrcr,ncat,max_blocks) , & ! tracers: 1: surface temperature of ice/snow (C) + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_state): Out of memory') + + end subroutine alloc_state + !======================================================================= ! ! Get ghost cell values for ice state variables in each thickness category. diff --git a/cicecore/cicedynB/infrastructure/ice_blocks.F90 b/cicecore/cicedynB/infrastructure/ice_blocks.F90 index 0b0b45dc7..b95ad6acb 100644 --- a/cicecore/cicedynB/infrastructure/ice_blocks.F90 +++ b/cicecore/cicedynB/infrastructure/ice_blocks.F90 @@ -42,9 +42,8 @@ module ice_blocks integer (int_kind), parameter, public :: & nghost = 1 ! number of ghost cells around each block - integer (int_kind), parameter, public :: &! size of block domain in - nx_block = block_size_x + 2*nghost, &! x,y dir including ghost - ny_block = block_size_y + 2*nghost ! cells + integer (int_kind), public :: &! size of block domain in + nx_block, ny_block ! x,y dir including ghost ! predefined directions for neighbor id routine ! Note: the directions that are commented out are implemented in @@ -146,6 +145,8 @@ subroutine create_blocks(nx_global, ny_global, ew_boundary_type, & ! !---------------------------------------------------------------------- + nx_block = block_size_x + 2*nghost ! size of block domain in x,y dir + ny_block = block_size_y + 2*nghost ! including ghost cells nblocks_x = (nx_global-1)/block_size_x + 1 nblocks_y = (ny_global-1)/block_size_y + 1 nblocks_tot = nblocks_x*nblocks_y diff --git a/cicecore/cicedynB/infrastructure/ice_domain.F90 b/cicecore/cicedynB/infrastructure/ice_domain.F90 index f10631aa3..58acd9735 100644 --- a/cicecore/cicedynB/infrastructure/ice_domain.F90 +++ b/cicecore/cicedynB/infrastructure/ice_domain.F90 @@ -92,7 +92,7 @@ subroutine init_domain_blocks use ice_distribution, only: processor_shape use ice_domain_size, only: ncat, nilyr, nslyr, max_blocks, & - nx_global, ny_global + nx_global, ny_global, block_size_x, block_size_y !---------------------------------------------------------------------- ! @@ -112,6 +112,11 @@ subroutine init_domain_blocks !---------------------------------------------------------------------- namelist /domain_nml/ nprocs, & + max_blocks, & + block_size_x, & + block_size_y, & + nx_global, & + ny_global, & processor_shape, & distribution_type, & distribution_wght, & @@ -138,6 +143,11 @@ subroutine init_domain_blocks maskhalo_dyn = .false. ! if true, use masked halos for dynamics maskhalo_remap = .false. ! if true, use masked halos for transport maskhalo_bound = .false. ! if true, use masked halos for bound_state + max_blocks = -1 ! max number of blocks per processor + block_size_x = -1 ! size of block in first horiz dimension + block_size_y = -1 ! size of block in second horiz dimension + nx_global = -1 ! NXGLOB, i-axis size + ny_global = -1 ! NYGLOB, j-axis size call get_fileunit(nu_nml) if (my_task == master_task) then @@ -169,6 +179,19 @@ subroutine init_domain_blocks call broadcast_scalar(maskhalo_dyn, master_task) call broadcast_scalar(maskhalo_remap, master_task) call broadcast_scalar(maskhalo_bound, master_task) + if (my_task == master_task) then + if (max_blocks < 1) then + max_blocks=( ((nx_global-1)/block_size_x + 1) * & + ((ny_global-1)/block_size_y + 1) ) / nprocs + write(nu_diag,'(/,a52,i6,/)') & + '(ice_domain): max_block < 1: max_block estimated to ',max_blocks + endif + endif + call broadcast_scalar(max_blocks, master_task) + call broadcast_scalar(block_size_x, master_task) + call broadcast_scalar(block_size_y, master_task) + call broadcast_scalar(nx_global, master_task) + call broadcast_scalar(ny_global, master_task) !---------------------------------------------------------------------- ! diff --git a/cicecore/cicedynB/infrastructure/ice_grid.F90 b/cicecore/cicedynB/infrastructure/ice_grid.F90 index dba4a9c00..2ff313473 100644 --- a/cicecore/cicedynB/infrastructure/ice_grid.F90 +++ b/cicecore/cicedynB/infrastructure/ice_grid.F90 @@ -34,7 +34,7 @@ module ice_grid private public :: init_grid1, init_grid2, & t2ugrid_vector, u2tgrid_vector, & - to_ugrid, to_tgrid + to_ugrid, to_tgrid, alloc_grid character (len=char_len_long), public :: & grid_format , & ! file format ('bin'=binary or 'nc'=netcdf) @@ -44,7 +44,7 @@ module ice_grid grid_type ! current options are rectangular (default), ! displaced_pole, tripole, regional - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & dxt , & ! width of T-cell through the middle (m) dyt , & ! height of T-cell through the middle (m) dxu , & ! width of U-cell through the middle (m) @@ -68,7 +68,7 @@ module ice_grid ocn_gridcell_frac ! only relevant for lat-lon grids ! gridcell value of [1 - (land fraction)] (T-cell) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & cyp , & ! 1.5*HTE - 0.5*HTE cxp , & ! 1.5*HTN - 0.5*HTN cym , & ! 0.5*HTE - 1.5*HTE @@ -77,14 +77,14 @@ module ice_grid dyhx ! 0.5*(HTN - HTN) ! Corners of grid boxes for history output - real (kind=dbl_kind), dimension (4,nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & lont_bounds, & ! longitude of gridbox corners for T point latt_bounds, & ! latitude of gridbox corners for T point lonu_bounds, & ! longitude of gridbox corners for U point latu_bounds ! latitude of gridbox corners for U point ! geometric quantities used for remapping transport - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & xav , & ! mean T-cell value of x yav , & ! mean T-cell value of y xxav , & ! mean T-cell value of xx @@ -97,21 +97,21 @@ module ice_grid ! yyyav ! mean T-cell value of yyy real (kind=dbl_kind), & - dimension (2,2,nx_block,ny_block,max_blocks), public :: & + dimension (:,:,:,:,:), allocatable, public :: & mne, & ! matrices used for coordinate transformations in remapping mnw, & ! ne = northeast corner, nw = northwest, etc. mse, & msw ! masks - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & hm , & ! land/boundary mask, thickness (T-cell) bm , & ! task/block id uvm , & ! land/boundary mask, velocity (U-cell) kmt ! ocean topography mask for bathymetry (T-cell) logical (kind=log_kind), & - dimension (nx_block,ny_block,max_blocks), public :: & + dimension (:,:,:), allocatable, public :: & tmask , & ! land/boundary mask, thickness (T-cell) umask , & ! land/boundary mask, velocity (U-cell) lmask_n, & ! northern hemisphere mask @@ -122,13 +122,75 @@ module ice_grid dxrect = 30.e5_dbl_kind ,&! uniform HTN (cm) dyrect = 30.e5_dbl_kind ! uniform HTE (cm) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & rndex_global ! global index for local subdomain (dbl) !======================================================================= contains +!======================================================================= +! +! Allocate space for all variables +! + subroutine alloc_grid + + integer (int_kind) :: ierr + + allocate( & + dxt (nx_block,ny_block,max_blocks), & ! width of T-cell through the middle (m) + dyt (nx_block,ny_block,max_blocks), & ! height of T-cell through the middle (m) + dxu (nx_block,ny_block,max_blocks), & ! width of U-cell through the middle (m) + dyu (nx_block,ny_block,max_blocks), & ! height of U-cell through the middle (m) + HTE (nx_block,ny_block,max_blocks), & ! length of eastern edge of T-cell (m) + HTN (nx_block,ny_block,max_blocks), & ! length of northern edge of T-cell (m) + tarea (nx_block,ny_block,max_blocks), & ! area of T-cell (m^2) + uarea (nx_block,ny_block,max_blocks), & ! area of U-cell (m^2) + tarear (nx_block,ny_block,max_blocks), & ! 1/tarea + uarear (nx_block,ny_block,max_blocks), & ! 1/uarea + tinyarea (nx_block,ny_block,max_blocks), & ! puny*tarea + tarean (nx_block,ny_block,max_blocks), & ! area of NH T-cells + tareas (nx_block,ny_block,max_blocks), & ! area of SH T-cells + ULON (nx_block,ny_block,max_blocks), & ! longitude of velocity pts (radians) + ULAT (nx_block,ny_block,max_blocks), & ! latitude of velocity pts (radians) + TLON (nx_block,ny_block,max_blocks), & ! longitude of temp pts (radians) + TLAT (nx_block,ny_block,max_blocks), & ! latitude of temp pts (radians) + ANGLE (nx_block,ny_block,max_blocks), & ! for conversions between POP grid and lat/lon + ANGLET (nx_block,ny_block,max_blocks), & ! ANGLE converted to T-cells + bathymetry(nx_block,ny_block,max_blocks),& ! ocean depth, for grounding keels and bergs (m) + ocn_gridcell_frac(nx_block,ny_block,max_blocks),& ! only relevant for lat-lon grids + cyp (nx_block,ny_block,max_blocks), & ! 1.5*HTE - 0.5*HTE + cxp (nx_block,ny_block,max_blocks), & ! 1.5*HTN - 0.5*HTN + cym (nx_block,ny_block,max_blocks), & ! 0.5*HTE - 1.5*HTE + cxm (nx_block,ny_block,max_blocks), & ! 0.5*HTN - 1.5*HTN + dxhy (nx_block,ny_block,max_blocks), & ! 0.5*(HTE - HTE) + dyhx (nx_block,ny_block,max_blocks), & ! 0.5*(HTN - HTN) + xav (nx_block,ny_block,max_blocks), & ! mean T-cell value of x + yav (nx_block,ny_block,max_blocks), & ! mean T-cell value of y + xxav (nx_block,ny_block,max_blocks), & ! mean T-cell value of xx + yyav (nx_block,ny_block,max_blocks), & ! mean T-cell value of yy + hm (nx_block,ny_block,max_blocks), & ! land/boundary mask, thickness (T-cell) + bm (nx_block,ny_block,max_blocks), & ! task/block id + uvm (nx_block,ny_block,max_blocks), & ! land/boundary mask, velocity (U-cell) + kmt (nx_block,ny_block,max_blocks), & ! ocean topography mask for bathymetry (T-cell) + tmask (nx_block,ny_block,max_blocks), & ! land/boundary mask, thickness (T-cell) + umask (nx_block,ny_block,max_blocks), & ! land/boundary mask, velocity (U-cell) + lmask_n (nx_block,ny_block,max_blocks), & ! northern hemisphere mask + lmask_s (nx_block,ny_block,max_blocks), & ! southern hemisphere mask + rndex_global(nx_block,ny_block,max_blocks), & ! global index for local subdomain (dbl) + lont_bounds(4,nx_block,ny_block,max_blocks), & ! longitude of gridbox corners for T point + latt_bounds(4,nx_block,ny_block,max_blocks), & ! latitude of gridbox corners for T point + lonu_bounds(4,nx_block,ny_block,max_blocks), & ! longitude of gridbox corners for U point + latu_bounds(4,nx_block,ny_block,max_blocks), & ! latitude of gridbox corners for U point + mne (2,2,nx_block,ny_block,max_blocks), & ! matrices used for coordinate transformations in remapping + mnw (2,2,nx_block,ny_block,max_blocks), & ! ne = northeast corner, nw = northwest, etc. + mse (2,2,nx_block,ny_block,max_blocks), & + msw (2,2,nx_block,ny_block,max_blocks), & + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_grid): Out of memory') + + end subroutine alloc_grid + !======================================================================= ! Distribute blocks across processors. The distribution is optimized @@ -1169,8 +1231,8 @@ subroutine rectgrid ! land in the upper left and lower right corners, ! otherwise open boundaries - imid = aint(real(nx_global)/c2,kind=int_kind) - jmid = aint(real(ny_global)/c2,kind=int_kind) + imid = nint(aint(real(nx_global)/c2)) + jmid = nint(aint(real(ny_global)/c2)) do j = 3,ny_global-2 do i = 3,nx_global-2 @@ -1424,26 +1486,23 @@ subroutine primary_grid_lengths_HTE(work_g) endif if (my_task == master_task) then - do j = 1, ny_global - do i = 1, nx_global - work_g(i,j) = work_g(i,j) * cm_to_m ! HTE - enddo - enddo - do j = 1, ny_global-1 + do j = 1, ny_global + do i = 1, nx_global + work_g(i,j) = work_g(i,j) * cm_to_m ! HTE + enddo + enddo + do j = 1, ny_global-1 do i = 1, nx_global work_g2(i,j) = p5*(work_g(i,j) + work_g(i,j+1)) ! dyu enddo - enddo - ! extrapolate to obtain dyu along j=ny_global - ! for CESM: use NYGLOB to prevent a compile time out of bounds - ! error when ny_global=1 as in the se dycore; this code is not - ! exersized in prescribed mode. -#if (NYGLOB>2) - do i = 1, nx_global - work_g2(i,ny_global) = c2*work_g(i,ny_global-1) & - - work_g(i,ny_global-2) ! dyu - enddo -#endif + enddo + ! extrapolate to obtain dyu along j=ny_global + if (ny_global > 1) then + do i = 1, nx_global + work_g2(i,ny_global) = c2*work_g(i,ny_global-1) & + - work_g(i,ny_global-2) ! dyu + enddo + endif endif call scatter_global(HTE, work_g, master_task, distrb_info, & field_loc_Eface, field_type_scalar) diff --git a/cicecore/drivers/cesm/CICE_InitMod.F90 b/cicecore/drivers/cesm/CICE_InitMod.F90 index 1efffec96..7c22d551c 100644 --- a/cicecore/drivers/cesm/CICE_InitMod.F90 +++ b/cicecore/drivers/cesm/CICE_InitMod.F90 @@ -57,22 +57,22 @@ end subroutine CICE_Initialize subroutine cice_init(mpicom_ice) use ice_arrays_column, only: hin_max, c_hi_range, zfswin, trcrn_sw, & - ocean_bio_all, ice_bio_net, snow_bio_net + ocean_bio_all, ice_bio_net, snow_bio_net, alloc_arrays_column use ice_calendar, only: dt, dt_dyn, write_ic, & init_calendar, calendar, time use ice_communicate, only: init_communicate, my_task, master_task use ice_diagnostics, only: init_diags use ice_domain, only: init_domain_blocks use ice_domain_size, only: ncat - use ice_dyn_eap, only: init_eap - use ice_dyn_shared, only: kdyn, init_evp + use ice_dyn_eap, only: init_eap, alloc_dyn_eap + use ice_dyn_shared, only: kdyn, init_evp, alloc_dyn_shared use ice_flux, only: init_coupler_flux, init_history_therm, & - init_history_dyn, init_flux_atm, init_flux_ocn + init_history_dyn, init_flux_atm, init_flux_ocn, alloc_flux use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & - get_forcing_atmo, get_forcing_ocn + get_forcing_atmo, get_forcing_ocn, alloc_forcing use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_data, faero_default, faero_optics - use ice_grid, only: init_grid1, init_grid2 + faero_data, faero_default, faero_optics, alloc_forcing_bgc + use ice_grid, only: init_grid1, init_grid2, alloc_grid use ice_history, only: init_hist, accum_hist use ice_restart_shared, only: restart, runid, runtype use ice_init, only: input_data, init_state @@ -109,6 +109,12 @@ subroutine cice_init(mpicom_ice) call init_domain_blocks ! set up block decomposition call init_grid1 ! domain distribution + call alloc_grid ! allocate grid + call alloc_arrays_column ! allocate column arrays + call alloc_state ! allocate state + call alloc_dyn_shared ! allocate dyn shared (init_uvel,init_vvel) + call alloc_flux_bgc ! allocate flux_bgc + call alloc_flux ! allocate flux call init_ice_timers ! initialize all timers call ice_timer_start(timer_total) ! start timing entire run call init_grid2 ! grid variables @@ -117,6 +123,7 @@ subroutine cice_init(mpicom_ice) call init_hist (dt) ! initialize output history file if (kdyn == 2) then + call alloc_dyn_eap ! allocate dyn_eap arrays call init_eap (dt_dyn) ! define eap dynamics parameters, variables else ! for both kdyn = 0 or 1 call init_evp (dt_dyn) ! define evp dynamics parameters, variables @@ -180,6 +187,7 @@ subroutine cice_init(mpicom_ice) ! if (tr_zaero) call fzaero_data ! data file (gx1) if (tr_aero .or. tr_zaero) call faero_default ! default values + if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry #endif #endif diff --git a/cicecore/drivers/cice/CICE_InitMod.F90 b/cicecore/drivers/cice/CICE_InitMod.F90 index 482c9085e..c0426eff7 100644 --- a/cicecore/drivers/cice/CICE_InitMod.F90 +++ b/cicecore/drivers/cice/CICE_InitMod.F90 @@ -58,22 +58,24 @@ end subroutine CICE_Initialize subroutine cice_init - use ice_arrays_column, only: hin_max, c_hi_range + use ice_arrays_column, only: hin_max, c_hi_range, alloc_arrays_column + use ice_state, only: alloc_state + use ice_flux_bgc, only: alloc_flux_bgc use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, & init_calendar, calendar use ice_communicate, only: init_communicate, my_task, master_task use ice_diagnostics, only: init_diags use ice_domain, only: init_domain_blocks use ice_domain_size, only: ncat - use ice_dyn_eap, only: init_eap - use ice_dyn_shared, only: kdyn, init_evp + use ice_dyn_eap, only: init_eap, alloc_dyn_eap + use ice_dyn_shared, only: kdyn, init_evp, alloc_dyn_shared use ice_flux, only: init_coupler_flux, init_history_therm, & - init_history_dyn, init_flux_atm, init_flux_ocn + init_history_dyn, init_flux_atm, init_flux_ocn, alloc_flux use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & - get_forcing_atmo, get_forcing_ocn + get_forcing_atmo, get_forcing_ocn, alloc_forcing use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_default, faero_optics - use ice_grid, only: init_grid1, init_grid2 + faero_default, faero_optics, alloc_forcing_bgc + use ice_grid, only: init_grid1, init_grid2, alloc_grid use ice_history, only: init_hist, accum_hist use ice_restart_shared, only: restart, runid, runtype use ice_init, only: input_data, init_state @@ -104,6 +106,12 @@ subroutine cice_init call init_domain_blocks ! set up block decomposition call init_grid1 ! domain distribution + call alloc_grid ! allocate grid arrays + call alloc_arrays_column ! allocate column arrays + call alloc_state ! allocate state arrays + call alloc_dyn_shared ! allocate dyn shared arrays + call alloc_flux_bgc ! allocate flux_bgc arrays + call alloc_flux ! allocate flux arrays call init_ice_timers ! initialize all timers call ice_timer_start(timer_total) ! start timing entire run call init_grid2 ! grid variables @@ -112,6 +120,7 @@ subroutine cice_init call init_hist (dt) ! initialize output history file if (kdyn == 2) then + call alloc_dyn_eap ! allocate dyn_eap arrays call init_eap (dt_dyn) ! define eap dynamics parameters, variables else ! for both kdyn = 0 or 1 call init_evp (dt_dyn) ! define evp dynamics parameters, variables @@ -180,6 +189,7 @@ subroutine cice_init ! if (tr_zaero) call fzaero_data ! data file (gx1) if (tr_aero .or. tr_zaero) call faero_default ! default values + if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry #endif #endif diff --git a/cicecore/drivers/hadgem3/CICE_InitMod.F90 b/cicecore/drivers/hadgem3/CICE_InitMod.F90 index 811c5d0d1..4a056110b 100644 --- a/cicecore/drivers/hadgem3/CICE_InitMod.F90 +++ b/cicecore/drivers/hadgem3/CICE_InitMod.F90 @@ -57,23 +57,25 @@ end subroutine CICE_Initialize subroutine cice_init + use ice_state, only: alloc_state + use ice_flux_bgc, only: alloc_flux_bgc use ice_arrays_column, only: hin_max, c_hi_range, zfswin, trcrn_sw, & - ocean_bio_all, ice_bio_net, snow_bio_net + ocean_bio_all, ice_bio_net, snow_bio_net, alloc_arrays_column use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, & init_calendar, calendar use ice_communicate, only: init_communicate, my_task, master_task use ice_diagnostics, only: init_diags use ice_domain, only: init_domain_blocks use ice_domain_size, only: ncat - use ice_dyn_eap, only: init_eap - use ice_dyn_shared, only: kdyn, init_evp, basalstress + use ice_dyn_eap, only: init_eap, alloc_dyn_eap + use ice_dyn_shared, only: kdyn, init_evp, basalstress, alloc_dyn_shared use ice_flux, only: init_coupler_flux, init_history_therm, & - init_history_dyn, init_flux_atm, init_flux_ocn + init_history_dyn, init_flux_atm, init_flux_ocn, alloc_flux use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & - get_forcing_atmo, get_forcing_ocn + get_forcing_atmo, get_forcing_ocn, alloc_forcing use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_data, faero_default, faero_optics - use ice_grid, only: init_grid1, init_grid2 + faero_data, faero_default, faero_optics, alloc_forcing_bgc + use ice_grid, only: init_grid1, init_grid2, alloc_grid use ice_history, only: init_hist, accum_hist use ice_restart_shared, only: restart, runid, runtype use ice_init, only: input_data, init_state @@ -104,6 +106,12 @@ subroutine cice_init call init_domain_blocks ! set up block decomposition call init_grid1 ! domain distribution + call alloc_grid ! allocate grid + call alloc_arrays_column ! allocate column arrays + call alloc_state ! allocate state + call alloc_dyn_shared ! allocate dyn shared (init_uvel,init_vvel) + call alloc_flux_bgc ! allocate flux_bgc + call alloc_flux ! allocate flux call init_ice_timers ! initialize all timers call ice_timer_start(timer_total) ! start timing entire run call init_grid2 ! grid variables @@ -112,6 +120,7 @@ subroutine cice_init call init_hist (dt) ! initialize output history file if (kdyn == 2) then + call alloc_dyn_eap ! allocate dyn_eap arrays call init_eap (dt_dyn) ! define eap dynamics parameters, variables else ! for both kdyn = 0 or 1 call init_evp (dt_dyn) ! define evp dynamics parameters, variables @@ -184,6 +193,7 @@ subroutine cice_init ! if (tr_zaero) call fzaero_data ! data file (gx1) if (tr_aero .or. tr_zaero) call faero_default ! default values + if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! Allocate biogeochemistry arrays if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry #endif #endif diff --git a/cicecore/shared/ice_arrays_column.F90 b/cicecore/shared/ice_arrays_column.F90 index 5c483d41d..1d255fcd1 100644 --- a/cicecore/shared/ice_arrays_column.F90 +++ b/cicecore/shared/ice_arrays_column.F90 @@ -17,10 +17,11 @@ module ice_arrays_column icepack_nmodal1, icepack_nmodal2 implicit none + public :: alloc_arrays_column ! icepack_atmo.F90 real (kind=dbl_kind), public, & - dimension (nx_block,ny_block,max_blocks) :: & + dimension (:,:,:), allocatable :: & Cdn_atm , & ! atm drag coefficient Cdn_ocn , & ! ocn drag coefficient ! form drag @@ -64,14 +65,14 @@ module ice_arrays_column ! icepack_meltpond_lvl.F90 real (kind=dbl_kind), public, & - dimension (nx_block,ny_block,ncat,max_blocks) :: & + dimension (:,:,:,:), allocatable :: & dhsn, & ! depth difference for snow on sea ice and pond ice ffracn ! fraction of fsurfn used to melt ipond ! icepack_shortwave.F90 ! category albedos real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & alvdrn , & ! visible direct albedo (fraction) alidrn , & ! near-ir direct albedo (fraction) alvdfn , & ! visible diffuse albedo (fraction) @@ -79,32 +80,32 @@ module ice_arrays_column ! albedo components for history real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & albicen, & ! bare ice albsnon, & ! snow albpndn, & ! pond apeffn ! effective pond area used for radiation calculation - real (kind=dbl_kind), dimension (nx_block,ny_block,ncat,max_blocks), & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, & public :: & snowfracn ! Category snow fraction used in radiation ! shortwave components real (kind=dbl_kind), & - dimension (nx_block,ny_block,nilyr,ncat,max_blocks), public :: & + dimension (:,:,:,:,:), allocatable, public :: & Iswabsn ! SW radiation absorbed in ice layers (W m-2) real (kind=dbl_kind), & - dimension (nx_block,ny_block,nslyr,ncat,max_blocks), public :: & + dimension (:,:,:,:,:), allocatable, public :: & Sswabsn ! SW radiation absorbed in snow layers (W m-2) - real (kind=dbl_kind), dimension (nx_block,ny_block,ncat,max_blocks), & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, & public :: & fswsfcn , & ! SW absorbed at ice/snow surface (W m-2) fswthrun , & ! SW through ice to ocean (W/m^2) fswintn ! SW absorbed in ice interior, below surface (W m-2) - real (kind=dbl_kind), dimension (nx_block,ny_block,nilyr+1,ncat,max_blocks), & + real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable, & public :: & fswpenln ! visible SW entering ice layers (W m-2) @@ -137,27 +138,27 @@ module ice_arrays_column icgrid , & ! interface grid for CICE (shortwave variable) swgrid ! grid for ice tracers used in dEdd scheme - real (kind=dbl_kind), dimension (nx_block,ny_block,ncat,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & first_ice_real ! .true. = c1, .false. = c0 logical (kind=log_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & first_ice ! distinguishes ice that disappears (e.g. melts) ! and reappears (e.g. transport) in a grid cell ! during a single time step from ice that was ! there the entire time step (true until ice forms) real (kind=dbl_kind), & - dimension (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & ocean_bio ! contains all the ocean bgc tracer concentrations ! diagnostic fluxes real (kind=dbl_kind), & - dimension (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & fbio_snoice, & ! fluxes from snow to ice fbio_atmice ! fluxes from atm to ice - real (kind=dbl_kind), dimension (nx_block,ny_block,icepack_max_nbtrcr, max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:), allocatable, public :: & ocean_bio_all ! fixed order, all values even for tracers false ! N(1:icepack_max_algae) = 1:icepack_max_algae ! Nit = icepack_max_algae + 1 @@ -183,76 +184,76 @@ module ice_arrays_column ! humic == 2*icepack_max_algae + icepack_max_doc + 8 + icepack_max_dic + icepack_max_don + 2*icepack_max_fe ! + icepack_max_aero - integer (kind=int_kind), dimension(nx_block, ny_block,icepack_max_algae, max_blocks), public :: & + integer (kind=int_kind), dimension(:,:,:,:), allocatable, public :: & algal_peak ! vertical location of algal maximum, 0 if no maximum real (kind=dbl_kind), & - dimension (nx_block,ny_block,nblyr+1,ncat,max_blocks), public :: & + dimension (:,:,:,:,:), allocatable, public :: & Zoo ! N losses accumulated in timestep (ie. zooplankton/bacteria) ! mmol/m^3 real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & dhbr_top , & ! brine top change dhbr_bot ! brine bottom change real (kind=dbl_kind), & - dimension (nx_block,ny_block,max_blocks), public :: & + dimension (:,:,:), allocatable, public :: & grow_net , & ! Specific growth rate (/s) per grid cell PP_net , & ! Total production (mg C/m^2/s) per grid cell hbri ! brine height, area-averaged for comparison with hi (m) real (kind=dbl_kind), & - dimension (nx_block,ny_block,nblyr+2,ncat,max_blocks), public :: & + dimension (:,:,:,:,:), allocatable, public :: & bphi , & ! porosity of layers bTiz ! layer temperatures interpolated on bio grid (C) real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & darcy_V ! darcy velocity positive up (m/s) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & zsal_tot , & ! Total ice salinity in per grid cell (g/m^2) chl_net , & ! Total chla (mg chla/m^2) per grid cell NO_net ! Total nitrate per grid cell - logical (kind=log_kind), dimension (nx_block,ny_block,max_blocks), public :: & + logical (kind=log_kind), dimension (:,:,:), allocatable, public :: & Rayleigh_criteria ! .true. means Ra_c was reached - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & Rayleigh_real ! .true. = c1, .false. = c0 real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & sice_rho ! avg sea ice density (kg/m^3) ! ech: diagnostic only? real (kind=dbl_kind), & - dimension (nx_block,ny_block,ncat,max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & fzsaln, & ! category fzsal(kg/m^2/s) fzsaln_g ! salt flux from gravity drainage only - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & fzsal , & ! Total flux of salt to ocean at time step for conservation fzsal_g ! Total gravity drainage flux - real (kind=dbl_kind), dimension (nx_block,ny_block,nblyr+1,ncat,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable, public :: & zfswin ! Shortwave flux into layers interpolated on bio grid (W/m^2) - real (kind=dbl_kind), dimension (nx_block,ny_block,nblyr+1,ncat,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:,:,:), allocatable, public :: & iDi , & ! igrid Diffusivity (m^2/s) iki ! Ice permeability (m^2) - real (kind=dbl_kind), dimension (nx_block,ny_block,max_blocks), public :: & + real (kind=dbl_kind), dimension (:,:,:), allocatable, public :: & upNO , & ! nitrate uptake rate (mmol/m^2/d) times aice upNH ! ammonium uptake rate (mmol/m^2/d) times aice real (kind=dbl_kind), & - dimension(nx_block,ny_block,max_ntrcr, ncat, max_blocks), public :: & + dimension(:,:,:,:,:), allocatable, public :: & trcrn_sw ! bgc tracers active in the delta-Eddington shortwave ! calculation on the shortwave grid (swgrid) real (kind=dbl_kind), & - dimension (nx_block,ny_block,icepack_max_nbtrcr, max_blocks), public :: & + dimension (:,:,:,:), allocatable, public :: & ice_bio_net , & ! depth integrated tracer (mmol/m^2) snow_bio_net ! depth integrated snow tracer (mmol/m^2) @@ -270,6 +271,94 @@ module ice_arrays_column R_C2N , & ! algal C to N (mole/mole) R_chl2N ! 3 algal chlorophyll to N (mg/mmol) +!======================================================================= + + contains + +!======================================================================= + + subroutine alloc_arrays_column + ! Allocate column arrays + use ice_exit, only: abort_ice + integer (int_kind) :: ierr + + allocate( & + Cdn_atm (nx_block,ny_block,max_blocks), & ! atm drag coefficient + Cdn_ocn (nx_block,ny_block,max_blocks), & ! ocn drag coefficient + hfreebd (nx_block,ny_block,max_blocks), & ! freeboard (m) + hdraft (nx_block,ny_block,max_blocks), & ! draft of ice + snow column (Stoessel1993) + hridge (nx_block,ny_block,max_blocks), & ! ridge height + distrdg (nx_block,ny_block,max_blocks), & ! distance between ridges + hkeel (nx_block,ny_block,max_blocks), & ! keel depth + dkeel (nx_block,ny_block,max_blocks), & ! distance between keels + lfloe (nx_block,ny_block,max_blocks), & ! floe length + dfloe (nx_block,ny_block,max_blocks), & ! distance between floes + Cdn_atm_skin (nx_block,ny_block,max_blocks), & ! neutral skin drag coefficient + Cdn_atm_floe (nx_block,ny_block,max_blocks), & ! neutral floe edge drag coefficient + Cdn_atm_pond (nx_block,ny_block,max_blocks), & ! neutral pond edge drag coefficient + Cdn_atm_rdg (nx_block,ny_block,max_blocks), & ! neutral ridge drag coefficient + Cdn_ocn_skin (nx_block,ny_block,max_blocks), & ! skin drag coefficient + Cdn_ocn_floe (nx_block,ny_block,max_blocks), & ! floe edge drag coefficient + Cdn_ocn_keel (nx_block,ny_block,max_blocks), & ! keel drag coefficient + Cdn_atm_ratio(nx_block,ny_block,max_blocks), & ! ratio drag atm / neutral drag atm + grow_net (nx_block,ny_block,max_blocks), & ! Specific growth rate (/s) per grid cell + PP_net (nx_block,ny_block,max_blocks), & ! Total production (mg C/m^2/s) per grid cell + hbri (nx_block,ny_block,max_blocks), & ! brine height, area-averaged for comparison with hi (m) + zsal_tot (nx_block,ny_block,max_blocks), & ! Total ice salinity in per grid cell (g/m^2) + chl_net (nx_block,ny_block,max_blocks), & ! Total chla (mg chla/m^2) per grid cell + NO_net (nx_block,ny_block,max_blocks), & ! Total nitrate per grid cell + Rayleigh_criteria & + (nx_block,ny_block,max_blocks), & ! .true. means Ra_c was reached + Rayleigh_real(nx_block,ny_block,max_blocks), & ! .true. = c1, .false. = c0 + fzsal (nx_block,ny_block,max_blocks), & ! Total flux of salt to ocean at time step for conservation + fzsal_g (nx_block,ny_block,max_blocks), & ! Total gravity drainage flux + upNO (nx_block,ny_block,max_blocks), & ! nitrate uptake rate (mmol/m^2/d) times aice + upNH (nx_block,ny_block,max_blocks), & ! ammonium uptake rate (mmol/m^2/d) times aice + dhsn (nx_block,ny_block,ncat,max_blocks), & ! depth difference for snow on sea ice and pond ice + ffracn (nx_block,ny_block,ncat,max_blocks), & ! fraction of fsurfn used to melt ipond + alvdrn (nx_block,ny_block,ncat,max_blocks), & ! visible direct albedo (fraction) + alidrn (nx_block,ny_block,ncat,max_blocks), & ! near-ir direct albedo (fraction) + alvdfn (nx_block,ny_block,ncat,max_blocks), & ! visible diffuse albedo (fraction) + alidfn (nx_block,ny_block,ncat,max_blocks), & ! near-ir diffuse albedo (fraction) + albicen (nx_block,ny_block,ncat,max_blocks), & ! bare ice + albsnon (nx_block,ny_block,ncat,max_blocks), & ! snow + albpndn (nx_block,ny_block,ncat,max_blocks), & ! pond + apeffn (nx_block,ny_block,ncat,max_blocks), & ! effective pond area used for radiation calculation + snowfracn (nx_block,ny_block,ncat,max_blocks), & ! Category snow fraction used in radiation + fswsfcn (nx_block,ny_block,ncat,max_blocks), & ! SW absorbed at ice/snow surface (W m-2) + fswthrun (nx_block,ny_block,ncat,max_blocks), & ! SW through ice to ocean (W/m^2) + fswintn (nx_block,ny_block,ncat,max_blocks), & ! SW absorbed in ice interior, below surface (W m-2) + first_ice_real & + (nx_block,ny_block,ncat,max_blocks), & ! .true. = c1, .false. = c0 + first_ice (nx_block,ny_block,ncat,max_blocks), & ! distinguishes ice that disappears (e.g. melts) and reappears (e.g. transport) + dhbr_top (nx_block,ny_block,ncat,max_blocks), & ! brine top change + dhbr_bot (nx_block,ny_block,ncat,max_blocks), & ! brine bottom change + darcy_V (nx_block,ny_block,ncat,max_blocks), & ! darcy velocity positive up (m/s) + sice_rho (nx_block,ny_block,ncat,max_blocks), & ! avg sea ice density (kg/m^3) ! ech: diagnostic only? + fzsaln (nx_block,ny_block,ncat,max_blocks), & ! category fzsal(kg/m^2/s) + fzsaln_g (nx_block,ny_block,ncat,max_blocks), & ! salt flux from gravity drainage only + ocean_bio (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! contains all the ocean bgc tracer concentrations + fbio_snoice (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! fluxes from snow to ice + fbio_atmice (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! fluxes from atm to ice + ocean_bio_all(nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! fixed order, all values even for tracers false + ice_bio_net (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! depth integrated tracer (mmol/m^2) + snow_bio_net (nx_block,ny_block,icepack_max_nbtrcr,max_blocks), & ! depth integrated snow tracer (mmol/m^2) + trcrn_sw (nx_block,ny_block,max_ntrcr,ncat,max_blocks), & ! bgc tracers active in the delta-Eddington shortwave + Iswabsn (nx_block,ny_block,nilyr,ncat,max_blocks), & ! SW radiation absorbed in ice layers (W m-2) + Sswabsn (nx_block,ny_block,nslyr,ncat,max_blocks), & ! SW radiation absorbed in snow layers (W m-2) + fswpenln (nx_block,ny_block,nilyr+1,ncat,max_blocks), & ! visible SW entering ice layers (W m-2) + Zoo (nx_block,ny_block,nblyr+1,ncat,max_blocks), & ! N losses accumulated in timestep (ie. zooplankton/bacteria) + zfswin (nx_block,ny_block,nblyr+1,ncat,max_blocks), & ! Shortwave flux into layers interpolated on bio grid (W/m^2) + iDi (nx_block,ny_block,nblyr+1,ncat,max_blocks), & ! igrid Diffusivity (m^2/s) + iki (nx_block,ny_block,nblyr+1,ncat,max_blocks), & ! Ice permeability (m^2) + bphi (nx_block,ny_block,nblyr+2,ncat,max_blocks), & ! porosity of layers + bTiz (nx_block,ny_block,nblyr+2,ncat,max_blocks), & ! layer temperatures interpolated on bio grid (C) + algal_peak (nx_block,ny_block,icepack_max_algae,max_blocks), & ! vertical location of algal maximum, 0 if no maximum + stat=ierr) + if (ierr/=0) call abort_ice('(alloc_arrays_column): Out of Memory') + + end subroutine alloc_arrays_column + !======================================================================= end module ice_arrays_column diff --git a/cicecore/shared/ice_domain_size.F90 b/cicecore/shared/ice_domain_size.F90 index b394194d5..a60e10c02 100644 --- a/cicecore/shared/ice_domain_size.F90 +++ b/cicecore/shared/ice_domain_size.F90 @@ -18,9 +18,14 @@ module ice_domain_size implicit none private + integer (kind=int_kind), public :: & + max_blocks , & ! max number of blocks per processor + block_size_x, & ! size of block in first horiz dimension + block_size_y, & ! size of block in second horiz dimension + nx_global , & ! i-axis size + ny_global ! j-axis size + integer (kind=int_kind), parameter, public :: & - nx_global = NXGLOB , & ! i-axis size - ny_global = NYGLOB , & ! j-axis size ncat = NICECAT , & ! number of categories nilyr = NICELYR , & ! number of ice layers per category nslyr = NSNWLYR , & ! number of snow layers per category @@ -59,10 +64,6 @@ module ice_domain_size + 1 , & ! for unused tracer flags max_nstrm = 5 ! max number of history output streams - integer (kind=int_kind), parameter, public :: & - block_size_x = BLCKX , & ! size of block in first horiz dimension - block_size_y = BLCKY ! size of block in second horiz dimension - !*** The model will inform the user of the correct !*** values for the parameter below. A value higher than !*** necessary will not cause the code to fail, but will @@ -72,9 +73,6 @@ module ice_domain_size !*** max_blocks = (nx_global/block_size_x)*(ny_global/block_size_y)/ !*** num_procs - integer (kind=int_kind), parameter, public :: & - max_blocks = MXBLCKS ! max number of blocks per processor - !======================================================================= end module ice_domain_size diff --git a/configuration/scripts/cice.build b/configuration/scripts/cice.build index f8657f8ee..bacb4c60e 100755 --- a/configuration/scripts/cice.build +++ b/configuration/scripts/cice.build @@ -25,7 +25,8 @@ endif if !(-d ${ICE_OBJDIR}) mkdir -p ${ICE_OBJDIR} cd ${ICE_OBJDIR} -setenv ICE_CPPDEFS "-DNXGLOB=${ICE_NXGLOB} -DNYGLOB=${ICE_NYGLOB} -DBLCKX=${ICE_BLCKX} -DBLCKY=${ICE_BLCKY} -DMXBLCKS=${ICE_MXBLCKS} -DNICELYR=${NICELYR} -DNSNWLYR=${NSNWLYR} -DNICECAT=${NICECAT} -DTRAGE=${TRAGE} -DTRFY=${TRFY} -DTRLVL=${TRLVL} -DTRPND=${TRPND} -DTRBRI=${TRBRI} -DNTRAERO=${NTRAERO} -DTRZS=${TRZS} -DNBGCLYR=${NBGCLYR} -DTRALG=${TRALG} -DTRBGCZ=${TRBGCZ} -DTRDOC=${TRDOC} -DTRDOC=${TRDOC} -DTRDIC=${TRDIC} -DTRDON=${TRDON} -DTRFED=${TRFED} -DTRFEP=${TRFEP} -DTRZAERO=${TRZAERO} -DTRBGCS=${TRBGCS} -DNUMIN=${NUMIN} -DNUMAX=${NUMAX}" +#setenv ICE_CPPDEFS "-DNXGLOB=${ICE_NXGLOB} -DNYGLOB=${ICE_NYGLOB} -DBLCKX=${ICE_BLCKX} -DBLCKY=${ICE_BLCKY} -DMXBLCKS=${ICE_MXBLCKS} -DNICELYR=${NICELYR} -DNSNWLYR=${NSNWLYR} -DNICECAT=${NICECAT} -DTRAGE=${TRAGE} -DTRFY=${TRFY} -DTRLVL=${TRLVL} -DTRPND=${TRPND} -DTRBRI=${TRBRI} -DNTRAERO=${NTRAERO} -DTRZS=${TRZS} -DNBGCLYR=${NBGCLYR} -DTRALG=${TRALG} -DTRBGCZ=${TRBGCZ} -DTRDOC=${TRDOC} -DTRDOC=${TRDOC} -DTRDIC=${TRDIC} -DTRDON=${TRDON} -DTRFED=${TRFED} -DTRFEP=${TRFEP} -DTRZAERO=${TRZAERO} -DTRBGCS=${TRBGCS} -DNUMIN=${NUMIN} -DNUMAX=${NUMAX}" +setenv ICE_CPPDEFS "-DNICELYR=${NICELYR} -DNSNWLYR=${NSNWLYR} -DNICECAT=${NICECAT} -DTRAGE=${TRAGE} -DTRFY=${TRFY} -DTRLVL=${TRLVL} -DTRPND=${TRPND} -DTRBRI=${TRBRI} -DNTRAERO=${NTRAERO} -DTRZS=${TRZS} -DNBGCLYR=${NBGCLYR} -DTRALG=${TRALG} -DTRBGCZ=${TRBGCZ} -DTRDOC=${TRDOC} -DTRDOC=${TRDOC} -DTRDIC=${TRDIC} -DTRDON=${TRDON} -DTRFED=${TRFED} -DTRFEP=${TRFEP} -DTRZAERO=${TRZAERO} -DTRBGCS=${TRBGCS} -DNUMIN=${NUMIN} -DNUMAX=${NUMAX}" if ($DITTO == 'yes') then setenv ICE_CPPDEFS "${ICE_CPPDEFS} -DREPRODUCIBLE" @@ -64,10 +65,6 @@ echo " " echo ICE_GRID = ${ICE_GRID} echo ICE_NTASK = ${ICE_NTASKS} echo ICE_NTHRD = ${ICE_NTHRDS} -echo "global N, block_size" -echo "x ${ICE_NXGLOB}, ${ICE_BLCKX}" -echo "y ${ICE_NYGLOB}, ${ICE_BLCKY}" -echo "max_blocks = ${ICE_MXBLCKS}" echo "ICE_CPPDEFS = ${ICE_CPPDEFS}" echo "Filepath = " cat ${ICE_OBJDIR}/Filepath diff --git a/configuration/scripts/cice.settings b/configuration/scripts/cice.settings index c4b71ef4a..f5cd9c7e8 100755 --- a/configuration/scripts/cice.settings +++ b/configuration/scripts/cice.settings @@ -17,15 +17,15 @@ setenv ICE_IOTYPE netcdf # set to none if netcdf library is unavailable setenv ICE_CLEANBUILD true setenv ICE_QUIETMODE false setenv ICE_GRID undefined -setenv ICE_NXGLOB undefined -setenv ICE_NYGLOB undefined +#setenv ICE_NXGLOB undefined # moved to namelist +#setenv ICE_NYGLOB undefined # moved to namelist setenv ICE_NTASKS undefined setenv ICE_NTHRDS undefined -setenv ICE_BLCKX undefined -setenv ICE_BLCKY undefined -setenv ICE_MXBLCKS undefined -setenv ICE_TEST undefined # Define if this is a test case -setenv ICE_TESTNAME undefined # Define if this is a test case +#setenv ICE_BLCKX undefined # moved to namelist +#setenv ICE_BLCKY undefined # moved to namelist +#setenv ICE_MXBLCKS undefined # moved to namelist +setenv ICE_TEST undefined +setenv ICE_TESTNAME undefined setenv ICE_BASELINE undefined setenv ICE_BASEGEN undefined setenv ICE_BASECOM undefined diff --git a/configuration/scripts/ice_in b/configuration/scripts/ice_in index ea31277c5..b804afd65 100644 --- a/configuration/scripts/ice_in +++ b/configuration/scripts/ice_in @@ -153,6 +153,11 @@ &domain_nml nprocs = 4 + nx_global = 100 + ny_global = 116 + block_size_x = 25 + block_size_y = 29 + max_blocks = -1 processor_shape = 'slenderX2' distribution_type = 'cartesian' distribution_wght = 'latitude' diff --git a/configuration/scripts/parse_namelist_from_settings.sh b/configuration/scripts/parse_namelist_from_env.sh similarity index 61% rename from configuration/scripts/parse_namelist_from_settings.sh rename to configuration/scripts/parse_namelist_from_env.sh index 3139d1879..4d829450f 100755 --- a/configuration/scripts/parse_namelist_from_settings.sh +++ b/configuration/scripts/parse_namelist_from_env.sh @@ -1,15 +1,14 @@ #!/bin/bash -f -if [[ "$#" -ne 2 ]]; then - echo "$0 ERROR: requires 2 arguments, the namelist and settings" +if [[ "$#" -ne 1 ]]; then + echo "$0 ERROR: requires 1 argument, the namelist to modify" exit -1 fi filename=$1 -filemods=$2 -#echo "$0 $1 $2" -echo "running parse_namelist_from_settings.sh" +#echo "$0 $1" +echo "running parse_namelist_from_env.sh" sed -i.sedbak -e 's|ICE_SANDBOX|'"${ICE_SANDBOX}"'|g' $filename sed -i.sedbak -e 's|ICE_MACHINE_INPUTDATA|'"${ICE_MACHINE_INPUTDATA}"'|g' $filename