From 362af79d6a8243579ac371545229397a99a3b846 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 6 Feb 2020 16:02:17 -0700 Subject: [PATCH 01/39] Add mizuRoute as a component --- Externals.cfg | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Externals.cfg b/Externals.cfg index b15f54e496..9a62c22138 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -26,11 +26,18 @@ repo_url = https://github.com/ESCOMP/mosart tag = mosart1_0_35 required = True +[mizuRoute] +local_path = components/mizuRoute +protocol = git +repo_url = https://github.com/ekluzek/mizuRoute +branch = ctsm-coupling +required = True + [cime] local_path = cime protocol = git -repo_url = https://github.com/ESMCI/cime -tag = branch_tags/cime5.8.15_a01 +repo_url = https://github.com/ekluzek/cime +branch = mizuRoute externals = ../Externals_cime.cfg required = True From d74be3abd88badca4dc9a21af9a2b19212f3de00 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 6 Feb 2020 22:06:40 -0700 Subject: [PATCH 02/39] Add a mizuRoute compset --- cime_config/config_compsets.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cime_config/config_compsets.xml b/cime_config/config_compsets.xml index a1954b5dde..88e6ad94e1 100644 --- a/cime_config/config_compsets.xml +++ b/cime_config/config_compsets.xml @@ -65,6 +65,11 @@ 2000_DATM%GSWP3v1_CLM50%SP_SICE_SOCN_RTM_SGLC_SWAV + + I2000Clm50SpMizGs + 2000_DATM%GSWP3v1_CLM50%SP_SICE_SOCN_MIZUROUTE_SGLC_SWAV + + I2000Clm50BgcCru 2000_DATM%CRUv7_CLM50%BGC_SICE_SOCN_MOSART_CISM2%NOEVOLVE_SWAV From a981e8ccfbee6b26809d29c69f9f86c1e81dfcfd Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 12 Feb 2020 14:03:04 -0700 Subject: [PATCH 03/39] Change to point to Naoki's branch rather than mine --- Externals.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals.cfg b/Externals.cfg index 9a62c22138..13d84a4054 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -29,7 +29,7 @@ required = True [mizuRoute] local_path = components/mizuRoute protocol = git -repo_url = https://github.com/ekluzek/mizuRoute +repo_url = https://github.com/nmizukami/mizuRoute branch = ctsm-coupling required = True From b9d1ddf79f65a9c568bacb5b14e120966836bc07 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 23 Mar 2020 13:08:20 -0600 Subject: [PATCH 04/39] changes for nuopc threading --- src/biogeochem/CNVegetationFacade.F90 | 54 ++++++++++++++------------- src/main/initSubgridMod.F90 | 45 +++++++++++----------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/biogeochem/CNVegetationFacade.F90 b/src/biogeochem/CNVegetationFacade.F90 index 4327a4e7ce..0dda6c6727 100644 --- a/src/biogeochem/CNVegetationFacade.F90 +++ b/src/biogeochem/CNVegetationFacade.F90 @@ -68,7 +68,7 @@ module CNVegetationFacade use WaterFluxBulkType , only : waterfluxbulk_type use Wateratm2lndBulkType , only : wateratm2lndbulk_type use SoilStateType , only : soilstate_type - use TemperatureType , only : temperature_type + use TemperatureType , only : temperature_type use CropType , only : crop_type use ch4Mod , only : ch4_type use CNDVType , only : dgvs_type @@ -148,7 +148,7 @@ module CNVegetationFacade ! - vocemis_inst ! - fireemis_inst ! - drydepvel_inst - + contains procedure, public :: Init procedure, public :: InitAccBuffer @@ -219,7 +219,7 @@ subroutine Init(this, bounds, NLFilename, nskip_steps) ! Note - always initialize the memory for cnveg_state_inst (used in biogeophys/) call this%cnveg_state_inst%Init(bounds) - + skip_steps = nskip_steps if (use_cn) then @@ -249,7 +249,7 @@ subroutine Init(this, bounds, NLFilename, nskip_steps) this%cnveg_carbonstate_inst%frootc_patch(begp:endp), & this%cnveg_carbonstate_inst%frootc_storage_patch(begp:endp), & this%cnveg_carbonstate_inst%deadstemc_patch(begp:endp) ) - call this%cnveg_nitrogenflux_inst%Init(bounds) + call this%cnveg_nitrogenflux_inst%Init(bounds) call this%c_products_inst%Init(bounds, species_non_isotope_type('C')) if (use_c13) then @@ -338,7 +338,7 @@ end subroutine CNReadNML subroutine InitAccBuffer(this, bounds) ! ! !DESCRIPTION: - ! Initialize accumulation buffer for types contained here + ! Initialize accumulation buffer for types contained here ! ! !USES: ! @@ -430,9 +430,9 @@ subroutine Restart(this, bounds, ncid, flag) ! ! !ARGUMENTS: class(cn_vegetation_type), intent(inout) :: this - type(bounds_type), intent(in) :: bounds - type(file_desc_t), intent(inout) :: ncid - character(len=*) , intent(in) :: flag + type(bounds_type), intent(in) :: bounds + type(file_desc_t), intent(inout) :: ncid + character(len=*) , intent(in) :: flag integer :: reseed_patch(bounds%endp-bounds%begp+1) integer :: num_reseed_patch ! @@ -645,7 +645,7 @@ subroutine DynamicAreaConservation(this, bounds, clump_index, & ! ! !ARGUMENTS: class(cn_vegetation_type), intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds ! Index of clump on which we're currently operating. Note that this implies that this ! routine must be called from within a clump loop. @@ -743,7 +743,7 @@ subroutine InitColumnBalance(this, bounds, num_allc, filter_allc, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_allc ! number of columns in allc filter integer , intent(in) :: filter_allc(:) ! filter for all active columns integer , intent(in) :: num_soilc ! number of soil columns in filter @@ -807,7 +807,7 @@ subroutine EcosystemDynamicsPreDrainage(this, bounds, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns integer , intent(in) :: num_soilp ! number of soil patches in filter @@ -870,7 +870,7 @@ subroutine EcosystemDynamicsPreDrainage(this, bounds, & this%dgvs_inst, photosyns_inst, saturated_excess_runoff_inst, energyflux_inst, & nutrient_competition_method, this%cnfire_method) - ! fire carbon emissions + ! fire carbon emissions call CNFireEmisUpdate(bounds, num_soilp, filter_soilp, & this%cnveg_carbonflux_inst, this%cnveg_carbonstate_inst, fireemis_inst ) @@ -899,7 +899,7 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_allc ! number of columns in allc filter integer , intent(in) :: filter_allc(:) ! filter for all active columns integer , intent(in) :: num_soilc ! number of soil columns in filter @@ -927,9 +927,9 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & character(len=*), parameter :: subname = 'EcosystemDynamicsPostDrainage' !----------------------------------------------------------------------- - ! Update the nitrogen leaching rate as a function of soluble mineral N + ! Update the nitrogen leaching rate as a function of soluble mineral N ! and total soil water outflow. - + call CNDriverLeaching(bounds, & num_soilc, filter_soilc, & num_soilp, filter_soilp, & @@ -937,7 +937,7 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & this%cnveg_nitrogenflux_inst, this%cnveg_nitrogenstate_inst, & soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst) - ! Set controls on very low values in critical state variables + ! Set controls on very low values in critical state variables call t_startf('CNPrecisionControl') call CNPrecisionControl(bounds, num_soilp, filter_soilp, & @@ -982,7 +982,7 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & ! On the radiation time step, use C state variables to calculate ! vegetation structure (LAI, SAI, height) - if (doalb) then + if (doalb) then call CNVegStructUpdate(num_soilp, filter_soilp, & waterdiagnosticbulk_inst, frictionvel_inst, this%dgvs_inst, this%cnveg_state_inst, & crop_inst, this%cnveg_carbonstate_inst, canopystate_inst) @@ -1004,7 +1004,7 @@ subroutine BalanceCheck(this, bounds, num_soilc, filter_soilc, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns type(soilbiogeochem_carbonflux_type) , intent(inout) :: soilbiogeochem_carbonflux_inst @@ -1019,7 +1019,9 @@ subroutine BalanceCheck(this, bounds, num_soilc, filter_soilc, & DA_nstep = get_nstep_since_startup_or_lastDA_restart_or_pause() if (DA_nstep <= skip_steps )then if (masterproc) then +!$OMP MASTER write(iulog,*) '--WARNING-- skipping CN balance check for first timesteps after startup or data assimilation' +!$OMP END MASTER end if else @@ -1050,7 +1052,7 @@ subroutine EndOfTimeStepVegDynamics(this, bounds, num_natvegp, filter_natvegp, & ! ! !ARGUMENTS: class(cn_vegetation_type), intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(inout) :: num_natvegp ! number of naturally-vegetated patches in filter integer , intent(inout) :: filter_natvegp(:) ! filter for naturally-vegetated patches type(atm2lnd_type) , intent(inout) :: atm2lnd_inst @@ -1116,7 +1118,7 @@ subroutine WriteHistory(this, bounds) ! ! !ARGUMENTS: class(cn_vegetation_type), intent(in) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds ! ! !LOCAL VARIABLES: @@ -1359,12 +1361,12 @@ function get_froot_carbon_patch(this, bounds, tlai) result(froot_carbon_patch) else ! To get leaf biomass: ! bleaf = LAI / slatop -! g/m2 = m2/m2 / m2/g -! To get root biomass: +! g/m2 = m2/m2 / m2/g +! To get root biomass: ! broot = bleaf * froot_leaf(ivt(p)) ! g/m2 = g/m2 * g/g do p=bounds%begp, bounds%endp - if (pftcon%slatop(patch%itype(p)) > 0._r8) then + if (pftcon%slatop(patch%itype(p)) > 0._r8) then froot_carbon_patch(p) = tlai(p) & / pftcon%slatop(patch%itype(p)) & *pftcon%froot_leaf(patch%itype(p)) @@ -1404,12 +1406,12 @@ function get_croot_carbon_patch(this, bounds, tlai) result(croot_carbon_patch) else ! To get leaf biomass: ! bleaf = LAI / slatop -! g/m2 = m2/m2 / m2/g -! To get root biomass: +! g/m2 = m2/m2 / m2/g +! To get root biomass: ! broot = bleaf * froot_leaf(ivt(p)) ! g/m2 = g/m2 * g/g do p=bounds%begp, bounds%endp - if (pftcon%slatop(patch%itype(p)) > 0._r8) then + if (pftcon%slatop(patch%itype(p)) > 0._r8) then croot_carbon_patch(p) = tlai(p) & / pftcon%slatop(patch%itype(p)) & *pftcon%stem_leaf(patch%itype(p)) & diff --git a/src/main/initSubgridMod.F90 b/src/main/initSubgridMod.F90 index 43851c337b..7cabcdbbda 100644 --- a/src/main/initSubgridMod.F90 +++ b/src/main/initSubgridMod.F90 @@ -13,10 +13,10 @@ module initSubgridMod use clm_varctl , only : iulog, use_fates use clm_varcon , only : namep, namec, namel use decompMod , only : bounds_type - use GridcellType , only : grc - use LandunitType , only : lun - use ColumnType , only : col - use PatchType , only : patch + use GridcellType , only : grc + use LandunitType , only : lun + use ColumnType , only : col + use PatchType , only : patch use column_varcon , only : is_hydrologically_active ! ! !PUBLIC TYPES: @@ -37,27 +37,27 @@ module initSubgridMod !----------------------------------------------------------------------- contains - + !------------------------------------------------------------------------------ subroutine clm_ptrs_compdown(bounds) ! ! !DESCRIPTION: - ! Assumes the part of the subgrid pointing up has been set. Fills + ! Assumes the part of the subgrid pointing up has been set. Fills ! in the data pointing down. Up is p_c, p_l, p_g, c_l, c_g, and l_g. ! ! This algorithm assumes all indices besides grid cell are monotonically ! increasing. (Note that grid cell index is NOT monotonically increasing, - ! hence we cannot set initial & final indices at the grid cell level - + ! hence we cannot set initial & final indices at the grid cell level - ! grc%luni, grc%lunf, etc.) ! ! Algorithm works as follows. The p, c, and l loops march through ! the full arrays (nump, numc, and numl) checking the "up" indexes. - ! As soon as the "up" index of the current (p,c,l) cell changes relative - ! to the previous (p,c,l) cell, the *i array will be set to point down + ! As soon as the "up" index of the current (p,c,l) cell changes relative + ! to the previous (p,c,l) cell, the *i array will be set to point down ! to that cell. The *f array follows the same logic, so it's always the ! last "up" index from the previous cell when an "up" index changes. ! - ! For example, a case where p_c(1:4) = 1 and p_c(5:12) = 2. This + ! For example, a case where p_c(1:4) = 1 and p_c(5:12) = 2. This ! subroutine will set c_pi(1) = 1, c_pf(1) = 4, c_pi(2) = 5, c_pf(2) = 12. ! ! !USES @@ -79,7 +79,7 @@ subroutine clm_ptrs_compdown(bounds) !--- Loop p through full local begp:endp length !--- Separately check the p_c, p_l, and p_g indexes for a change in !--- the "up" index. - !--- If there is a change, verify that the current c,l,g is within the + !--- If there is a change, verify that the current c,l,g is within the !--- valid range, and set c_pi, l_pi, or g_pi to that current c,l,g !--- Constantly update the c_pf, l_pf, and g_pf array. When the !--- g, l, c index changes, the *_pf array will be set correctly @@ -167,7 +167,7 @@ subroutine clm_ptrs_check(bounds) integer :: ltype ! landunit type logical :: error ! error flag !------------------------------------------------------------------------------ - +!$OMP CRITICAL associate( & begg => bounds%begg, & endg => bounds%endg, & @@ -178,10 +178,8 @@ subroutine clm_ptrs_check(bounds) begp => bounds%begp, & endp => bounds%endp & ) - if (masterproc) write(iulog,*) ' ' if (masterproc) write(iulog,*) '---clm_ptrs_check:' - !--- check index ranges --- error = .false. do g = begg, endg @@ -192,12 +190,12 @@ subroutine clm_ptrs_check(bounds) end if end do end do + if (error) then write(iulog,*) ' clm_ptrs_check: g index ranges - ERROR' call endrun(msg=errMsg(sourcefile, __LINE__)) end if if (masterproc) write(iulog,*) ' clm_ptrs_check: g index ranges - OK' - error = .false. if (minval(lun%gridcell(begl:endl)) < begg .or. maxval(lun%gridcell(begl:endl)) > endg) error=.true. if (minval(lun%coli(begl:endl)) < begc .or. maxval(lun%coli(begl:endl)) > endc) error=.true. @@ -286,7 +284,6 @@ subroutine clm_ptrs_check(bounds) endif enddo if (masterproc) write(iulog,*) ' clm_ptrs_check: p mono increasing - OK' - !--- check that the tree is internally consistent --- error = .false. do g = begg, endg @@ -323,9 +320,9 @@ subroutine clm_ptrs_check(bounds) enddo ! g if (masterproc) write(iulog,*) ' clm_ptrs_check: tree consistent - OK' if (masterproc) write(iulog,*) ' ' - end associate - +!$OMP END CRITICAL + end subroutine clm_ptrs_check !----------------------------------------------------------------------- @@ -346,10 +343,10 @@ subroutine add_landunit(li, gi, ltype, wtgcell) real(r8) , intent(in) :: wtgcell ! weight of the landunit relative to the grid cell ! ! !LOCAL VARIABLES: - + character(len=*), parameter :: subname = 'add_landunit' !----------------------------------------------------------------------- - + li = li + 1 lun%gridcell(li) = gi @@ -442,10 +439,10 @@ subroutine add_patch(pi, ci, ptype, wtcol) ! !LOCAL VARIABLES: integer :: li ! landunit index integer :: lb_offset ! offset between natpft_lb and 1 - + character(len=*), parameter :: subname = 'add_patch' !----------------------------------------------------------------------- - + pi = pi + 1 patch%column(pi) = ci @@ -456,7 +453,7 @@ subroutine add_patch(pi, ci, ptype, wtcol) patch%wtcol(pi) = wtcol ! TODO (MV, 10-17-14): The following must be commented out because - ! currently patch%itype is used in CanopyTemperatureMod to calculate + ! currently patch%itype is used in CanopyTemperatureMod to calculate ! z0m(p) and displa(p) - and is still called even when fates is on !if (.not. use_fates) then @@ -469,7 +466,7 @@ subroutine add_patch(pi, ci, ptype, wtcol) else patch%mxy(pi) = ispval end if - + end subroutine add_patch From 6bcaafec6715b5f44e177d4617d96908f8d197b2 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 23 Mar 2020 13:18:19 -0600 Subject: [PATCH 05/39] Change CMEPS to my branch --- Externals_cime.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals_cime.cfg b/Externals_cime.cfg index 4751386a44..3eeafa11f6 100644 --- a/Externals_cime.cfg +++ b/Externals_cime.cfg @@ -1,7 +1,7 @@ [cmeps] -hash = 253f612acae07b2b1dc73c84f1bb30b8e1b86ddd +branch = mizuroute protocol = git -repo_url = https://github.com/ESCOMP/CMEPS.git +repo_url = https://github.com/ekluzek/CMEPS.git local_path = src/drivers/nuopc/ required = True From 7d036aafbf9f8d38bfa23223eb54008b8e0402f6 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Mon, 23 Mar 2020 11:51:55 -0600 Subject: [PATCH 06/39] fixed bug --- src/cpl/nuopc/lnd_import_export.F90 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cpl/nuopc/lnd_import_export.F90 b/src/cpl/nuopc/lnd_import_export.F90 index 0838b7a00a..ad99008be8 100644 --- a/src/cpl/nuopc/lnd_import_export.F90 +++ b/src/cpl/nuopc/lnd_import_export.F90 @@ -20,7 +20,7 @@ module lnd_import_export use glc2lndMod , only : glc2lnd_type use domainMod , only : ldomain use spmdMod , only : masterproc - use seq_drydep_mod , only : seq_drydep_readnl, n_drydep, seq_drydep_init + use seq_drydep_mod , only : seq_drydep_readnl, n_drydep use shr_megan_mod , only : shr_megan_readnl, shr_megan_mechcomps_n use shr_fire_emis_mod , only : shr_fire_emis_readnl use shr_carma_mod , only : shr_carma_readnl @@ -187,7 +187,6 @@ subroutine advertise_fields(gcomp, flds_scalar_name, glc_present, cism_evolve, r if (drydep_nflds > 0) then call fldlist_add(fldsFrLnd_num, fldsFrLnd, 'Sl_ddvel', ungridded_lbound=1, ungridded_ubound=drydep_nflds) end if - call seq_drydep_init( ) ! MEGAN VOC emissions fluxes from land call shr_megan_readnl('drv_flds_in', megan_nflds) From 1f555943be822fdd0443da02948c80ab7cd7631c Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Thu, 2 Apr 2020 10:06:44 -0600 Subject: [PATCH 07/39] add SetVM as public interface --- src/cpl/nuopc/lnd_comp_nuopc.F90 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index 075c93c8ed..f192fb48cd 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -8,6 +8,7 @@ module lnd_comp_nuopc use NUOPC , only : NUOPC_CompDerive, NUOPC_CompSetEntryPoint, NUOPC_CompSpecialize use NUOPC , only : NUOPC_CompFilterPhaseMap, NUOPC_CompAttributeGet, NUOPC_CompAttributeSet use NUOPC_Model , only : model_routine_SS => SetServices + use NUOPC_Model , only : SetVM use NUOPC_Model , only : model_label_Advance => label_Advance use NUOPC_Model , only : model_label_DataInitialize => label_DataInitialize use NUOPC_Model , only : model_label_SetRunClock => label_SetRunClock @@ -39,7 +40,7 @@ module lnd_comp_nuopc use lnd_shr_methods , only : set_component_logging, get_component_instance, log_clock_advance use perf_mod , only : t_startf, t_stopf, t_barrierf use netcdf , only : nf90_open, nf90_nowrite, nf90_noerr, nf90_close, nf90_strerror - use netcdf , only : nf90_inq_dimid, nf90_inq_varid, nf90_get_var + use netcdf , only : nf90_inq_dimid, nf90_inq_varid, nf90_get_var use netcdf , only : nf90_inquire_dimension, nf90_inquire_variable implicit none @@ -47,6 +48,7 @@ module lnd_comp_nuopc ! Module routines public :: SetServices + public :: SetVM private :: InitializeP0 private :: InitializeAdvertise private :: InitializeRealize @@ -66,7 +68,7 @@ module lnd_comp_nuopc integer :: flds_scalar_index_ny = 0 integer :: flds_scalar_index_nextsw_cday = 0 - logical :: glc_present + logical :: glc_present logical :: rof_prognostic integer, parameter :: dbug = 0 character(*),parameter :: modName = "(lnd_comp_nuopc)" @@ -167,7 +169,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_VM) :: vm integer :: lmpicom - integer :: ierr + integer :: ierr integer :: n integer :: localpet integer :: compid ! component id @@ -294,7 +296,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (trim(cvalue) == 'sglc') then glc_present = .false. else - glc_present = .true. + glc_present = .true. cism_evolve = .true. call NUOPC_CompAttributeGet(gcomp, name="cism_evolve", value=cvalue, isPresent=isPresent, isSet=isSet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -395,7 +397,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer :: maxIndex(2) real(r8) :: mincornerCoord(2) real(r8) :: maxcornerCoord(2) - type(ESMF_Grid) :: lgrid + type(ESMF_Grid) :: lgrid character(len=*),parameter :: subname=trim(modName)//':(InitializeRealize) ' !------------------------------------------------------------------------------- @@ -553,7 +555,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! If no land then abort for now ! TODO: need to handle the case of noland with CMEPS ! if ( noland ) then - ! call shr_sys_abort(trim(subname)//"ERROR: Currently cannot handle case of single column with non-land") + ! call shr_sys_abort(trim(subname)//"ERROR: Currently cannot handle case of single column with non-land") ! end if ! obtain global index array for just land points which includes mask=0 or ocean points @@ -785,7 +787,7 @@ subroutine ModelAdvance(gcomp, rc) !------------------------ ! Run CTSM !------------------------ - + use clm_instMod, only : water_inst, atm2lnd_inst, glc2lnd_inst, lnd2atm_inst, lnd2glc_inst ! input/output variables @@ -1210,7 +1212,7 @@ subroutine clm_orbital_init(gcomp, logunit, mastertask, rc) ! input/output variables type(ESMF_GridComp) , intent(in) :: gcomp integer , intent(in) :: logunit - logical , intent(in) :: mastertask + logical , intent(in) :: mastertask integer , intent(out) :: rc ! output error ! local variables @@ -1304,12 +1306,12 @@ end subroutine clm_orbital_init subroutine clm_orbital_update(clock, logunit, mastertask, eccen, obliqr, lambm0, mvelpp, rc) !---------------------------------------------------------- - ! Update orbital settings + ! Update orbital settings !---------------------------------------------------------- ! input/output variables type(ESMF_Clock) , intent(in) :: clock - integer , intent(in) :: logunit + integer , intent(in) :: logunit logical , intent(in) :: mastertask real(R8) , intent(inout) :: eccen ! orbital eccentricity real(R8) , intent(inout) :: obliqr ! Earths obliquity in rad @@ -1319,7 +1321,7 @@ subroutine clm_orbital_update(clock, logunit, mastertask, eccen, obliqr, lambm0 ! local variables type(ESMF_Time) :: CurrTime ! current time - integer :: year ! model year at current time + integer :: year ! model year at current time integer :: orb_year ! orbital year for current orbital computation character(len=CL) :: msgstr ! temporary logical :: lprint @@ -1335,7 +1337,7 @@ subroutine clm_orbital_update(clock, logunit, mastertask, eccen, obliqr, lambm0 orb_year = orb_iyear + (year - orb_iyear_align) lprint = mastertask else - orb_year = orb_iyear + orb_year = orb_iyear if (first_time) then lprint = mastertask first_time = .false. From a1029030c85111fbbba050c4624ebb803f85d6d1 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 6 Apr 2020 13:35:25 -0600 Subject: [PATCH 08/39] add threading support, fix pe layout --- cime_config/config_pes.xml | 836 +++++++++++++++---------------- src/cpl/nuopc/lnd_comp_nuopc.F90 | 32 +- 2 files changed, 446 insertions(+), 422 deletions(-) diff --git a/cime_config/config_pes.xml b/cime_config/config_pes.xml index 9467994e62..b692ccc6b7 100644 --- a/cime_config/config_pes.xml +++ b/cime_config/config_pes.xml @@ -7,34 +7,34 @@ none - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -44,34 +44,34 @@ none - -1 - -9 - -9 - -9 - -9 - -9 - -9 - -9 + -1 + -9 + -9 + -9 + -9 + -9 + -9 + -9 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + 0 + -1 + -1 + -1 + -1 + -1 + -1 + -1 @@ -91,24 +91,24 @@ -4 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + 0 + -1 + -1 + -1 + -1 + -1 + -1 + -1 @@ -118,34 +118,34 @@ none - -2 - -2 - -2 - -2 - -2 - -2 - -2 - -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -155,34 +155,34 @@ none - 180 - 180 - 180 - 180 - 180 - 180 - 180 - 180 + 180 + 180 + 180 + 180 + 180 + 180 + 180 + 180 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -192,34 +192,34 @@ none - -1 - -40 - -40 - -40 - -40 - -40 - -40 - -40 + -10 + -10 + -10 + -10 + -10 + -10 + -10 + -10 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -229,34 +229,34 @@ none - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -266,7 +266,7 @@ none - -1 + -1 -50 -50 -50 @@ -276,24 +276,24 @@ -50 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + 0 + -1 + -1 + -1 + -1 + -1 + -1 + -1 @@ -303,71 +303,71 @@ none - -8 - -8 - -8 - -8 - -8 - -8 - -8 - -8 + -8 + -8 + -8 + -8 + -8 + -8 + -8 + -8 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 - + none - -16 - -16 - -16 - -16 - -16 - -16 - -16 - -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -377,34 +377,34 @@ none - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -414,34 +414,34 @@ none - -16 - -16 - -16 - -16 - -16 - -16 - -16 - -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -451,34 +451,34 @@ none - -32 - -32 - -32 - -32 - -32 - -32 - -32 - -32 + -32 + -32 + -32 + -32 + -32 + -32 + -32 + -32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -488,34 +488,34 @@ none - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -525,34 +525,34 @@ none - 5 - 5 - 5 - 5 - 5 - 5 - 5 - 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -562,35 +562,35 @@ none - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 1> - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -600,35 +600,35 @@ none - -2 - -2 - -2 - -2 - -2 - -2 - -2 - -2 - -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 1> - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -638,35 +638,35 @@ none - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 1> - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index f192fb48cd..f35cdefbcc 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -19,7 +19,7 @@ module lnd_comp_nuopc use shr_file_mod , only : shr_file_getlogunit, shr_file_setlogunit use shr_orb_mod , only : shr_orb_decl, shr_orb_params, SHR_ORB_UNDEF_REAL, SHR_ORB_UNDEF_INT use shr_cal_mod , only : shr_cal_noleap, shr_cal_gregorian, shr_cal_ymd2date - use spmdMod , only : masterproc, mpicom, spmd_init + use spmdMod , only : masterproc, mpicom, spmd_init, npes use decompMod , only : bounds_type, ldecomp, get_proc_bounds use domainMod , only : ldomain use controlMod , only : control_setNL @@ -178,6 +178,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) character(len=CL) :: logmsg logical :: isPresent, isSet logical :: cism_evolve + integer :: ierror, commsize character(len=*), parameter :: subname=trim(modName)//':(InitializeAdvertise) ' character(len=*), parameter :: format = "('("//trim(subname)//") :',A)" !------------------------------------------------------------------------------- @@ -201,13 +202,14 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call mpi_comm_dup(lmpicom, mpicom, ierr) + ! Note still need compid for those parts of the code that use the data model ! functionality through subroutine calls call NUOPC_CompAttributeGet(gcomp, name='MCTID', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return read(cvalue,*) compid ! convert from string to integer - call spmd_init( mpicom, compid ) + call spmd_init(mpicom, compid) !---------------------------------------------------------------------------- ! determine instance information @@ -331,7 +333,8 @@ end subroutine InitializeAdvertise subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) use clm_instMod, only : lnd2atm_inst, lnd2glc_inst, water_inst - +!$ use omp_lib, only : omp_set_num_threads + use ESMF, only : ESMF_VM, ESMF_VMGet ! input/output variables type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState @@ -342,6 +345,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! local variables type(ESMF_Mesh) :: mesh, gridmesh ! esmf mesh type(ESMF_DistGrid) :: DistGrid ! esmf global index space descriptor + type(ESMF_VM) :: vm type(ESMF_Time) :: currTime ! Current time type(ESMF_Time) :: startTime ! Start time type(ESMF_Time) :: stopTime ! Stop time @@ -360,6 +364,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer :: curr_tod ! Start time of day (sec) integer :: dtime_sync ! coupling time-step from the input synchronization clock integer :: dtime_clm ! ctsm time-step + integer :: localPet + integer :: localpecount integer, pointer :: gindex(:) ! global index space for land and ocean points integer, pointer :: gindex_lnd(:) ! global index space for just land points integer, pointer :: gindex_ocn(:) ! global index space for just ocean points @@ -410,7 +416,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (iulog) - #if (defined _MEMTRACE) if (masterproc) then lbnum=1 @@ -418,6 +423,13 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) endif #endif + call ESMF_GridCompGet(gcomp, vm=vm, localPet=localPet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + +!$ call omp_set_num_threads(localPeCount) + !---------------------- ! Obtain attribute values !---------------------- @@ -789,6 +801,8 @@ subroutine ModelAdvance(gcomp, rc) !------------------------ use clm_instMod, only : water_inst, atm2lnd_inst, glc2lnd_inst, lnd2atm_inst, lnd2glc_inst +!$ use omp_lib, only : omp_set_num_threads + use ESMF, only : ESMF_VM, ESMF_VMGet ! input/output variables type(ESMF_GridComp) :: gcomp @@ -800,6 +814,7 @@ subroutine ModelAdvance(gcomp, rc) type(ESMF_Time) :: currTime type(ESMF_Time) :: nextTime type(ESMF_State) :: importState, exportState + type(ESMF_VM) :: vm character(ESMF_MAXSTR) :: cvalue character(ESMF_MAXSTR) :: case_name ! case name integer :: ymd ! CTSM current date (YYYYMMDD) @@ -814,6 +829,8 @@ subroutine ModelAdvance(gcomp, rc) integer :: tod_sync ! Sync current time of day (sec) integer :: dtime ! time step increment (sec) integer :: nstep ! time step index + integer :: localPet + integer :: localpecount logical :: rstwr ! .true. ==> write restart file before returning logical :: nlend ! .true. ==> last time-step logical :: dosend ! true => send data back to driver @@ -835,6 +852,13 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) + call ESMF_GridCompGet(gcomp, vm=vm, localPet=localPet, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc) + if (chkerr(rc,__LINE__,u_FILE_u)) return + +!$ call omp_set_num_threads(localPeCount) + call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (iulog) From 4573f9e63bf27456e44c91d9c3cd298d22b4a821 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 10 Apr 2020 13:45:23 -0600 Subject: [PATCH 09/39] mv _shr_nuopc.F90 to nuopc_cap_share --- cime_config/buildlib | 4 +- src/biogeochem/CNFireBaseMod.F90 | 478 ++++++++-------- src/cpl/nuopc/lnd_comp_nuopc.F90 | 8 +- src/cpl/nuopc/lnd_import_export.F90 | 20 +- src/cpl/nuopc/lnd_shr_methods.F90 | 838 ---------------------------- src/main/clm_initializeMod.F90 | 4 +- 6 files changed, 259 insertions(+), 1093 deletions(-) delete mode 100644 src/cpl/nuopc/lnd_shr_methods.F90 diff --git a/cime_config/buildlib b/cime_config/buildlib index fabf2e8d45..1a567f4e01 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -33,7 +33,7 @@ def _main_func(): gmake_j = case.get_value("GMAKE_J") gmake = case.get_value("GMAKE") driver = case.get_value("COMP_INTERFACE").lower() - + cimeroot = case.get_value("CIMEROOT") #------------------------------------------------------- # create Filepath file #------------------------------------------------------- @@ -55,6 +55,8 @@ def _main_func(): os.path.join(lnd_root,"src","utils"), os.path.join(lnd_root,"src","cpl"), os.path.join(lnd_root,"src","cpl",driver)] + if driver == 'nuopc': + paths.append(os.path.join(cimeroot,"src","drivers","nuopc","nuopc_cap_share")) with open(filepath_file, "w") as filepath: filepath.write("\n".join(paths)) filepath.write("\n") diff --git a/src/biogeochem/CNFireBaseMod.F90 b/src/biogeochem/CNFireBaseMod.F90 index 75f10e9555..56acf2a57d 100644 --- a/src/biogeochem/CNFireBaseMod.F90 +++ b/src/biogeochem/CNFireBaseMod.F90 @@ -4,12 +4,12 @@ module CNFireBaseMod !----------------------------------------------------------------------- ! !DESCRIPTION: - ! module for fire dynamics + ! module for fire dynamics ! created in Nov, 2012 and revised in Apr, 2013 by F. Li and S. Levis ! based on Li et al. (2012a,b; 2013) ! revised in Apr, 2014 according Li et al.(2014) - ! Fire-related parameters were calibrated or tuned in Apr, 2013 based on the - ! 20th Century transient simulations at f19_g16 with (newfire05_clm45sci15_clm4_0_58) + ! Fire-related parameters were calibrated or tuned in Apr, 2013 based on the + ! 20th Century transient simulations at f19_g16 with (newfire05_clm45sci15_clm4_0_58) ! a CLM4.5 version, Qian et al. (2006) atmospheric forcing, and ! climatological lightning data. ! @@ -57,7 +57,7 @@ module CNFireBaseMod ! !PRIVATE MEMBER DATA: real(r8) :: borealat = 40._r8 ! Latitude for boreal peat fires real(r8) :: lfuel=75._r8 ! lower threshold of fuel mass (gC/m2) for ignition, Li et al.(2014) - real(r8) :: ufuel=650._r8 ! upper threshold of fuel mass(gC/m2) for ignition + real(r8) :: ufuel=650._r8 ! upper threshold of fuel mass(gC/m2) for ignition real(r8) :: g0=0.05_r8 ! g(W) when W=0 m/s real(r8) :: rh_low=30.0_r8 ! Relative humidty low (%) real(r8) :: rh_hgh=80.0_r8 ! Relative humidty high (%) @@ -81,8 +81,8 @@ module CNFireBaseMod real(r8), public, pointer :: forc_lnfm(:) ! Lightning frequency real(r8), public, pointer :: forc_hdm(:) ! Human population density - type(shr_strdata_type) :: sdat_hdm ! Human population density input data stream - type(shr_strdata_type) :: sdat_lnfm ! Lightning input data stream + type(shr_strdata_type), pointer :: sdat_hdm ! Human population density input data stream + type(shr_strdata_type), pointer :: sdat_lnfm ! Lightning input data stream contains @@ -119,7 +119,7 @@ subroutine CNFireInit( this, bounds, NLFilename ) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename !----------------------------------------------------------------------- @@ -252,7 +252,7 @@ subroutine CNFireInterp(this,bounds) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds !----------------------------------------------------------------------- if ( this%need_lightning_and_popdens ) then @@ -269,13 +269,13 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_ cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) ! ! !DESCRIPTION: - ! Computes column-level burned area + ! Computes column-level burned area ! ! !USES: ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns integer , intent(in) :: num_soilp ! number of soil patches in filter @@ -307,8 +307,8 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! Fire effects routine for coupled carbon-nitrogen code (CN). ! Relies primarily on estimate of fractional area burned, from CNFireArea(). ! - ! Total fire carbon emissions (g C/m2 land area/yr) - ! =avg(COL_FIRE_CLOSS)*seconds_per_year + avg(SOMC_FIRE)*seconds_per_year + + ! Total fire carbon emissions (g C/m2 land area/yr) + ! =avg(COL_FIRE_CLOSS)*seconds_per_year + avg(SOMC_FIRE)*seconds_per_year + ! avg(LF_CONV_CFLUX)*seconds_per_year*min(1.0,avg(LFC2)*seconds_per_year)*0.8 ! where avg means the temporal average in a year ! seconds_per_year is the number of seconds in a year. @@ -324,7 +324,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns integer , intent(in) :: num_soilp ! number of soil patches in filter @@ -375,188 +375,188 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! emis. = emissions ! decomp. = decomposing - associate( & - croot_prof => croot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of coarse roots - stem_prof => stem_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of stems - froot_prof => froot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of fine roots - leaf_prof => leaf_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of leaves + associate( & + croot_prof => croot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of coarse roots + stem_prof => stem_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of stems + froot_prof => froot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of fine roots + leaf_prof => leaf_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of leaves totsomc => totsomc_col , & ! Input: [real(r8) (:) ] (gC/m2) total soil organic matter C decomp_cpools_vr => decomp_cpools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) VR decomp. (litter, cwd, soil) decomp_npools_vr => decomp_npools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) VR decomp. (litter, cwd, soil) somc_fire => somc_fire_col , & ! Output: [real(r8) (:) ] (gC/m2/s) fire C emissions due to peat burning - - is_cwd => decomp_cascade_con%is_cwd , & ! Input: [logical (:) ] TRUE => pool is a cwd pool - is_litter => decomp_cascade_con%is_litter , & ! Input: [logical (:) ] TRUE => pool is a litter pool - - woody => pftcon%woody , & ! Input: woody lifeform (1=woody, 0=not woody) - cc_leaf => pftcon%cc_leaf , & ! Input: - cc_lstem => pftcon%cc_lstem , & ! Input: - cc_dstem => pftcon%cc_dstem , & ! Input: - cc_other => pftcon%cc_other , & ! Input: - fm_leaf => pftcon%fm_leaf , & ! Input: - fm_lstem => pftcon%fm_lstem , & ! Input: - fm_other => pftcon%fm_other , & ! Input: - fm_root => pftcon%fm_root , & ! Input: - fm_lroot => pftcon%fm_lroot , & ! Input: - fm_droot => pftcon%fm_droot , & ! Input: - lf_flab => pftcon%lf_flab , & ! Input: - lf_fcel => pftcon%lf_fcel , & ! Input: - lf_flig => pftcon%lf_flig , & ! Input: - fr_flab => pftcon%fr_flab , & ! Input: - fr_fcel => pftcon%fr_fcel , & ! Input: - fr_flig => pftcon%fr_flig , & ! Input: + + is_cwd => decomp_cascade_con%is_cwd , & ! Input: [logical (:) ] TRUE => pool is a cwd pool + is_litter => decomp_cascade_con%is_litter , & ! Input: [logical (:) ] TRUE => pool is a litter pool + + woody => pftcon%woody , & ! Input: woody lifeform (1=woody, 0=not woody) + cc_leaf => pftcon%cc_leaf , & ! Input: + cc_lstem => pftcon%cc_lstem , & ! Input: + cc_dstem => pftcon%cc_dstem , & ! Input: + cc_other => pftcon%cc_other , & ! Input: + fm_leaf => pftcon%fm_leaf , & ! Input: + fm_lstem => pftcon%fm_lstem , & ! Input: + fm_other => pftcon%fm_other , & ! Input: + fm_root => pftcon%fm_root , & ! Input: + fm_lroot => pftcon%fm_lroot , & ! Input: + fm_droot => pftcon%fm_droot , & ! Input: + lf_flab => pftcon%lf_flab , & ! Input: + lf_fcel => pftcon%lf_fcel , & ! Input: + lf_flig => pftcon%lf_flig , & ! Input: + fr_flab => pftcon%fr_flab , & ! Input: + fr_fcel => pftcon%fr_fcel , & ! Input: + fr_flig => pftcon%fr_flig , & ! Input: cmb_cmplt_fact => cnfire_const%cmb_cmplt_fact , & ! Input: [real(r8) (:) ] Combustion completion factor (unitless) - - nind => dgvs_inst%nind_patch , & ! Input: [real(r8) (:) ] number of individuals (#/m2) - - cropf_col => cnveg_state_inst%cropf_col , & ! Input: [real(r8) (:) ] cropland fraction in veg column + + nind => dgvs_inst%nind_patch , & ! Input: [real(r8) (:) ] number of individuals (#/m2) + + cropf_col => cnveg_state_inst%cropf_col , & ! Input: [real(r8) (:) ] cropland fraction in veg column farea_burned => cnveg_state_inst%farea_burned_col , & ! Input: [real(r8) (:) ] fractional area burned (/sec) - fbac1 => cnveg_state_inst%fbac1_col , & ! Input: [real(r8) (:) ] burned area out of conv. region due to LU fire + fbac1 => cnveg_state_inst%fbac1_col , & ! Input: [real(r8) (:) ] burned area out of conv. region due to LU fire fbac => cnveg_state_inst%fbac_col , & ! Input: [real(r8) (:) ] total burned area out of conversion (/sec) - baf_crop => cnveg_state_inst%baf_crop_col , & ! Input: [real(r8) (:) ] BAF for cropland - baf_peatf => cnveg_state_inst%baf_peatf_col , & ! Input: [real(r8) (:) ] BAF for peatlabd - trotr1_col => cnveg_state_inst%trotr1_col , & ! Input: [real(r8) (:) ] patch weight of BET on the column (0-1) - trotr2_col => cnveg_state_inst%trotr2_col , & ! Input: [real(r8) (:) ] patch weight of BDT on the column (0-1) + baf_crop => cnveg_state_inst%baf_crop_col , & ! Input: [real(r8) (:) ] BAF for cropland + baf_peatf => cnveg_state_inst%baf_peatf_col , & ! Input: [real(r8) (:) ] BAF for peatlabd + trotr1_col => cnveg_state_inst%trotr1_col , & ! Input: [real(r8) (:) ] patch weight of BET on the column (0-1) + trotr2_col => cnveg_state_inst%trotr2_col , & ! Input: [real(r8) (:) ] patch weight of BDT on the column (0-1) dtrotr_col => cnveg_state_inst%dtrotr_col , & ! Input: [real(r8) (:) ] ann. decreased frac. coverage of BET+BDT (0-1) on GC lfc => cnveg_state_inst%lfc_col , & ! Input: [real(r8) (:) ] conv. area frac. of BET+BDT that haven't burned before lfc2 => cnveg_state_inst%lfc2_col , & ! Output: [real(r8) (:) ] conv. area frac. of BET+BDT burned this dt (/sec) - - leafcmax => cnveg_carbonstate_inst%leafcmax_patch , & ! Output: [real(r8) (:) ] (gC/m2) ann max leaf C - leafc => cnveg_carbonstate_inst%leafc_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C - leafc_storage => cnveg_carbonstate_inst%leafc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C storage - leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C transfer - livestemc => cnveg_carbonstate_inst%livestemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C - livestemc_storage => cnveg_carbonstate_inst%livestemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C storage - livestemc_xfer => cnveg_carbonstate_inst%livestemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C transfer - deadstemc => cnveg_carbonstate_inst%deadstemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C - deadstemc_storage => cnveg_carbonstate_inst%deadstemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C storage - deadstemc_xfer => cnveg_carbonstate_inst%deadstemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C transfer - frootc => cnveg_carbonstate_inst%frootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C - frootc_storage => cnveg_carbonstate_inst%frootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C storage - frootc_xfer => cnveg_carbonstate_inst%frootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C transfer - livecrootc => cnveg_carbonstate_inst%livecrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C - livecrootc_storage => cnveg_carbonstate_inst%livecrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C storage - livecrootc_xfer => cnveg_carbonstate_inst%livecrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C transfer - deadcrootc => cnveg_carbonstate_inst%deadcrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C - deadcrootc_storage => cnveg_carbonstate_inst%deadcrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C storage - deadcrootc_xfer => cnveg_carbonstate_inst%deadcrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C transfer - gresp_storage => cnveg_carbonstate_inst%gresp_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration storage - gresp_xfer => cnveg_carbonstate_inst%gresp_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration transfer - - leafn => cnveg_nitrogenstate_inst%leafn_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N - leafn_storage => cnveg_nitrogenstate_inst%leafn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N storage - leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N transfer - livestemn => cnveg_nitrogenstate_inst%livestemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N - livestemn_storage => cnveg_nitrogenstate_inst%livestemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N storage - livestemn_xfer => cnveg_nitrogenstate_inst%livestemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N transfer - deadstemn => cnveg_nitrogenstate_inst%deadstemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N - deadstemn_storage => cnveg_nitrogenstate_inst%deadstemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N storage - deadstemn_xfer => cnveg_nitrogenstate_inst%deadstemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N transfer - frootn => cnveg_nitrogenstate_inst%frootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N - frootn_storage => cnveg_nitrogenstate_inst%frootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N storage - frootn_xfer => cnveg_nitrogenstate_inst%frootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N transfer - livecrootn => cnveg_nitrogenstate_inst%livecrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N - livecrootn_storage => cnveg_nitrogenstate_inst%livecrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N storage - livecrootn_xfer => cnveg_nitrogenstate_inst%livecrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N transfer - deadcrootn => cnveg_nitrogenstate_inst%deadcrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N - deadcrootn_storage => cnveg_nitrogenstate_inst%deadcrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N storage - deadcrootn_xfer => cnveg_nitrogenstate_inst%deadcrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N transfer - retransn => cnveg_nitrogenstate_inst%retransn_patch , & ! Input: [real(r8) (:) ] (gN/m2) plant pool of retranslocated N - + + leafcmax => cnveg_carbonstate_inst%leafcmax_patch , & ! Output: [real(r8) (:) ] (gC/m2) ann max leaf C + leafc => cnveg_carbonstate_inst%leafc_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C + leafc_storage => cnveg_carbonstate_inst%leafc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C storage + leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C transfer + livestemc => cnveg_carbonstate_inst%livestemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C + livestemc_storage => cnveg_carbonstate_inst%livestemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C storage + livestemc_xfer => cnveg_carbonstate_inst%livestemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C transfer + deadstemc => cnveg_carbonstate_inst%deadstemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C + deadstemc_storage => cnveg_carbonstate_inst%deadstemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C storage + deadstemc_xfer => cnveg_carbonstate_inst%deadstemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C transfer + frootc => cnveg_carbonstate_inst%frootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C + frootc_storage => cnveg_carbonstate_inst%frootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C storage + frootc_xfer => cnveg_carbonstate_inst%frootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C transfer + livecrootc => cnveg_carbonstate_inst%livecrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C + livecrootc_storage => cnveg_carbonstate_inst%livecrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C storage + livecrootc_xfer => cnveg_carbonstate_inst%livecrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C transfer + deadcrootc => cnveg_carbonstate_inst%deadcrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C + deadcrootc_storage => cnveg_carbonstate_inst%deadcrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C storage + deadcrootc_xfer => cnveg_carbonstate_inst%deadcrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C transfer + gresp_storage => cnveg_carbonstate_inst%gresp_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration storage + gresp_xfer => cnveg_carbonstate_inst%gresp_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration transfer + + leafn => cnveg_nitrogenstate_inst%leafn_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N + leafn_storage => cnveg_nitrogenstate_inst%leafn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N storage + leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N transfer + livestemn => cnveg_nitrogenstate_inst%livestemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N + livestemn_storage => cnveg_nitrogenstate_inst%livestemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N storage + livestemn_xfer => cnveg_nitrogenstate_inst%livestemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N transfer + deadstemn => cnveg_nitrogenstate_inst%deadstemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N + deadstemn_storage => cnveg_nitrogenstate_inst%deadstemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N storage + deadstemn_xfer => cnveg_nitrogenstate_inst%deadstemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N transfer + frootn => cnveg_nitrogenstate_inst%frootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N + frootn_storage => cnveg_nitrogenstate_inst%frootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N storage + frootn_xfer => cnveg_nitrogenstate_inst%frootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N transfer + livecrootn => cnveg_nitrogenstate_inst%livecrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N + livecrootn_storage => cnveg_nitrogenstate_inst%livecrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N storage + livecrootn_xfer => cnveg_nitrogenstate_inst%livecrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N transfer + deadcrootn => cnveg_nitrogenstate_inst%deadcrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N + deadcrootn_storage => cnveg_nitrogenstate_inst%deadcrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N storage + deadcrootn_xfer => cnveg_nitrogenstate_inst%deadcrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N transfer + retransn => cnveg_nitrogenstate_inst%retransn_patch , & ! Input: [real(r8) (:) ] (gN/m2) plant pool of retranslocated N + fire_mortality_c_to_cwdc => cnveg_carbonflux_inst%fire_mortality_c_to_cwdc_col , & ! Input: [real(r8) (:,:) ] C flux fire mortality to CWD (gC/m3/s) - m_leafc_to_fire => cnveg_carbonflux_inst%m_leafc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc - m_leafc_storage_to_fire => cnveg_carbonflux_inst%m_leafc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_storage - m_leafc_xfer_to_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_xfer - m_livestemc_to_fire => cnveg_carbonflux_inst%m_livestemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from livestemc - m_livestemc_storage_to_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_storage - m_livestemc_xfer_to_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_xfer - m_deadstemc_to_fire => cnveg_carbonflux_inst%m_deadstemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer - m_deadstemc_storage_to_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_storage - m_deadstemc_xfer_to_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer - m_frootc_to_fire => cnveg_carbonflux_inst%m_frootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc - m_frootc_storage_to_fire => cnveg_carbonflux_inst%m_frootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_storage - m_frootc_xfer_to_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_xfer - m_livecrootc_to_fire => cnveg_carbonflux_inst%m_livecrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc - m_livecrootc_storage_to_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_storage - m_livecrootc_xfer_to_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_xfer - m_deadcrootc_to_fire => cnveg_carbonflux_inst%m_deadcrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc - m_deadcrootc_storage_to_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_storage - m_deadcrootc_xfer_to_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_xfer - m_gresp_storage_to_fire => cnveg_carbonflux_inst%m_gresp_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_storage - m_gresp_xfer_to_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_xfer - m_leafc_to_litter_fire => cnveg_carbonflux_inst%m_leafc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafc_storage_to_litter_fire => cnveg_carbonflux_inst%m_leafc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_to_deadstemc_fire => cnveg_carbonflux_inst%m_livestemc_to_deadstemc_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemc_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootc_to_litter_fire => cnveg_carbonflux_inst%m_frootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_frootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_to_deadcrootc_fire => cnveg_carbonflux_inst%m_livecrootc_to_deadcrootc_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootc_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_gresp_storage_to_litter_fire => cnveg_carbonflux_inst%m_gresp_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_gresp_xfer_to_litter_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafc_to_fire => cnveg_carbonflux_inst%m_leafc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc + m_leafc_storage_to_fire => cnveg_carbonflux_inst%m_leafc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_storage + m_leafc_xfer_to_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_xfer + m_livestemc_to_fire => cnveg_carbonflux_inst%m_livestemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from livestemc + m_livestemc_storage_to_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_storage + m_livestemc_xfer_to_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_xfer + m_deadstemc_to_fire => cnveg_carbonflux_inst%m_deadstemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer + m_deadstemc_storage_to_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_storage + m_deadstemc_xfer_to_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer + m_frootc_to_fire => cnveg_carbonflux_inst%m_frootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc + m_frootc_storage_to_fire => cnveg_carbonflux_inst%m_frootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_storage + m_frootc_xfer_to_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_xfer + m_livecrootc_to_fire => cnveg_carbonflux_inst%m_livecrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc + m_livecrootc_storage_to_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_storage + m_livecrootc_xfer_to_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_xfer + m_deadcrootc_to_fire => cnveg_carbonflux_inst%m_deadcrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc + m_deadcrootc_storage_to_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_storage + m_deadcrootc_xfer_to_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_xfer + m_gresp_storage_to_fire => cnveg_carbonflux_inst%m_gresp_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_storage + m_gresp_xfer_to_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_xfer + m_leafc_to_litter_fire => cnveg_carbonflux_inst%m_leafc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafc_storage_to_litter_fire => cnveg_carbonflux_inst%m_leafc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_to_deadstemc_fire => cnveg_carbonflux_inst%m_livestemc_to_deadstemc_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemc_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootc_to_litter_fire => cnveg_carbonflux_inst%m_frootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_frootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_to_deadcrootc_fire => cnveg_carbonflux_inst%m_livecrootc_to_deadcrootc_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootc_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_gresp_storage_to_litter_fire => cnveg_carbonflux_inst%m_gresp_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_gresp_xfer_to_litter_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] m_decomp_cpools_to_fire_vr => cnveg_carbonflux_inst%m_decomp_cpools_to_fire_vr_col , & ! Output: [real(r8) (:,:,:) ] (gC/m3/s) VR decomp. C fire loss - m_c_to_litr_met_fire => cnveg_carbonflux_inst%m_c_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] - m_c_to_litr_cel_fire => cnveg_carbonflux_inst%m_c_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] - m_c_to_litr_lig_fire => cnveg_carbonflux_inst%m_c_to_litr_lig_fire_col , & ! Output: [real(r8) (:,:) ] - + m_c_to_litr_met_fire => cnveg_carbonflux_inst%m_c_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] + m_c_to_litr_cel_fire => cnveg_carbonflux_inst%m_c_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] + m_c_to_litr_lig_fire => cnveg_carbonflux_inst%m_c_to_litr_lig_fire_col , & ! Output: [real(r8) (:,:) ] + fire_mortality_n_to_cwdn => cnveg_nitrogenflux_inst%fire_mortality_n_to_cwdn_col , & ! Input: [real(r8) (:,:) ] N flux fire mortality to CWD (gN/m3/s) - m_leafn_to_fire => cnveg_nitrogenflux_inst%m_leafn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn - m_leafn_storage_to_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_storage - m_leafn_xfer_to_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_xfer - m_livestemn_to_fire => cnveg_nitrogenflux_inst%m_livestemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn - m_livestemn_storage_to_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_s - m_livestemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_xfer - m_deadstemn_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn - m_deadstemn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_storage - m_deadstemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_xfer - m_frootn_to_fire => cnveg_nitrogenflux_inst%m_frootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn - m_frootn_storage_to_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_storage - m_frootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_xfer - m_livecrootn_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. m_livecrootn_to_fire - m_livecrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_storage - m_livecrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_xfer - m_deadcrootn_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn - m_deadcrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_storage - m_deadcrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_xfer - m_retransn_to_fire => cnveg_nitrogenflux_inst%m_retransn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. retransn - m_leafn_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_to_deadstemn_fire => cnveg_nitrogenflux_inst%m_livestemn_to_deadstemn_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootn_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_to_deadcrootn_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_deadcrootn_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_retransn_to_litter_fire => cnveg_nitrogenflux_inst%m_retransn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafn_to_fire => cnveg_nitrogenflux_inst%m_leafn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn + m_leafn_storage_to_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_storage + m_leafn_xfer_to_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_xfer + m_livestemn_to_fire => cnveg_nitrogenflux_inst%m_livestemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn + m_livestemn_storage_to_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_s + m_livestemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_xfer + m_deadstemn_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn + m_deadstemn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_storage + m_deadstemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_xfer + m_frootn_to_fire => cnveg_nitrogenflux_inst%m_frootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn + m_frootn_storage_to_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_storage + m_frootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_xfer + m_livecrootn_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. m_livecrootn_to_fire + m_livecrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_storage + m_livecrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_xfer + m_deadcrootn_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn + m_deadcrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_storage + m_deadcrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_xfer + m_retransn_to_fire => cnveg_nitrogenflux_inst%m_retransn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. retransn + m_leafn_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_to_deadstemn_fire => cnveg_nitrogenflux_inst%m_livestemn_to_deadstemn_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootn_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_to_deadcrootn_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_deadcrootn_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_retransn_to_litter_fire => cnveg_nitrogenflux_inst%m_retransn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] m_decomp_npools_to_fire_vr => cnveg_nitrogenflux_inst%m_decomp_npools_to_fire_vr_col , & ! Output: [real(r8) (:,:,:) ] VR decomp. N fire loss (gN/m3/s) - m_n_to_litr_met_fire => cnveg_nitrogenflux_inst%m_n_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] - m_n_to_litr_cel_fire => cnveg_nitrogenflux_inst%m_n_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] - m_n_to_litr_lig_fire => cnveg_nitrogenflux_inst%m_n_to_litr_lig_fire_col & ! Output: [real(r8) (:,:) ] + m_n_to_litr_met_fire => cnveg_nitrogenflux_inst%m_n_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] + m_n_to_litr_cel_fire => cnveg_nitrogenflux_inst%m_n_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] + m_n_to_litr_lig_fire => cnveg_nitrogenflux_inst%m_n_to_litr_lig_fire_col & ! Output: [real(r8) (:,:) ] ) transient_landcover = run_has_transient_landcover() @@ -607,14 +607,14 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte m_deadstemc_storage_to_fire(p) = deadstemc_storage(p) * f * cc_other(patch%itype(p)) m_deadstemc_xfer_to_fire(p) = deadstemc_xfer(p) * f * cc_other(patch%itype(p)) m_frootc_to_fire(p) = frootc(p) * f * 0._r8 - m_frootc_storage_to_fire(p) = frootc_storage(p) * f * cc_other(patch%itype(p)) + m_frootc_storage_to_fire(p) = frootc_storage(p) * f * cc_other(patch%itype(p)) m_frootc_xfer_to_fire(p) = frootc_xfer(p) * f * cc_other(patch%itype(p)) m_livecrootc_to_fire(p) = livecrootc(p) * f * 0._r8 - m_livecrootc_storage_to_fire(p) = livecrootc_storage(p) * f * cc_other(patch%itype(p)) - m_livecrootc_xfer_to_fire(p) = livecrootc_xfer(p) * f * cc_other(patch%itype(p)) + m_livecrootc_storage_to_fire(p) = livecrootc_storage(p) * f * cc_other(patch%itype(p)) + m_livecrootc_xfer_to_fire(p) = livecrootc_xfer(p) * f * cc_other(patch%itype(p)) m_deadcrootc_to_fire(p) = deadcrootc(p) * f * 0._r8 - m_deadcrootc_storage_to_fire(p) = deadcrootc_storage(p) * f* cc_other(patch%itype(p)) - m_deadcrootc_xfer_to_fire(p) = deadcrootc_xfer(p) * f * cc_other(patch%itype(p)) + m_deadcrootc_storage_to_fire(p) = deadcrootc_storage(p) * f* cc_other(patch%itype(p)) + m_deadcrootc_xfer_to_fire(p) = deadcrootc_xfer(p) * f * cc_other(patch%itype(p)) m_gresp_storage_to_fire(p) = gresp_storage(p) * f * cc_other(patch%itype(p)) m_gresp_xfer_to_fire(p) = gresp_xfer(p) * f * cc_other(patch%itype(p)) @@ -632,11 +632,11 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte m_frootn_to_fire(p) = frootn(p) * f * 0._r8 m_frootn_storage_to_fire(p) = frootn_storage(p) * f * cc_other(patch%itype(p)) m_frootn_xfer_to_fire(p) = frootn_xfer(p) * f * cc_other(patch%itype(p)) - m_livecrootn_to_fire(p) = livecrootn(p) * f * 0._r8 - m_livecrootn_storage_to_fire(p) = livecrootn_storage(p) * f * cc_other(patch%itype(p)) + m_livecrootn_to_fire(p) = livecrootn(p) * f * 0._r8 + m_livecrootn_storage_to_fire(p) = livecrootn_storage(p) * f * cc_other(patch%itype(p)) m_livecrootn_xfer_to_fire(p) = livecrootn_xfer(p) * f * cc_other(patch%itype(p)) m_deadcrootn_to_fire(p) = deadcrootn(p) * f * 0._r8 - m_deadcrootn_xfer_to_fire(p) = deadcrootn_xfer(p) * f * cc_other(patch%itype(p)) + m_deadcrootn_xfer_to_fire(p) = deadcrootn_xfer(p) * f * cc_other(patch%itype(p)) m_deadcrootn_storage_to_fire(p) = deadcrootn_storage(p) * f * cc_other(patch%itype(p)) m_retransn_to_fire(p) = retransn(p) * f * cc_other(patch%itype(p)) @@ -655,13 +655,13 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 (stem and root live or dead assumed to have the same transport) m_livestemc_to_litter_fire(p) = livestemc(p) * f * & (1._r8 - cc_lstem(patch%itype(p))) * & - fm_droot(patch%itype(p)) + fm_droot(patch%itype(p)) m_livestemc_storage_to_litter_fire(p) = livestemc_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) m_livestemc_xfer_to_litter_fire(p) = livestemc_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) ! NOTE: It looks incorrect to use fm_droot here, but it's used to represent the fraction of plant-tissue mortality for deadstem/deadcroot ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 m_livestemc_to_deadstemc_fire(p) = livestemc(p) * f * & @@ -671,7 +671,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 (stem and root live or dead assumed to have the same transport) m_deadstemc_to_litter_fire(p) = deadstemc(p) * f * m * & (1._r8 - cc_dstem(patch%itype(p))) * & - fm_droot(patch%itype(p)) + fm_droot(patch%itype(p)) m_deadstemc_storage_to_litter_fire(p) = deadstemc_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -692,10 +692,10 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_droot(patch%itype(p)) m_livecrootc_storage_to_litter_fire(p) = livecrootc_storage(p) * f * & (1._r8- cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livecrootc_xfer_to_litter_fire(p) = livecrootc_xfer(p) * f * & (1._r8- cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livecrootc_to_deadcrootc_fire(p) = livecrootc(p) * f * & (fm_lroot(patch%itype(p))-fm_droot(patch%itype(p))) m_deadcrootc_to_litter_fire(p) = deadcrootc(p) * f * m * & @@ -705,22 +705,22 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_other(patch%itype(p)) m_deadcrootc_xfer_to_litter_fire(p) = deadcrootc_xfer(p) * f * & (1._r8- cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_gresp_storage_to_litter_fire(p) = gresp_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_gresp_xfer_to_litter_fire(p) = gresp_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) - ! nitrogen pools + ! nitrogen pools m_leafn_to_litter_fire(p) = leafn(p) * f * & (1._r8 - cc_leaf(patch%itype(p))) * & fm_leaf(patch%itype(p)) m_leafn_storage_to_litter_fire(p) = leafn_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_leafn_xfer_to_litter_fire(p) = leafn_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -731,7 +731,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_droot(patch%itype(p)) m_livestemn_storage_to_litter_fire(p) = livestemn_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livestemn_xfer_to_litter_fire(p) = livestemn_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -744,7 +744,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 (stem and root live or dead assumed to have the same transport) m_deadstemn_to_litter_fire(p) = deadstemn(p) * f * m * & (1._r8 - cc_dstem(patch%itype(p))) * & - fm_droot(patch%itype(p)) + fm_droot(patch%itype(p)) m_deadstemn_storage_to_litter_fire(p) = deadstemn_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -768,7 +768,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_other(patch%itype(p)) m_livecrootn_xfer_to_litter_fire(p) = livecrootn_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livecrootn_to_deadcrootn_fire(p) = livecrootn(p) * f * & (fm_lroot(patch%itype(p))-fm_droot(patch%itype(p))) m_deadcrootn_to_litter_fire(p) = deadcrootn(p) * f * m * & @@ -781,12 +781,12 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_other(patch%itype(p)) m_retransn_to_litter_fire(p) = retransn(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) if (use_cndv) then if ( woody(patch%itype(p)) == 1._r8 )then if ( livestemc(p)+deadstemc(p) > 0._r8 )then - nind(p) = nind(p)*(1._r8-1._r8*fm_droot(patch%itype(p))*f) + nind(p) = nind(p)*(1._r8-1._r8*fm_droot(patch%itype(p))*f) else nind(p) = 0._r8 end if @@ -795,7 +795,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte if (patch%itype(p) == noveg) leafcmax(p) = 0._r8 end if - end do ! end of patches loop + end do ! end of patches loop ! fire-induced transfer of carbon and nitrogen pools to litter and cwd @@ -843,13 +843,13 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte +(m_livecrootc_storage_to_litter_fire(p) + & m_livecrootc_xfer_to_litter_fire(p) & +m_deadcrootc_storage_to_litter_fire(p) + & - m_deadcrootc_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) + m_deadcrootc_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) m_c_to_litr_cel_fire(c,j)=m_c_to_litr_cel_fire(c,j) + & (m_leafc_to_litter_fire(p)*lf_fcel(patch%itype(p))*leaf_prof(p,j) + & - m_frootc_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootc_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) m_c_to_litr_lig_fire(c,j)=m_c_to_litr_lig_fire(c,j) + & (m_leafc_to_litter_fire(p)*lf_flig(patch%itype(p))*leaf_prof(p,j) + & - m_frootc_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootc_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) m_n_to_litr_met_fire(c,j)=m_n_to_litr_met_fire(c,j) + & ((m_leafn_to_litter_fire(p)*lf_flab(patch%itype(p)) & @@ -865,26 +865,26 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte +(m_livecrootn_storage_to_litter_fire(p) + & m_livecrootn_xfer_to_litter_fire(p) & +m_deadcrootn_storage_to_litter_fire(p) + & - m_deadcrootn_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) + m_deadcrootn_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) m_n_to_litr_cel_fire(c,j)=m_n_to_litr_cel_fire(c,j) + & (m_leafn_to_litter_fire(p)*lf_fcel(patch%itype(p))*leaf_prof(p,j) + & - m_frootn_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootn_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) m_n_to_litr_lig_fire(c,j)=m_n_to_litr_lig_fire(c,j) + & (m_leafn_to_litter_fire(p)*lf_flig(patch%itype(p))*leaf_prof(p,j) + & - m_frootn_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootn_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) end if end if end do end do end do ! - ! vertically-resolved decomposing C/N fire loss + ! vertically-resolved decomposing C/N fire loss ! column loop ! do fc = 1,num_soilc c = filter_soilc(fc) - f = farea_burned(c) + f = farea_burned(c) do j = 1, nlevdecomp ! carbon fluxes @@ -952,7 +952,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! They will be added here in proportion to the carbon emission ! Emission factors differ for various fire types - end associate + end associate end subroutine CNFireFluxes @@ -974,16 +974,16 @@ subroutine hdm_init( this, bounds, NLFilename ) ! !ARGUMENTS: implicit none class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! !LOCAL VARIABLES: integer :: stream_year_first_popdens ! first year in pop. dens. stream to use integer :: stream_year_last_popdens ! last year in pop. dens. stream to use - integer :: model_year_align_popdens ! align stream_year_first_hdm with + integer :: model_year_align_popdens ! align stream_year_first_hdm with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_popdens ! population density streams filename character(len=CL) :: popdensmapalgo = 'bilinear' ! mapping alogrithm for population density character(*), parameter :: subName = "('hdmdyn_init')" @@ -1026,17 +1026,19 @@ subroutine hdm_init( this, bounds, NLFilename ) if (masterproc) then write(iulog,*) ' ' write(iulog,*) 'popdens_streams settings:' - write(iulog,*) ' stream_year_first_popdens = ',stream_year_first_popdens - write(iulog,*) ' stream_year_last_popdens = ',stream_year_last_popdens - write(iulog,*) ' model_year_align_popdens = ',model_year_align_popdens + write(iulog,*) ' stream_year_first_popdens = ',stream_year_first_popdens + write(iulog,*) ' stream_year_last_popdens = ',stream_year_last_popdens + write(iulog,*) ' model_year_align_popdens = ',model_year_align_popdens write(iulog,*) ' stream_fldFileName_popdens = ',stream_fldFileName_popdens write(iulog,*) ' ' endif call clm_domain_mct (bounds, dom_clm) - + if (.not. associated(this%sdat_hdm)) then + allocate(this%sdat_hdm) + endif call shr_strdata_create(this%sdat_hdm,name="clmhdm", & - pio_subsystem=pio_subsystem, & + pio_subsystem=pio_subsystem, & pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & @@ -1049,7 +1051,7 @@ subroutine hdm_init( this, bounds, NLFilename ) domFileName=trim(stream_fldFileName_popdens), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -1072,7 +1074,7 @@ subroutine hdm_init( this, bounds, NLFilename ) ptr_lnd=this%forc_hdm, default='inactive') end subroutine hdm_init - + !----------------------------------------------------------------------- subroutine hdm_interp( this, bounds) ! @@ -1084,7 +1086,7 @@ subroutine hdm_interp( this, bounds) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: g, ig @@ -1105,7 +1107,7 @@ subroutine hdm_interp( this, bounds) ig = ig+1 this%forc_hdm(g) = this%sdat_hdm%avs(1)%rAttr(1,ig) end do - + end subroutine hdm_interp !----------------------------------------------------------------------- @@ -1127,16 +1129,16 @@ subroutine lnfm_init( this, bounds, NLFilename ) ! !ARGUMENTS: implicit none class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! ! !LOCAL VARIABLES: integer :: stream_year_first_lightng ! first year in Lightning stream to use integer :: stream_year_last_lightng ! last year in Lightning stream to use - integer :: model_year_align_lightng ! align stream_year_first_lnfm with + integer :: model_year_align_lightng ! align stream_year_first_lnfm with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_lightng ! lightning stream filename to read character(len=CL) :: lightngmapalgo = 'bilinear'! Mapping alogrithm character(*), parameter :: subName = "('lnfmdyn_init')" @@ -1179,17 +1181,19 @@ subroutine lnfm_init( this, bounds, NLFilename ) if (masterproc) then write(iulog,*) ' ' write(iulog,*) 'light_stream settings:' - write(iulog,*) ' stream_year_first_lightng = ',stream_year_first_lightng - write(iulog,*) ' stream_year_last_lightng = ',stream_year_last_lightng - write(iulog,*) ' model_year_align_lightng = ',model_year_align_lightng + write(iulog,*) ' stream_year_first_lightng = ',stream_year_first_lightng + write(iulog,*) ' stream_year_last_lightng = ',stream_year_last_lightng + write(iulog,*) ' model_year_align_lightng = ',model_year_align_lightng write(iulog,*) ' stream_fldFileName_lightng = ',stream_fldFileName_lightng write(iulog,*) ' ' endif call clm_domain_mct (bounds, dom_clm) - + if (.not. associated(this%sdat_lnfm)) then + allocate(this%sdat_lnfm) + endif call shr_strdata_create(this%sdat_lnfm,name="clmlnfm", & - pio_subsystem=pio_subsystem, & + pio_subsystem=pio_subsystem, & pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & @@ -1202,7 +1206,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) domFileName=trim(stream_fldFileName_lightng), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -1224,7 +1228,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) ptr_lnd=this%forc_lnfm, default='inactive') end subroutine lnfm_init - + !----------------------------------------------------------------------- subroutine lnfm_interp(this, bounds ) ! @@ -1236,7 +1240,7 @@ subroutine lnfm_interp(this, bounds ) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: g, ig @@ -1257,7 +1261,7 @@ subroutine lnfm_interp(this, bounds ) ig = ig+1 this%forc_lnfm(g) = this%sdat_lnfm%avs(1)%rAttr(1,ig) end do - + end subroutine lnfm_interp end module CNFireBaseMod diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index f35cdefbcc..8ecb57231c 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -36,8 +36,8 @@ module lnd_comp_nuopc use clm_driver , only : clm_drv use lnd_import_export , only : advertise_fields, realize_fields use lnd_import_export , only : import_fields, export_fields - use lnd_shr_methods , only : chkerr, state_setscalar, state_getscalar, state_diagnose, alarmInit - use lnd_shr_methods , only : set_component_logging, get_component_instance, log_clock_advance + use nuopc_shr_methods , only : chkerr, state_setscalar, state_getscalar, state_diagnose, alarmInit + use nuopc_shr_methods , only : set_component_logging, get_component_instance, log_clock_advance use perf_mod , only : t_startf, t_stopf, t_barrierf use netcdf , only : nf90_open, nf90_nowrite, nf90_noerr, nf90_close, nf90_strerror use netcdf , only : nf90_inq_dimid, nf90_inq_varid, nf90_get_var @@ -429,7 +429,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return !$ call omp_set_num_threads(localPeCount) - + print *,__FILE__,__LINE__,localPeCount !---------------------- ! Obtain attribute values !---------------------- @@ -781,7 +781,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) #if (defined _MEMTRACE) if(masterproc) then - write(iulog,*) TRIM(Sub) // ':end::' + write(iulog,*) TRIM(subname) // ':end::' lbnum=1 call memmon_dump_fort('memmon.out','lnd_comp_nuopc_InitializeRealize:end::',lbnum) call memmon_reset_addr() diff --git a/src/cpl/nuopc/lnd_import_export.F90 b/src/cpl/nuopc/lnd_import_export.F90 index ad99008be8..8bcec5adaa 100644 --- a/src/cpl/nuopc/lnd_import_export.F90 +++ b/src/cpl/nuopc/lnd_import_export.F90 @@ -25,7 +25,7 @@ module lnd_import_export use shr_fire_emis_mod , only : shr_fire_emis_readnl use shr_carma_mod , only : shr_carma_readnl use shr_ndep_mod , only : shr_ndep_readnl - use lnd_shr_methods , only : chkerr + use nuopc_shr_methods , only : chkerr implicit none private ! except @@ -56,7 +56,7 @@ module lnd_import_export integer, parameter :: gridTofieldMap = 2 ! ungridded dimension is innermost ! from atm->lnd - integer :: ndep_nflds ! number of nitrogen deposition fields from atm->lnd/ocn + integer :: ndep_nflds ! number of nitrogen deposition fields from atm->lnd/ocn ! from lnd->atm character(len=cx) :: carma_fields ! List of CARMA fields from lnd->atm @@ -67,7 +67,7 @@ module lnd_import_export logical :: flds_co2a ! use case logical :: flds_co2b ! use case logical :: flds_co2c ! use case - integer :: glc_nec ! number of glc elevation classes + integer :: glc_nec ! number of glc elevation classes integer, parameter :: debug = 0 ! internal debug level character(*),parameter :: F01 = "('(lnd_import_export) ',a,i5,2x,i5,2x,d21.14)" @@ -262,7 +262,7 @@ subroutine advertise_fields(gcomp, flds_scalar_name, glc_present, cism_evolve, r call fldlist_add(fldsToLnd_num, fldsToLnd, 'Faxa_ocph', ungridded_lbound=1, ungridded_ubound=3) ! from atm - wet dust deposition frluxes (4 sizes) - ! (1) => dstwet1, (2) => dstwet2, (3) => dstwet3, (4) => dstwet4 + ! (1) => dstwet1, (2) => dstwet2, (3) => dstwet3, (4) => dstwet4 call fldlist_add(fldsToLnd_num, fldsToLnd, 'Faxa_dstwet', ungridded_lbound=1, ungridded_ubound=4) ! from - atm dry dust deposition frluxes (4 sizes) @@ -290,10 +290,10 @@ subroutine advertise_fields(gcomp, flds_scalar_name, glc_present, cism_evolve, r end if if (glc_present) then - ! from land-ice (glc) - no elevation classes + ! from land-ice (glc) - no elevation classes call fldlist_add(fldsToLnd_num, fldsToLnd, 'Sg_icemask' ) ! mask of where cism is running - call fldlist_add(fldsToLnd_num, fldsToLnd, 'Sg_icemask_coupled_fluxes') ! - + call fldlist_add(fldsToLnd_num, fldsToLnd, 'Sg_icemask_coupled_fluxes') ! + ! from land-ice (glc) - fields for all glc->lnd elevation classes (1:glc_nec) plus bare land (index 0) call fldlist_add(fldsToLnd_num, fldsToLnd, 'Sg_ice_covered_elev', ungridded_lbound=1, ungridded_ubound=glc_nec+1) call fldlist_add(fldsToLnd_num, fldsToLnd, 'Sg_topo_elev' , ungridded_lbound=1, ungridded_ubound=glc_nec+1) @@ -319,7 +319,7 @@ subroutine realize_fields(gcomp, Emesh, flds_scalar_name, flds_scalar_num, rc) type(ESMF_GridComp) , intent(inout) :: gcomp type(ESMF_Mesh) , intent(in) :: Emesh character(len=*) , intent(in) :: flds_scalar_name - integer , intent(in) :: flds_scalar_num + integer , intent(in) :: flds_scalar_num integer , intent(out) :: rc ! local variables @@ -652,12 +652,12 @@ subroutine import_fields( gcomp, bounds, glc_present, rof_prognostic, & !-------------------------- ! Land-ice (glc) fields !-------------------------- - + if (glc_present) then ! We could avoid setting these fields if glc_present is .false., if that would ! help with performance. (The downside would be that we wouldn't have these fields ! available for diagnostic purposes or to force a later T compset with dlnd.) - + do num = 0,glc_nec call state_getimport(importState, 'Sg_ice_covered_elev', bounds, frac_grc(:,num), ungridded_index=num+1, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return diff --git a/src/cpl/nuopc/lnd_shr_methods.F90 b/src/cpl/nuopc/lnd_shr_methods.F90 deleted file mode 100644 index 344eda650e..0000000000 --- a/src/cpl/nuopc/lnd_shr_methods.F90 +++ /dev/null @@ -1,838 +0,0 @@ -module lnd_shr_methods - - use ESMF , only : operator(<), operator(/=), operator(+) - use ESMF , only : operator(-), operator(*) , operator(>=) - use ESMF , only : operator(<=), operator(>), operator(==) - use ESMF , only : ESMF_LOGERR_PASSTHRU, ESMF_LogFoundError, ESMF_LOGMSG_ERROR, ESMF_MAXSTR - use ESMF , only : ESMF_SUCCESS, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_FAILURE - use ESMF , only : ESMF_State, ESMF_StateGet - use ESMF , only : ESMF_Field, ESMF_FieldGet - use ESMF , only : ESMF_GridComp, ESMF_GridCompGet, ESMF_GridCompSet - use ESMF , only : ESMF_GeomType_Flag, ESMF_FieldStatus_Flag - use ESMF , only : ESMF_Mesh, ESMF_MeshGet - use ESMF , only : ESMF_GEOMTYPE_MESH, ESMF_GEOMTYPE_GRID, ESMF_FIELDSTATUS_COMPLETE - use ESMF , only : ESMF_Clock, ESMF_ClockCreate, ESMF_ClockGet, ESMF_ClockSet - use ESMF , only : ESMF_ClockPrint, ESMF_ClockAdvance - use ESMF , only : ESMF_Alarm, ESMF_AlarmCreate, ESMF_AlarmGet, ESMF_AlarmSet - use ESMF , only : ESMF_Calendar, ESMF_CALKIND_NOLEAP, ESMF_CALKIND_GREGORIAN - use ESMF , only : ESMF_Time, ESMF_TimeGet, ESMF_TimeSet - use ESMF , only : ESMF_TimeInterval, ESMF_TimeIntervalSet, ESMF_TimeIntervalGet - use ESMF , only : ESMF_VM, ESMF_VMGet, ESMF_VMBroadcast, ESMF_VMGetCurrent - use NUOPC , only : NUOPC_CompAttributeGet - use NUOPC_Model , only : NUOPC_ModelGet - use shr_kind_mod , only : r8 => shr_kind_r8, cl=>shr_kind_cl, cs=>shr_kind_cs - use shr_sys_mod , only : shr_sys_abort - use shr_file_mod , only : shr_file_setlogunit, shr_file_getLogUnit - - implicit none - private - - public :: memcheck - public :: get_component_instance - public :: set_component_logging - public :: log_clock_advance - public :: state_getscalar - public :: state_setscalar - public :: state_diagnose - public :: alarmInit - public :: chkerr - - private :: timeInit - private :: field_getfldptr - - ! Clock and alarm options - character(len=*), private, parameter :: & - optNONE = "none" , & - optNever = "never" , & - optNSteps = "nsteps" , & - optNStep = "nstep" , & - optNSeconds = "nseconds" , & - optNSecond = "nsecond" , & - optNMinutes = "nminutes" , & - optNMinute = "nminute" , & - optNHours = "nhours" , & - optNHour = "nhour" , & - optNDays = "ndays" , & - optNDay = "nday" , & - optNMonths = "nmonths" , & - optNMonth = "nmonth" , & - optNYears = "nyears" , & - optNYear = "nyear" , & - optMonthly = "monthly" , & - optYearly = "yearly" , & - optDate = "date" , & - optIfdays0 = "ifdays0" - - ! Module data - integer, parameter :: SecPerDay = 86400 ! Seconds per day - integer, parameter :: memdebug_level=1 - character(len=1024) :: msgString - character(len=*), parameter :: u_FILE_u = & - __FILE__ - -!=============================================================================== -contains -!=============================================================================== - - subroutine memcheck(string, level, mastertask) - - ! input/output variables - character(len=*) , intent(in) :: string - integer , intent(in) :: level - logical , intent(in) :: mastertask - - ! local variables - integer :: ierr - integer, external :: GPTLprint_memusage - !----------------------------------------------------------------------- - - if ((mastertask .and. memdebug_level > level) .or. memdebug_level > level+1) then - ierr = GPTLprint_memusage(string) - endif - - end subroutine memcheck - -!=============================================================================== - - subroutine get_component_instance(gcomp, inst_suffix, inst_index, rc) - - ! input/output variables - type(ESMF_GridComp) :: gcomp - character(len=*) , intent(out) :: inst_suffix - integer , intent(out) :: inst_index - integer , intent(out) :: rc - - ! local variables - logical :: isPresent - character(len=4) :: cvalue - !----------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - call NUOPC_CompAttributeGet(gcomp, name="inst_suffix", isPresent=isPresent, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if (isPresent) then - call NUOPC_CompAttributeGet(gcomp, name="inst_suffix", value=inst_suffix, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - cvalue = inst_suffix(2:) - read(cvalue, *) inst_index - else - inst_suffix = "" - inst_index=1 - endif - - end subroutine get_component_instance - -!=============================================================================== - - subroutine set_component_logging(gcomp, mastertask, logunit, shrlogunit, rc) - - ! input/output variables - type(ESMF_GridComp) :: gcomp - logical, intent(in) :: mastertask - integer, intent(out) :: logunit - integer, intent(out) :: shrlogunit - integer, intent(out) :: rc - - ! local variables - character(len=CL) :: diro - character(len=CL) :: logfile - !----------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - shrlogunit = 6 - - if (mastertask) then - call NUOPC_CompAttributeGet(gcomp, name="diro", value=diro, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call NUOPC_CompAttributeGet(gcomp, name="logfile", value=logfile, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - open(newunit=logunit,file=trim(diro)//"/"//trim(logfile)) - else - logUnit = 6 - endif - - call shr_file_setLogUnit (logunit) - - end subroutine set_component_logging - -!=============================================================================== - - subroutine log_clock_advance(clock, component, logunit, rc) - - ! input/output variables - type(ESMF_Clock) :: clock - character(len=*) , intent(in) :: component - integer , intent(in) :: logunit - integer , intent(out) :: rc - - ! local variables - character(len=CL) :: cvalue, prestring - !----------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - write(prestring, *) "------>Advancing ",trim(component)," from: " - call ESMF_ClockPrint(clock, options="currTime", unit=cvalue, preString=trim(prestring), rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - write(logunit, *) trim(cvalue) - - call ESMF_ClockPrint(clock, options="stopTime", unit=cvalue, & - preString="--------------------------------> to: ", rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - write(logunit, *) trim(cvalue) - - end subroutine log_clock_advance - -!=============================================================================== - - subroutine state_getscalar(state, scalar_id, scalar_value, flds_scalar_name, flds_scalar_num, rc) - - ! ---------------------------------------------- - ! Get scalar data from State for a particular name and broadcast it to all other pets - ! ---------------------------------------------- - - ! input/output variables - type(ESMF_State), intent(in) :: state - integer, intent(in) :: scalar_id - real(r8), intent(out) :: scalar_value - character(len=*), intent(in) :: flds_scalar_name - integer, intent(in) :: flds_scalar_num - integer, intent(inout) :: rc - - ! local variables - integer :: mytask, ierr, len - type(ESMF_VM) :: vm - type(ESMF_Field) :: field - real(r8), pointer :: farrayptr(:,:) - real(r8) :: tmp(1) - character(len=*), parameter :: subname='(state_getscalar)' - ! ---------------------------------------------- - - rc = ESMF_SUCCESS - - call ESMF_VMGetCurrent(vm, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_VMGet(vm, localPet=mytask, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_StateGet(State, itemName=trim(flds_scalar_name), field=field, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if (mytask == 0) then - call ESMF_FieldGet(field, farrayPtr = farrayptr, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (scalar_id < 0 .or. scalar_id > flds_scalar_num) then - call ESMF_LogWrite(trim(subname)//": ERROR in scalar_id", ESMF_LOGMSG_INFO, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=u_FILE_u)) return - endif - tmp(:) = farrayptr(scalar_id,:) - endif - call ESMF_VMBroadCast(vm, tmp, 1, 0, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - scalar_value = tmp(1) - - end subroutine state_getscalar - -!================================================================================ - - subroutine state_setscalar(scalar_value, scalar_id, State, flds_scalar_name, flds_scalar_num, rc) - - ! ---------------------------------------------- - ! Set scalar data from State for a particular name - ! ---------------------------------------------- - - ! input/output arguments - real(r8), intent(in) :: scalar_value - integer, intent(in) :: scalar_id - type(ESMF_State), intent(inout) :: State - character(len=*), intent(in) :: flds_scalar_name - integer, intent(in) :: flds_scalar_num - integer, intent(inout) :: rc - - ! local variables - integer :: mytask - type(ESMF_Field) :: lfield - type(ESMF_VM) :: vm - real(r8), pointer :: farrayptr(:,:) - character(len=*), parameter :: subname='(state_setscalar)' - ! ---------------------------------------------- - - rc = ESMF_SUCCESS - - call ESMF_VMGetCurrent(vm, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_VMGet(vm, localPet=mytask, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_StateGet(State, itemName=trim(flds_scalar_name), field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if (mytask == 0) then - call ESMF_FieldGet(lfield, farrayPtr = farrayptr, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (scalar_id < 0 .or. scalar_id > flds_scalar_num) then - call ESMF_LogWrite(trim(subname)//": ERROR in scalar_id", ESMF_LOGMSG_INFO) - rc = ESMF_FAILURE - return - endif - farrayptr(scalar_id,1) = scalar_value - endif - - end subroutine state_setscalar - -!=============================================================================== - - subroutine state_diagnose(State, string, rc) - - ! ---------------------------------------------- - ! Diagnose status of State - ! ---------------------------------------------- - - type(ESMF_State), intent(in) :: state - character(len=*), intent(in) :: string - integer , intent(out) :: rc - - ! local variables - integer :: i,j,n - type(ESMf_Field) :: lfield - integer :: fieldCount, lrank - character(ESMF_MAXSTR) ,pointer :: lfieldnamelist(:) - real(r8), pointer :: dataPtr1d(:) - real(r8), pointer :: dataPtr2d(:,:) - character(len=*),parameter :: subname='(state_diagnose)' - ! ---------------------------------------------- - - call ESMF_StateGet(state, itemCount=fieldCount, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - allocate(lfieldnamelist(fieldCount)) - - call ESMF_StateGet(state, itemNameList=lfieldnamelist, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - do n = 1, fieldCount - - call ESMF_StateGet(state, itemName=lfieldnamelist(n), field=lfield, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call field_getfldptr(lfield, fldptr1=dataPtr1d, fldptr2=dataPtr2d, rank=lrank, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if (lrank == 0) then - ! no local data - elseif (lrank == 1) then - if (size(dataPtr1d) > 0) then - write(msgString,'(A,3g14.7,i8)') trim(string)//': '//trim(lfieldnamelist(n)), & - minval(dataPtr1d), maxval(dataPtr1d), sum(dataPtr1d), size(dataPtr1d) - else - write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" - endif - elseif (lrank == 2) then - if (size(dataPtr2d) > 0) then - write(msgString,'(A,3g14.7,i8)') trim(string)//': '//trim(lfieldnamelist(n)), & - minval(dataPtr2d), maxval(dataPtr2d), sum(dataPtr2d), size(dataPtr2d) - else - write(msgString,'(A,a)') trim(string)//': '//trim(lfieldnamelist(n))," no data" - endif - else - call ESMF_LogWrite(trim(subname)//": ERROR rank not supported ", ESMF_LOGMSG_ERROR) - rc = ESMF_FAILURE - return - endif - call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO) - enddo - - deallocate(lfieldnamelist) - - end subroutine state_diagnose - -!=============================================================================== - - subroutine field_getfldptr(field, fldptr1, fldptr2, rank, abort, rc) - - ! ---------------------------------------------- - ! for a field, determine rank and return fldptr1 or fldptr2 - ! abort is true by default and will abort if fldptr is not yet allocated in field - ! rank returns 0, 1, or 2. 0 means fldptr not allocated and abort=false - ! ---------------------------------------------- - - ! input/output variables - type(ESMF_Field) , intent(in) :: field - real(r8), pointer , intent(inout), optional :: fldptr1(:) - real(r8), pointer , intent(inout), optional :: fldptr2(:,:) - integer , intent(out) , optional :: rank - logical , intent(in) , optional :: abort - integer , intent(out) , optional :: rc - - ! local variables - type(ESMF_GeomType_Flag) :: geomtype - type(ESMF_FieldStatus_Flag) :: status - type(ESMF_Mesh) :: lmesh - integer :: lrank, nnodes, nelements - logical :: labort - character(len=*), parameter :: subname='(field_getfldptr)' - ! ---------------------------------------------- - - if (.not.present(rc)) then - call ESMF_LogWrite(trim(subname)//": ERROR rc not present ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return - endif - - rc = ESMF_SUCCESS - - labort = .true. - if (present(abort)) then - labort = abort - endif - lrank = -99 - - call ESMF_FieldGet(field, status=status, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if (status /= ESMF_FIELDSTATUS_COMPLETE) then - lrank = 0 - if (labort) then - call ESMF_LogWrite(trim(subname)//": ERROR data not allocated ", ESMF_LOGMSG_INFO, rc=rc) - rc = ESMF_FAILURE - return - else - call ESMF_LogWrite(trim(subname)//": WARNING data not allocated ", ESMF_LOGMSG_INFO, rc=rc) - endif - else - - call ESMF_FieldGet(field, geomtype=geomtype, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - if (geomtype == ESMF_GEOMTYPE_GRID) then - call ESMF_FieldGet(field, rank=lrank, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - elseif (geomtype == ESMF_GEOMTYPE_MESH) then - call ESMF_FieldGet(field, rank=lrank, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldGet(field, mesh=lmesh, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_MeshGet(lmesh, numOwnedNodes=nnodes, numOwnedElements=nelements, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - if (nnodes == 0 .and. nelements == 0) lrank = 0 - else - call ESMF_LogWrite(trim(subname)//": ERROR geomtype not supported ", & - ESMF_LOGMSG_INFO, rc=rc) - rc = ESMF_FAILURE - return - endif ! geomtype - - if (lrank == 0) then - call ESMF_LogWrite(trim(subname)//": no local nodes or elements ", & - ESMF_LOGMSG_INFO) - elseif (lrank == 1) then - if (.not.present(fldptr1)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=1 array ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return - endif - call ESMF_FieldGet(field, farrayPtr=fldptr1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - elseif (lrank == 2) then - if (.not.present(fldptr2)) then - call ESMF_LogWrite(trim(subname)//": ERROR missing rank=2 array ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return - endif - call ESMF_FieldGet(field, farrayPtr=fldptr2, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - else - call ESMF_LogWrite(trim(subname)//": ERROR in rank ", & - ESMF_LOGMSG_ERROR, line=__LINE__, file=u_FILE_u) - rc = ESMF_FAILURE - return - endif - - endif ! status - - if (present(rank)) then - rank = lrank - endif - - end subroutine field_getfldptr - -!=============================================================================== - - subroutine alarmInit( clock, alarm, option, & - opt_n, opt_ymd, opt_tod, RefTime, alarmname, rc) - - ! Setup an alarm in a clock - ! Notes: The ringtime sent to AlarmCreate MUST be the next alarm - ! time. If you send an arbitrary but proper ringtime from the - ! past and the ring interval, the alarm will always go off on the - ! next clock advance and this will cause serious problems. Even - ! if it makes sense to initialize an alarm with some reference - ! time and the alarm interval, that reference time has to be - ! advance forward to be >= the current time. In the logic below - ! we set an appropriate "NextAlarm" and then we make sure to - ! advance it properly based on the ring interval. - - ! input/output variables - type(ESMF_Clock) , intent(inout) :: clock ! clock - type(ESMF_Alarm) , intent(inout) :: alarm ! alarm - character(len=*) , intent(in) :: option ! alarm option - integer , optional , intent(in) :: opt_n ! alarm freq - integer , optional , intent(in) :: opt_ymd ! alarm ymd - integer , optional , intent(in) :: opt_tod ! alarm tod (sec) - type(ESMF_Time) , optional , intent(in) :: RefTime ! ref time - character(len=*) , optional , intent(in) :: alarmname ! alarm name - integer , intent(inout) :: rc ! Return code - - ! local variables - type(ESMF_Calendar) :: cal ! calendar - integer :: lymd ! local ymd - integer :: ltod ! local tod - integer :: cyy,cmm,cdd,csec ! time info - character(len=64) :: lalarmname ! local alarm name - logical :: update_nextalarm ! update next alarm - type(ESMF_Time) :: CurrTime ! Current Time - type(ESMF_Time) :: NextAlarm ! Next restart alarm time - type(ESMF_TimeInterval) :: AlarmInterval ! Alarm interval - integer :: sec - character(len=*), parameter :: subname = '(set_alarmInit): ' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - lalarmname = 'alarm_unknown' - if (present(alarmname)) lalarmname = trim(alarmname) - ltod = 0 - if (present(opt_tod)) ltod = opt_tod - lymd = -1 - if (present(opt_ymd)) lymd = opt_ymd - - call ESMF_ClockGet(clock, CurrTime=CurrTime, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - call ESMF_TimeGet(CurrTime, yy=cyy, mm=cmm, dd=cdd, s=csec, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - ! initial guess of next alarm, this will be updated below - if (present(RefTime)) then - NextAlarm = RefTime - else - NextAlarm = CurrTime - endif - - ! Determine calendar - call ESMF_ClockGet(clock, calendar=cal) - - ! Determine inputs for call to create alarm - selectcase (trim(option)) - - case (optNONE) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .false. - - case (optNever) - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=9999, mm=12, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .false. - - case (optDate) - if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') - end if - if (lymd < 0 .or. ltod < 0) then - call shr_sys_abort(subname//trim(option)//'opt_ymd, opt_tod invalid') - end if - call ESMF_TimeIntervalSet(AlarmInterval, yy=9999, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call timeInit(NextAlarm, lymd, cal, ltod, rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .false. - - case (optIfdays0) - if (.not. present(opt_ymd)) then - call shr_sys_abort(subname//trim(option)//' requires opt_ymd') - end if - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=opt_n, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .true. - - case (optNSteps) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNStep) - if (.not.present(opt_n)) call shr_sys_abort(subname//trim(option)//' requires opt_n') - if (opt_n <= 0) call shr_sys_abort(subname//trim(option)//' invalid opt_n') - call ESMF_ClockGet(clock, TimeStep=AlarmInterval, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNSeconds) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNSecond) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMinutes) - call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMinute) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=60, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNHours) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNHour) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, s=3600, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNDays) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNDay) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, d=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMonths) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNMonth) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optMonthly) - call ESMF_TimeIntervalSet(AlarmInterval, mm=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=cyy, mm=cmm, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .true. - - case (optNYears) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optNYear) - if (.not.present(opt_n)) then - call shr_sys_abort(subname//trim(option)//' requires opt_n') - end if - if (opt_n <= 0) then - call shr_sys_abort(subname//trim(option)//' invalid opt_n') - end if - call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - AlarmInterval = AlarmInterval * opt_n - update_nextalarm = .true. - - case (optYearly) - call ESMF_TimeIntervalSet(AlarmInterval, yy=1, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - call ESMF_TimeSet( NextAlarm, yy=cyy, mm=1, dd=1, s=0, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - update_nextalarm = .true. - - case default - call shr_sys_abort(subname//'unknown option '//trim(option)) - - end select - - ! -------------------------------------------------------------------------------- - ! --- AlarmInterval and NextAlarm should be set --- - ! -------------------------------------------------------------------------------- - - ! --- advance Next Alarm so it won't ring on first timestep for - ! --- most options above. go back one alarminterval just to be careful - - if (update_nextalarm) then - NextAlarm = NextAlarm - AlarmInterval - do while (NextAlarm <= CurrTime) - NextAlarm = NextAlarm + AlarmInterval - enddo - endif - - alarm = ESMF_AlarmCreate( name=lalarmname, clock=clock, ringTime=NextAlarm, & - ringInterval=AlarmInterval, rc=rc) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - end subroutine alarmInit - -!=============================================================================== - - subroutine timeInit( Time, ymd, cal, tod, rc) - - ! Create the ESMF_Time object corresponding to the given input time, - ! given in YMD (Year Month Day) and TOD (Time-of-day) format. - ! Set the time by an integer as YYYYMMDD and integer seconds in the day - - ! input/output parameters: - type(ESMF_Time) , intent(inout) :: Time ! ESMF time - integer , intent(in) :: ymd ! year, month, day YYYYMMDD - type(ESMF_Calendar) , intent(in) :: cal ! ESMF calendar - integer , intent(in) :: tod ! time of day in seconds - integer , intent(out) :: rc - - ! local variables - integer :: year, mon, day ! year, month, day as integers - integer :: tdate ! temporary date - integer :: date ! coded-date (yyyymmdd) - character(len=*), parameter :: subname='(timeInit)' - !------------------------------------------------------------------------------- - - rc = ESMF_SUCCESS - - if ( (ymd < 0) .or. (tod < 0) .or. (tod > SecPerDay) )then - call shr_sys_abort( subname//'ERROR yymmdd is a negative number or time-of-day out of bounds' ) - end if - - tdate = abs(date) - year = int(tdate/10000) - if (date < 0) year = -year - mon = int( mod(tdate,10000)/ 100) - day = mod(tdate, 100) - - call ESMF_TimeSet( Time, yy=year, mm=mon, dd=day, s=tod, calendar=cal, rc=rc ) - if (chkerr(rc,__LINE__,u_FILE_u)) return - - end subroutine timeInit - -!=============================================================================== - - logical function chkerr(rc, line, file) - - integer, intent(in) :: rc - integer, intent(in) :: line - character(len=*), intent(in) :: file - - integer :: lrc - - chkerr = .false. - lrc = rc - if (ESMF_LogFoundError(rcToCheck=lrc, msg=ESMF_LOGERR_PASSTHRU, line=line, file=file)) then - chkerr = .true. - endif - end function chkerr - -end module lnd_shr_methods diff --git a/src/main/clm_initializeMod.F90 b/src/main/clm_initializeMod.F90 index b7549eb282..c53d9b3edb 100644 --- a/src/main/clm_initializeMod.F90 +++ b/src/main/clm_initializeMod.F90 @@ -280,7 +280,7 @@ subroutine initialize2( ) use clm_varctl , only : use_crop, ndep_from_cpl use clm_varorb , only : eccen, mvelpp, lambm0, obliqr use clm_time_manager , only : get_step_size_real, get_curr_calday - use clm_time_manager , only : get_curr_date, get_nstep, advance_timestep + use clm_time_manager , only : get_curr_date, get_nstep, advance_timestep use clm_time_manager , only : timemgr_init, timemgr_restart_io, timemgr_restart, is_restart use CIsoAtmTimeseriesMod , only : C14_init_BombSpike, use_c14_bombspike, C13_init_TimeSeries, use_c13_timeseries use DaylengthMod , only : InitDaylength @@ -436,9 +436,7 @@ subroutine initialize2( ) end if ! Initialize instances of all derived types as well as time constant variables - call clm_instInit(bounds_proc) - ! Initialize SNICAR optical and aging parameters call SnowOptics_init( ) ! SNICAR optical parameters: From f5de7e42e92cb134b09b4a2edeceb6d43d3c8db8 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 10 Apr 2020 14:39:42 -0600 Subject: [PATCH 10/39] This should be LND not inst_name --- src/biogeochem/CNFireBaseMod.F90 | 6 +-- src/biogeochem/SatellitePhenologyMod.F90 | 59 +++++++++++----------- src/biogeochem/ch4FInundatedStreamType.F90 | 32 ++++++------ src/biogeophys/UrbanTimeVarType.F90 | 15 +++--- src/main/ncdio_pio.F90.in | 7 ++- src/main/ndepStreamMod.F90 | 3 +- 6 files changed, 57 insertions(+), 65 deletions(-) diff --git a/src/biogeochem/CNFireBaseMod.F90 b/src/biogeochem/CNFireBaseMod.F90 index 56acf2a57d..b45004fa59 100644 --- a/src/biogeochem/CNFireBaseMod.F90 +++ b/src/biogeochem/CNFireBaseMod.F90 @@ -963,7 +963,6 @@ subroutine hdm_init( this, bounds, NLFilename ) ! Initialize data stream information for population density. ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -1039,7 +1038,7 @@ subroutine hdm_init( this, bounds, NLFilename ) endif call shr_strdata_create(this%sdat_hdm,name="clmhdm", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -1118,7 +1117,6 @@ subroutine lnfm_init( this, bounds, NLFilename ) ! Initialize data stream information for Lightning. ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -1194,7 +1192,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) endif call shr_strdata_create(this%sdat_lnfm,name="clmlnfm", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & diff --git a/src/biogeochem/SatellitePhenologyMod.F90 b/src/biogeochem/SatellitePhenologyMod.F90 index 9b287a85b2..5d20d03d4f 100644 --- a/src/biogeochem/SatellitePhenologyMod.F90 +++ b/src/biogeochem/SatellitePhenologyMod.F90 @@ -2,8 +2,8 @@ module SatellitePhenologyMod !----------------------------------------------------------------------- ! !DESCRIPTION: - ! CLM Satelitte Phenology model (SP) ecosystem dynamics (phenology, vegetation). - ! Allow some subroutines to be used by the CLM Carbon Nitrogen model (CLMCN) + ! CLM Satelitte Phenology model (SP) ecosystem dynamics (phenology, vegetation). + ! Allow some subroutines to be used by the CLM Carbon Nitrogen model (CLMCN) ! so that DryDeposition code can get estimates of LAI differences between months. ! ! !USES: @@ -22,14 +22,14 @@ module SatellitePhenologyMod use decompMod , only : gsmap_lnd_gdc2glo use domainMod , only : ldomain use fileutils , only : getavu, relavu - use PatchType , only : patch + use PatchType , only : patch use CanopyStateType , only : canopystate_type use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type use perf_mod , only : t_startf, t_stopf use spmdMod , only : masterproc use spmdMod , only : mpicom, comp_id use mct_mod - use ncdio_pio + use ncdio_pio ! ! !PUBLIC TYPES: implicit none @@ -62,7 +62,7 @@ module SatellitePhenologyMod !----------------------------------------------------------------------- contains - + !----------------------------------------------------------------------- ! ! lai_init @@ -74,7 +74,6 @@ subroutine lai_init(bounds) ! ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -92,10 +91,10 @@ subroutine lai_init(bounds) integer :: i ! index integer :: stream_year_first_lai ! first year in Lai stream to use integer :: stream_year_last_lai ! last year in Lai stream to use - integer :: model_year_align_lai ! align stream_year_first_lai with + integer :: model_year_align_lai ! align stream_year_first_lai with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_lai ! lai stream filename to read character(len=CL) :: lai_mapalgo = 'bilinear' ! Mapping alogrithm @@ -147,9 +146,9 @@ subroutine lai_init(bounds) write(iulog,*) ' ' write(iulog,*) 'lai_stream settings:' - write(iulog,*) ' stream_year_first_lai = ',stream_year_first_lai - write(iulog,*) ' stream_year_last_lai = ',stream_year_last_lai - write(iulog,*) ' model_year_align_lai = ',model_year_align_lai + write(iulog,*) ' stream_year_first_lai = ',stream_year_first_lai + write(iulog,*) ' stream_year_last_lai = ',stream_year_last_lai + write(iulog,*) ' model_year_align_lai = ',model_year_align_lai write(iulog,*) ' stream_fldFileName_lai = ',trim(stream_fldFileName_lai) endif @@ -162,8 +161,8 @@ subroutine lai_init(bounds) fldList = shr_string_listCreateField( numLaiFields, laiString ) call shr_strdata_create(sdat_lai,name="laidyn", & - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -175,7 +174,7 @@ subroutine lai_init(bounds) domFileName=trim(stream_fldFileName_lai), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -208,7 +207,7 @@ subroutine lai_interp(bounds, canopystate_inst) ! ! !ARGUMENTS: implicit none - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds type(canopystate_type) , intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: @@ -266,7 +265,7 @@ subroutine SatellitePhenologyInit (bounds) use shr_infnan_mod, only : nan => shr_infnan_nan, assignment(=) ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: ier ! error code @@ -309,7 +308,7 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & use pftconMod, only : noveg, nbrdlf_dcd_brl_shrub ! ! !ARGUMENTS: - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_nolakep ! number of column non-lake points in patch filter integer , intent(in) :: filter_nolakep(bounds%endp-bounds%begp+1) ! patch filter for non-lake points type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst @@ -322,14 +321,14 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & !----------------------------------------------------------------------- associate( & - frac_sno => waterdiagnosticbulk_inst%frac_sno_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1) - snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m) - tlai => canopystate_inst%tlai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index, no burying by snow + frac_sno => waterdiagnosticbulk_inst%frac_sno_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1) + snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m) + tlai => canopystate_inst%tlai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index, no burying by snow tsai => canopystate_inst%tsai_patch , & ! Output: [real(r8) (:) ] one-sided stem area index, no burying by snow elai => canopystate_inst%elai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index with burying by snow esai => canopystate_inst%esai_patch , & ! Output: [real(r8) (:) ] one-sided stem area index with burying by snow - htop => canopystate_inst%htop_patch , & ! Output: [real(r8) (:) ] canopy top (m) - hbot => canopystate_inst%hbot_patch , & ! Output: [real(r8) (:) ] canopy bottom (m) + htop => canopystate_inst%htop_patch , & ! Output: [real(r8) (:) ] canopy top (m) + hbot => canopystate_inst%hbot_patch , & ! Output: [real(r8) (:) ] canopy bottom (m) frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch & ! Output: [integer (:) ] fraction of vegetation not covered by snow (0 OR 1) [-] ) @@ -370,7 +369,7 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & ! problems associated with very small lai and sai. ! snow burial fraction for short vegetation (e.g. grasses) as in - ! Wang and Zeng, 2007. + ! Wang and Zeng, 2007. if (patch%itype(p) > noveg .and. patch%itype(p) <= nbrdlf_dcd_brl_shrub ) then ol = min( max(snow_depth(c)-hbot(p), 0._r8), htop(p)-hbot(p)) @@ -412,7 +411,7 @@ subroutine interpMonthlyVeg (bounds, canopystate_inst) use clm_time_manager, only : get_curr_date, get_step_size_real, get_nstep ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds type(canopystate_type), intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: @@ -470,12 +469,12 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) use shr_scam_mod, only : shr_scam_getCloseLatLon ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds type(canopystate_type), intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: type(file_desc_t) :: ncid ! netcdf id - real(r8), pointer :: annlai(:,:) ! 12 months of monthly lai from input data set + real(r8), pointer :: annlai(:,:) ! 12 months of monthly lai from input data set real(r8), pointer :: mlai(:,:) ! lai read from input files real(r8):: closelat,closelon ! single column vars integer :: ier ! error code @@ -492,13 +491,13 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) character(len=32) :: subname = 'readAnnualVegetation' !----------------------------------------------------------------------- - annlai => canopystate_inst%annlai_patch + annlai => canopystate_inst%annlai_patch ! Determine necessary indices allocate(mlai(bounds%begg:bounds%endg,0:maxveg), stat=ier) if (ier /= 0) then - write(iulog,*)subname, 'allocation error ' + write(iulog,*)subname, 'allocation error ' call endrun(msg=errMsg(sourcefile, __LINE__)) end if @@ -544,7 +543,7 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) else !! non-vegetated pft annlai(k,p) = 0._r8 end if - end do ! end of loop over patches + end do ! end of loop over patches enddo ! months loop @@ -571,7 +570,7 @@ subroutine readMonthlyVegetation (bounds, & use netcdf ! ! !ARGUMENTS: - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds character(len=*) , intent(in) :: fveg ! file with monthly vegetation data integer , intent(in) :: months(2) ! months to be interpolated (1 to 12) type(canopystate_type), intent(inout) :: canopystate_inst diff --git a/src/biogeochem/ch4FInundatedStreamType.F90 b/src/biogeochem/ch4FInundatedStreamType.F90 index a0f9dec105..bdbc7cc647 100644 --- a/src/biogeochem/ch4FInundatedStreamType.F90 +++ b/src/biogeochem/ch4FInundatedStreamType.F90 @@ -3,8 +3,8 @@ module ch4FInundatedStreamType #include "shr_assert.h" - !----------------------------------------------------------------------- - ! !DESCRIPTION: + !----------------------------------------------------------------------- + ! !DESCRIPTION: ! Contains methods for reading in finundated streams file for methane code. ! ! !USES @@ -60,11 +60,10 @@ module ch4FInundatedStreamType !============================================================================== subroutine Init(this, bounds, NLFilename) - ! + ! ! Initialize the ch4 finundated stream object ! ! Uses: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar, get_curr_date use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -83,12 +82,12 @@ subroutine Init(this, bounds, NLFilename) ! arguments implicit none class(ch4finundatedstream_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! local variables integer :: ig, g ! Indices - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information type(shr_strdata_type) :: sdat ! input data stream integer :: index_ZWT0 = 0 ! Index of ZWT0 field integer :: index_F0 = 0 ! Index of F0 field @@ -111,8 +110,8 @@ subroutine Init(this, bounds, NLFilename) call clm_domain_mct (bounds, dom_clm) call shr_strdata_create(sdat,name=stream_name,& - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -124,7 +123,7 @@ subroutine Init(this, bounds, NLFilename) domFileName=trim(control%stream_fldFileName_ch4finundated), & domTvarName='time', & domXvarName='LONGXY' , & - domYvarName='LATIXY' , & + domYvarName='LATIXY' , & domAreaName='AREA', & domMaskName='LANDMASK', & filePath='', & @@ -191,7 +190,7 @@ end subroutine Init logical function UseStreams(this) ! ! !DESCRIPTION: - ! Return true if + ! Return true if ! ! !USES: ! @@ -201,9 +200,9 @@ logical function UseStreams(this) ! ! !LOCAL VARIABLES: if ( trim(control%stream_fldFileName_ch4finundated) == '' )then - UseStreams = .false. + UseStreams = .false. else - UseStreams = .true. + UseStreams = .true. end if end function UseStreams @@ -246,7 +245,7 @@ subroutine CalcFinundated(this, bounds, num_soilc, filter_soilc, soilhydrology_i waterdiagnosticbulk_inst, qflx_surf_lag_col, finundated ) ! ! !DESCRIPTION: - ! + ! ! Calculate finundated according to the appropriate methodology ! ! !USES: @@ -312,11 +311,10 @@ end subroutine CalcFinundated !============================================================================== subroutine ReadNML(this, bounds, NLFilename) - ! - ! Read the namelist data stream information. + ! + ! Read the namelist data stream information. ! ! Uses: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -329,7 +327,7 @@ subroutine ReadNML(this, bounds, NLFilename) ! arguments implicit none class(streamcontrol_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! local variables diff --git a/src/biogeophys/UrbanTimeVarType.F90 b/src/biogeophys/UrbanTimeVarType.F90 index c23b5ff050..bbc5b67567 100644 --- a/src/biogeophys/UrbanTimeVarType.F90 +++ b/src/biogeophys/UrbanTimeVarType.F90 @@ -12,7 +12,7 @@ module UrbanTimeVarType use clm_varctl , only : iulog use landunit_varcon , only : isturb_MIN, isturb_MAX use clm_varcon , only : spval - use LandunitType , only : lun + use LandunitType , only : lun use GridcellType , only : grc use mct_mod use shr_strdata_mod , only : shr_strdata_type @@ -34,10 +34,10 @@ module UrbanTimeVarType procedure, public :: Init ! Allocate and initialize urbantv procedure, public :: urbantv_init ! Initialize urban time varying stream procedure, public :: urbantv_interp ! Interpolate urban time varying stream - + end type urbantv_type - !----------------------------------------------------------------------- + !----------------------------------------------------------------------- character(15), private :: stream_var_name(isturb_MIN:isturb_MAX) character(len=*), parameter, private :: sourcefile = & @@ -56,7 +56,7 @@ subroutine Init(this, bounds, NLFilename) ! ! !ARGUMENTS: class(urbantv_type) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds character(len=*) , intent(in) :: NLFilename ! Namelist filename ! ! !LOCAL VARIABLES: @@ -90,7 +90,6 @@ subroutine urbantv_init(this, bounds, NLFilename) ! Initialize data stream information for urban time varying data ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -117,11 +116,11 @@ subroutine urbantv_init(this, bounds, NLFilename) integer :: ifield ! field index integer :: stream_year_first_urbantv ! first year in urban tv stream to use integer :: stream_year_last_urbantv ! last year in urban tv stream to use - integer :: model_year_align_urbantv ! align stream_year_first_urbantv + integer :: model_year_align_urbantv ! align stream_year_first_urbantv ! with this model year integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_urbantv ! urban tv streams filename character(len=CL) :: urbantvmapalgo = 'nn' ! mapping alogrithm for urban ac character(len=CL) :: fldList ! field string @@ -189,7 +188,7 @@ subroutine urbantv_init(this, bounds, NLFilename) call shr_strdata_create(this%sdat_urbantv,name="clmurbantv", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & diff --git a/src/main/ncdio_pio.F90.in b/src/main/ncdio_pio.F90.in index 3ccc9f19a4..c9cbc54c8c 100644 --- a/src/main/ncdio_pio.F90.in +++ b/src/main/ncdio_pio.F90.in @@ -176,12 +176,11 @@ contains ! ! !USES: use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat - use clm_varctl , only : inst_name !----------------------------------------------------------------------- - PIO_subsystem => shr_pio_getiosys(inst_name) - io_type = shr_pio_getiotype(inst_name) - io_netcdf_format = shr_pio_getioformat(inst_name) + PIO_subsystem => shr_pio_getiosys('LND') + io_type = shr_pio_getiotype('LND') + io_netcdf_format = shr_pio_getioformat('LND') end subroutine ncd_pio_init !----------------------------------------------------------------------- diff --git a/src/main/ndepStreamMod.F90 b/src/main/ndepStreamMod.F90 index ac8548a8c1..3c8ef90c5b 100644 --- a/src/main/ndepStreamMod.F90 +++ b/src/main/ndepStreamMod.F90 @@ -51,7 +51,6 @@ subroutine ndep_init(bounds, NLFilename) ! ! Uses: use shr_kind_mod , only : CS => shr_kind_cs - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -134,7 +133,7 @@ subroutine ndep_init(bounds, NLFilename) call shr_strdata_create(sdat,name="clmndep", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & From ff78f7ac96975e23c9a558ff6e89b5baaf7b8a80 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Mon, 1 Jun 2020 15:57:30 -0600 Subject: [PATCH 11/39] Point to cime and CMEPS versions that have mizuRoute changes incorporated into them as well as mvertens versions for RTM and MOSART that have her latest nuopc changes in them --- Externals.cfg | 12 ++++++------ Externals_cime.cfg | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Externals.cfg b/Externals.cfg index 9d7f7fa6eb..6a0c1fc0c3 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -15,15 +15,15 @@ required = True [rtm] local_path = components/rtm protocol = git -repo_url = https://github.com/ESCOMP/rtm -tag = rtm1_0_71 +repo_url = https://github.com/mvertens/rtm +hash = 03a804eaa002805d87c9340f6ca3d542ff4598d5 required = True [mosart] local_path = components/mosart protocol = git -repo_url = https://github.com/ESCOMP/mosart -tag = mosart1_0_36 +repo_url = https://github.com/mvertens/mosart +hash = e441da118009eb00e3a8e4136058bf0a3f717ea0 required = True [mizuRoute] @@ -36,8 +36,8 @@ required = True [cime] local_path = cime protocol = git -repo_url = https://github.com/ekluzek/cime -branch = mizuRoute +repo_url = https://github.com/ESMCI/cime +hash = 1b049969f7271cf01ac7e2133a83c9b23c7f963d externals = ../Externals_cime.cfg required = True diff --git a/Externals_cime.cfg b/Externals_cime.cfg index 3eeafa11f6..0203691221 100644 --- a/Externals_cime.cfg +++ b/Externals_cime.cfg @@ -1,7 +1,7 @@ [cmeps] -branch = mizuroute +hash = 7ba0be9d94c8ea54b081b3804cbbffcfe7a25e08 protocol = git -repo_url = https://github.com/ekluzek/CMEPS.git +repo_url = https://github.com/ESCOMP/CMEPS.git local_path = src/drivers/nuopc/ required = True From b3908c33402d16579ec3ddf1e38826bae598bd6e Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Thu, 4 Jun 2020 14:58:41 -0600 Subject: [PATCH 12/39] Update the mosart hash as it couldn't build with the previous version --- Externals.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals.cfg b/Externals.cfg index 6a0c1fc0c3..0e35c60288 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -23,7 +23,7 @@ required = True local_path = components/mosart protocol = git repo_url = https://github.com/mvertens/mosart -hash = e441da118009eb00e3a8e4136058bf0a3f717ea0 +hash = 2b30936 required = True [mizuRoute] From c9f122e8f21b8c90dc8c19a7dafb1ef0cdfb4fc9 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Fri, 19 Jun 2020 11:44:26 -0600 Subject: [PATCH 13/39] Update externals according to latest nuopc_dev branch --- Externals.cfg | 10 +++++----- Externals_cime.cfg | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Externals.cfg b/Externals.cfg index 0e35c60288..87bb0dd71f 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -15,15 +15,15 @@ required = True [rtm] local_path = components/rtm protocol = git -repo_url = https://github.com/mvertens/rtm -hash = 03a804eaa002805d87c9340f6ca3d542ff4598d5 +repo_url = https://github.com/ekluzek/rtm +branch = upnuopc required = True [mosart] local_path = components/mosart protocol = git -repo_url = https://github.com/mvertens/mosart -hash = 2b30936 +repo_url = https://github.com/ekluzek/mosart +branch = upnupopc required = True [mizuRoute] @@ -37,7 +37,7 @@ required = True local_path = cime protocol = git repo_url = https://github.com/ESMCI/cime -hash = 1b049969f7271cf01ac7e2133a83c9b23c7f963d +hash = 4427dd05147c42f19f5283793676867572138ed7 externals = ../Externals_cime.cfg required = True diff --git a/Externals_cime.cfg b/Externals_cime.cfg index 0203691221..43ff73b3ee 100644 --- a/Externals_cime.cfg +++ b/Externals_cime.cfg @@ -1,9 +1,23 @@ [cmeps] -hash = 7ba0be9d94c8ea54b081b3804cbbffcfe7a25e08 +hash = 70b5daa protocol = git repo_url = https://github.com/ESCOMP/CMEPS.git local_path = src/drivers/nuopc/ required = True +[fox] +hash = 0ed59c1 +protocol = git +repo_url = https://github.com/ESMCI/fox.git +local_path = src/externals/fox +required = True + +[cdeps] +hash = 5b29c3e +protocol = git +repo_url = https://github.com/ESCOMP/CDEPS.git +local_path = src/components/cdeps +required = True + [externals_description] schema_version = 1.0.0 From b65030e0eb4f4c3c817167580976d198e1e36905 Mon Sep 17 00:00:00 2001 From: Erik Kluzek Date: Wed, 24 Jun 2020 13:55:34 -0600 Subject: [PATCH 14/39] Point to mizuRoute cime branch again --- Externals.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Externals.cfg b/Externals.cfg index 87bb0dd71f..106a9e04cc 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -36,8 +36,8 @@ required = True [cime] local_path = cime protocol = git -repo_url = https://github.com/ESMCI/cime -hash = 4427dd05147c42f19f5283793676867572138ed7 +repo_url = https://github.com/ekluzek/cime +branch = mizuRoute externals = ../Externals_cime.cfg required = True From fa3d7bc7638004e993fd5738b935cef6e0be21c1 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sun, 19 Jul 2020 18:46:58 -0600 Subject: [PATCH 15/39] fixed problem in previous merge --- cime_config/buildlib | 1 + src/biogeochem/CNFireBaseMod.F90 | 484 ++++++++++----------- src/biogeochem/CNVegetationFacade.F90 | 54 ++- src/biogeochem/SatellitePhenologyMod.F90 | 122 ++++-- src/biogeochem/ch4FInundatedStreamType.F90 | 31 +- src/biogeophys/SoilMoistureStreamMod.F90 | 3 +- src/biogeophys/UrbanTimeVarType.F90 | 14 +- 7 files changed, 369 insertions(+), 340 deletions(-) diff --git a/cime_config/buildlib b/cime_config/buildlib index e67960a5c3..95fd0b14c3 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -92,6 +92,7 @@ def _main_func(): gmake = case.get_value("GMAKE") gmake_opts = get_standard_makefile_args(case) driver = case.get_value("COMP_INTERFACE").lower() + cimeroot = case.get_value("CIMEROOT") lilac_mode = case.get_value("LILAC_MODE") if lilac_mode == 'on': diff --git a/src/biogeochem/CNFireBaseMod.F90 b/src/biogeochem/CNFireBaseMod.F90 index 8677fc4b23..e99d5c6e3b 100644 --- a/src/biogeochem/CNFireBaseMod.F90 +++ b/src/biogeochem/CNFireBaseMod.F90 @@ -4,12 +4,12 @@ module CNFireBaseMod !----------------------------------------------------------------------- ! !DESCRIPTION: - ! module for fire dynamics + ! module for fire dynamics ! created in Nov, 2012 and revised in Apr, 2013 by F. Li and S. Levis ! based on Li et al. (2012a,b; 2013) ! revised in Apr, 2014 according Li et al.(2014) - ! Fire-related parameters were calibrated or tuned in Apr, 2013 based on the - ! 20th Century transient simulations at f19_g16 with (newfire05_clm45sci15_clm4_0_58) + ! Fire-related parameters were calibrated or tuned in Apr, 2013 based on the + ! 20th Century transient simulations at f19_g16 with (newfire05_clm45sci15_clm4_0_58) ! a CLM4.5 version, Qian et al. (2006) atmospheric forcing, and ! climatological lightning data. ! @@ -57,7 +57,7 @@ module CNFireBaseMod ! !PRIVATE MEMBER DATA: real(r8) :: borealat = 40._r8 ! Latitude for boreal peat fires real(r8) :: lfuel=75._r8 ! lower threshold of fuel mass (gC/m2) for ignition, Li et al.(2014) - real(r8) :: ufuel=650._r8 ! upper threshold of fuel mass(gC/m2) for ignition + real(r8) :: ufuel=650._r8 ! upper threshold of fuel mass(gC/m2) for ignition real(r8) :: g0=0.05_r8 ! g(W) when W=0 m/s real(r8) :: rh_low=30.0_r8 ! Relative humidty low (%) real(r8) :: rh_hgh=80.0_r8 ! Relative humidty high (%) @@ -86,8 +86,8 @@ module CNFireBaseMod real(r8), public, pointer :: forc_lnfm(:) ! Lightning frequency real(r8), public, pointer :: forc_hdm(:) ! Human population density - type(shr_strdata_type), pointer :: sdat_hdm ! Human population density input data stream - type(shr_strdata_type), pointer :: sdat_lnfm ! Lightning input data stream + type(shr_strdata_type) :: sdat_hdm ! Human population density input data stream + type(shr_strdata_type) :: sdat_lnfm ! Lightning input data stream contains @@ -145,7 +145,7 @@ subroutine CNFireInit( this, bounds, NLFilename ) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename !----------------------------------------------------------------------- @@ -278,7 +278,7 @@ subroutine CNFireInterp(this,bounds) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds !----------------------------------------------------------------------- if ( this%need_lightning_and_popdens() ) then @@ -295,13 +295,13 @@ subroutine CNFireArea (this, bounds, num_soilc, filter_soilc, num_soilp, filter_ cnveg_state_inst, cnveg_carbonstate_inst, totlitc_col, decomp_cpools_vr_col, t_soi17cm_col) ! ! !DESCRIPTION: - ! Computes column-level burned area + ! Computes column-level burned area ! ! !USES: ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns integer , intent(in) :: num_soilp ! number of soil patches in filter @@ -333,8 +333,8 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! Fire effects routine for coupled carbon-nitrogen code (CN). ! Relies primarily on estimate of fractional area burned, from CNFireArea(). ! - ! Total fire carbon emissions (g C/m2 land area/yr) - ! =avg(COL_FIRE_CLOSS)*seconds_per_year + avg(SOMC_FIRE)*seconds_per_year + + ! Total fire carbon emissions (g C/m2 land area/yr) + ! =avg(COL_FIRE_CLOSS)*seconds_per_year + avg(SOMC_FIRE)*seconds_per_year + ! avg(LF_CONV_CFLUX)*seconds_per_year*min(1.0,avg(LFC2)*seconds_per_year)*0.8 ! where avg means the temporal average in a year ! seconds_per_year is the number of seconds in a year. @@ -350,7 +350,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns integer , intent(in) :: num_soilp ! number of soil patches in filter @@ -401,188 +401,188 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! emis. = emissions ! decomp. = decomposing - associate( & - croot_prof => croot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of coarse roots - stem_prof => stem_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of stems - froot_prof => froot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of fine roots - leaf_prof => leaf_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of leaves + associate( & + croot_prof => croot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of coarse roots + stem_prof => stem_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of stems + froot_prof => froot_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of fine roots + leaf_prof => leaf_prof_patch , & ! Input: [real(r8) (:,:) ] (1/m) profile of leaves totsomc => totsomc_col , & ! Input: [real(r8) (:) ] (gC/m2) total soil organic matter C decomp_cpools_vr => decomp_cpools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) VR decomp. (litter, cwd, soil) decomp_npools_vr => decomp_npools_vr_col , & ! Input: [real(r8) (:,:,:) ] (gC/m3) VR decomp. (litter, cwd, soil) somc_fire => somc_fire_col , & ! Output: [real(r8) (:) ] (gC/m2/s) fire C emissions due to peat burning - - is_cwd => decomp_cascade_con%is_cwd , & ! Input: [logical (:) ] TRUE => pool is a cwd pool - is_litter => decomp_cascade_con%is_litter , & ! Input: [logical (:) ] TRUE => pool is a litter pool - - woody => pftcon%woody , & ! Input: woody lifeform (1=woody, 0=not woody) - cc_leaf => pftcon%cc_leaf , & ! Input: - cc_lstem => pftcon%cc_lstem , & ! Input: - cc_dstem => pftcon%cc_dstem , & ! Input: - cc_other => pftcon%cc_other , & ! Input: - fm_leaf => pftcon%fm_leaf , & ! Input: - fm_lstem => pftcon%fm_lstem , & ! Input: - fm_other => pftcon%fm_other , & ! Input: - fm_root => pftcon%fm_root , & ! Input: - fm_lroot => pftcon%fm_lroot , & ! Input: - fm_droot => pftcon%fm_droot , & ! Input: - lf_flab => pftcon%lf_flab , & ! Input: - lf_fcel => pftcon%lf_fcel , & ! Input: - lf_flig => pftcon%lf_flig , & ! Input: - fr_flab => pftcon%fr_flab , & ! Input: - fr_fcel => pftcon%fr_fcel , & ! Input: - fr_flig => pftcon%fr_flig , & ! Input: + + is_cwd => decomp_cascade_con%is_cwd , & ! Input: [logical (:) ] TRUE => pool is a cwd pool + is_litter => decomp_cascade_con%is_litter , & ! Input: [logical (:) ] TRUE => pool is a litter pool + + woody => pftcon%woody , & ! Input: woody lifeform (1=woody, 0=not woody) + cc_leaf => pftcon%cc_leaf , & ! Input: + cc_lstem => pftcon%cc_lstem , & ! Input: + cc_dstem => pftcon%cc_dstem , & ! Input: + cc_other => pftcon%cc_other , & ! Input: + fm_leaf => pftcon%fm_leaf , & ! Input: + fm_lstem => pftcon%fm_lstem , & ! Input: + fm_other => pftcon%fm_other , & ! Input: + fm_root => pftcon%fm_root , & ! Input: + fm_lroot => pftcon%fm_lroot , & ! Input: + fm_droot => pftcon%fm_droot , & ! Input: + lf_flab => pftcon%lf_flab , & ! Input: + lf_fcel => pftcon%lf_fcel , & ! Input: + lf_flig => pftcon%lf_flig , & ! Input: + fr_flab => pftcon%fr_flab , & ! Input: + fr_fcel => pftcon%fr_fcel , & ! Input: + fr_flig => pftcon%fr_flig , & ! Input: cmb_cmplt_fact => cnfire_const%cmb_cmplt_fact , & ! Input: [real(r8) (:) ] Combustion completion factor (unitless) - - nind => dgvs_inst%nind_patch , & ! Input: [real(r8) (:) ] number of individuals (#/m2) - - cropf_col => cnveg_state_inst%cropf_col , & ! Input: [real(r8) (:) ] cropland fraction in veg column + + nind => dgvs_inst%nind_patch , & ! Input: [real(r8) (:) ] number of individuals (#/m2) + + cropf_col => cnveg_state_inst%cropf_col , & ! Input: [real(r8) (:) ] cropland fraction in veg column farea_burned => cnveg_state_inst%farea_burned_col , & ! Input: [real(r8) (:) ] fractional area burned (/sec) - fbac1 => cnveg_state_inst%fbac1_col , & ! Input: [real(r8) (:) ] burned area out of conv. region due to LU fire + fbac1 => cnveg_state_inst%fbac1_col , & ! Input: [real(r8) (:) ] burned area out of conv. region due to LU fire fbac => cnveg_state_inst%fbac_col , & ! Input: [real(r8) (:) ] total burned area out of conversion (/sec) - baf_crop => cnveg_state_inst%baf_crop_col , & ! Input: [real(r8) (:) ] BAF for cropland - baf_peatf => cnveg_state_inst%baf_peatf_col , & ! Input: [real(r8) (:) ] BAF for peatlabd - trotr1_col => cnveg_state_inst%trotr1_col , & ! Input: [real(r8) (:) ] patch weight of BET on the column (0-1) - trotr2_col => cnveg_state_inst%trotr2_col , & ! Input: [real(r8) (:) ] patch weight of BDT on the column (0-1) + baf_crop => cnveg_state_inst%baf_crop_col , & ! Input: [real(r8) (:) ] BAF for cropland + baf_peatf => cnveg_state_inst%baf_peatf_col , & ! Input: [real(r8) (:) ] BAF for peatlabd + trotr1_col => cnveg_state_inst%trotr1_col , & ! Input: [real(r8) (:) ] patch weight of BET on the column (0-1) + trotr2_col => cnveg_state_inst%trotr2_col , & ! Input: [real(r8) (:) ] patch weight of BDT on the column (0-1) dtrotr_col => cnveg_state_inst%dtrotr_col , & ! Input: [real(r8) (:) ] ann. decreased frac. coverage of BET+BDT (0-1) on GC lfc => cnveg_state_inst%lfc_col , & ! Input: [real(r8) (:) ] conv. area frac. of BET+BDT that haven't burned before lfc2 => cnveg_state_inst%lfc2_col , & ! Output: [real(r8) (:) ] conv. area frac. of BET+BDT burned this dt (/sec) - - leafcmax => cnveg_carbonstate_inst%leafcmax_patch , & ! Output: [real(r8) (:) ] (gC/m2) ann max leaf C - leafc => cnveg_carbonstate_inst%leafc_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C - leafc_storage => cnveg_carbonstate_inst%leafc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C storage - leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C transfer - livestemc => cnveg_carbonstate_inst%livestemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C - livestemc_storage => cnveg_carbonstate_inst%livestemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C storage - livestemc_xfer => cnveg_carbonstate_inst%livestemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C transfer - deadstemc => cnveg_carbonstate_inst%deadstemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C - deadstemc_storage => cnveg_carbonstate_inst%deadstemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C storage - deadstemc_xfer => cnveg_carbonstate_inst%deadstemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C transfer - frootc => cnveg_carbonstate_inst%frootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C - frootc_storage => cnveg_carbonstate_inst%frootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C storage - frootc_xfer => cnveg_carbonstate_inst%frootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C transfer - livecrootc => cnveg_carbonstate_inst%livecrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C - livecrootc_storage => cnveg_carbonstate_inst%livecrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C storage - livecrootc_xfer => cnveg_carbonstate_inst%livecrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C transfer - deadcrootc => cnveg_carbonstate_inst%deadcrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C - deadcrootc_storage => cnveg_carbonstate_inst%deadcrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C storage - deadcrootc_xfer => cnveg_carbonstate_inst%deadcrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C transfer - gresp_storage => cnveg_carbonstate_inst%gresp_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration storage - gresp_xfer => cnveg_carbonstate_inst%gresp_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration transfer - - leafn => cnveg_nitrogenstate_inst%leafn_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N - leafn_storage => cnveg_nitrogenstate_inst%leafn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N storage - leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N transfer - livestemn => cnveg_nitrogenstate_inst%livestemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N - livestemn_storage => cnveg_nitrogenstate_inst%livestemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N storage - livestemn_xfer => cnveg_nitrogenstate_inst%livestemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N transfer - deadstemn => cnveg_nitrogenstate_inst%deadstemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N - deadstemn_storage => cnveg_nitrogenstate_inst%deadstemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N storage - deadstemn_xfer => cnveg_nitrogenstate_inst%deadstemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N transfer - frootn => cnveg_nitrogenstate_inst%frootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N - frootn_storage => cnveg_nitrogenstate_inst%frootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N storage - frootn_xfer => cnveg_nitrogenstate_inst%frootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N transfer - livecrootn => cnveg_nitrogenstate_inst%livecrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N - livecrootn_storage => cnveg_nitrogenstate_inst%livecrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N storage - livecrootn_xfer => cnveg_nitrogenstate_inst%livecrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N transfer - deadcrootn => cnveg_nitrogenstate_inst%deadcrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N - deadcrootn_storage => cnveg_nitrogenstate_inst%deadcrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N storage - deadcrootn_xfer => cnveg_nitrogenstate_inst%deadcrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N transfer - retransn => cnveg_nitrogenstate_inst%retransn_patch , & ! Input: [real(r8) (:) ] (gN/m2) plant pool of retranslocated N - + + leafcmax => cnveg_carbonstate_inst%leafcmax_patch , & ! Output: [real(r8) (:) ] (gC/m2) ann max leaf C + leafc => cnveg_carbonstate_inst%leafc_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C + leafc_storage => cnveg_carbonstate_inst%leafc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C storage + leafc_xfer => cnveg_carbonstate_inst%leafc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) leaf C transfer + livestemc => cnveg_carbonstate_inst%livestemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C + livestemc_storage => cnveg_carbonstate_inst%livestemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C storage + livestemc_xfer => cnveg_carbonstate_inst%livestemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live stem C transfer + deadstemc => cnveg_carbonstate_inst%deadstemc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C + deadstemc_storage => cnveg_carbonstate_inst%deadstemc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C storage + deadstemc_xfer => cnveg_carbonstate_inst%deadstemc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead stem C transfer + frootc => cnveg_carbonstate_inst%frootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C + frootc_storage => cnveg_carbonstate_inst%frootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C storage + frootc_xfer => cnveg_carbonstate_inst%frootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) fine root C transfer + livecrootc => cnveg_carbonstate_inst%livecrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C + livecrootc_storage => cnveg_carbonstate_inst%livecrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C storage + livecrootc_xfer => cnveg_carbonstate_inst%livecrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) live coarse root C transfer + deadcrootc => cnveg_carbonstate_inst%deadcrootc_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C + deadcrootc_storage => cnveg_carbonstate_inst%deadcrootc_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C storage + deadcrootc_xfer => cnveg_carbonstate_inst%deadcrootc_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) dead coarse root C transfer + gresp_storage => cnveg_carbonstate_inst%gresp_storage_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration storage + gresp_xfer => cnveg_carbonstate_inst%gresp_xfer_patch , & ! Input: [real(r8) (:) ] (gC/m2) growth respiration transfer + + leafn => cnveg_nitrogenstate_inst%leafn_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N + leafn_storage => cnveg_nitrogenstate_inst%leafn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N storage + leafn_xfer => cnveg_nitrogenstate_inst%leafn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) leaf N transfer + livestemn => cnveg_nitrogenstate_inst%livestemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N + livestemn_storage => cnveg_nitrogenstate_inst%livestemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N storage + livestemn_xfer => cnveg_nitrogenstate_inst%livestemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live stem N transfer + deadstemn => cnveg_nitrogenstate_inst%deadstemn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N + deadstemn_storage => cnveg_nitrogenstate_inst%deadstemn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N storage + deadstemn_xfer => cnveg_nitrogenstate_inst%deadstemn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead stem N transfer + frootn => cnveg_nitrogenstate_inst%frootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N + frootn_storage => cnveg_nitrogenstate_inst%frootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N storage + frootn_xfer => cnveg_nitrogenstate_inst%frootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) fine root N transfer + livecrootn => cnveg_nitrogenstate_inst%livecrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N + livecrootn_storage => cnveg_nitrogenstate_inst%livecrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N storage + livecrootn_xfer => cnveg_nitrogenstate_inst%livecrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) live coarse root N transfer + deadcrootn => cnveg_nitrogenstate_inst%deadcrootn_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N + deadcrootn_storage => cnveg_nitrogenstate_inst%deadcrootn_storage_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N storage + deadcrootn_xfer => cnveg_nitrogenstate_inst%deadcrootn_xfer_patch , & ! Input: [real(r8) (:) ] (gN/m2) dead coarse root N transfer + retransn => cnveg_nitrogenstate_inst%retransn_patch , & ! Input: [real(r8) (:) ] (gN/m2) plant pool of retranslocated N + fire_mortality_c_to_cwdc => cnveg_carbonflux_inst%fire_mortality_c_to_cwdc_col , & ! Input: [real(r8) (:,:) ] C flux fire mortality to CWD (gC/m3/s) - m_leafc_to_fire => cnveg_carbonflux_inst%m_leafc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc - m_leafc_storage_to_fire => cnveg_carbonflux_inst%m_leafc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_storage - m_leafc_xfer_to_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_xfer - m_livestemc_to_fire => cnveg_carbonflux_inst%m_livestemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from livestemc - m_livestemc_storage_to_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_storage - m_livestemc_xfer_to_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_xfer - m_deadstemc_to_fire => cnveg_carbonflux_inst%m_deadstemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer - m_deadstemc_storage_to_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_storage - m_deadstemc_xfer_to_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer - m_frootc_to_fire => cnveg_carbonflux_inst%m_frootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc - m_frootc_storage_to_fire => cnveg_carbonflux_inst%m_frootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_storage - m_frootc_xfer_to_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_xfer - m_livecrootc_to_fire => cnveg_carbonflux_inst%m_livecrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc - m_livecrootc_storage_to_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_storage - m_livecrootc_xfer_to_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_xfer - m_deadcrootc_to_fire => cnveg_carbonflux_inst%m_deadcrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc - m_deadcrootc_storage_to_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_storage - m_deadcrootc_xfer_to_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_xfer - m_gresp_storage_to_fire => cnveg_carbonflux_inst%m_gresp_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_storage - m_gresp_xfer_to_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_xfer - m_leafc_to_litter_fire => cnveg_carbonflux_inst%m_leafc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafc_storage_to_litter_fire => cnveg_carbonflux_inst%m_leafc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemc_to_deadstemc_fire => cnveg_carbonflux_inst%m_livestemc_to_deadstemc_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemc_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootc_to_litter_fire => cnveg_carbonflux_inst%m_frootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_frootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootc_to_deadcrootc_fire => cnveg_carbonflux_inst%m_livecrootc_to_deadcrootc_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootc_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_gresp_storage_to_litter_fire => cnveg_carbonflux_inst%m_gresp_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_gresp_xfer_to_litter_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafc_to_fire => cnveg_carbonflux_inst%m_leafc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc + m_leafc_storage_to_fire => cnveg_carbonflux_inst%m_leafc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_storage + m_leafc_xfer_to_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from leafc_xfer + m_livestemc_to_fire => cnveg_carbonflux_inst%m_livestemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) fire C emis. from livestemc + m_livestemc_storage_to_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_storage + m_livestemc_xfer_to_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livestemc_xfer + m_deadstemc_to_fire => cnveg_carbonflux_inst%m_deadstemc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer + m_deadstemc_storage_to_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_storage + m_deadstemc_xfer_to_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadstemc_xfer + m_frootc_to_fire => cnveg_carbonflux_inst%m_frootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc + m_frootc_storage_to_fire => cnveg_carbonflux_inst%m_frootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_storage + m_frootc_xfer_to_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. frootc_xfer + m_livecrootc_to_fire => cnveg_carbonflux_inst%m_livecrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc + m_livecrootc_storage_to_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_storage + m_livecrootc_xfer_to_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. livecrootc_xfer + m_deadcrootc_to_fire => cnveg_carbonflux_inst%m_deadcrootc_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc + m_deadcrootc_storage_to_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_storage + m_deadcrootc_xfer_to_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. deadcrootc_xfer + m_gresp_storage_to_fire => cnveg_carbonflux_inst%m_gresp_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_storage + m_gresp_xfer_to_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gC/m2/s) C emis. gresp_xfer + m_leafc_to_litter_fire => cnveg_carbonflux_inst%m_leafc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafc_storage_to_litter_fire => cnveg_carbonflux_inst%m_leafc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_leafc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livestemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemc_to_deadstemc_fire => cnveg_carbonflux_inst%m_livestemc_to_deadstemc_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemc_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadstemc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootc_to_litter_fire => cnveg_carbonflux_inst%m_frootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_frootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_frootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_livecrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootc_to_deadcrootc_fire => cnveg_carbonflux_inst%m_livecrootc_to_deadcrootc_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootc_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootc_storage_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootc_xfer_to_litter_fire => cnveg_carbonflux_inst%m_deadcrootc_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_gresp_storage_to_litter_fire => cnveg_carbonflux_inst%m_gresp_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_gresp_xfer_to_litter_fire => cnveg_carbonflux_inst%m_gresp_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] m_decomp_cpools_to_fire_vr => cnveg_carbonflux_inst%m_decomp_cpools_to_fire_vr_col , & ! Output: [real(r8) (:,:,:) ] (gC/m3/s) VR decomp. C fire loss - m_c_to_litr_met_fire => cnveg_carbonflux_inst%m_c_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] - m_c_to_litr_cel_fire => cnveg_carbonflux_inst%m_c_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] - m_c_to_litr_lig_fire => cnveg_carbonflux_inst%m_c_to_litr_lig_fire_col , & ! Output: [real(r8) (:,:) ] - + m_c_to_litr_met_fire => cnveg_carbonflux_inst%m_c_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] + m_c_to_litr_cel_fire => cnveg_carbonflux_inst%m_c_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] + m_c_to_litr_lig_fire => cnveg_carbonflux_inst%m_c_to_litr_lig_fire_col , & ! Output: [real(r8) (:,:) ] + fire_mortality_n_to_cwdn => cnveg_nitrogenflux_inst%fire_mortality_n_to_cwdn_col , & ! Input: [real(r8) (:,:) ] N flux fire mortality to CWD (gN/m3/s) - m_leafn_to_fire => cnveg_nitrogenflux_inst%m_leafn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn - m_leafn_storage_to_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_storage - m_leafn_xfer_to_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_xfer - m_livestemn_to_fire => cnveg_nitrogenflux_inst%m_livestemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn - m_livestemn_storage_to_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_s - m_livestemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_xfer - m_deadstemn_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn - m_deadstemn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_storage - m_deadstemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_xfer - m_frootn_to_fire => cnveg_nitrogenflux_inst%m_frootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn - m_frootn_storage_to_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_storage - m_frootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_xfer - m_livecrootn_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. m_livecrootn_to_fire - m_livecrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_storage - m_livecrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_xfer - m_deadcrootn_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn - m_deadcrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_storage - m_deadcrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_xfer - m_retransn_to_fire => cnveg_nitrogenflux_inst%m_retransn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. retransn - m_leafn_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_leafn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livestemn_to_deadstemn_fire => cnveg_nitrogenflux_inst%m_livestemn_to_deadstemn_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadstemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootn_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_frootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_livecrootn_to_deadcrootn_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_deadcrootn_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_deadcrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] - m_retransn_to_litter_fire => cnveg_nitrogenflux_inst%m_retransn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafn_to_fire => cnveg_nitrogenflux_inst%m_leafn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn + m_leafn_storage_to_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_storage + m_leafn_xfer_to_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. leafn_xfer + m_livestemn_to_fire => cnveg_nitrogenflux_inst%m_livestemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn + m_livestemn_storage_to_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_s + m_livestemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livestemn_xfer + m_deadstemn_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn + m_deadstemn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_storage + m_deadstemn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadstemn_xfer + m_frootn_to_fire => cnveg_nitrogenflux_inst%m_frootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn + m_frootn_storage_to_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_storage + m_frootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. frootn_xfer + m_livecrootn_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. m_livecrootn_to_fire + m_livecrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_storage + m_livecrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. livecrootn_xfer + m_deadcrootn_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn + m_deadcrootn_storage_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_storage + m_deadcrootn_xfer_to_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. deadcrootn_xfer + m_retransn_to_fire => cnveg_nitrogenflux_inst%m_retransn_to_fire_patch , & ! Input: [real(r8) (:) ] (gN/m2/s) N emis. retransn + m_leafn_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_leafn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_leafn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livestemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livestemn_to_deadstemn_fire => cnveg_nitrogenflux_inst%m_livestemn_to_deadstemn_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadstemn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadstemn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootn_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_frootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_frootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_livecrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_livecrootn_to_deadcrootn_fire => cnveg_nitrogenflux_inst%m_livecrootn_to_deadcrootn_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootn_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootn_storage_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_storage_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_deadcrootn_xfer_to_litter_fire => cnveg_nitrogenflux_inst%m_deadcrootn_xfer_to_litter_fire_patch , & ! Output: [real(r8) (:) ] + m_retransn_to_litter_fire => cnveg_nitrogenflux_inst%m_retransn_to_litter_fire_patch , & ! Output: [real(r8) (:) ] m_decomp_npools_to_fire_vr => cnveg_nitrogenflux_inst%m_decomp_npools_to_fire_vr_col , & ! Output: [real(r8) (:,:,:) ] VR decomp. N fire loss (gN/m3/s) - m_n_to_litr_met_fire => cnveg_nitrogenflux_inst%m_n_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] - m_n_to_litr_cel_fire => cnveg_nitrogenflux_inst%m_n_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] - m_n_to_litr_lig_fire => cnveg_nitrogenflux_inst%m_n_to_litr_lig_fire_col & ! Output: [real(r8) (:,:) ] + m_n_to_litr_met_fire => cnveg_nitrogenflux_inst%m_n_to_litr_met_fire_col , & ! Output: [real(r8) (:,:) ] + m_n_to_litr_cel_fire => cnveg_nitrogenflux_inst%m_n_to_litr_cel_fire_col , & ! Output: [real(r8) (:,:) ] + m_n_to_litr_lig_fire => cnveg_nitrogenflux_inst%m_n_to_litr_lig_fire_col & ! Output: [real(r8) (:,:) ] ) transient_landcover = run_has_transient_landcover() @@ -633,14 +633,14 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte m_deadstemc_storage_to_fire(p) = deadstemc_storage(p) * f * cc_other(patch%itype(p)) m_deadstemc_xfer_to_fire(p) = deadstemc_xfer(p) * f * cc_other(patch%itype(p)) m_frootc_to_fire(p) = frootc(p) * f * 0._r8 - m_frootc_storage_to_fire(p) = frootc_storage(p) * f * cc_other(patch%itype(p)) + m_frootc_storage_to_fire(p) = frootc_storage(p) * f * cc_other(patch%itype(p)) m_frootc_xfer_to_fire(p) = frootc_xfer(p) * f * cc_other(patch%itype(p)) m_livecrootc_to_fire(p) = livecrootc(p) * f * 0._r8 - m_livecrootc_storage_to_fire(p) = livecrootc_storage(p) * f * cc_other(patch%itype(p)) - m_livecrootc_xfer_to_fire(p) = livecrootc_xfer(p) * f * cc_other(patch%itype(p)) + m_livecrootc_storage_to_fire(p) = livecrootc_storage(p) * f * cc_other(patch%itype(p)) + m_livecrootc_xfer_to_fire(p) = livecrootc_xfer(p) * f * cc_other(patch%itype(p)) m_deadcrootc_to_fire(p) = deadcrootc(p) * f * 0._r8 - m_deadcrootc_storage_to_fire(p) = deadcrootc_storage(p) * f* cc_other(patch%itype(p)) - m_deadcrootc_xfer_to_fire(p) = deadcrootc_xfer(p) * f * cc_other(patch%itype(p)) + m_deadcrootc_storage_to_fire(p) = deadcrootc_storage(p) * f* cc_other(patch%itype(p)) + m_deadcrootc_xfer_to_fire(p) = deadcrootc_xfer(p) * f * cc_other(patch%itype(p)) m_gresp_storage_to_fire(p) = gresp_storage(p) * f * cc_other(patch%itype(p)) m_gresp_xfer_to_fire(p) = gresp_xfer(p) * f * cc_other(patch%itype(p)) @@ -658,11 +658,11 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte m_frootn_to_fire(p) = frootn(p) * f * 0._r8 m_frootn_storage_to_fire(p) = frootn_storage(p) * f * cc_other(patch%itype(p)) m_frootn_xfer_to_fire(p) = frootn_xfer(p) * f * cc_other(patch%itype(p)) - m_livecrootn_to_fire(p) = livecrootn(p) * f * 0._r8 - m_livecrootn_storage_to_fire(p) = livecrootn_storage(p) * f * cc_other(patch%itype(p)) + m_livecrootn_to_fire(p) = livecrootn(p) * f * 0._r8 + m_livecrootn_storage_to_fire(p) = livecrootn_storage(p) * f * cc_other(patch%itype(p)) m_livecrootn_xfer_to_fire(p) = livecrootn_xfer(p) * f * cc_other(patch%itype(p)) m_deadcrootn_to_fire(p) = deadcrootn(p) * f * 0._r8 - m_deadcrootn_xfer_to_fire(p) = deadcrootn_xfer(p) * f * cc_other(patch%itype(p)) + m_deadcrootn_xfer_to_fire(p) = deadcrootn_xfer(p) * f * cc_other(patch%itype(p)) m_deadcrootn_storage_to_fire(p) = deadcrootn_storage(p) * f * cc_other(patch%itype(p)) m_retransn_to_fire(p) = retransn(p) * f * cc_other(patch%itype(p)) @@ -681,13 +681,13 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 (stem and root live or dead assumed to have the same transport) m_livestemc_to_litter_fire(p) = livestemc(p) * f * & (1._r8 - cc_lstem(patch%itype(p))) * & - fm_droot(patch%itype(p)) + fm_droot(patch%itype(p)) m_livestemc_storage_to_litter_fire(p) = livestemc_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) m_livestemc_xfer_to_litter_fire(p) = livestemc_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) ! NOTE: It looks incorrect to use fm_droot here, but it's used to represent the fraction of plant-tissue mortality for deadstem/deadcroot ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 m_livestemc_to_deadstemc_fire(p) = livestemc(p) * f * & @@ -697,7 +697,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 (stem and root live or dead assumed to have the same transport) m_deadstemc_to_litter_fire(p) = deadstemc(p) * f * m * & (1._r8 - cc_dstem(patch%itype(p))) * & - fm_droot(patch%itype(p)) + fm_droot(patch%itype(p)) m_deadstemc_storage_to_litter_fire(p) = deadstemc_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -718,10 +718,10 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_droot(patch%itype(p)) m_livecrootc_storage_to_litter_fire(p) = livecrootc_storage(p) * f * & (1._r8- cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livecrootc_xfer_to_litter_fire(p) = livecrootc_xfer(p) * f * & (1._r8- cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livecrootc_to_deadcrootc_fire(p) = livecrootc(p) * f * & (fm_lroot(patch%itype(p))-fm_droot(patch%itype(p))) m_deadcrootc_to_litter_fire(p) = deadcrootc(p) * f * m * & @@ -731,22 +731,22 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_other(patch%itype(p)) m_deadcrootc_xfer_to_litter_fire(p) = deadcrootc_xfer(p) * f * & (1._r8- cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_gresp_storage_to_litter_fire(p) = gresp_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_gresp_xfer_to_litter_fire(p) = gresp_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) - ! nitrogen pools + ! nitrogen pools m_leafn_to_litter_fire(p) = leafn(p) * f * & (1._r8 - cc_leaf(patch%itype(p))) * & fm_leaf(patch%itype(p)) m_leafn_storage_to_litter_fire(p) = leafn_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_leafn_xfer_to_litter_fire(p) = leafn_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -757,7 +757,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_droot(patch%itype(p)) m_livestemn_storage_to_litter_fire(p) = livestemn_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livestemn_xfer_to_litter_fire(p) = livestemn_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -770,7 +770,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! EBK Oct/06/2017 see bug 2516 http://bugs.cgd.ucar.edu/show_bug.cgi?id=2516 (stem and root live or dead assumed to have the same transport) m_deadstemn_to_litter_fire(p) = deadstemn(p) * f * m * & (1._r8 - cc_dstem(patch%itype(p))) * & - fm_droot(patch%itype(p)) + fm_droot(patch%itype(p)) m_deadstemn_storage_to_litter_fire(p) = deadstemn_storage(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & fm_other(patch%itype(p)) @@ -794,7 +794,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_other(patch%itype(p)) m_livecrootn_xfer_to_litter_fire(p) = livecrootn_xfer(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) m_livecrootn_to_deadcrootn_fire(p) = livecrootn(p) * f * & (fm_lroot(patch%itype(p))-fm_droot(patch%itype(p))) m_deadcrootn_to_litter_fire(p) = deadcrootn(p) * f * m * & @@ -807,12 +807,12 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte fm_other(patch%itype(p)) m_retransn_to_litter_fire(p) = retransn(p) * f * & (1._r8 - cc_other(patch%itype(p))) * & - fm_other(patch%itype(p)) + fm_other(patch%itype(p)) if (use_cndv) then if ( woody(patch%itype(p)) == 1._r8 )then if ( livestemc(p)+deadstemc(p) > 0._r8 )then - nind(p) = nind(p)*(1._r8-1._r8*fm_droot(patch%itype(p))*f) + nind(p) = nind(p)*(1._r8-1._r8*fm_droot(patch%itype(p))*f) else nind(p) = 0._r8 end if @@ -821,7 +821,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte if (patch%itype(p) == noveg) leafcmax(p) = 0._r8 end if - end do ! end of patches loop + end do ! end of patches loop ! fire-induced transfer of carbon and nitrogen pools to litter and cwd @@ -869,13 +869,13 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte +(m_livecrootc_storage_to_litter_fire(p) + & m_livecrootc_xfer_to_litter_fire(p) & +m_deadcrootc_storage_to_litter_fire(p) + & - m_deadcrootc_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) + m_deadcrootc_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) m_c_to_litr_cel_fire(c,j)=m_c_to_litr_cel_fire(c,j) + & (m_leafc_to_litter_fire(p)*lf_fcel(patch%itype(p))*leaf_prof(p,j) + & - m_frootc_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootc_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) m_c_to_litr_lig_fire(c,j)=m_c_to_litr_lig_fire(c,j) + & (m_leafc_to_litter_fire(p)*lf_flig(patch%itype(p))*leaf_prof(p,j) + & - m_frootc_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootc_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) m_n_to_litr_met_fire(c,j)=m_n_to_litr_met_fire(c,j) + & ((m_leafn_to_litter_fire(p)*lf_flab(patch%itype(p)) & @@ -891,26 +891,26 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte +(m_livecrootn_storage_to_litter_fire(p) + & m_livecrootn_xfer_to_litter_fire(p) & +m_deadcrootn_storage_to_litter_fire(p) + & - m_deadcrootn_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) + m_deadcrootn_xfer_to_litter_fire(p))* croot_prof(p,j))* patch%wtcol(p) m_n_to_litr_cel_fire(c,j)=m_n_to_litr_cel_fire(c,j) + & (m_leafn_to_litter_fire(p)*lf_fcel(patch%itype(p))*leaf_prof(p,j) + & - m_frootn_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootn_to_litter_fire(p)*fr_fcel(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) m_n_to_litr_lig_fire(c,j)=m_n_to_litr_lig_fire(c,j) + & (m_leafn_to_litter_fire(p)*lf_flig(patch%itype(p))*leaf_prof(p,j) + & - m_frootn_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) + m_frootn_to_litter_fire(p)*fr_flig(patch%itype(p))*froot_prof(p,j))* patch%wtcol(p) end if end if end do end do end do ! - ! vertically-resolved decomposing C/N fire loss + ! vertically-resolved decomposing C/N fire loss ! column loop ! do fc = 1,num_soilc c = filter_soilc(fc) - f = farea_burned(c) + f = farea_burned(c) do j = 1, nlevdecomp ! carbon fluxes @@ -978,7 +978,7 @@ subroutine CNFireFluxes (this, bounds, num_soilc, filter_soilc, num_soilp, filte ! They will be added here in proportion to the carbon emission ! Emission factors differ for various fire types - end associate + end associate end subroutine CNFireFluxes @@ -1023,16 +1023,16 @@ subroutine hdm_init( this, bounds, NLFilename ) ! !ARGUMENTS: implicit none class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! !LOCAL VARIABLES: integer :: stream_year_first_popdens ! first year in pop. dens. stream to use integer :: stream_year_last_popdens ! last year in pop. dens. stream to use - integer :: model_year_align_popdens ! align stream_year_first_hdm with + integer :: model_year_align_popdens ! align stream_year_first_hdm with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_popdens ! population density streams filename character(len=CL) :: popdensmapalgo = 'bilinear' ! mapping alogrithm for population density character(len=CL) :: popdens_tintalgo = 'nearest'! time interpolation alogrithm for population density @@ -1078,21 +1078,19 @@ subroutine hdm_init( this, bounds, NLFilename ) if (masterproc) then write(iulog,*) ' ' write(iulog,*) 'popdens_streams settings:' - write(iulog,*) ' stream_year_first_popdens = ',stream_year_first_popdens - write(iulog,*) ' stream_year_last_popdens = ',stream_year_last_popdens - write(iulog,*) ' model_year_align_popdens = ',model_year_align_popdens + write(iulog,*) ' stream_year_first_popdens = ',stream_year_first_popdens + write(iulog,*) ' stream_year_last_popdens = ',stream_year_last_popdens + write(iulog,*) ' model_year_align_popdens = ',model_year_align_popdens write(iulog,*) ' stream_fldFileName_popdens = ',stream_fldFileName_popdens write(iulog,*) ' popdens_tintalgo = ',popdens_tintalgo write(iulog,*) ' ' endif call clm_domain_mct (bounds, dom_clm) - if (.not. associated(this%sdat_hdm)) then - allocate(this%sdat_hdm) - endif + call shr_strdata_create(this%sdat_hdm,name="clmhdm", & - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -1104,11 +1102,11 @@ subroutine hdm_init( this, bounds, NLFilename ) domFileName=trim(stream_fldFileName_popdens), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & - filename=(/trim(stream_fldFileName_popdens)/) , & + filename=(/trim(stream_fldFileName_popdens)/), & fldListFile='hdm', & fldListModel='hdm', & fillalgo='none', & @@ -1127,7 +1125,7 @@ subroutine hdm_init( this, bounds, NLFilename ) ptr_lnd=this%forc_hdm, default='inactive') end subroutine hdm_init - + !----------------------------------------------------------------------- subroutine hdm_interp( this, bounds) ! @@ -1139,7 +1137,7 @@ subroutine hdm_interp( this, bounds) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: g, ig @@ -1160,7 +1158,7 @@ subroutine hdm_interp( this, bounds) ig = ig+1 this%forc_hdm(g) = this%sdat_hdm%avs(1)%rAttr(1,ig) end do - + end subroutine hdm_interp !----------------------------------------------------------------------- @@ -1181,16 +1179,16 @@ subroutine lnfm_init( this, bounds, NLFilename ) ! !ARGUMENTS: implicit none class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! ! !LOCAL VARIABLES: integer :: stream_year_first_lightng ! first year in Lightning stream to use integer :: stream_year_last_lightng ! last year in Lightning stream to use - integer :: model_year_align_lightng ! align stream_year_first_lnfm with + integer :: model_year_align_lightng ! align stream_year_first_lnfm with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_lightng ! lightning stream filename to read character(len=CL) :: lightng_tintalgo = 'linear'! time interpolation alogrithm character(len=CL) :: lightngmapalgo = 'bilinear'! Mapping alogrithm @@ -1236,21 +1234,19 @@ subroutine lnfm_init( this, bounds, NLFilename ) if (masterproc) then write(iulog,*) ' ' write(iulog,*) 'light_stream settings:' - write(iulog,*) ' stream_year_first_lightng = ',stream_year_first_lightng - write(iulog,*) ' stream_year_last_lightng = ',stream_year_last_lightng - write(iulog,*) ' model_year_align_lightng = ',model_year_align_lightng + write(iulog,*) ' stream_year_first_lightng = ',stream_year_first_lightng + write(iulog,*) ' stream_year_last_lightng = ',stream_year_last_lightng + write(iulog,*) ' model_year_align_lightng = ',model_year_align_lightng write(iulog,*) ' stream_fldFileName_lightng = ',stream_fldFileName_lightng write(iulog,*) ' lightng_tintalgo = ',lightng_tintalgo write(iulog,*) ' ' endif call clm_domain_mct (bounds, dom_clm) - if (.not. associated(this%sdat_lnfm)) then - allocate(this%sdat_lnfm) - endif + call shr_strdata_create(this%sdat_lnfm,name="clmlnfm", & - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -1262,7 +1258,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) domFileName=trim(stream_fldFileName_lightng), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -1285,7 +1281,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) ptr_lnd=this%forc_lnfm, default='inactive') end subroutine lnfm_init - + !----------------------------------------------------------------------- subroutine lnfm_interp(this, bounds ) ! @@ -1297,7 +1293,7 @@ subroutine lnfm_interp(this, bounds ) ! ! !ARGUMENTS: class(cnfire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: g, ig @@ -1318,7 +1314,7 @@ subroutine lnfm_interp(this, bounds ) ig = ig+1 this%forc_lnfm(g) = this%sdat_lnfm%avs(1)%rAttr(1,ig) end do - + end subroutine lnfm_interp end module CNFireBaseMod diff --git a/src/biogeochem/CNVegetationFacade.F90 b/src/biogeochem/CNVegetationFacade.F90 index 536526bdba..efd45634a6 100644 --- a/src/biogeochem/CNVegetationFacade.F90 +++ b/src/biogeochem/CNVegetationFacade.F90 @@ -68,7 +68,7 @@ module CNVegetationFacade use WaterFluxBulkType , only : waterfluxbulk_type use Wateratm2lndBulkType , only : wateratm2lndbulk_type use SoilStateType , only : soilstate_type - use TemperatureType , only : temperature_type + use TemperatureType , only : temperature_type use CropType , only : crop_type use ch4Mod , only : ch4_type use CNDVType , only : dgvs_type @@ -149,7 +149,7 @@ module CNVegetationFacade ! - vocemis_inst ! - fireemis_inst ! - drydepvel_inst - + contains procedure, public :: Init procedure, public :: InitAccBuffer @@ -223,7 +223,7 @@ subroutine Init(this, bounds, NLFilename, nskip_steps, params_ncid) ! Note - always initialize the memory for cnveg_state_inst (used in biogeophys/) call this%cnveg_state_inst%Init(bounds) - + skip_steps = nskip_steps if (use_cn) then @@ -256,7 +256,7 @@ subroutine Init(this, bounds, NLFilename, nskip_steps, params_ncid) this%cnveg_carbonstate_inst%frootc_patch(begp:endp), & this%cnveg_carbonstate_inst%frootc_storage_patch(begp:endp), & this%cnveg_carbonstate_inst%deadstemc_patch(begp:endp) ) - call this%cnveg_nitrogenflux_inst%Init(bounds) + call this%cnveg_nitrogenflux_inst%Init(bounds) call this%c_products_inst%Init(bounds, species_non_isotope_type('C')) if (use_c13) then @@ -349,7 +349,7 @@ end subroutine CNReadNML subroutine InitAccBuffer(this, bounds) ! ! !DESCRIPTION: - ! Initialize accumulation buffer for types contained here + ! Initialize accumulation buffer for types contained here ! ! !USES: ! @@ -441,9 +441,9 @@ subroutine Restart(this, bounds, ncid, flag) ! ! !ARGUMENTS: class(cn_vegetation_type), intent(inout) :: this - type(bounds_type), intent(in) :: bounds - type(file_desc_t), intent(inout) :: ncid - character(len=*) , intent(in) :: flag + type(bounds_type), intent(in) :: bounds + type(file_desc_t), intent(inout) :: ncid + character(len=*) , intent(in) :: flag integer :: reseed_patch(bounds%endp-bounds%begp+1) integer :: num_reseed_patch ! @@ -656,7 +656,7 @@ subroutine DynamicAreaConservation(this, bounds, clump_index, & ! ! !ARGUMENTS: class(cn_vegetation_type), intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds ! Index of clump on which we're currently operating. Note that this implies that this ! routine must be called from within a clump loop. @@ -761,7 +761,7 @@ subroutine InitColumnBalance(this, bounds, num_allc, filter_allc, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_allc ! number of columns in allc filter integer , intent(in) :: filter_allc(:) ! filter for all active columns integer , intent(in) :: num_soilc ! number of soil columns in filter @@ -895,7 +895,7 @@ subroutine EcosystemDynamicsPreDrainage(this, bounds, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns integer , intent(in) :: num_soilp ! number of soil patches in filter @@ -958,7 +958,7 @@ subroutine EcosystemDynamicsPreDrainage(this, bounds, & this%dgvs_inst, photosyns_inst, saturated_excess_runoff_inst, energyflux_inst, & nutrient_competition_method, this%cnfire_method, this%dribble_crophrv_xsmrpool_2atm) - ! fire carbon emissions + ! fire carbon emissions call CNFireEmisUpdate(bounds, num_soilp, filter_soilp, & this%cnveg_carbonflux_inst, this%cnveg_carbonstate_inst, fireemis_inst ) @@ -987,7 +987,7 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_allc ! number of columns in allc filter integer , intent(in) :: filter_allc(:) ! filter for all active columns integer , intent(in) :: num_soilc ! number of soil columns in filter @@ -1015,9 +1015,9 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & character(len=*), parameter :: subname = 'EcosystemDynamicsPostDrainage' !----------------------------------------------------------------------- - ! Update the nitrogen leaching rate as a function of soluble mineral N + ! Update the nitrogen leaching rate as a function of soluble mineral N ! and total soil water outflow. - + call CNDriverLeaching(bounds, & num_soilc, filter_soilc, & num_soilp, filter_soilp, & @@ -1025,7 +1025,7 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & this%cnveg_nitrogenflux_inst, this%cnveg_nitrogenstate_inst, & soilbiogeochem_nitrogenflux_inst, soilbiogeochem_nitrogenstate_inst) - ! Set controls on very low values in critical state variables + ! Set controls on very low values in critical state variables call t_startf('CNPrecisionControl') call CNPrecisionControl(bounds, num_soilp, filter_soilp, & @@ -1070,7 +1070,7 @@ subroutine EcosystemDynamicsPostDrainage(this, bounds, num_allc, filter_allc, & ! On the radiation time step, use C state variables to calculate ! vegetation structure (LAI, SAI, height) - if (doalb) then + if (doalb) then call CNVegStructUpdate(num_soilp, filter_soilp, & waterdiagnosticbulk_inst, frictionvel_inst, this%dgvs_inst, this%cnveg_state_inst, & crop_inst, this%cnveg_carbonstate_inst, canopystate_inst) @@ -1093,7 +1093,7 @@ subroutine BalanceCheck(this, bounds, num_soilc, filter_soilc, & ! ! !ARGUMENTS: class(cn_vegetation_type) , intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_soilc ! number of soil columns in filter integer , intent(in) :: filter_soilc(:) ! filter for soil columns type(soilbiogeochem_carbonflux_type) , intent(inout) :: soilbiogeochem_carbonflux_inst @@ -1109,9 +1109,7 @@ subroutine BalanceCheck(this, bounds, num_soilc, filter_soilc, & DA_nstep = get_nstep_since_startup_or_lastDA_restart_or_pause() if (DA_nstep <= skip_steps )then if (masterproc) then -!$OMP MASTER write(iulog,*) '--WARNING-- skipping CN balance check for first timesteps after startup or data assimilation' -!$OMP END MASTER end if else @@ -1147,7 +1145,7 @@ subroutine EndOfTimeStepVegDynamics(this, bounds, num_natvegp, filter_natvegp, & ! ! !ARGUMENTS: class(cn_vegetation_type), intent(inout) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(inout) :: num_natvegp ! number of naturally-vegetated patches in filter integer , intent(inout) :: filter_natvegp(:) ! filter for naturally-vegetated patches type(atm2lnd_type) , intent(inout) :: atm2lnd_inst @@ -1213,7 +1211,7 @@ subroutine WriteHistory(this, bounds) ! ! !ARGUMENTS: class(cn_vegetation_type), intent(in) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds ! ! !LOCAL VARIABLES: @@ -1456,12 +1454,12 @@ function get_froot_carbon_patch(this, bounds, tlai) result(froot_carbon_patch) else ! To get leaf biomass: ! bleaf = LAI / slatop -! g/m2 = m2/m2 / m2/g -! To get root biomass: +! g/m2 = m2/m2 / m2/g +! To get root biomass: ! broot = bleaf * froot_leaf(ivt(p)) ! g/m2 = g/m2 * g/g do p=bounds%begp, bounds%endp - if (pftcon%slatop(patch%itype(p)) > 0._r8) then + if (pftcon%slatop(patch%itype(p)) > 0._r8) then froot_carbon_patch(p) = tlai(p) & / pftcon%slatop(patch%itype(p)) & *pftcon%froot_leaf(patch%itype(p)) @@ -1501,12 +1499,12 @@ function get_croot_carbon_patch(this, bounds, tlai) result(croot_carbon_patch) else ! To get leaf biomass: ! bleaf = LAI / slatop -! g/m2 = m2/m2 / m2/g -! To get root biomass: +! g/m2 = m2/m2 / m2/g +! To get root biomass: ! broot = bleaf * froot_leaf(ivt(p)) ! g/m2 = g/m2 * g/g do p=bounds%begp, bounds%endp - if (pftcon%slatop(patch%itype(p)) > 0._r8) then + if (pftcon%slatop(patch%itype(p)) > 0._r8) then croot_carbon_patch(p) = tlai(p) & / pftcon%slatop(patch%itype(p)) & *pftcon%stem_leaf(patch%itype(p)) & diff --git a/src/biogeochem/SatellitePhenologyMod.F90 b/src/biogeochem/SatellitePhenologyMod.F90 index 78b2cf0e24..82b53fb862 100644 --- a/src/biogeochem/SatellitePhenologyMod.F90 +++ b/src/biogeochem/SatellitePhenologyMod.F90 @@ -1,5 +1,7 @@ module SatellitePhenologyMod +#include "shr_assert.h" + !----------------------------------------------------------------------- ! !DESCRIPTION: ! CLM Satelitte Phenology model (SP) ecosystem dynamics (phenology, vegetation). @@ -11,6 +13,7 @@ module SatellitePhenologyMod use shr_strdata_mod , only : shr_strdata_print, shr_strdata_advance use shr_kind_mod , only : r8 => shr_kind_r8 use shr_kind_mod , only : CL => shr_kind_CL + use shr_kind_mod , only : CXX => shr_kind_CXX use shr_log_mod , only : errMsg => shr_log_errMsg use decompMod , only : bounds_type use abortutils , only : endrun @@ -23,7 +26,7 @@ module SatellitePhenologyMod use fileutils , only : getavu, relavu use PatchType , only : patch use CanopyStateType , only : canopystate_type - use WaterstateType , only : waterstate_type + use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type use perf_mod , only : t_startf, t_stopf use spmdMod , only : masterproc use spmdMod , only : mpicom, comp_id @@ -39,16 +42,18 @@ module SatellitePhenologyMod public :: SatellitePhenologyInit ! Dynamically allocate memory public :: interpMonthlyVeg ! interpolate monthly vegetation data public :: readAnnualVegetation ! Read in annual vegetation (needed for Dry-deposition) + public :: lai_advance ! Advance the LAI streams (outside of a Open-MP threading loop) ! ! !PRIVATE MEMBER FUNCTIONS: private :: readMonthlyVegetation ! read monthly vegetation data for two months - private :: lai_init ! position datasets for LAI - private :: lai_interp ! interpolates between two years of LAI data + private :: lai_init ! position datasets for LAI + private :: lai_interp ! interpolates between two years of LAI data (when LAI streams are being used) ! !PRIVATE MEMBER DATA: type(shr_strdata_type) :: sdat_lai ! LAI input data stream ! ! !PRIVATE TYPES: + integer, allocatable :: g_to_ig(:) ! Array matching gridcell index to data index integer , private :: InterpMonths1 ! saved month index real(r8), private :: timwt(2) ! time weights for month 1 and month 2 real(r8), private, allocatable :: mlai2t(:,:) ! lai for interpolation (2 months) @@ -73,7 +78,6 @@ subroutine lai_init(bounds) ! ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -97,12 +101,13 @@ subroutine lai_init(bounds) type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_lai ! lai stream filename to read character(len=CL) :: lai_mapalgo = 'bilinear' ! Mapping alogrithm + character(len=CL) :: lai_tintalgo = 'linear' ! Time interpolation alogrithm character(*), parameter :: subName = "('laidyn_init')" character(*), parameter :: F00 = "('(laidyn_init) ',4a)" character(*), parameter :: laiString = "LAI" ! base string for field string integer , parameter :: numLaiFields = 16 ! number of fields to build field string - character(SHR_KIND_CXX) :: fldList ! field string + character(len=CXX) :: fldList ! field string !----------------------------------------------------------------------- ! ! deal with namelist variables here in init @@ -112,7 +117,8 @@ subroutine lai_init(bounds) stream_year_last_lai, & model_year_align_lai, & lai_mapalgo, & - stream_fldFileName_lai + stream_fldFileName_lai, & + lai_tintalgo ! Default values for namelist stream_year_first_lai = 1 ! first year in stream to use @@ -141,6 +147,7 @@ subroutine lai_init(bounds) call shr_mpi_bcast(stream_year_last_lai, mpicom) call shr_mpi_bcast(model_year_align_lai, mpicom) call shr_mpi_bcast(stream_fldFileName_lai, mpicom) + call shr_mpi_bcast(lai_tintalgo, mpicom) if (masterproc) then @@ -150,6 +157,7 @@ subroutine lai_init(bounds) write(iulog,*) ' stream_year_last_lai = ',stream_year_last_lai write(iulog,*) ' model_year_align_lai = ',model_year_align_lai write(iulog,*) ' stream_fldFileName_lai = ',trim(stream_fldFileName_lai) + write(iulog,*) ' lai_tintalgo = ',trim(lai_tintalgo) endif @@ -162,7 +170,7 @@ subroutine lai_init(bounds) call shr_strdata_create(sdat_lai,name="laidyn", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -171,7 +179,7 @@ subroutine lai_init(bounds) yearAlign=model_year_align_lai, & offset=0, & domFilePath='', & - domFileName=trim(stream_fldFileName_lai), & + domFileName=trim(stream_fldFileName_lai), & domTvarName='time', & domXvarName='lon' , & domYvarName='lat' , & @@ -183,6 +191,7 @@ subroutine lai_init(bounds) fldListModel=fldList, & fillalgo='none', & mapalgo=lai_mapalgo, & + tintalgo=lai_tintalgo, & calendar=get_calendar(), & taxmode='cycle' ) @@ -194,37 +203,71 @@ end subroutine lai_init !----------------------------------------------------------------------- ! - ! lai_interp + ! lai_advance ! !----------------------------------------------------------------------- - subroutine lai_interp(bounds, canopystate_inst) + subroutine lai_advance( bounds ) ! - ! Interpolate data stream information for Lai. + ! Advance LAI streams ! ! !USES: use clm_time_manager, only : get_curr_date - use pftconMod , only : noveg ! ! !ARGUMENTS: implicit none type(bounds_type) , intent(in) :: bounds - type(canopystate_type) , intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: - integer :: ivt, p, g, ip, ig, gpft + integer :: g, ig ! Indices integer :: year ! year (0, ...) for nstep+1 integer :: mon ! month (1, ..., 12) for nstep+1 integer :: day ! day of month (1, ..., 31) for nstep+1 integer :: sec ! seconds into current date for nstep+1 integer :: mcdate ! Current model date (yyyymmdd) - character(len=CL) :: stream_var_name !----------------------------------------------------------------------- call get_curr_date(year, mon, day, sec) mcdate = year*10000 + mon*100 + day call shr_strdata_advance(sdat_lai, mcdate, sec, mpicom, 'laidyn') + if ( .not. allocated(g_to_ig) )then + allocate (g_to_ig(bounds%begg:bounds%endg) ) + + ig = 0 + do g = bounds%begg,bounds%endg + ig = ig+1 + g_to_ig(g) = ig + end do + end if + + end subroutine lai_advance + + !----------------------------------------------------------------------- + ! + ! lai_interp + ! + !----------------------------------------------------------------------- + subroutine lai_interp(bounds, canopystate_inst) + ! + ! Interpolate data stream information for Lai. + ! + ! !USES: + use pftconMod , only : noveg + ! + ! !ARGUMENTS: + implicit none + type(bounds_type) , intent(in) :: bounds + type(canopystate_type) , intent(inout) :: canopystate_inst + ! + ! !LOCAL VARIABLES: + integer :: ivt, p, ip, ig + character(len=CL) :: stream_var_name + !----------------------------------------------------------------------- + SHR_ASSERT_FL( (lbound(g_to_ig,1) <= bounds%begg ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(g_to_ig,1) >= bounds%endg ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(sdat_lai%avs(1)%rAttr,2) <= g_to_ig(bounds%begg) ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(sdat_lai%avs(1)%rAttr,2) >= g_to_ig(bounds%endg) ), sourcefile, __LINE__) do p = bounds%begp, bounds%endp ivt = patch%itype(p) if (ivt /= noveg) then ! vegetated pft @@ -232,17 +275,7 @@ subroutine lai_interp(bounds, canopystate_inst) stream_var_name = 'LAI_'//trim(adjustl(stream_var_name)) ip = mct_aVect_indexRA(sdat_lai%avs(1),trim(stream_var_name)) endif - gpft = patch%gridcell(p) - - ! - ! Determine vector index corresponding to gpft - ! - ig = 0 - do g = bounds%begg,bounds%endg - ig = ig+1 - if (g == gpft) exit - end do - + ig = g_to_ig(patch%gridcell(p)) ! ! Set lai for each gridcell/patch combination ! @@ -298,7 +331,7 @@ end subroutine SatellitePhenologyInit !----------------------------------------------------------------------- subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & - waterstate_inst, canopystate_inst) + waterdiagnosticbulk_inst, canopystate_inst) ! ! !DESCRIPTION: ! Ecosystem dynamics: phenology, vegetation @@ -311,7 +344,7 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_nolakep ! number of column non-lake points in patch filter integer , intent(in) :: filter_nolakep(bounds%endp-bounds%begp+1) ! patch filter for non-lake points - type(waterstate_type) , intent(in) :: waterstate_inst + type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst type(canopystate_type) , intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: @@ -321,8 +354,8 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & !----------------------------------------------------------------------- associate( & - frac_sno => waterstate_inst%frac_sno_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1) - snow_depth => waterstate_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m) + frac_sno => waterdiagnosticbulk_inst%frac_sno_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1) + snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m) tlai => canopystate_inst%tlai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index, no burying by snow tsai => canopystate_inst%tsai_patch , & ! Output: [real(r8) (:) ] one-sided stem area index, no burying by snow elai => canopystate_inst%elai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index with burying by snow @@ -336,6 +369,7 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & call lai_interp(bounds, canopystate_inst) endif + do fp = 1, num_nolakep p = filter_nolakep(fp) c = patch%column(p) @@ -408,7 +442,7 @@ subroutine interpMonthlyVeg (bounds, canopystate_inst) ! ! !USES: use clm_varctl , only : fsurdat - use clm_time_manager, only : get_curr_date, get_step_size, get_nstep + use clm_time_manager, only : get_curr_date, get_step_size_real, get_nstep ! ! !ARGUMENTS: type(bounds_type), intent(in) :: bounds @@ -427,7 +461,7 @@ subroutine interpMonthlyVeg (bounds, canopystate_inst) (/31,28,31,30,31,30,31,31,30,31,30,31/) !days per month !----------------------------------------------------------------------- - dtime = get_step_size() + dtime = get_step_size_real() call get_curr_date(kyr, kmo, kda, ksec, offset=int(dtime)) @@ -461,7 +495,7 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) ! read 12 months of veg data for dry deposition ! ! !USES: - use clm_varpar , only : numpft + use clm_varpar , only : maxveg, maxsoil_patches use pftconMod , only : noveg use domainMod , only : ldomain use fileutils , only : getfil @@ -495,7 +529,7 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) ! Determine necessary indices - allocate(mlai(bounds%begg:bounds%endg,0:numpft), stat=ier) + allocate(mlai(bounds%begg:bounds%endg,0:maxveg), stat=ier) if (ier /= 0) then write(iulog,*)subname, 'allocation error ' call endrun(msg=errMsg(sourcefile, __LINE__)) @@ -516,7 +550,7 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) write(iulog,*)trim(subname), 'ldomain%ns,ns,= ',ldomain%ns,ns call endrun(msg=errMsg(sourcefile, __LINE__)) end if - call check_dim(ncid, 'lsmpft', numpft+1) + call check_dim(ncid, 'lsmpft', maxsoil_patches) if (single_column) then call shr_scam_getCloseLatLon(locfn, scmlat, scmlon, & @@ -529,13 +563,13 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) dim1name=grlnd, nt=k) !! only vegetated patches have nonzero values - !! Assign lai/sai/hgtt/hgtb to the top [maxpatch_pft] patches + !! Assign lai/sai/hgtt/hgtb to the top [maxsoil_patches] patches !! as determined in subroutine surfrd do p = bounds%begp,bounds%endp g =patch%gridcell(p) if (patch%itype(p) /= noveg) then !! vegetated pft - do l = 0, numpft + do l = 0, maxveg if (l == patch%itype(p)) then annlai(k,p) = mlai(g,l) end if @@ -561,7 +595,7 @@ subroutine readMonthlyVegetation (bounds, & ! Read monthly vegetation data for two consec. months. ! ! !USES: - use clm_varpar , only : numpft + use clm_varpar , only : maxveg use pftconMod , only : noveg use fileutils , only : getfil use spmdMod , only : masterproc, mpicom, MPI_REAL8, MPI_INTEGER @@ -598,10 +632,10 @@ subroutine readMonthlyVegetation (bounds, & ! Determine necessary indices allocate(& - mlai(bounds%begg:bounds%endg,0:numpft), & - msai(bounds%begg:bounds%endg,0:numpft), & - mhgtt(bounds%begg:bounds%endg,0:numpft), & - mhgtb(bounds%begg:bounds%endg,0:numpft), & + mlai(bounds%begg:bounds%endg,0:maxveg), & + msai(bounds%begg:bounds%endg,0:maxveg), & + mhgtt(bounds%begg:bounds%endg,0:maxveg), & + mhgtb(bounds%begg:bounds%endg,0:maxveg), & stat=ier) if (ier /= 0) then write(iulog,*)subname, 'allocation big error ' @@ -640,13 +674,13 @@ subroutine readMonthlyVegetation (bounds, & if (.not. readvar) call endrun(msg=' ERROR: MONTHLY_HEIGHT_TOP NOT on fveg file'//errMsg(sourcefile, __LINE__)) ! Only vegetated patches have nonzero values - ! Assign lai/sai/hgtt/hgtb to the top [maxpatch_pft] patches + ! Assign lai/sai/hgtt/hgtb to the top [maxsoil_patches] patches ! as determined in subroutine surfrd do p = bounds%begp,bounds%endp g =patch%gridcell(p) if (patch%itype(p) /= noveg) then ! vegetated pft - do l = 0, numpft + do l = 0, maxveg if (l == patch%itype(p)) then mlai2t(p,k) = mlai(g,l) msai2t(p,k) = msai(g,l) diff --git a/src/biogeochem/ch4FInundatedStreamType.F90 b/src/biogeochem/ch4FInundatedStreamType.F90 index bdbc7cc647..57498cc032 100644 --- a/src/biogeochem/ch4FInundatedStreamType.F90 +++ b/src/biogeochem/ch4FInundatedStreamType.F90 @@ -3,8 +3,8 @@ module ch4FInundatedStreamType #include "shr_assert.h" - !----------------------------------------------------------------------- - ! !DESCRIPTION: + !----------------------------------------------------------------------- + ! !DESCRIPTION: ! Contains methods for reading in finundated streams file for methane code. ! ! !USES @@ -60,7 +60,7 @@ module ch4FInundatedStreamType !============================================================================== subroutine Init(this, bounds, NLFilename) - ! + ! ! Initialize the ch4 finundated stream object ! ! Uses: @@ -82,12 +82,12 @@ subroutine Init(this, bounds, NLFilename) ! arguments implicit none class(ch4finundatedstream_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! local variables integer :: ig, g ! Indices - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information type(shr_strdata_type) :: sdat ! input data stream integer :: index_ZWT0 = 0 ! Index of ZWT0 field integer :: index_F0 = 0 ! Index of F0 field @@ -110,8 +110,8 @@ subroutine Init(this, bounds, NLFilename) call clm_domain_mct (bounds, dom_clm) call shr_strdata_create(sdat,name=stream_name,& - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -123,7 +123,7 @@ subroutine Init(this, bounds, NLFilename) domFileName=trim(control%stream_fldFileName_ch4finundated), & domTvarName='time', & domXvarName='LONGXY' , & - domYvarName='LATIXY' , & + domYvarName='LATIXY' , & domAreaName='AREA', & domMaskName='LANDMASK', & filePath='', & @@ -190,7 +190,7 @@ end subroutine Init logical function UseStreams(this) ! ! !DESCRIPTION: - ! Return true if + ! Return true if ! ! !USES: ! @@ -200,9 +200,9 @@ logical function UseStreams(this) ! ! !LOCAL VARIABLES: if ( trim(control%stream_fldFileName_ch4finundated) == '' )then - UseStreams = .false. + UseStreams = .false. else - UseStreams = .true. + UseStreams = .true. end if end function UseStreams @@ -245,7 +245,7 @@ subroutine CalcFinundated(this, bounds, num_soilc, filter_soilc, soilhydrology_i waterdiagnosticbulk_inst, qflx_surf_lag_col, finundated ) ! ! !DESCRIPTION: - ! + ! ! Calculate finundated according to the appropriate methodology ! ! !USES: @@ -311,10 +311,11 @@ end subroutine CalcFinundated !============================================================================== subroutine ReadNML(this, bounds, NLFilename) - ! - ! Read the namelist data stream information. + ! + ! Read the namelist data stream information. ! ! Uses: + use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -327,7 +328,7 @@ subroutine ReadNML(this, bounds, NLFilename) ! arguments implicit none class(streamcontrol_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! local variables diff --git a/src/biogeophys/SoilMoistureStreamMod.F90 b/src/biogeophys/SoilMoistureStreamMod.F90 index 3b1e22f9a5..c276f7f826 100644 --- a/src/biogeophys/SoilMoistureStreamMod.F90 +++ b/src/biogeophys/SoilMoistureStreamMod.F90 @@ -67,7 +67,6 @@ subroutine PrescribedSoilMoistureInit(bounds) ! ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -172,7 +171,7 @@ subroutine PrescribedSoilMoistureInit(bounds) call shr_strdata_create(sdat_soilm,name="soil_moisture", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsMap_lnd2Dsoi_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & diff --git a/src/biogeophys/UrbanTimeVarType.F90 b/src/biogeophys/UrbanTimeVarType.F90 index f18afa01ce..c2d4aac3f3 100644 --- a/src/biogeophys/UrbanTimeVarType.F90 +++ b/src/biogeophys/UrbanTimeVarType.F90 @@ -12,7 +12,7 @@ module UrbanTimeVarType use clm_varctl , only : iulog use landunit_varcon , only : isturb_MIN, isturb_MAX use clm_varcon , only : spval - use LandunitType , only : lun + use LandunitType , only : lun use GridcellType , only : grc use mct_mod use shr_strdata_mod , only : shr_strdata_type @@ -34,10 +34,10 @@ module UrbanTimeVarType procedure, public :: Init ! Allocate and initialize urbantv procedure, public :: urbantv_init ! Initialize urban time varying stream procedure, public :: urbantv_interp ! Interpolate urban time varying stream - + end type urbantv_type - !----------------------------------------------------------------------- + !----------------------------------------------------------------------- character(15), private :: stream_var_name(isturb_MIN:isturb_MAX) character(len=*), parameter, private :: sourcefile = & @@ -56,7 +56,7 @@ subroutine Init(this, bounds, NLFilename) ! ! !ARGUMENTS: class(urbantv_type) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds character(len=*) , intent(in) :: NLFilename ! Namelist filename ! ! !LOCAL VARIABLES: @@ -116,11 +116,11 @@ subroutine urbantv_init(this, bounds, NLFilename) integer :: ifield ! field index integer :: stream_year_first_urbantv ! first year in urban tv stream to use integer :: stream_year_last_urbantv ! last year in urban tv stream to use - integer :: model_year_align_urbantv ! align stream_year_first_urbantv + integer :: model_year_align_urbantv ! align stream_year_first_urbantv ! with this model year integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_urbantv ! urban tv streams filename character(len=CL) :: urbantvmapalgo = 'nn' ! mapping alogrithm for urban ac character(len=CL) :: urbantv_tintalgo = 'linear' ! time interpolation alogrithm @@ -192,7 +192,7 @@ subroutine urbantv_init(this, bounds, NLFilename) call shr_strdata_create(this%sdat_urbantv,name="clmurbantv", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & From dc08bfd7a573620e9699c65f9c42ae09108a5ae4 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sun, 19 Jul 2020 18:48:57 -0600 Subject: [PATCH 16/39] fixed more problems in previous merge --- src/biogeochem/ch4FInundatedStreamType.F90 | 1 - src/cpl/nuopc/lnd_comp_nuopc.F90 | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/biogeochem/ch4FInundatedStreamType.F90 b/src/biogeochem/ch4FInundatedStreamType.F90 index 57498cc032..12db0528f8 100644 --- a/src/biogeochem/ch4FInundatedStreamType.F90 +++ b/src/biogeochem/ch4FInundatedStreamType.F90 @@ -315,7 +315,6 @@ subroutine ReadNML(this, bounds, NLFilename) ! Read the namelist data stream information. ! ! Uses: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index 0102413c61..06382d8cb2 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -24,7 +24,7 @@ module lnd_comp_nuopc use domainMod , only : ldomain use controlMod , only : control_setNL use clm_varorb , only : eccen, obliqr, lambm0, mvelpp - use clm_varctl , only : inst_index, inst_suffix, inst_name + use clm_varctl , only : inst_index, inst_suffix use clm_varctl , only : single_column, clm_varctl_set, iulog use clm_varctl , only : nsrStartup, nsrContinue, nsrBranch use clm_varcon , only : re @@ -217,8 +217,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - inst_name = "LND"//trim(inst_suffix) - !---------------------------------------------------------------------------- ! reset shr logging to my log file !---------------------------------------------------------------------------- From efc3fdd8cdb765bfdcc37d0dfba2782632f4f2de Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Mon, 20 Jul 2020 17:17:23 -0600 Subject: [PATCH 17/39] bug fixes needed for compilation --- src/cpl/nuopc/lnd_comp_nuopc.F90 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index 06382d8cb2..61eee73fc2 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -357,6 +357,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer :: curr_ymd ! Start date (YYYYMMDD) integer :: curr_tod ! Start time of day (sec) integer :: dtime_sync ! coupling time-step from the input synchronization clock + integer :: localPet + integer :: localpecount integer, pointer :: gindex(:) ! global index space for land and ocean points integer, pointer :: gindex_lnd(:) ! global index space for just land points integer, pointer :: gindex_ocn(:) ! global index space for just ocean points From 1d3996c12c5cb54f9e83affd17a7a7b23139d102 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sat, 25 Jul 2020 17:18:47 -0600 Subject: [PATCH 18/39] merged in the changes in PR#1085 from jedwards --- cime_config/config_pes.xml | 836 ++++++++++++++++++------------------- src/main/histFileMod.F90 | 208 ++++----- src/main/ncdio_pio.F90.in | 7 +- 3 files changed, 529 insertions(+), 522 deletions(-) diff --git a/cime_config/config_pes.xml b/cime_config/config_pes.xml index 6ce8f366a9..0d1559791d 100644 --- a/cime_config/config_pes.xml +++ b/cime_config/config_pes.xml @@ -7,34 +7,34 @@ none - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -44,34 +44,34 @@ none - -1 - -9 - -9 - -9 - -9 - -9 - -9 - -9 + -1 + -9 + -9 + -9 + -9 + -9 + -9 + -9 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + 0 + -1 + -1 + -1 + -1 + -1 + -1 + -1 @@ -91,24 +91,24 @@ -4 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + 0 + -1 + -1 + -1 + -1 + -1 + -1 + -1 @@ -118,34 +118,34 @@ none - -2 - -2 - -2 - -2 - -2 - -2 - -2 - -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -155,34 +155,34 @@ none - 180 - 180 - 180 - 180 - 180 - 180 - 180 - 180 + 180 + 180 + 180 + 180 + 180 + 180 + 180 + 180 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -192,34 +192,34 @@ none - -10 - -10 - -10 - -10 - -10 - -10 - -10 - -10 + -1 + -40 + -40 + -40 + -40 + -40 + -40 + -40 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + -1 + -1 + -1 + -1 + -1 + -1 + -1 @@ -229,34 +229,34 @@ none - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -266,7 +266,7 @@ none - -1 + -1 -50 -50 -50 @@ -276,24 +276,24 @@ -50 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + 0 + -1 + -1 + -1 + -1 + -1 + -1 + -1 @@ -303,71 +303,71 @@ none - -8 - -8 - -8 - -8 - -8 - -8 - -8 - -8 + -8 + -8 + -8 + -8 + -8 + -8 + -8 + -8 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 - + none - -16 - -16 - -16 - -16 - -16 - -16 - -16 - -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -377,34 +377,34 @@ none - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -525,34 +525,34 @@ none - -16 - -16 - -16 - -16 - -16 - -16 - -16 - -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 + -16 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -562,34 +562,34 @@ none - -32 - -32 - -32 - -32 - -32 - -32 - -32 - -32 + -32 + -32 + -32 + -32 + -32 + -32 + -32 + -32 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -710,34 +710,34 @@ none - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -747,34 +747,34 @@ none - 5 - 5 - 5 - 5 - 5 - 5 - 5 - 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5 + 5 - 1 - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -784,35 +784,35 @@ none - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 - -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 + -4 1> - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -822,35 +822,35 @@ none - -2 - -2 - -2 - -2 - -2 - -2 - -2 - -2 - -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 + -2 1> - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 @@ -860,35 +860,35 @@ none - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 - -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 + -1 1> - 1 - 1 - 1 - 1 - 1 - 1 - 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index 7405e6166b..c0caa845ca 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -2780,89 +2780,89 @@ subroutine htape_timeconst(t, mode) !*** Grid definition variables *** !------------------------------------------------------------------------------- ! For define mode -- only do this for first time-sample - if (mode == 'define' .and. tape(t)%ntimes == 1) then + if(tape(t)%ntimes == 1) then + if (mode == 'define') then + + if (ldomain%isgrid2d) then + call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, dim1name='lon', & + long_name='coordinate longitude', units='degrees_east', & + ncid=nfid(t), missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='coordinate longitude', units='degrees_east', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, dim1name='lat', & + long_name='coordinate latitude', units='degrees_north', & + ncid=nfid(t), missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='coordinate latitude', units='degrees_north', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & + dim1name='lon', dim2name='lat',& + long_name='grid cell areas', units='km^2', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='grid cell areas', units='km^2', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & + dim1name='lon', dim2name='lat', & + long_name='land fraction', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='land fraction', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='landmask', xtype=ncd_int, & + dim1name='lon', dim2name='lat', & + long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + else + call ncd_defvar(varname='landmask', xtype=ncd_int, & + dim1name=grlnd, & + long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='pftmask' , xtype=ncd_int, & + dim1name='lon', dim2name='lat', & + long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + else + call ncd_defvar(varname='pftmask' , xtype=ncd_int, & + dim1name=grlnd, & + long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & + dim1name='lon', dim2name='lat', & + long_name='index of shallowest bedrock layer', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + else + call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & + dim1name=grlnd, & + long_name='index of shallowest bedrock layer', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, dim1name='lon', & - long_name='coordinate longitude', units='degrees_east', & - ncid=nfid(t), missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='coordinate longitude', units='degrees_east', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, dim1name='lat', & - long_name='coordinate latitude', units='degrees_north', & - ncid=nfid(t), missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='coordinate latitude', units='degrees_north', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & - dim1name='lon', dim2name='lat',& - long_name='grid cell areas', units='km^2', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='grid cell areas', units='km^2', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & - dim1name='lon', dim2name='lat', & - long_name='land fraction', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='land fraction', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='landmask', xtype=ncd_int, & - dim1name='lon', dim2name='lat', & - long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - else - call ncd_defvar(varname='landmask', xtype=ncd_int, & - dim1name=grlnd, & - long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='pftmask' , xtype=ncd_int, & - dim1name='lon', dim2name='lat', & - long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - else - call ncd_defvar(varname='pftmask' , xtype=ncd_int, & - dim1name=grlnd, & - long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & - dim1name='lon', dim2name='lat', & - long_name='index of shallowest bedrock layer', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - else - call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & - dim1name=grlnd, & - long_name='index of shallowest bedrock layer', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) end if else if (mode == 'write') then - ! Most of this is constant and only needs to be done on tape(t)%ntimes=1 - ! But, some may change for dynamic PATCH mode for example - if (ldomain%isgrid2d) then call ncd_io(varname='lon', data=lon1d, ncid=nfid(t), flag='write') call ncd_io(varname='lat', data=lat1d, ncid=nfid(t), flag='write') @@ -2923,7 +2923,7 @@ subroutine hfields_write(t, mode) ! Write/define 1d topological info - if (.not. tape(t)%dov2xy) then + if (.not. tape(t)%dov2xy .and. tape(t)%ntimes==1) then if (mode == 'define') then call hfields_1dinfo(t, mode='define') else if (mode == 'write') then @@ -3501,37 +3501,39 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & endif call t_startf('hist_htapes_wrapup_tconst') - ! Write time constant history variables + ! Write time constant history variables (not all are time constant!) call htape_timeconst(t, mode='write') ! Write 3D time constant history variables to first history tapes - if ( do_3Dtconst .and. tape(t)%ntimes == 1 )then - call htape_timeconst3D(t, & - bounds, watsat_col, sucsat_col, bsw_col, hksat_col, mode='write') - do_3Dtconst = .false. - end if + if (tape(t)%ntimes == 1) then + if ( do_3Dtconst .and. tape(t)%ntimes == 1 )then + call htape_timeconst3D(t, & + bounds, watsat_col, sucsat_col, bsw_col, hksat_col, mode='write') + do_3Dtconst = .false. + end if - if (masterproc) then - write(iulog,*) - write(iulog,*) trim(subname),' : Writing current time sample to local history file ', & - trim(locfnh(t)),' at nstep = ',get_nstep(), & - ' for history time interval beginning at ', tape(t)%begtime, & - ' and ending at ',time - write(iulog,*) - call shr_sys_flush(iulog) - endif + if (masterproc) then + write(iulog,*) + write(iulog,*) trim(subname),' : Writing current time sample to local history file ', & + trim(locfnh(t)),' at nstep = ',get_nstep(), & + ' for history time interval beginning at ', tape(t)%begtime, & + ' and ending at ',time + write(iulog,*) + call shr_sys_flush(iulog) + endif - ! Update beginning time of next interval - tape(t)%begtime = time - call t_stopf('hist_htapes_wrapup_tconst') + ! Update beginning time of next interval + tape(t)%begtime = time + call t_stopf('hist_htapes_wrapup_tconst') - ! Write history time samples - call t_startf('hist_htapes_wrapup_write') - call hfields_write(t, mode='write') - call t_stopf('hist_htapes_wrapup_write') + ! Write history time samples + call t_startf('hist_htapes_wrapup_write') + call hfields_write(t, mode='write') + call t_stopf('hist_htapes_wrapup_write') - ! Zero necessary history buffers - call hfields_zero(t) + ! Zero necessary history buffers + call hfields_zero(t) + end if end if diff --git a/src/main/ncdio_pio.F90.in b/src/main/ncdio_pio.F90.in index f116dc91f2..10df7072af 100644 --- a/src/main/ncdio_pio.F90.in +++ b/src/main/ncdio_pio.F90.in @@ -33,7 +33,7 @@ module ncdio_pio use pio , only : pio_put_att, pio_put_var, pio_read_darray, pio_real, pio_seterrorhandling use pio , only : pio_setframe, pio_unlimited, pio_write, pio_write_darray, var_desc_t use pio , only : pio_iotask_rank, PIO_REARR_SUBSET, PIO_REARR_BOX - use pio , only : pio_inq_vartype + use pio , only : pio_inq_vartype, pio_syncfile ! ! !PUBLIC TYPES: implicit none @@ -2541,4 +2541,9 @@ contains end subroutine ncd_getiodesc + subroutine ncd_pio_syncfile(ncid) + type(file_desc_t) :: ncid + call pio_syncfile(ncid) + end subroutine ncd_pio_syncfile + end module ncdio_pio From 81a35b7a2dbaa7366c104293126346326521eb0a Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Wed, 29 Jul 2020 14:49:14 -0600 Subject: [PATCH 19/39] fixed pio problem --- cime_config/testdefs/testlist_clm.xml | 14 +- src/main/histFileMod.F90 | 279 +++++++++++++------------- src/main/ncdio_pio.F90.in | 1 + 3 files changed, 146 insertions(+), 148 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index 413cdc4216..ae540d6309 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -183,7 +183,7 @@ - + @@ -225,7 +225,7 @@ - + @@ -267,7 +267,7 @@ - + @@ -1321,7 +1321,7 @@ - + @@ -1330,7 +1330,7 @@ - + @@ -1541,7 +1541,7 @@ - + @@ -1747,7 +1747,7 @@ - + diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index c0caa845ca..dc242a3cf3 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -13,14 +13,14 @@ module histFileMod use spmdMod , only : masterproc use abortutils , only : endrun use clm_varctl , only : iulog, use_vertsoilc, use_fates - use clm_varcon , only : spval, ispval, dzsoi_decomp + use clm_varcon , only : spval, ispval, dzsoi_decomp use clm_varcon , only : grlnd, nameg, namel, namec, namep, nameCohort use decompMod , only : get_proc_bounds, get_proc_global, bounds_type use GetGlobalValuesMod , only : GetGlobalIndexArray - use GridcellType , only : grc - use LandunitType , only : lun - use ColumnType , only : col - use PatchType , only : patch + use GridcellType , only : grc + use LandunitType , only : lun + use ColumnType , only : col + use PatchType , only : patch use EDTypesMod , only : nclmax use EDTypesMod , only : nlevleaf use FatesInterfaceMod , only : nlevsclass, nlevage @@ -29,7 +29,7 @@ module histFileMod use FatesLitterMod , only : ncwd use EDTypesMod , only : num_elements_fates => num_elements use FatesInterfaceMod , only : maxveg_fates => numpft - use ncdio_pio + use ncdio_pio ! implicit none @@ -163,7 +163,7 @@ module histFileMod private :: hfields_write ! Write a variable to a history tape private :: hfields_1dinfo ! Define/output 1d subgrid info if appropriate private :: hist_update_hbuf_field_1d ! Updates history buffer for specific field and tape - private :: hist_update_hbuf_field_2d ! Updates history buffer for specific field and tape + private :: hist_update_hbuf_field_2d ! Updates history buffer for specific field and tape private :: hist_set_snow_field_2d ! Set values in history field dimensioned by levsno private :: list_index ! Find index of field in exclude list private :: set_hist_filename ! Determine history dataset filenames @@ -202,7 +202,7 @@ module histFileMod ! for 2D arrays, where the second dimension is allowed ! to be 1 integer :: num2d ! size of hbuf second dimension (e.g. number of vertical levels) - integer :: hpindex ! history pointer index + integer :: hpindex ! history pointer index character(len=scale_type_strlen) :: p2c_scale_type ! scale factor when averaging patch to column character(len=scale_type_strlen) :: c2l_scale_type ! scale factor when averaging column to landunit character(len=scale_type_strlen) :: l2g_scale_type ! scale factor when averaging landunit to gridcell @@ -359,7 +359,7 @@ subroutine masterlist_addfld (fname, numdims, type1d, type1d_out, & integer :: numl ! total number of landunits across all processors integer :: numc ! total number of columns across all processors integer :: nump ! total number of pfts across all processors - type(bounds_type) :: bounds + type(bounds_type) :: bounds character(len=*),parameter :: subname = 'masterlist_addfld' !------------------------------------------------------------------------ @@ -681,7 +681,7 @@ subroutine htapes_fieldlist() fexcl(:,8) = hist_fexcl8(:) fexcl(:,9) = hist_fexcl9(:) fexcl(:,10) = hist_fexcl10(:) - + ! First ensure contents of fincl and fexcl are valid names @@ -861,7 +861,7 @@ end subroutine htapes_fieldlist logical function is_mapping_upto_subgrid( type1d, type1d_out ) result ( mapping) ! ! !DESCRIPTION: - ! + ! ! Return true if this field will be mapped into a higher subgrid level ! If false it will be output on it's native grid ! @@ -917,7 +917,7 @@ subroutine htape_addfld (t, f, avgflag) integer :: beg1d_out,end1d_out ! history output per-proc 1d beginning and ending indices integer :: beg1d,end1d ! beginning and ending indices for this field (assume already set) integer :: num1d_out ! history output 1d size - type(bounds_type) :: bounds + type(bounds_type) :: bounds character(len=*),parameter :: subname = 'htape_addfld' !----------------------------------------------------------------------- @@ -1020,7 +1020,7 @@ subroutine htape_addfld (t, f, avgflag) ! Fields native bounds beg1d = masterlist(f)%field%beg1d end1d = masterlist(f)%field%end1d - + ! Alloccate and initialize history buffer and related info num2d = tape(t)%hlist(n)%field%num2d @@ -1058,7 +1058,7 @@ subroutine hist_update_hbuf(bounds) ! into its history buffer for appropriate tapes. ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: t ! tape index @@ -1073,8 +1073,8 @@ subroutine hist_update_hbuf(bounds) !$OMP PARALLEL DO PRIVATE (f, num2d, numdims) do f = 1,tape(t)%nflds numdims = tape(t)%hlist(f)%field%numdims - - if ( numdims == 1) then + + if ( numdims == 1) then call hist_update_hbuf_field_1d (t, f, bounds) else num2d = tape(t)%hlist(f)%field%num2d @@ -1103,7 +1103,7 @@ subroutine hist_update_hbuf_field_1d (t, f, bounds) ! !ARGUMENTS: integer, intent(in) :: t ! tape index integer, intent(in) :: f ! field index - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: hpindex ! history pointer index @@ -1317,7 +1317,7 @@ subroutine hist_update_hbuf_field_1d (t, f, bounds) if ( end1d .eq. ubound(field,1) ) then k_offset = 0 else - k_offset = 1 - beg1d + k_offset = 1 - beg1d endif do k = beg1d,end1d valid = .true. @@ -1397,7 +1397,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d) ! !ARGUMENTS: integer, intent(in) :: t ! tape index integer, intent(in) :: f ! field index - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds integer, intent(in) :: num2d ! size of second dimension ! ! !LOCAL VARIABLES: @@ -1420,7 +1420,7 @@ subroutine hist_update_hbuf_field_2d (t, f, bounds, num2d) integer , pointer :: nacs(:,:) ! accumulation counter real(r8), pointer :: field(:,:) ! clm 2d pointer field logical :: field_allocated! whether 'field' was allocated here - logical , pointer :: active(:) ! flag saying whether each point is active (used for type1d = landunit/column/pft) + logical , pointer :: active(:) ! flag saying whether each point is active (used for type1d = landunit/column/pft) !(this refers to a point being active, NOT a history field being active) real(r8), allocatable :: field_gcell(:,:) ! gridcell level field (used if mapping to gridcell is done) character(len=*),parameter :: subname = 'hist_update_hbuf_field_2d' @@ -1720,7 +1720,7 @@ end subroutine hist_update_hbuf_field_2d subroutine hist_set_snow_field_2d (field_out, field_in, no_snow_behavior, type1d, beg1d, end1d) ! ! !DESCRIPTION: - ! Set values in history field dimensioned by levsno. + ! Set values in history field dimensioned by levsno. ! ! This routine handles what to do when a given snow layer doesn't exist for a given ! point, based on the no_snow_behavior argument. Options are: @@ -1790,7 +1790,7 @@ subroutine hist_set_snow_field_2d (field_out, field_in, no_snow_behavior, type1d num_snow_layers = abs(snl(c)) num_nonexistent_layers = num_levels - num_snow_layers - + ! Fill output field appropriately for each layer ! When only a subset of snow layers exist, it is the LAST num_snow_layers that exist ! Levels are rearranged such that the top snow layer (surface layer) becomes level 1, etc. @@ -1801,7 +1801,7 @@ subroutine hist_set_snow_field_2d (field_out, field_in, no_snow_behavior, type1d do level = (num_levels-num_nonexistent_layers), 1, -1 field_out(point, level) = field_in(point, level+num_nonexistent_layers) end do - + end do end associate @@ -1953,7 +1953,7 @@ subroutine htape_create (t, histrest) else lnfid => nfid(t) endif - + ! BUG(wjs, 2014-10-20, bugz 1730) Workaround for ! http://bugs.cgd.ucar.edu/show_bug.cgi?id=1730 ! - 1-d hist files have problems with pnetcdf. A better workaround in terms of @@ -2066,7 +2066,7 @@ subroutine htape_create (t, histrest) call ncd_defdim(lnfid, 'string_length', hist_dim_name_length, strlen_dimid) call ncd_defdim(lnfid, 'scale_type_string_length', scale_type_strlen, dimid) call ncd_defdim( lnfid, 'levdcmp', nlevdecomp_full, dimid) - + if(use_fates)then call ncd_defdim(lnfid, 'fates_levscag', nlevsclass * nlevage, dimid) call ncd_defdim(lnfid, 'fates_levscagpf', nlevsclass * nlevage * maxveg_fates, dimid) @@ -2124,7 +2124,7 @@ subroutine htape_add_ltype_metadata(lnfid) character(len=*), parameter :: subname = 'htape_add_ltype_metadata' !----------------------------------------------------------------------- - + do ltype = 1, max_lunit attname = att_prefix // landunit_names(ltype) call ncd_putatt(lnfid, ncd_global, attname, ltype) @@ -2175,7 +2175,7 @@ subroutine htape_add_natpft_metadata(lnfid) character(len=*), parameter :: subname = 'htape_add_natpft_metadata' !----------------------------------------------------------------------- - + do ptype = natpft_lb, natpft_ub ptype_1_indexing = ptype + (1 - natpft_lb) attname = att_prefix // pftname(ptype) @@ -2205,7 +2205,7 @@ subroutine htape_add_cft_metadata(lnfid) character(len=*), parameter :: subname = 'htape_add_cft_metadata' !----------------------------------------------------------------------- - + do ptype = cft_lb, cft_ub ptype_1_indexing = ptype + (1 - cft_lb) attname = att_prefix // pftname(ptype) @@ -2233,11 +2233,11 @@ subroutine htape_timeconst3D(t, & ! ! !ARGUMENTS: integer , intent(in) :: t ! tape index - type(bounds_type) , intent(in) :: bounds - real(r8) , intent(in) :: watsat_col( bounds%begc:,1: ) - real(r8) , intent(in) :: sucsat_col( bounds%begc:,1: ) - real(r8) , intent(in) :: bsw_col( bounds%begc:,1: ) - real(r8) , intent(in) :: hksat_col( bounds%begc:,1: ) + type(bounds_type) , intent(in) :: bounds + real(r8) , intent(in) :: watsat_col( bounds%begc:,1: ) + real(r8) , intent(in) :: sucsat_col( bounds%begc:,1: ) + real(r8) , intent(in) :: bsw_col( bounds%begc:,1: ) + real(r8) , intent(in) :: hksat_col( bounds%begc:,1: ) character(len=*) , intent(in) :: mode ! 'define' or 'write' ! ! !LOCAL VARIABLES: @@ -2453,7 +2453,7 @@ subroutine htape_timeconst3D(t, & l = col%landunit(c) if (lun%lakpoi(l)) then ! Field indices MUST match varnamesl array order above! - if (ifld ==1) histil(c,lev) = col%z_lake(c,lev) + if (ifld ==1) histil(c,lev) = col%z_lake(c,lev) if (ifld ==2) histil(c,lev) = col%dz_lake(c,lev) end if end do @@ -2579,9 +2579,9 @@ subroutine htape_timeconst(t, mode) long_name='coordinate lake levels', units='m', ncid=nfid(t)) call ncd_defvar(varname='levdcmp', xtype=tape(t)%ncprec, dim1name='levdcmp', & long_name='coordinate soil levels', units='m', ncid=nfid(t)) - + if(use_fates)then - + call ncd_defvar(varname='fates_levscls', xtype=tape(t)%ncprec, dim1name='fates_levscls', & long_name='FATES diameter size class lower bound', units='cm', ncid=nfid(t)) call ncd_defvar(varname='fates_scmap_levscag', xtype=ncd_int, dim1name='fates_levscag', & @@ -2684,7 +2684,7 @@ subroutine htape_timeconst(t, mode) dim1id(1) = time_dimid str = 'days since ' // basedate // " " // basesec call ncd_defvar(nfid(t), 'time', tape(t)%ncprec, 1, dim1id, varid, & - long_name='time',units=str) + long_name='time',units=str) cal = get_calendar() if ( trim(cal) == NO_LEAP_C )then caldesc = "noleap" @@ -2705,7 +2705,7 @@ subroutine htape_timeconst(t, mode) else sec_hist_nhtfrq = hist_nhtfrq(t) end if - + dtime = get_step_size() if (sec_hist_nhtfrq == 0) then !month time_period_freq = 'month_1' @@ -2859,24 +2859,23 @@ subroutine htape_timeconst(t, mode) imissing_value=ispval, ifill_value=ispval) end if - end if - - else if (mode == 'write') then + else if (mode == 'write') then - if (ldomain%isgrid2d) then - call ncd_io(varname='lon', data=lon1d, ncid=nfid(t), flag='write') - call ncd_io(varname='lat', data=lat1d, ncid=nfid(t), flag='write') - else - call ncd_io(varname='lon', data=ldomain%lonc, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='lat', data=ldomain%latc, dim1name=grlnd, ncid=nfid(t), flag='write') - end if - call ncd_io(varname='area' , data=ldomain%area, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='landfrac', data=ldomain%frac, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='landmask', data=ldomain%mask, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='pftmask' , data=ldomain%pftm, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='nbedrock' , data=grc%nbedrock, dim1name=grlnd, ncid=nfid(t), flag='write') + if (ldomain%isgrid2d) then + call ncd_io(varname='lon', data=lon1d, ncid=nfid(t), flag='write') + call ncd_io(varname='lat', data=lat1d, ncid=nfid(t), flag='write') + else + call ncd_io(varname='lon', data=ldomain%lonc, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='lat', data=ldomain%latc, dim1name=grlnd, ncid=nfid(t), flag='write') + end if + call ncd_io(varname='area' , data=ldomain%area, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='landfrac', data=ldomain%frac, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='landmask', data=ldomain%mask, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='pftmask' , data=ldomain%pftm, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='nbedrock' , data=grc%nbedrock, dim1name=grlnd, ncid=nfid(t), flag='write') - end if ! (define/write mode + end if ! (define/write mode + endif end subroutine htape_timeconst @@ -3075,7 +3074,7 @@ subroutine hfields_1dinfo(t, mode) integer , pointer :: ilarr(:) ! temporary integer , pointer :: iparr(:) ! temporary type(file_desc_t), pointer :: ncid ! netcdf file - type(bounds_type) :: bounds + type(bounds_type) :: bounds character(len=*),parameter :: subname = 'hfields_1dinfo' !----------------------------------------------------------------------- @@ -3384,11 +3383,11 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & ! !ARGUMENTS: logical, intent(in) :: rstwr ! true => write restart file this step logical, intent(in) :: nlend ! true => end of run on this step - type(bounds_type) , intent(in) :: bounds - real(r8) , intent(in) :: watsat_col( bounds%begc:,1: ) - real(r8) , intent(in) :: sucsat_col( bounds%begc:,1: ) - real(r8) , intent(in) :: bsw_col( bounds%begc:,1: ) - real(r8) , intent(in) :: hksat_col( bounds%begc:,1: ) + type(bounds_type) , intent(in) :: bounds + real(r8) , intent(in) :: watsat_col( bounds%begc:,1: ) + real(r8) , intent(in) :: sucsat_col( bounds%begc:,1: ) + real(r8) , intent(in) :: bsw_col( bounds%begc:,1: ) + real(r8) , intent(in) :: hksat_col( bounds%begc:,1: ) ! ! !LOCAL VARIABLES: integer :: t ! tape index @@ -3503,37 +3502,36 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & call t_startf('hist_htapes_wrapup_tconst') ! Write time constant history variables (not all are time constant!) call htape_timeconst(t, mode='write') - - ! Write 3D time constant history variables to first history tapes if (tape(t)%ntimes == 1) then - if ( do_3Dtconst .and. tape(t)%ntimes == 1 )then + ! Write 3D time constant history variables to first history tapes + if ( do_3Dtconst )then call htape_timeconst3D(t, & bounds, watsat_col, sucsat_col, bsw_col, hksat_col, mode='write') do_3Dtconst = .false. end if + endif - if (masterproc) then - write(iulog,*) - write(iulog,*) trim(subname),' : Writing current time sample to local history file ', & - trim(locfnh(t)),' at nstep = ',get_nstep(), & - ' for history time interval beginning at ', tape(t)%begtime, & - ' and ending at ',time - write(iulog,*) - call shr_sys_flush(iulog) - endif + if (masterproc) then + write(iulog,*) + write(iulog,*) trim(subname),' : Writing current time sample to local history file ', & + trim(locfnh(t)),' at nstep = ',get_nstep(), & + ' for history time interval beginning at ', tape(t)%begtime, & + ' and ending at ',time + write(iulog,*) + call shr_sys_flush(iulog) + endif - ! Update beginning time of next interval - tape(t)%begtime = time - call t_stopf('hist_htapes_wrapup_tconst') + ! Update beginning time of next interval + tape(t)%begtime = time + call t_stopf('hist_htapes_wrapup_tconst') - ! Write history time samples - call t_startf('hist_htapes_wrapup_write') - call hfields_write(t, mode='write') - call t_stopf('hist_htapes_wrapup_write') + ! Write history time samples + call t_startf('hist_htapes_wrapup_write') + call hfields_write(t, mode='write') + call t_stopf('hist_htapes_wrapup_write') - ! Zero necessary history buffers - call hfields_zero(t) - end if + ! Zero necessary history buffers + call hfields_zero(t) end if @@ -3561,11 +3559,11 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & write(iulog,*) endif - call ncd_pio_closefile(nfid(t)) - - if (.not.if_stop .and. (tape(t)%ntimes/=tape(t)%mfilt)) then - call ncd_pio_openfile (nfid(t), trim(locfnh(t)), ncd_write) - end if + if (if_stop .or. (tape(t)%ntimes==tape(t)%mfilt)) then + call ncd_pio_closefile(nfid(t)) + else + call ncd_pio_syncfile(nfid(t)) + endif else if (masterproc) then write(iulog,*) trim(subname),' : history tape ',t,': no open file to close' @@ -3574,8 +3572,8 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & endif end do - ! Reset number of time samples to zero if file is full - + ! Reset number of time samples to zero if file is full + do t = 1, ntapes if (.not. history_tape_in_use(t)) then cycle @@ -3585,7 +3583,7 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & tape(t)%ntimes = 0 end if end do - + end subroutine hist_htapes_wrapup !----------------------------------------------------------------------- @@ -3607,7 +3605,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) use pio ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds type(file_desc_t), intent(inout) :: ncid ! netcdf file character(len=*) , intent(in) :: flag !'read' or 'write' character(len=*) , intent(in), optional :: rdate ! restart file time stamp for name @@ -3737,7 +3735,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) ier = PIO_put_att(ncid, vardesc%varid, 'interpinic_flag', iflag_skip) ! max_nflds is the maximum number of fields on any tape - ! max_flds is the maximum number possible number of fields + ! max_flds is the maximum number possible number of fields max_nflds = max_nFields() @@ -3770,7 +3768,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) num2d = tape(t)%hlist(f)%field%num2d nacs => tape(t)%hlist(f)%nacs hbuf => tape(t)%hlist(f)%hbuf - + if (type1d_out == grlnd) then if (ldomain%isgrid2d) then dim1name = 'lon' ; dim2name = 'lat' @@ -3780,10 +3778,10 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) else dim1name = type1d_out ; dim2name = 'undefined' endif - + if (dim2name == 'undefined') then if (num2d == 1) then - call ncd_defvar(ncid=ncid_hist(t), varname=trim(name), xtype=ncd_double, & + call ncd_defvar(ncid=ncid_hist(t), varname=trim(name), xtype=ncd_double, & dim1name=dim1name, & long_name=trim(long_name), units=trim(units)) call ncd_defvar(ncid=ncid_hist(t), varname=trim(name_acc), xtype=ncd_int, & @@ -3825,9 +3823,9 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) call ncd_defdim( ncid_hist(t), 'avgflag_len' , avgflag_strlen, dimid) call ncd_defdim( ncid_hist(t), 'scalar' , 1 , dimid) call ncd_defdim( ncid_hist(t), 'max_chars' , max_chars , dimid) - call ncd_defdim( ncid_hist(t), 'max_nflds' , max_nflds , dimid) - call ncd_defdim( ncid_hist(t), 'max_flds' , max_flds , dimid) - + call ncd_defdim( ncid_hist(t), 'max_nflds' , max_nflds , dimid) + call ncd_defdim( ncid_hist(t), 'max_flds' , max_flds , dimid) + call ncd_defvar(ncid=ncid_hist(t), varname='nhtfrq', xtype=ncd_int, & long_name="Frequency of history writes", & comment="Namelist item", & @@ -3867,7 +3865,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) call ncd_defvar(ncid=ncid_hist(t), varname='begtime', xtype=ncd_double, & long_name="Beginning time", units="time units", & dim1name='scalar') - + call ncd_defvar(ncid=ncid_hist(t), varname='num2d', xtype=ncd_int, & long_name="Size of second dimension", units="unitless", & dim1name='max_nflds' ) @@ -3909,7 +3907,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) call ncd_enddef(ncid_hist(t)) - end do ! end of ntapes loop + end do ! end of ntapes loop RETURN @@ -3933,7 +3931,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) call ncd_io('locfnh', my_locfnh, 'write', ncid, nt=t) call ncd_io('locfnhr', my_locfnhr, 'write', ncid, nt=t) end do - + fincl(:,1) = hist_fincl1(:) fincl(:,2) = hist_fincl2(:) fincl(:,3) = hist_fincl3(:) @@ -3982,7 +3980,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) itemp(:) = 0 do f=1,tape(t)%nflds itemp(f) = tape(t)%hlist(f)%field%num2d - end do + end do call ncd_io(varname='num2d', data=itemp(:), ncid=ncid_hist(t), flag='write') itemp(:) = 0 @@ -4025,7 +4023,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) call ncd_io('l2g_scale_type', l2g_scale_type, 'write', ncid_hist(t)) deallocate(tname,tlongname,tunits,tmpstr,tavgflag) deallocate(p2c_scale_type, c2l_scale_type, l2g_scale_type) - enddo + enddo deallocate(itemp) ! @@ -4079,7 +4077,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) end if ! Determine necessary indices - the following is needed if model decomposition is different on restart - + start(1)=1 if ( is_restart() )then @@ -4094,7 +4092,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) if ( t == 1 )then call ncd_inqdlen(ncid_hist(1),dimid,max_nflds,name='max_nflds') - + allocate(itemp(max_nflds)) end if @@ -4277,7 +4275,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) hist_fexcl10(:) = fexcl(:,10) end if - + if ( allocated(itemp) ) deallocate(itemp) end if @@ -4288,8 +4286,8 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) ! so that subsequent time samples are added until the file is full. ! A new history file is used on a branch run. !====================================================================== - - if (flag == 'write') then + + if (flag == 'write') then do t = 1,ntapes if (.not. history_tape_in_use(t)) then @@ -4316,7 +4314,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) write(iulog,*) trim(subname),' ERROR: allocation' call endrun(msg=errMsg(sourcefile, __LINE__)) end if - + hbuf1d(beg1d_out:end1d_out) = hbuf(beg1d_out:end1d_out,1) nacs1d(beg1d_out:end1d_out) = nacs(beg1d_out:end1d_out,1) @@ -4340,9 +4338,9 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) call ncd_pio_closefile(ncid_hist(t)) - end do ! end of ntapes loop + end do ! end of ntapes loop - else if (flag == 'read') then + else if (flag == 'read') then ! Read history restart information if history files are not full @@ -4363,7 +4361,7 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) end1d_out = tape(t)%hlist(f)%field%end1d_out nacs => tape(t)%hlist(f)%nacs hbuf => tape(t)%hlist(f)%hbuf - + if (num2d == 1) then allocate(hbuf1d(beg1d_out:end1d_out), & nacs1d(beg1d_out:end1d_out), stat=status) @@ -4371,15 +4369,15 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) write(iulog,*) trim(subname),' ERROR: allocation' call endrun(msg=errMsg(sourcefile, __LINE__)) end if - + call ncd_io(ncid=ncid_hist(t), flag='read', varname=trim(name), & dim1name=type1d_out, data=hbuf1d) call ncd_io(ncid=ncid_hist(t), flag='read', varname=trim(name_acc), & dim1name=type1d_out, data=nacs1d) - + hbuf(beg1d_out:end1d_out,1) = hbuf1d(beg1d_out:end1d_out) nacs(beg1d_out:end1d_out,1) = nacs1d(beg1d_out:end1d_out) - + deallocate(hbuf1d) deallocate(nacs1d) else @@ -4391,13 +4389,13 @@ subroutine hist_restart_ncd (bounds, ncid, flag, rdate) end do end if - + call ncd_pio_closefile(ncid_hist(t)) - + end do - + end if - + end subroutine hist_restart_ncd !----------------------------------------------------------------------- @@ -4419,7 +4417,7 @@ integer function max_nFields() end do return end function max_nFields - + !----------------------------------------------------------------------- character(len=max_namlen) function getname (inname) ! @@ -4616,7 +4614,7 @@ subroutine hist_addfld1d (fname, units, avgflag, long_name, type1d_out, & character(len=scale_type_strlen) :: scale_type_p2c ! scale type for subgrid averaging of pfts to column character(len=scale_type_strlen) :: scale_type_c2l ! scale type for subgrid averaging of columns to landunits character(len=scale_type_strlen) :: scale_type_l2g ! scale type for subgrid averaging of landunits to gridcells - type(bounds_type):: bounds ! boudns + type(bounds_type):: bounds ! boudns character(len=16):: l_default ! local version of 'default' character(len=*),parameter :: subname = 'hist_addfld1d' !------------------------------------------------------------------------ @@ -4770,10 +4768,10 @@ subroutine hist_addfld1d (fname, units, avgflag, long_name, type1d_out, & ! Add field to masterlist - call masterlist_addfld (fname=trim(fname), numdims=1, type1d=l_type1d, & + call masterlist_addfld (fname=trim(fname), numdims=1, type1d=l_type1d, & type1d_out=l_type1d_out, type2d='unset', num2d=1, & units=units, avgflag=avgflag, long_name=long_name, hpindex=hpindex, & - p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, & + p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, & l2g_scale_type=scale_type_l2g) l_default = 'active' @@ -4843,13 +4841,13 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, character(len=scale_type_strlen) :: scale_type_p2c ! scale type for subgrid averaging of pfts to column character(len=scale_type_strlen) :: scale_type_c2l ! scale type for subgrid averaging of columns to landunits character(len=scale_type_strlen) :: scale_type_l2g ! scale type for subgrid averaging of landunits to gridcells - type(bounds_type):: bounds + type(bounds_type):: bounds character(len=16):: l_default ! local version of 'default' character(len=*),parameter :: subname = 'hist_addfld2d' !------------------------------------------------------------------------ call get_proc_bounds(bounds) - + ! Error-check no_snow_behavior optional argument: It should be present if and only if ! type2d is 'levsno', and its value should be one of the public no_snow_* parameters ! defined above. @@ -4942,7 +4940,7 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, case ('levsno') num2d = nlevsno case ('nlevcan') - num2d = nlevcan + num2d = nlevcan case ('nvegwcs') num2d = nvegwcs case default @@ -5086,12 +5084,12 @@ subroutine hist_addfld2d (fname, type2d, units, avgflag, long_name, type1d_out, ! Add field to masterlist - call masterlist_addfld (fname=trim(fname), numdims=2, type1d=l_type1d, & + call masterlist_addfld (fname=trim(fname), numdims=2, type1d=l_type1d, & type1d_out=l_type1d_out, type2d=type2d, num2d=num2d, & units=units, avgflag=avgflag, long_name=long_name, hpindex=hpindex, & - p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, & + p2c_scale_type=scale_type_p2c, c2l_scale_type=scale_type_c2l, & l2g_scale_type=scale_type_l2g, no_snow_behavior=no_snow_behavior) - + l_default = 'active' if (present(default)) then l_default = default @@ -5243,12 +5241,12 @@ end subroutine hist_add_subscript subroutine strip_null(str) character(len=*), intent(inout) :: str - integer :: i + integer :: i do i=1,len(str) if(ichar(str(i:i))==0) str(i:i)=' ' end do end subroutine strip_null - + !------------------------------------------------------------------------ subroutine hist_do_disp (ntapes, hist_ntimes, hist_mfilt, if_stop, if_disphist, rstwr, nlend) ! @@ -5265,7 +5263,7 @@ subroutine hist_do_disp (ntapes, hist_ntimes, hist_mfilt, if_stop, if_disphist, logical, intent(out) :: if_stop !true => last time step of run logical, intent(out) :: if_disphist(ntapes) !true => save and dispose history file logical, intent(in) :: rstwr - logical, intent(in) :: nlend + logical, intent(in) :: nlend ! ! !LOCAL VARIABLES: integer :: t ! history tape index @@ -5275,26 +5273,26 @@ subroutine hist_do_disp (ntapes, hist_ntimes, hist_mfilt, if_stop, if_disphist, rest_now = .false. stop_now = .false. - + if (nlend) stop_now = .true. if (rstwr) rest_now = .true. - + if_stop = stop_now - + if (stop_now) then ! End of run - dispose all history files - + if_disphist(1:ntapes) = .true. - + else if (rest_now) then ! Restart - dispose all history files - + do t = 1,ntapes if_disphist(t) = .true. end do else ! Dispose - + if_disphist(1:ntapes) = .false. do t = 1,ntapes if (hist_ntimes(t) == hist_mfilt(t)) then @@ -5302,7 +5300,7 @@ subroutine hist_do_disp (ntapes, hist_ntimes, hist_mfilt, if_stop, if_disphist, endif end do endif - + end subroutine hist_do_disp !----------------------------------------------------------------------- @@ -5342,4 +5340,3 @@ end function avgflag_valid end module histFileMod - diff --git a/src/main/ncdio_pio.F90.in b/src/main/ncdio_pio.F90.in index 10df7072af..a57a20793d 100644 --- a/src/main/ncdio_pio.F90.in +++ b/src/main/ncdio_pio.F90.in @@ -68,6 +68,7 @@ module ncdio_pio public :: ncd_inqvdlen ! inquire variable dimension size public :: ncd_inqvdname ! inquire variable dimension name public :: ncd_io ! write local data + public :: ncd_pio_syncfile ! flush file contents to disk integer,parameter,public :: ncd_int = pio_int integer,parameter,public :: ncd_log =-pio_int From a4a9e50a9e200d38fa2963d02dc9e76c93d72585 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sat, 1 Aug 2020 13:57:57 -0600 Subject: [PATCH 20/39] changed wallclock time for runs that timed out with nuopc --- cime_config/testdefs/testlist_clm.xml | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/cime_config/testdefs/testlist_clm.xml b/cime_config/testdefs/testlist_clm.xml index ae540d6309..53b7a0ee06 100644 --- a/cime_config/testdefs/testlist_clm.xml +++ b/cime_config/testdefs/testlist_clm.xml @@ -183,7 +183,7 @@ - + @@ -1025,7 +1025,7 @@ - + @@ -1321,7 +1321,7 @@ - + @@ -1330,7 +1330,7 @@ - + @@ -1352,16 +1352,6 @@ - - - - - - - - - - @@ -1376,7 +1366,7 @@ - + @@ -1541,7 +1531,7 @@ - + @@ -1747,7 +1737,7 @@ - + From 5655dcfa11311472f394739246a91abed6c9fc6a Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Tue, 11 Aug 2020 11:59:49 -0600 Subject: [PATCH 21/39] updates for 3d stream input --- cime_config/buildlib | 4 +- src/cpl/nuopc/SoilMoistureStreamMod.F90 | 390 ++++++++++++++++++++++++ src/cpl/nuopc/lnd_comp_nuopc.F90 | 28 +- src/cpl/nuopc/lnd_comp_shr.F90 | 15 + 4 files changed, 424 insertions(+), 13 deletions(-) create mode 100644 src/cpl/nuopc/SoilMoistureStreamMod.F90 create mode 100644 src/cpl/nuopc/lnd_comp_shr.F90 diff --git a/cime_config/buildlib b/cime_config/buildlib index 95fd0b14c3..f4baea01a0 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -106,6 +106,7 @@ def _main_func(): caseroot = case.get_value("CASEROOT") paths = [os.path.join(caseroot,"SourceMods","src.clm"), + os.path.join(lnd_root,"src","cpl",driver), os.path.join(lnd_root,"src","main"), os.path.join(lnd_root,"src","biogeophys"), os.path.join(lnd_root,"src","biogeochem"), @@ -119,8 +120,7 @@ def _main_func(): os.path.join(lnd_root,"src","fates","fire"), os.path.join(lnd_root,"src","fates","parteh"), os.path.join(lnd_root,"src","utils"), - os.path.join(lnd_root,"src","cpl"), - os.path.join(lnd_root,"src","cpl",driver)] + os.path.join(lnd_root,"src","cpl")] if driver == 'nuopc': paths.append(os.path.join(cimeroot,"src","drivers","nuopc","nuopc_cap_share")) diff --git a/src/cpl/nuopc/SoilMoistureStreamMod.F90 b/src/cpl/nuopc/SoilMoistureStreamMod.F90 new file mode 100644 index 0000000000..d8ea3b5fe9 --- /dev/null +++ b/src/cpl/nuopc/SoilMoistureStreamMod.F90 @@ -0,0 +1,390 @@ +module SoilMoistureStreamMod + +#include "shr_assert.h" + + !----------------------------------------------------------------------- + ! !DESCRIPTION: + ! Read in soil moisture from data stream + ! + ! !USES: + use ESMF + use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_print + use dshr_strdata_mod , only : shr_strdata_init_from_inline, shr_strdata_advance + use dshr_methods_mod , only : dshr_fldbun_getfldptr + use dshr_stream_mod , only : shr_stream_file_null + use shr_kind_mod , only : r8 => shr_kind_r8, cl => shr_kind_CL, cxx => shr_kind_CXX + use shr_log_mod , only : errMsg => shr_log_errMsg + use shr_mpi_mod , only : shr_mpi_bcast + use decompMod , only : bounds_type + use abortutils , only : endrun + use clm_varctl , only : iulog, use_soil_moisture_streams + use controlMod , only : NLFilename + use LandunitType , only : lun + use ColumnType , only : col + use SoilStateType , only : soilstate_type + use WaterStateBulkType , only : waterstatebulk_type + use perf_mod , only : t_startf, t_stopf + use spmdMod , only : masterproc, mpicom, iam + use clm_time_manager , only : get_calendar, get_curr_date + use clm_nlUtilsMod , only : find_nlgroup_name + use clm_varpar , only : nlevsoi + use clm_varcon , only : denh2o, denice, watmin, spval + use landunit_varcon , only : istsoil, istcrop + use lnd_comp_shr , only : mesh, model_meshfile, model_clock + ! + ! !PUBLIC TYPES: + implicit none + private + ! + ! !PUBLIC MEMBER FUNCTIONS: + public :: PrescribedSoilMoistureInit ! position datasets for soil moisture + public :: PrescribedSoilMoistureAdvance ! Advance the soil moisture stream (outside of Open-MP loops) + public :: PrescribedSoilMoistureInterp ! interpolates between two periods of soil moisture data + + ! !PRIVATE MEMBER DATA: + type(shr_strdata_type) :: sdat_soilm ! soil moisture input data stream + character(*), parameter :: stream_var_name = "H2OSOI" ! base string for field string + character(len=CL) :: stream_lev_dimname = 'levsoi' ! name of vertical layer dimension + integer, allocatable :: g_to_ig(:) ! Array matching gridcell index to data index + logical :: soilm_ignore_data_if_missing ! If should ignore overridding a point with soil moisture data + ! from the streams file, if the streams file shows that point + ! as missing (namelist item) + ! !PRIVATE TYPES: + character(len=*), parameter, private :: sourcefile = & + __FILE__ + character(*), parameter :: u_FILE_u = & + __FILE__ + !----------------------------------------------------------------------- + +contains + + !----------------------------------------------------------------------- + ! + ! soil_moisture_init + ! + !----------------------------------------------------------------------- + subroutine PrescribedSoilMoistureInit(bounds) + ! + ! Initialize data stream information for soil moisture. + ! + ! !USES: + ! + ! !ARGUMENTS: + implicit none + type(bounds_type), intent(in) :: bounds ! bounds + ! + ! !LOCAL VARIABLES: + integer :: rc ! error coe + integer :: i ! index + integer :: stream_year_first_soilm ! first year in Ustar stream to use + integer :: stream_year_last_soilm ! last year in Ustar stream to use + integer :: model_year_align_soilm ! align stream_year_first_soilm with + integer :: nu_nml ! unit for namelist file + integer :: nml_error ! namelist i/o error flag + integer :: soilm_offset ! Offset in time for dataset (sec) + character(len=CL) :: stream_fldfilename_soilm ! ustar stream filename to read + character(len=CL) :: soilm_tintalgo = 'linear' ! Time interpolation alogrithm + character(len=CL) :: stream_mapalgo = 'bilinear' + real(r8) :: stream_dtlimit = 15._r8 + character(len=CL) :: stream_taxmode = 'cycle' + character(*), parameter :: subName = "('PrescribedSoilMoistureInit')" + character(*), parameter :: F00 = "('(PrescribedSoilMoistureInit) ',4a)" + !----------------------------------------------------------------------- + ! + ! deal with namelist variables here in init + ! + namelist /soil_moisture_streams/ & + stream_year_first_soilm, & + stream_year_last_soilm, & + model_year_align_soilm, & + soilm_tintalgo, & + soilm_offset, & + soilm_ignore_data_if_missing, & + stream_fldfilename_soilm + + ! Default values for namelist + stream_year_first_soilm = 1 ! first year in stream to use + stream_year_last_soilm = 1 ! last year in stream to use + model_year_align_soilm = 1 ! align stream_year_first_soilm with this model year + stream_fldfilename_soilm = shr_stream_file_null + soilm_offset = 0 + soilm_ignore_data_if_missing = .false. + + ! Read soilm_streams namelist + if (masterproc) then + open( newunit=nu_nml, file=trim(NLFilename), status='old', iostat=nml_error ) + call find_nlgroup_name(nu_nml, 'soil_moisture_streams', status=nml_error) + if (nml_error == 0) then + read(nu_nml, nml=soil_moisture_streams,iostat=nml_error) + if (nml_error /= 0) then + call endrun(subname // ':: ERROR reading soil_moisture_streams namelist') + end if + else + call endrun(subname // ':: ERROR finding soilm_streams namelist') + end if + close(nu_nml) + endif + + call shr_mpi_bcast(stream_year_first_soilm, mpicom) + call shr_mpi_bcast(stream_year_last_soilm, mpicom) + call shr_mpi_bcast(model_year_align_soilm, mpicom) + call shr_mpi_bcast(stream_fldfilename_soilm, mpicom) + call shr_mpi_bcast(soilm_tintalgo, mpicom) + call shr_mpi_bcast(soilm_offset, mpicom) + call shr_mpi_bcast(soilm_ignore_data_if_missing, mpicom) + + if (masterproc) then + write(iulog,*) ' ' + write(iulog,*) 'soil_moisture_stream settings:' + write(iulog,*) ' stream_year_first_soilm = ',stream_year_first_soilm + write(iulog,*) ' stream_year_last_soilm = ',stream_year_last_soilm + write(iulog,*) ' model_year_align_soilm = ',model_year_align_soilm + write(iulog,*) ' stream_fldfilename_soilm = ',trim(stream_fldfilename_soilm) + write(iulog,*) ' soilm_tintalgo = ',trim(soilm_tintalgo) + write(iulog,*) ' soilm_offset = ',soilm_offset + if ( soilm_ignore_data_if_missing ) then + write(iulog,*) ' Do NOT override a point with streams data if the streams data is missing' + else + write(iulog,*) ' Abort, if you find a model point where the input streams data is set to missing value' + end if + endif + + ! Initialize the cdeps data type sdat_soilm + ! TODO: for now stream_meshfile is the same as the model meshfile - must generalize this if want to have + ! stream be at a different resolution + + call shr_strdata_init_from_inline(sdat_soilm, & + my_task = iam, & + logunit = iulog, & + compname = 'LND', & + model_clock = model_clock, & + model_mesh = mesh, & + stream_meshfile = model_meshfile, & + stream_lev_dimname = trim(stream_lev_dimname), & + stream_mapalgo = trim(stream_mapalgo), & + stream_filenames = (/trim(stream_fldfilename_soilm)/), & + stream_fldlistFile = (/trim(stream_var_name)/), & + stream_fldListModel = (/trim(stream_var_name)/), & + stream_yearFirst = stream_year_first_soilm, & + stream_yearLast = stream_year_last_soilm, & + stream_yearAlign = model_year_align_soilm, & + stream_offset = soilm_offset, & + stream_taxmode = stream_taxmode, & + stream_dtlimit = stream_dtlimit, & + stream_tintalgo = soilm_tintalgo, & + rc = rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + + if (masterproc) then + call shr_strdata_print(sdat_soilm,'soil moisture data') + endif + + end subroutine PrescribedSoilMoistureInit + + !----------------------------------------------------------------------- + ! + ! PrescribedSoilMoistureAdvance + ! + !----------------------------------------------------------------------- + subroutine PrescribedSoilMoistureAdvance( bounds ) + ! + ! Advanace the prescribed soil moisture stream + ! + ! !USES: + ! + ! !ARGUMENTS: + type(bounds_type) , intent(in) :: bounds + ! + ! !LOCAL VARIABLES: + integer :: rc + integer :: g, ig + integer :: ier ! error code + integer :: year ! year (0, ...) for nstep+1 + integer :: mon ! month (1, ..., 12) for nstep+1 + integer :: day ! day of month (1, ..., 31) for nstep+1 + integer :: sec ! seconds into current date for nstep+1 + integer :: mcdate ! Current model date (yyyymmdd) + !----------------------------------------------------------------------- + + rc = ESMF_SUCCESS + + call get_curr_date(year, mon, day, sec) + mcdate = year*10000 + mon*100 + day + + ! Advance sdat stream + call shr_strdata_advance(sdat_soilm, ymd=mcdate, tod=sec, logunit=iulog, istr='soil_moisture', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + + ! Map gridcell to 1->local_size (g_to_ig is a module variable) + ier = 0 + if ( .not. allocated(g_to_ig) )then + allocate (g_to_ig(bounds%begg:bounds%endg), stat=ier) + if (ier /= 0) then + write(iulog,*) 'Prescribed soil moisture allocation error' + call endrun(msg=errMsg(sourcefile, __LINE__)) + end if + + ig = 0 + do g = bounds%begg,bounds%endg + ig = ig+1 + g_to_ig(g) = ig + end do + end if + + end subroutine PrescribedSoilMoistureAdvance + + !----------------------------------------------------------------------- + ! + ! PrescribedSoilMoistureInterp + ! + !----------------------------------------------------------------------- + subroutine PrescribedSoilMoistureInterp(bounds, soilstate_inst, waterstatebulk_inst) + ! + ! Assign data stream information for prescribed soil moisture. + ! + ! !USES: + ! + ! !ARGUMENTS: + implicit none + type(bounds_type) , intent(in) :: bounds + type(soilstate_type) , intent(in) :: soilstate_inst + type(waterstatebulk_type) , intent(inout) :: waterstatebulk_inst + ! + ! !LOCAL VARIABLES: + integer :: rc + integer :: c, g, j, ig, n + real(r8) :: soilm_liq_frac ! liquid fraction of soil moisture + real(r8) :: soilm_ice_frac ! ice fraction of soil moisture + real(r8) :: moisture_increment ! soil moisture adjustment increment + real(r8) :: h2osoi_vol_initial ! initial vwc value + real(r8), pointer :: dataptr2d(:,:) ! first dimension is level, second is data on that level + character(*), parameter :: subName = "('PrescribedSoilMoistureInterp')" + !----------------------------------------------------------------------- + + SHR_ASSERT_FL( (lbound(g_to_ig,1) <= bounds%begg ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(g_to_ig,1) >= bounds%endg ), sourcefile, __LINE__) + associate( & + dz => col%dz , & ! Input: [real(r8) (:,:) ] layer depth (m) + watsat => soilstate_inst%watsat_col , & ! Input: [real(r8) (:,:) ] volumetric soil water at saturation (porosity) + h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input/Output: [real(r8) (:,:) ] liquid water (kg/m2) + h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input/Output: [real(r8) (:,:) ] ice water (kg/m2) + h2osoi_vol => waterstatebulk_inst%h2osoi_vol_col , & ! Output: volumetric soil water (m3/m3) + h2osoi_vol_prs => waterstatebulk_inst%h2osoi_vol_prs_grc & ! Output: prescribed volumetric soil water (m3/m3) + ) + SHR_ASSERT_FL( (lbound(h2osoi_vol,1) <= bounds%begc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_vol,1) >= bounds%endc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(h2osoi_vol,2) == 1 ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_vol,2) >= nlevsoi ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(dz,1) <= bounds%begc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(dz,1) >= bounds%endc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(dz,2) <= 1 ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(dz,2) >= nlevsoi ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(watsat,1) <= bounds%begc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(watsat,1) >= bounds%endc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(watsat,2) <= 1 ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(watsat,2) >= nlevsoi ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(h2osoi_liq,1) <= bounds%begc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_liq,1) >= bounds%endc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(h2osoi_liq,2) <= 1 ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_liq,2) >= nlevsoi ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(h2osoi_ice,1) <= bounds%begc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_ice,1) >= bounds%endc ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(h2osoi_ice,2) <= 1 ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_ice,2) >= nlevsoi ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(h2osoi_vol_prs,1) <= bounds%begg ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_vol_prs,1) >= bounds%endg ), sourcefile, __LINE__) + SHR_ASSERT_FL( (lbound(h2osoi_vol_prs,2) == 1 ), sourcefile, __LINE__) + SHR_ASSERT_FL( (ubound(h2osoi_vol_prs,2) >= nlevsoi ), sourcefile, __LINE__) + + ! Get pointer for stream data that is time and spatially interpolate to model time and grid + call dshr_fldbun_getFldPtr(sdat_soilm%pstrm(1)%fldbun_model, trim(stream_var_name), fldptr2=dataptr2d, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then + call ESMF_Finalize(endflag=ESMF_END_ABORT) + end if + + ! Check that inner most dimensino of dataptr2d is equal to nlevsoi + if (size(dataptr2d,dim=1) /= nlevsoi) then + if (masterproc) then + write(iulog,*) 'ERROR: dataptr2d(dim=1) = ',size(dataptr2d,dim=1),& + ' and nlevsoi = ',nlevsoi,' must match ' + end if + call endrun(trim(subname) // & + ' ERROR:: The input soil moisture stream does not have levels equal to nlevsoi') + end if + + ! Set the prescribed soil moisture read from the file everywhere + do g = bounds%begg, bounds%endg + ig = g_to_ig(g) + do j = 1, nlevsoi + h2osoi_vol_prs(g,j) = dataptr2d(j,ig) + + ! If soil moiture is being interpolated in time and the result is + ! large that probably means one of the two data points is missing (set to spval) + if ( h2osoi_vol_prs(g,j) > 10.0_r8 .and. (h2osoi_vol_prs(g,j) /= spval) )then + h2osoi_vol_prs(g,j) = spval + end if + end do + end do + + do c = bounds%begc, bounds%endc + ! Set variable for each gridcell/column combination + g = col%gridcell(c) + ig = g_to_ig(g) + + ! EBK Jan/2020, also check weights on gridcell (See https://github.com/ESCOMP/CTSM/issues/847) + if ( (lun%itype(col%landunit(c)) == istsoil) .or. & + (lun%itype(col%landunit(c)) == istcrop) .and. (col%wtgcell(c) /= 0._r8) ) then + + ! this is a 2d field (gridcell/nlevsoi) ! + do j = 1, nlevsoi + ! if soil water is zero, liq/ice fractions cannot be calculated + if((h2osoi_liq(c, j) + h2osoi_ice(c, j)) > 0._r8) then + + ! save original soil moisture value + h2osoi_vol_initial = h2osoi_vol(c,j) + + ! Check if the vegetated land mask from the dataset on the + ! file is different + if ( (h2osoi_vol_prs(g,j) == spval) .and. (h2osoi_vol_initial /= spval) )then + if ( soilm_ignore_data_if_missing )then + cycle + else + write(iulog,*) 'Input soil moisture dataset is not vegetated as expected: gridcell=', & + g, ' active = ', col%active(c) + call endrun(subname //& + ' ERROR:: The input soil moisture stream is NOT vegetated for one of the land points' ) + end if + end if + + ! update volumetric soil moisture from data prescribed from the file + h2osoi_vol(c,j) = h2osoi_vol_prs(g,j) + + ! calculate liq/ice mass fractions + soilm_liq_frac = h2osoi_liq(c, j) /(h2osoi_liq(c, j) + h2osoi_ice(c, j)) + soilm_ice_frac = h2osoi_ice(c, j) /(h2osoi_liq(c, j) + h2osoi_ice(c, j)) + + ! calculate moisture increment + moisture_increment = h2osoi_vol(c,j) - h2osoi_vol_initial + ! add limitation check + moisture_increment = min((watsat(c,j) - h2osoi_vol_initial),max(-(h2osoi_vol_initial-watmin),moisture_increment)) + + ! update liq/ice water mass due to (volumetric) moisture increment + h2osoi_liq(c,j) = h2osoi_liq(c,j) + (soilm_liq_frac * moisture_increment * dz(c, j) * denh2o) + h2osoi_ice(c,j) = h2osoi_ice(c,j) + (soilm_ice_frac * moisture_increment * dz(c, j) * denice) + + else + call endrun(subname // ':: ERROR h2osoil liquid plus ice is zero') + endif + enddo + endif + end do + + end associate + + end subroutine PrescribedSoilMoistureInterp + +end module SoilMoistureStreamMod diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index 61eee73fc2..ef85e6dc5c 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -34,14 +34,14 @@ module lnd_comp_nuopc use clm_time_manager , only : get_curr_date, get_curr_calday use clm_initializeMod , only : initialize1, initialize2 use clm_driver , only : clm_drv - use lnd_import_export , only : advertise_fields, realize_fields - use lnd_import_export , only : import_fields, export_fields use nuopc_shr_methods , only : chkerr, state_setscalar, state_getscalar, state_diagnose, alarmInit use nuopc_shr_methods , only : set_component_logging, get_component_instance, log_clock_advance use perf_mod , only : t_startf, t_stopf, t_barrierf use netcdf , only : nf90_open, nf90_nowrite, nf90_noerr, nf90_close, nf90_strerror use netcdf , only : nf90_inq_dimid, nf90_inq_varid, nf90_get_var use netcdf , only : nf90_inquire_dimension, nf90_inquire_variable + use lnd_import_export , only : advertise_fields, realize_fields, import_fields, export_fields + use lnd_comp_shr , only : mesh, model_meshfile, model_clock implicit none private ! except @@ -201,7 +201,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call mpi_comm_dup(lmpicom, mpicom, ierr) - ! Note still need compid for those parts of the code that use the data model ! functionality through subroutine calls call NUOPC_CompAttributeGet(gcomp, name='MCTID', value=cvalue, rc=rc) @@ -340,7 +339,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Mesh) :: mesh, gridmesh ! esmf mesh + type(ESMF_Mesh) :: gridmesh ! temporary esmf mesh type(ESMF_DistGrid) :: DistGrid ! esmf global index space descriptor type(ESMF_VM) :: vm type(ESMF_Time) :: currTime ! Current time @@ -423,6 +422,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) !$ call omp_set_num_threads(localPeCount) print *,__FILE__,__LINE__,localPeCount + !---------------------- ! Obtain attribute values !---------------------- @@ -544,6 +544,12 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ref_tod_in=ref_tod, & dtime_in=dtime_sync) + !---------------------------------------------------------------------------- + ! Set model clock in lnd_comp_shr + !---------------------------------------------------------------------------- + + model_clock = clock + !---------------------- ! Read namelist, grid and surface data !---------------------- @@ -597,11 +603,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) !-------------------------------- ! determine if the mesh will be created or read in - call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=cvalue, rc=rc) + call NUOPC_CompAttributeGet(gcomp, name='mesh_lnd', value=model_meshfile, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - if (single_column) cvalue = 'create_mesh' + if (single_column) model_meshfile = 'create_mesh' - if (cvalue == 'create_mesh') then + if (trim(model_meshfile) == 'create_mesh') then ! get the datm grid from the domain file call NUOPC_CompAttributeGet(gcomp, name='domain_lnd', value=cvalue, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -658,11 +664,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return else ! read in the mesh from the file - mesh = ESMF_MeshCreate(filename=trim(cvalue), fileformat=ESMF_FILEFORMAT_ESMFMESH, & + mesh = ESMF_MeshCreate(filename=trim(model_meshfile), fileformat=ESMF_FILEFORMAT_ESMFMESH, & elementDistgrid=Distgrid, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (masterproc) then - write(iulog,*)'mesh file for domain is ',trim(cvalue) + write(iulog,*)'mesh file for domain is ',trim(model_meshfile) end if end if @@ -778,7 +784,7 @@ subroutine ModelAdvance(gcomp, rc) !------------------------ use clm_instMod, only : water_inst, atm2lnd_inst, glc2lnd_inst, lnd2atm_inst, lnd2glc_inst -!$ use omp_lib, only : omp_set_num_threads + !$ use omp_lib, only : omp_set_num_threads use ESMF, only : ESMF_VM, ESMF_VMGet ! input/output variables @@ -834,7 +840,7 @@ subroutine ModelAdvance(gcomp, rc) call ESMF_VMGet(vm, pet=localPet, peCount=localPeCount, rc=rc) if (chkerr(rc,__LINE__,u_FILE_u)) return -!$ call omp_set_num_threads(localPeCount) + !$ call omp_set_num_threads(localPeCount) call shr_file_getLogUnit (shrlogunit) call shr_file_setLogUnit (iulog) diff --git a/src/cpl/nuopc/lnd_comp_shr.F90 b/src/cpl/nuopc/lnd_comp_shr.F90 new file mode 100644 index 0000000000..dd619c7648 --- /dev/null +++ b/src/cpl/nuopc/lnd_comp_shr.F90 @@ -0,0 +1,15 @@ +module lnd_comp_shr + + ! Model mesh info is here in order to be leveraged by CDEPS in line calls + + use ESMF + use shr_kind_mod, only : r8 => shr_kind_r8, cl=>shr_kind_cl + + implicit none + public + + type(ESMF_Clock) :: model_clock ! model clock + type(ESMF_Mesh) :: mesh ! model_mesh + character(len=cl) :: model_meshfile ! model mesh file + +end module lnd_comp_shr From 32df50ab5d43a9d2e25384f7c74877675f43a48e Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Mon, 24 Aug 2020 14:42:42 -0600 Subject: [PATCH 22/39] updates for running single column --- src/cpl/nuopc/lnd_comp_nuopc.F90 | 79 ++++++++++++++++---------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index ef85e6dc5c..5aa668f416 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -656,13 +656,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return ! create the mesh from the grid - gridmesh = ESMF_MeshCreate(lgrid, rc=rc) + mesh = ESMF_MeshCreate(lgrid, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - ! Now redistribute the mesh to use the internal distrid - mesh = ESMF_MeshCreate(gridmesh, elementDistgrid=Distgrid, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return else + ! read in the mesh from the file mesh = ESMF_MeshCreate(filename=trim(model_meshfile), fileformat=ESMF_FILEFORMAT_ESMFMESH, & elementDistgrid=Distgrid, rc=rc) @@ -670,15 +668,16 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (masterproc) then write(iulog,*)'mesh file for domain is ',trim(model_meshfile) end if - end if - ! Determine the areas on the mesh - areaField = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8, name='mesh_areas', meshloc=ESMF_MESHLOC_ELEMENT, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldRegridGetArea(areaField, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - call ESMF_FieldGet(areaField, farrayPtr=areaPtr, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! Determine the areas on the mesh + areaField = ESMF_FieldCreate(mesh, ESMF_TYPEKIND_R8, name='mesh_areas', meshloc=ESMF_MESHLOC_ELEMENT, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldRegridGetArea(areaField, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + call ESMF_FieldGet(areaField, farrayPtr=areaPtr, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + + end if ! realize the actively coupled fields call realize_fields(gcomp, mesh, flds_scalar_name, flds_scalar_num, rc) @@ -695,33 +694,35 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! obtain mesh lats and lons !-------------------------------- - call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - allocate(ownedElemCoords(spatialDim*numOwnedElements)) - call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - do g = bounds%begg,bounds%endg - n = 1 + (g - bounds%begg) - mesh_lon = ownedElemCoords(2*n-1) - mesh_lat = ownedElemCoords(2*n) - mesh_area = areaPtr(n) - if (abs(mesh_lon - ldomain%lonc(g)) > tolerance_latlon) then - write(6,100)'ERROR: clm_lon, mesh_lon, diff_lon = ',& - ldomain%lonc(g), mesh_lon, abs(mesh_lon - ldomain%lonc(g)) - !call shr_sys_abort() - end if - if (abs(mesh_lat - ldomain%latc(g)) > tolerance_latlon) then - write(6,100)'ERROR: clm_lat, mesh_lat, diff_lat = ',& - ldomain%latc(g), mesh_lat, abs(mesh_lat - ldomain%latc(g)) - !call shr_sys_abort() - end if - if (abs(mesh_area - ldomain%area(g)/(re*re)) > tolerance_area) then - write(6,100)'ERROR: clm_area, mesh_area, diff_area = ',& - ldomain%area(g)/(re*re), mesh_area, abs(mesh_area - ldomain%area(g)/(re*re)) - !call shr_sys_abort() - end if - end do -100 format(a,3(d13.5,2x)) + if (trim(model_meshfile) /= 'create_mesh') then + call ESMF_MeshGet(mesh, spatialDim=spatialDim, numOwnedElements=numOwnedElements, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + allocate(ownedElemCoords(spatialDim*numOwnedElements)) + call ESMF_MeshGet(mesh, ownedElemCoords=ownedElemCoords) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + do g = bounds%begg,bounds%endg + n = 1 + (g - bounds%begg) + mesh_lon = ownedElemCoords(2*n-1) + mesh_lat = ownedElemCoords(2*n) + mesh_area = areaPtr(n) + if (abs(mesh_lon - ldomain%lonc(g)) > tolerance_latlon) then + write(6,100)'ERROR: clm_lon, mesh_lon, diff_lon = ',& + ldomain%lonc(g), mesh_lon, abs(mesh_lon - ldomain%lonc(g)) + !call shr_sys_abort() + end if + if (abs(mesh_lat - ldomain%latc(g)) > tolerance_latlon) then + write(6,100)'ERROR: clm_lat, mesh_lat, diff_lat = ',& + ldomain%latc(g), mesh_lat, abs(mesh_lat - ldomain%latc(g)) + !call shr_sys_abort() + end if + if (abs(mesh_area - ldomain%area(g)/(re*re)) > tolerance_area) then + write(6,100)'ERROR: clm_area, mesh_area, diff_area = ',& + ldomain%area(g)/(re*re), mesh_area, abs(mesh_area - ldomain%area(g)/(re*re)) + !call shr_sys_abort() + end if + end do +100 format(a,3(d13.5,2x)) + end if !-------------------------------- ! Create land export state From 3fe5bb5f8f2f96a98e25e86695c835b298d95b98 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Wed, 26 Aug 2020 06:21:57 -0600 Subject: [PATCH 23/39] fix assign sring to logical --- src/cpl/nuopc/lnd_comp_nuopc.F90 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index 5aa668f416..e8b1b76f5a 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -300,7 +300,13 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return if (isPresent .and. isSet) then call ESMF_LogWrite(trim(subname)//' cism_evolve = '//trim(cvalue), ESMF_LOGMSG_INFO) - write (cism_evolve,*) cvalue + if (trim(cvalue) .eq. '.true.') then + cism_evolve = .true. + else if (trim(cvalue) .eq. '.false.') then + cism_evolve = .false. + else + call shr_sys_abort(subname//'Could not determine cism_evolve value '//trim(cvalue)) + endif else call shr_sys_abort(subname//'Need to set cism_evolve if glc is present') endif @@ -549,7 +555,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) !---------------------------------------------------------------------------- model_clock = clock - + !---------------------- ! Read namelist, grid and surface data !---------------------- @@ -909,7 +915,7 @@ subroutine ModelAdvance(gcomp, rc) caldayp1 = get_curr_calday(offset=dtime) if (nstep == 0) then - doalb = .false. + doalb = .false. else if (nstep == 1) then doalb = (abs(nextsw_cday- caldayp1) < 1.e-10_r8) else From ba1d9e691c34ba8ab3f3396f9b1e46bc9a7ee18c Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Tue, 6 Oct 2020 08:18:29 -0600 Subject: [PATCH 24/39] move initialization of iulog --- src/cpl/nuopc/lnd_comp_nuopc.F90 | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index e8b1b76f5a..eb9ebcab8a 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -201,6 +201,13 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call mpi_comm_dup(lmpicom, mpicom, ierr) + !---------------------------------------------------------------------------- + ! reset shr logging to my log file + !---------------------------------------------------------------------------- + + call set_component_logging(gcomp, localPet==0, iulog, shrlogunit, rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! Note still need compid for those parts of the code that use the data model ! functionality through subroutine calls call NUOPC_CompAttributeGet(gcomp, name='MCTID', value=cvalue, rc=rc) @@ -216,13 +223,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- - ! reset shr logging to my log file - !---------------------------------------------------------------------------- - - call set_component_logging(gcomp, localPet==0, iulog, shrlogunit, rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return - !---------------------------------------------------------------------------- ! advertise fields !---------------------------------------------------------------------------- @@ -327,7 +327,6 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call shr_file_setLogUnit (shrlogunit) call ESMF_LogWrite(subname//' done', ESMF_LOGMSG_INFO) - end subroutine InitializeAdvertise !=============================================================================== @@ -427,7 +426,6 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) if (chkerr(rc,__LINE__,u_FILE_u)) return !$ call omp_set_num_threads(localPeCount) - print *,__FILE__,__LINE__,localPeCount !---------------------- ! Obtain attribute values From 81c00100dfb5b23233d55f43853c70deaa584bb7 Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Mon, 12 Oct 2020 20:38:01 -0600 Subject: [PATCH 25/39] replaced global unity mask on mesh with land mask --- src/cpl/nuopc/lnd_comp_nuopc.F90 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index eb9ebcab8a..8e91d21949 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -366,6 +366,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, pointer :: gindex(:) ! global index space for land and ocean points integer, pointer :: gindex_lnd(:) ! global index space for just land points integer, pointer :: gindex_ocn(:) ! global index space for just ocean points + integer, pointer :: mask(:) ! local land/ocean mask character(ESMF_MAXSTR) :: cvalue ! config data integer :: nlnd, nocn ! local size ofarrays integer :: g,n ! indices @@ -589,11 +590,14 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) ! create a global index that includes both land and ocean points nocn = size(gindex_ocn) allocate(gindex(nlnd + nocn)) + allocate(mask(nlnd + nocn)) do n = 1,nlnd+nocn if (n <= nlnd) then gindex(n) = gindex_lnd(n) + mask(n) = 1 else gindex(n) = gindex_ocn(n-nlnd) + mask(n) = 0 end if end do @@ -663,6 +667,11 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh = ESMF_MeshCreate(lgrid, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! reset the global mask (which is 1) to the land/ocean mask + call ESMF_MeshSet(mesh, elementMask=mask, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) return + deallocate(mask) + else ! read in the mesh from the file From 5f26ef833ac566c93fe5c0e439cba48551923f5b Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 12 Nov 2020 15:50:33 -0700 Subject: [PATCH 26/39] Add mizuRoute external (Copied from previous addition from @ekluzek) --- Externals.cfg | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Externals.cfg b/Externals.cfg index c021a25771..d1f7704306 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -26,6 +26,13 @@ repo_url = https://github.com/ESCOMP/MOSART tag = mosart1_0_38 required = True +[mizuRoute] +local_path = components/mizuRoute +protocol = git +repo_url = https://github.com/nmizukami/mizuRoute +hash = 34723c2 +required = True + [cdeps] hash = 45b7a85 protocol = git From 090f2e34310d3582e1cff91791bb502a196f13c2 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 12 Nov 2020 16:34:30 -0700 Subject: [PATCH 27/39] Change shr_pio_getiotype to use 'LND' rather than inst_name Same as what was done in f5de7e42e (changes to CNFireBaseMod.F90 are now needed in FireDataBaseType.f90) --- src/main/FireDataBaseType.F90 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/FireDataBaseType.F90 b/src/main/FireDataBaseType.F90 index 5f3edc529b..1e02033c95 100644 --- a/src/main/FireDataBaseType.F90 +++ b/src/main/FireDataBaseType.F90 @@ -147,7 +147,6 @@ subroutine hdm_init( this, bounds, NLFilename ) ! Initialize data stream information for population density. ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -225,7 +224,7 @@ subroutine hdm_init( this, bounds, NLFilename ) call shr_strdata_create(this%sdat_hdm,name="clmhdm", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -304,7 +303,6 @@ subroutine lnfm_init( this, bounds, NLFilename ) ! Initialize data stream information for Lightning. ! ! !USES: - use clm_varctl , only : inst_name use clm_time_manager , only : get_calendar use ncdio_pio , only : pio_subsystem use shr_pio_mod , only : shr_pio_getiotype @@ -382,7 +380,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) call shr_strdata_create(this%sdat_lnfm,name="clmlnfm", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype(inst_name), & + pio_iotype=shr_pio_getiotype('LND'), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & From 17b929b3c423cea405af41106ae8093dafd32d37 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 12 Nov 2020 17:12:29 -0700 Subject: [PATCH 28/39] Restore histFileMod to how it is on master The changes in histFileMod on this branch came from https://github.com/ESCOMP/CTSM/pull/1085, but we ended up redoing that PR in a different way. --- src/main/histFileMod.F90 | 214 +++++++++++++++++++-------------------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/src/main/histFileMod.F90 b/src/main/histFileMod.F90 index 0115499e41..8e6be4a571 100644 --- a/src/main/histFileMod.F90 +++ b/src/main/histFileMod.F90 @@ -2774,102 +2774,103 @@ subroutine htape_timeconst(t, mode) !*** Grid definition variables *** !------------------------------------------------------------------------------- ! For define mode -- only do this for first time-sample - if(tape(t)%ntimes == 1) then - if (mode == 'define') then + if (mode == 'define' .and. tape(t)%ntimes == 1) then - if (ldomain%isgrid2d) then - call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, dim1name='lon', & - long_name='coordinate longitude', units='degrees_east', & - ncid=nfid(t), missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='coordinate longitude', units='degrees_east', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, dim1name='lat', & - long_name='coordinate latitude', units='degrees_north', & - ncid=nfid(t), missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='coordinate latitude', units='degrees_north', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & - dim1name='lon', dim2name='lat',& - long_name='grid cell areas', units='km^2', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='grid cell areas', units='km^2', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & - dim1name='lon', dim2name='lat', & - long_name='land fraction', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - else - call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & - dim1name=grlnd, & - long_name='land fraction', ncid=nfid(t), & - missing_value=spval, fill_value=spval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='landmask', xtype=ncd_int, & - dim1name='lon', dim2name='lat', & - long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - else - call ncd_defvar(varname='landmask', xtype=ncd_int, & - dim1name=grlnd, & - long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='pftmask' , xtype=ncd_int, & - dim1name='lon', dim2name='lat', & - long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - else - call ncd_defvar(varname='pftmask' , xtype=ncd_int, & - dim1name=grlnd, & - long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - end if - if (ldomain%isgrid2d) then - call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & - dim1name='lon', dim2name='lat', & - long_name='index of shallowest bedrock layer', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - else - call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & - dim1name=grlnd, & - long_name='index of shallowest bedrock layer', ncid=nfid(t), & - imissing_value=ispval, ifill_value=ispval) - end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, dim1name='lon', & + long_name='coordinate longitude', units='degrees_east', & + ncid=nfid(t), missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='lon', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='coordinate longitude', units='degrees_east', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, dim1name='lat', & + long_name='coordinate latitude', units='degrees_north', & + ncid=nfid(t), missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='lat', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='coordinate latitude', units='degrees_north', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & + dim1name='lon', dim2name='lat',& + long_name='grid cell areas', units='km^2', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='area', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='grid cell areas', units='km^2', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & + dim1name='lon', dim2name='lat', & + long_name='land fraction', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + else + call ncd_defvar(varname='landfrac', xtype=tape(t)%ncprec, & + dim1name=grlnd, & + long_name='land fraction', ncid=nfid(t), & + missing_value=spval, fill_value=spval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='landmask', xtype=ncd_int, & + dim1name='lon', dim2name='lat', & + long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + else + call ncd_defvar(varname='landmask', xtype=ncd_int, & + dim1name=grlnd, & + long_name='land/ocean mask (0.=ocean and 1.=land)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='pftmask' , xtype=ncd_int, & + dim1name='lon', dim2name='lat', & + long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + else + call ncd_defvar(varname='pftmask' , xtype=ncd_int, & + dim1name=grlnd, & + long_name='pft real/fake mask (0.=fake and 1.=real)', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + end if + if (ldomain%isgrid2d) then + call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & + dim1name='lon', dim2name='lat', & + long_name='index of shallowest bedrock layer', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + else + call ncd_defvar(varname='nbedrock' , xtype=ncd_int, & + dim1name=grlnd, & + long_name='index of shallowest bedrock layer', ncid=nfid(t), & + imissing_value=ispval, ifill_value=ispval) + end if - else if (mode == 'write') then + else if (mode == 'write') then - if (ldomain%isgrid2d) then - call ncd_io(varname='lon', data=lon1d, ncid=nfid(t), flag='write') - call ncd_io(varname='lat', data=lat1d, ncid=nfid(t), flag='write') - else - call ncd_io(varname='lon', data=ldomain%lonc, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='lat', data=ldomain%latc, dim1name=grlnd, ncid=nfid(t), flag='write') - end if - call ncd_io(varname='area' , data=ldomain%area, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='landfrac', data=ldomain%frac, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='landmask', data=ldomain%mask, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='pftmask' , data=ldomain%pftm, dim1name=grlnd, ncid=nfid(t), flag='write') - call ncd_io(varname='nbedrock' , data=grc%nbedrock, dim1name=grlnd, ncid=nfid(t), flag='write') + ! Most of this is constant and only needs to be done on tape(t)%ntimes=1 + ! But, some may change for dynamic PATCH mode for example - end if ! (define/write mode - endif + if (ldomain%isgrid2d) then + call ncd_io(varname='lon', data=lon1d, ncid=nfid(t), flag='write') + call ncd_io(varname='lat', data=lat1d, ncid=nfid(t), flag='write') + else + call ncd_io(varname='lon', data=ldomain%lonc, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='lat', data=ldomain%latc, dim1name=grlnd, ncid=nfid(t), flag='write') + end if + call ncd_io(varname='area' , data=ldomain%area, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='landfrac', data=ldomain%frac, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='landmask', data=ldomain%mask, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='pftmask' , data=ldomain%pftm, dim1name=grlnd, ncid=nfid(t), flag='write') + call ncd_io(varname='nbedrock' , data=grc%nbedrock, dim1name=grlnd, ncid=nfid(t), flag='write') + + end if ! (define/write mode end subroutine htape_timeconst @@ -2916,7 +2917,7 @@ subroutine hfields_write(t, mode) ! Write/define 1d topological info - if (.not. tape(t)%dov2xy .and. tape(t)%ntimes==1) then + if (.not. tape(t)%dov2xy) then if (mode == 'define') then call hfields_1dinfo(t, mode='define') else if (mode == 'write') then @@ -3494,16 +3495,15 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & endif call t_startf('hist_htapes_wrapup_tconst') - ! Write time constant history variables (not all are time constant!) + ! Write time constant history variables call htape_timeconst(t, mode='write') - if (tape(t)%ntimes == 1) then - ! Write 3D time constant history variables to first history tapes - if ( do_3Dtconst )then - call htape_timeconst3D(t, & - bounds, watsat_col, sucsat_col, bsw_col, hksat_col, mode='write') - do_3Dtconst = .false. - end if - endif + + ! Write 3D time constant history variables to first history tapes + if ( do_3Dtconst .and. tape(t)%ntimes == 1 )then + call htape_timeconst3D(t, & + bounds, watsat_col, sucsat_col, bsw_col, hksat_col, mode='write') + do_3Dtconst = .false. + end if if (masterproc) then write(iulog,*) @@ -3553,11 +3553,11 @@ subroutine hist_htapes_wrapup( rstwr, nlend, bounds, & write(iulog,*) endif - if (if_stop .or. (tape(t)%ntimes==tape(t)%mfilt)) then - call ncd_pio_closefile(nfid(t)) - else - call ncd_pio_syncfile(nfid(t)) - endif + call ncd_pio_closefile(nfid(t)) + + if (.not.if_stop .and. (tape(t)%ntimes/=tape(t)%mfilt)) then + call ncd_pio_openfile (nfid(t), trim(locfnh(t)), ncd_write) + end if else if (masterproc) then write(iulog,*) trim(subname),' : history tape ',t,': no open file to close' From 01c36e67fa4bd80d1bc31280665f326b7701008c Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Thu, 12 Nov 2020 17:13:56 -0700 Subject: [PATCH 29/39] Remove unneeded ncd_pio_syncfile This came from https://github.com/ESCOMP/CTSM/pull/1085, but we ended up redoing that PR in a different way on master. --- src/main/ncdio_pio.F90.in | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/ncdio_pio.F90.in b/src/main/ncdio_pio.F90.in index 5ee1af4df4..0eb8725514 100644 --- a/src/main/ncdio_pio.F90.in +++ b/src/main/ncdio_pio.F90.in @@ -33,7 +33,7 @@ module ncdio_pio use pio , only : pio_put_att, pio_put_var, pio_read_darray, pio_real, pio_seterrorhandling use pio , only : pio_setframe, pio_unlimited, pio_write, pio_write_darray, var_desc_t use pio , only : pio_iotask_rank, PIO_REARR_SUBSET, PIO_REARR_BOX - use pio , only : pio_inq_vartype, pio_real, pio_syncfile + use pio , only : pio_inq_vartype, pio_real use array_utils , only : convert_to_logical ! ! !PUBLIC TYPES: @@ -72,7 +72,6 @@ module ncdio_pio public :: ncd_inqvdlen ! inquire variable dimension size public :: ncd_inqvdname ! inquire variable dimension name public :: ncd_io ! write local data - public :: ncd_pio_syncfile ! flush file contents to disk integer,parameter,public :: ncd_int = pio_int integer,parameter,public :: ncd_log =-pio_int @@ -2740,9 +2739,4 @@ contains end subroutine ncd_getiodesc - subroutine ncd_pio_syncfile(ncid) - type(file_desc_t) :: ncid - call pio_syncfile(ncid) - end subroutine ncd_pio_syncfile - end module ncdio_pio From 93dc54abd8a68b85f15e85766695d8c3bba3320c Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Fri, 13 Nov 2020 07:58:07 -0700 Subject: [PATCH 30/39] move nuopc share code build to csm_share library --- cime_config/buildlib | 2 -- 1 file changed, 2 deletions(-) diff --git a/cime_config/buildlib b/cime_config/buildlib index f4baea01a0..a6dab8210c 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -121,8 +121,6 @@ def _main_func(): os.path.join(lnd_root,"src","fates","parteh"), os.path.join(lnd_root,"src","utils"), os.path.join(lnd_root,"src","cpl")] - if driver == 'nuopc': - paths.append(os.path.join(cimeroot,"src","drivers","nuopc","nuopc_cap_share")) if lilac_mode == 'on': paths.append(os.path.join(lnd_root,"lilac","src")) From f8131bc98051475bbbec6e23b612f0c0a273f276 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 13 Nov 2020 14:17:35 -0700 Subject: [PATCH 31/39] Add comments --- src/biogeophys/SoilMoistureStreamMod.F90 | 9 +++++++++ src/cpl/nuopc/SoilMoistureStreamMod.F90 | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/biogeophys/SoilMoistureStreamMod.F90 b/src/biogeophys/SoilMoistureStreamMod.F90 index c276f7f826..edca4150f8 100644 --- a/src/biogeophys/SoilMoistureStreamMod.F90 +++ b/src/biogeophys/SoilMoistureStreamMod.F90 @@ -1,5 +1,14 @@ module SoilMoistureStreamMod + ! ********************************************************************** + ! --------------------------- IMPORTANT NOTE --------------------------- + ! + ! In cases using the NUOPC driver/mediator, we use a different version of this module, + ! based on CDEPS, which resides in src/cpl/nuopc/. Changes to the science here should + ! also be made in the similar file in src/cpl/nuopc. Once we start using CDEPS by + ! default, we can remove this version and move the CDEPS-based version into its place. + ! ********************************************************************** + #include "shr_assert.h" !----------------------------------------------------------------------- diff --git a/src/cpl/nuopc/SoilMoistureStreamMod.F90 b/src/cpl/nuopc/SoilMoistureStreamMod.F90 index d8ea3b5fe9..3c6b23a0aa 100644 --- a/src/cpl/nuopc/SoilMoistureStreamMod.F90 +++ b/src/cpl/nuopc/SoilMoistureStreamMod.F90 @@ -1,5 +1,15 @@ module SoilMoistureStreamMod + ! ********************************************************************** + ! --------------------------- IMPORTANT NOTE --------------------------- + ! + ! This file is here temporarily in order to exercise the CDEPS stream code for this 3-d + ! stream. In cases using the NUOPC driver/mediator, this version is used instead of the + ! version in src/biogeophys. Changes to the science here should also be made in the + ! similar file in src/biogeophys. Once we start using CDEPS by default, we can remove + ! the version in src/biogeophys and move this version into there. + ! ********************************************************************** + #include "shr_assert.h" !----------------------------------------------------------------------- From 7ddec31d337ccd714f8b1cdf7605633d310c7173 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 13 Nov 2020 14:21:25 -0700 Subject: [PATCH 32/39] Remove OMP CRITICAL block in clm_ptrs_check Jim Edwards added this earlier on this branch, but I don't think it's actually needed. --- src/main/initSubgridMod.F90 | 45 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/initSubgridMod.F90 b/src/main/initSubgridMod.F90 index 7cabcdbbda..43851c337b 100644 --- a/src/main/initSubgridMod.F90 +++ b/src/main/initSubgridMod.F90 @@ -13,10 +13,10 @@ module initSubgridMod use clm_varctl , only : iulog, use_fates use clm_varcon , only : namep, namec, namel use decompMod , only : bounds_type - use GridcellType , only : grc - use LandunitType , only : lun - use ColumnType , only : col - use PatchType , only : patch + use GridcellType , only : grc + use LandunitType , only : lun + use ColumnType , only : col + use PatchType , only : patch use column_varcon , only : is_hydrologically_active ! ! !PUBLIC TYPES: @@ -37,27 +37,27 @@ module initSubgridMod !----------------------------------------------------------------------- contains - + !------------------------------------------------------------------------------ subroutine clm_ptrs_compdown(bounds) ! ! !DESCRIPTION: - ! Assumes the part of the subgrid pointing up has been set. Fills + ! Assumes the part of the subgrid pointing up has been set. Fills ! in the data pointing down. Up is p_c, p_l, p_g, c_l, c_g, and l_g. ! ! This algorithm assumes all indices besides grid cell are monotonically ! increasing. (Note that grid cell index is NOT monotonically increasing, - ! hence we cannot set initial & final indices at the grid cell level - + ! hence we cannot set initial & final indices at the grid cell level - ! grc%luni, grc%lunf, etc.) ! ! Algorithm works as follows. The p, c, and l loops march through ! the full arrays (nump, numc, and numl) checking the "up" indexes. - ! As soon as the "up" index of the current (p,c,l) cell changes relative - ! to the previous (p,c,l) cell, the *i array will be set to point down + ! As soon as the "up" index of the current (p,c,l) cell changes relative + ! to the previous (p,c,l) cell, the *i array will be set to point down ! to that cell. The *f array follows the same logic, so it's always the ! last "up" index from the previous cell when an "up" index changes. ! - ! For example, a case where p_c(1:4) = 1 and p_c(5:12) = 2. This + ! For example, a case where p_c(1:4) = 1 and p_c(5:12) = 2. This ! subroutine will set c_pi(1) = 1, c_pf(1) = 4, c_pi(2) = 5, c_pf(2) = 12. ! ! !USES @@ -79,7 +79,7 @@ subroutine clm_ptrs_compdown(bounds) !--- Loop p through full local begp:endp length !--- Separately check the p_c, p_l, and p_g indexes for a change in !--- the "up" index. - !--- If there is a change, verify that the current c,l,g is within the + !--- If there is a change, verify that the current c,l,g is within the !--- valid range, and set c_pi, l_pi, or g_pi to that current c,l,g !--- Constantly update the c_pf, l_pf, and g_pf array. When the !--- g, l, c index changes, the *_pf array will be set correctly @@ -167,7 +167,7 @@ subroutine clm_ptrs_check(bounds) integer :: ltype ! landunit type logical :: error ! error flag !------------------------------------------------------------------------------ -!$OMP CRITICAL + associate( & begg => bounds%begg, & endg => bounds%endg, & @@ -178,8 +178,10 @@ subroutine clm_ptrs_check(bounds) begp => bounds%begp, & endp => bounds%endp & ) + if (masterproc) write(iulog,*) ' ' if (masterproc) write(iulog,*) '---clm_ptrs_check:' + !--- check index ranges --- error = .false. do g = begg, endg @@ -190,12 +192,12 @@ subroutine clm_ptrs_check(bounds) end if end do end do - if (error) then write(iulog,*) ' clm_ptrs_check: g index ranges - ERROR' call endrun(msg=errMsg(sourcefile, __LINE__)) end if if (masterproc) write(iulog,*) ' clm_ptrs_check: g index ranges - OK' + error = .false. if (minval(lun%gridcell(begl:endl)) < begg .or. maxval(lun%gridcell(begl:endl)) > endg) error=.true. if (minval(lun%coli(begl:endl)) < begc .or. maxval(lun%coli(begl:endl)) > endc) error=.true. @@ -284,6 +286,7 @@ subroutine clm_ptrs_check(bounds) endif enddo if (masterproc) write(iulog,*) ' clm_ptrs_check: p mono increasing - OK' + !--- check that the tree is internally consistent --- error = .false. do g = begg, endg @@ -320,9 +323,9 @@ subroutine clm_ptrs_check(bounds) enddo ! g if (masterproc) write(iulog,*) ' clm_ptrs_check: tree consistent - OK' if (masterproc) write(iulog,*) ' ' - end associate -!$OMP END CRITICAL + end associate + end subroutine clm_ptrs_check !----------------------------------------------------------------------- @@ -343,10 +346,10 @@ subroutine add_landunit(li, gi, ltype, wtgcell) real(r8) , intent(in) :: wtgcell ! weight of the landunit relative to the grid cell ! ! !LOCAL VARIABLES: - + character(len=*), parameter :: subname = 'add_landunit' !----------------------------------------------------------------------- - + li = li + 1 lun%gridcell(li) = gi @@ -439,10 +442,10 @@ subroutine add_patch(pi, ci, ptype, wtcol) ! !LOCAL VARIABLES: integer :: li ! landunit index integer :: lb_offset ! offset between natpft_lb and 1 - + character(len=*), parameter :: subname = 'add_patch' !----------------------------------------------------------------------- - + pi = pi + 1 patch%column(pi) = ci @@ -453,7 +456,7 @@ subroutine add_patch(pi, ci, ptype, wtcol) patch%wtcol(pi) = wtcol ! TODO (MV, 10-17-14): The following must be commented out because - ! currently patch%itype is used in CanopyTemperatureMod to calculate + ! currently patch%itype is used in CanopyTemperatureMod to calculate ! z0m(p) and displa(p) - and is still called even when fates is on !if (.not. use_fates) then @@ -466,7 +469,7 @@ subroutine add_patch(pi, ci, ptype, wtcol) else patch%mxy(pi) = ispval end if - + end subroutine add_patch From 07045ffa92a1241b9750fd98d586a23d22b29b7d Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 13 Nov 2020 14:58:06 -0700 Subject: [PATCH 33/39] Update cime --- Externals.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals.cfg b/Externals.cfg index d1f7704306..14e9df1799 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -44,7 +44,7 @@ required = True local_path = cime protocol = git repo_url = https://github.com/ESMCI/cime -tag = branch_tags/cime5.8.32_a01 +tag = branch_tags/cime5.8.32_a02 externals = ../Externals_cime.cfg required = True From c61920a6bdefff572609cd3e1672f1eb3784326b Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 13 Nov 2020 15:02:22 -0700 Subject: [PATCH 34/39] Remove Externals_cime.cfg Move cmeps into main Externals.cfg --- Externals.cfg | 22 ++++++++++++++-------- Externals_cime.cfg | 9 --------- 2 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 Externals_cime.cfg diff --git a/Externals.cfg b/Externals.cfg index 14e9df1799..f57280c888 100644 --- a/Externals.cfg +++ b/Externals.cfg @@ -33,19 +33,25 @@ repo_url = https://github.com/nmizukami/mizuRoute hash = 34723c2 required = True -[cdeps] -hash = 45b7a85 -protocol = git -repo_url = https://github.com/ESCOMP/CDEPS.git -local_path = components/cdeps -required = True - [cime] local_path = cime protocol = git repo_url = https://github.com/ESMCI/cime tag = branch_tags/cime5.8.32_a02 -externals = ../Externals_cime.cfg +required = True + +[cmeps] +local_path = cime/src/drivers/nuopc/ +protocol = git +repo_url = https://github.com/ESCOMP/CMEPS.git +hash = 7654038 +required = True + +[cdeps] +local_path = components/cdeps +protocol = git +repo_url = https://github.com/ESCOMP/CDEPS.git +hash = 45b7a85 required = True [doc-builder] diff --git a/Externals_cime.cfg b/Externals_cime.cfg deleted file mode 100644 index a4ef9d88e8..0000000000 --- a/Externals_cime.cfg +++ /dev/null @@ -1,9 +0,0 @@ -[cmeps] -hash = 7654038 -protocol = git -repo_url = https://github.com/ESCOMP/CMEPS.git -local_path = src/drivers/nuopc/ -required = True - -[externals_description] -schema_version = 1.0.0 From 555242546213691a00e4ee86725a4d7866e8f03d Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Fri, 13 Nov 2020 15:07:11 -0700 Subject: [PATCH 35/39] Squashed 'manage_externals/' changes from c33a3bd2a..39ad53263 39ad53263 Merge pull request #150 from gold2718/fix_combo_config 75f8f02f5 Merge pull request #152 from jedwards4b/sort_by_local_path 42687bd53 remove commented code 29e26af81 fix pylint issues 7c9f3c613 add a test for nested repo checkout 75c5353d2 fix spacing 24a3726a1 improve sorting, checkout externals with each comp 29f45b086 remove py2 test and fix super call 880a4e765 remove decode 1c53be854 no need for set call 36c56dbac simplier fix for issue dc67cc682 simpler solution b32c6fca9 fix to allow submodule name different from path 5b5e1c2b0 Merge pull request #144 from billsacks/improve_errmsg c983863c4 Add another option for dealing with modified externals 59ce252cf Add some details to the error message when externals are modified be5a1a4d7 Merge pull request #143 from jedwards4b/add_exclude 2aa014a1b fix lint issue 49cd5e890 fix lint issues 418173ffd Added tests for ExternalsDescriptionDict afab352c8 fix lint issue be85b7d1b fix the test a580a570b push test d43710864 add a test 21affe33c fix formatting issue 72e6b64ae add an exclude option git-subtree-dir: manage_externals git-subtree-split: 39ad532636944b8e759ad9e56ef5f453aaea81f0 --- .gitignore | 3 + .travis.yml | 3 +- manic/checkout.py | 33 ++++-- manic/externals_description.py | 41 +++++-- manic/sourcetree.py | 16 +-- test/test_sys_checkout.py | 151 ++++++++++++++++++++++-- test/test_unit_externals_description.py | 77 ++++++++++++ 7 files changed, 280 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 411de5d96e..a71ac0cd75 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,6 @@ components/ # generated python files *.pyc + +# test tmp file +test/tmp diff --git a/.travis.yml b/.travis.yml index 1990cb9604..d9b24c584d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python os: linux -python: - - "2.7" +python: - "3.4" - "3.5" - "3.6" diff --git a/manic/checkout.py b/manic/checkout.py index edc5655954..8dd1798d7a 100755 --- a/manic/checkout.py +++ b/manic/checkout.py @@ -279,6 +279,9 @@ def commandline_arguments(args=None): help='The externals description filename. ' 'Default: %(default)s.') + parser.add_argument('-x', '--exclude', nargs='*', + help='Component(s) listed in the externals file which should be ignored.') + parser.add_argument('-o', '--optional', action='store_true', default=False, help='By default only the required externals ' 'are checked out. This flag will also checkout the ' @@ -362,7 +365,7 @@ def main(args): root_dir = os.path.abspath(os.getcwd()) external_data = read_externals_description_file(root_dir, args.externals) external = create_externals_description( - external_data, components=args.components) + external_data, components=args.components, exclude=args.exclude) for comp in args.components: if comp not in external.keys(): @@ -377,29 +380,37 @@ def main(args): if args.status: # user requested status-only - for comp in sorted(tree_status.keys()): + for comp in sorted(tree_status): tree_status[comp].log_status_message(args.verbose) else: # checkout / update the external repositories. safe_to_update = check_safe_to_update_repos(tree_status) if not safe_to_update: # print status - for comp in sorted(tree_status.keys()): + for comp in sorted(tree_status): tree_status[comp].log_status_message(args.verbose) # exit gracefully msg = """The external repositories labeled with 'M' above are not in a clean state. -The following are two options for how to proceed: +The following are three options for how to proceed: -(1) Go into each external that is not in a clean state and issue either - an 'svn status' or a 'git status' command. Either revert or commit - your changes so that all externals are in a clean state. (Note, - though, that it is okay to have untracked files in your working +(1) Go into each external that is not in a clean state and issue either a 'git status' or + an 'svn status' command (depending on whether the external is managed by git or + svn). Either revert or commit your changes so that all externals are in a clean + state. (To revert changes in git, follow the instructions given when you run 'git + status'.) (Note, though, that it is okay to have untracked files in your working directory.) Then rerun {program_name}. -(2) Alternatively, you do not have to rely on {program_name}. Instead, you - can manually update out-of-sync externals (labeled with 's' above) - as described in the configuration file {config_file}. +(2) Alternatively, you do not have to rely on {program_name}. Instead, you can manually + update out-of-sync externals (labeled with 's' above) as described in the + configuration file {config_file}. (For example, run 'git fetch' and 'git checkout' + commands to checkout the appropriate tags for each external, as given in + {config_file}.) + +(3) You can also use {program_name} to manage most, but not all externals: You can specify + one or more externals to ignore using the '-x' or '--exclude' argument to + {program_name}. Excluding externals labeled with 'M' will allow {program_name} to + update the other, non-excluded externals. The external repositories labeled with '?' above are not under version diff --git a/manic/externals_description.py b/manic/externals_description.py index bd644c9814..918d616e37 100644 --- a/manic/externals_description.py +++ b/manic/externals_description.py @@ -253,9 +253,21 @@ def read_gitmodules_file(root_dir, file_name): ExternalsDescription.REPO_URL, url) externals_description.set(sec_name, ExternalsDescription.REQUIRED, 'True') - git_hash = submods[sec_name]['hash'] - externals_description.set(sec_name, - ExternalsDescription.HASH, git_hash) + if sec_name in submods: + submod_name = sec_name + else: + # The section name does not have to match the path + submod_name = path + + if submod_name in submods: + git_hash = submods[submod_name]['hash'] + externals_description.set(sec_name, + ExternalsDescription.HASH, + git_hash) + else: + emsg = "submodule status has no section, '{}'" + emsg += "\nCheck section names in externals config file" + fatal_error(emsg.format(submod_name)) # Required items externals_description.add_section(DESCRIPTION_SECTION) @@ -264,18 +276,18 @@ def read_gitmodules_file(root_dir, file_name): return externals_description def create_externals_description( - model_data, model_format='cfg', components=None, parent_repo=None): + model_data, model_format='cfg', components=None, exclude=None, parent_repo=None): """Create the a externals description object from the provided data """ externals_description = None if model_format == 'dict': externals_description = ExternalsDescriptionDict( - model_data, components=components) + model_data, components=components, exclude=exclude) elif model_format == 'cfg': major, _, _ = get_cfg_schema_version(model_data) if major == 1: externals_description = ExternalsDescriptionConfigV1( - model_data, components=components, parent_repo=parent_repo) + model_data, components=components, exclude=exclude, parent_repo=parent_repo) else: msg = ('Externals description file has unsupported schema ' 'version "{0}".'.format(major)) @@ -710,7 +722,7 @@ class ExternalsDescriptionDict(ExternalsDescription): """ - def __init__(self, model_data, components=None): + def __init__(self, model_data, components=None, exclude=None): """Parse a native dictionary into a externals description. """ ExternalsDescription.__init__(self) @@ -722,10 +734,15 @@ def __init__(self, model_data, components=None): self._input_patch = 0 self._verify_schema_version() if components: - for key in model_data.items(): + for key in list(model_data.keys()): if key not in components: del model_data[key] + if exclude: + for key in list(model_data.keys()): + if key in exclude: + del model_data[key] + self.update(model_data) self._check_user_input() @@ -736,7 +753,7 @@ class ExternalsDescriptionConfigV1(ExternalsDescription): """ - def __init__(self, model_data, components=None, parent_repo=None): + def __init__(self, model_data, components=None, exclude=None, parent_repo=None): """Convert the config data into a standardized dict that can be used to construct the source objects @@ -749,7 +766,7 @@ def __init__(self, model_data, components=None, parent_repo=None): get_cfg_schema_version(model_data) self._verify_schema_version() self._remove_metadata(model_data) - self._parse_cfg(model_data, components=components) + self._parse_cfg(model_data, components=components, exclude=exclude) self._check_user_input() @staticmethod @@ -761,7 +778,7 @@ def _remove_metadata(model_data): """ model_data.remove_section(DESCRIPTION_SECTION) - def _parse_cfg(self, cfg_data, components=None): + def _parse_cfg(self, cfg_data, components=None, exclude=None): """Parse a config_parser object into a externals description. """ def list_to_dict(input_list, convert_to_lower_case=True): @@ -778,7 +795,7 @@ def list_to_dict(input_list, convert_to_lower_case=True): for section in cfg_data.sections(): name = config_string_cleaner(section.lower().strip()) - if components and name not in components: + if (components and name not in components) or (exclude and name in exclude): continue self[name] = {} self[name].update(list_to_dict(cfg_data.items(section))) diff --git a/manic/sourcetree.py b/manic/sourcetree.py index b9c9c21082..54de763c30 100644 --- a/manic/sourcetree.py +++ b/manic/sourcetree.py @@ -331,12 +331,14 @@ def checkout(self, verbosity, load_all, load_comp=None): printlog('Checking out externals: ', end='') if load_all: - load_comps = self._all_components.keys() + tmp_comps = self._all_components.keys() elif load_comp is not None: - load_comps = [load_comp] + tmp_comps = [load_comp] else: - load_comps = self._required_compnames - + tmp_comps = self._required_compnames + # Sort by path so that if paths are nested the + # parent repo is checked out first. + load_comps = sorted(tmp_comps, key=lambda comp: self._all_components[comp].get_local_path()) # checkout the primary externals for comp in load_comps: if verbosity < VERBOSITY_VERBOSE: @@ -346,8 +348,6 @@ def checkout(self, verbosity, load_all, load_comp=None): # output a newline printlog(EMPTY_STR) self._all_components[comp].checkout(verbosity, load_all) - printlog('') - - # now give each external an opportunitity to checkout it's externals. - for comp in load_comps: + # now give each external an opportunitity to checkout it's externals. self._all_components[comp].checkout_externals(verbosity, load_all) + printlog('') diff --git a/test/test_sys_checkout.py b/test/test_sys_checkout.py index df726f2b70..118bee5308 100644 --- a/test/test_sys_checkout.py +++ b/test/test_sys_checkout.py @@ -38,6 +38,7 @@ import os import os.path import shutil +import sys import unittest from manic.externals_description import ExternalsDescription @@ -85,6 +86,8 @@ CFG_SUB_NAME = 'sub-externals.cfg' README_NAME = 'readme.txt' REMOTE_BRANCH_FEATURE2 = 'feature2' +NESTED_NAME = ['./fred', './fred/wilma', './fred/wilma/barney'] + SVN_TEST_REPO = 'https://github.com/escomp/cesm' @@ -160,6 +163,23 @@ def container_simple_required(self, dest_dir): self.write_config(dest_dir) + def container_nested_required(self, dest_dir, order): + """Create a container externals file with only simple externals. + + """ + self.create_config() + self.create_section(SIMPLE_REPO_NAME, 'simp_tag', nested=True, + tag='tag1', path=NESTED_NAME[order[0]]) + + self.create_section(SIMPLE_REPO_NAME, 'simp_branch', nested=True, + branch=REMOTE_BRANCH_FEATURE2, path=NESTED_NAME[order[1]]) + + self.create_section(SIMPLE_REPO_NAME, 'simp_hash', nested=True, + ref_hash='60b1cc1a38d63', path=NESTED_NAME[order[2]]) + + self.write_config(dest_dir) + + def container_simple_optional(self, dest_dir): """Create a container externals file with optional simple externals @@ -261,7 +281,7 @@ def create_metadata(self): def create_section(self, repo_type, name, tag='', branch='', ref_hash='', required=True, path=EXTERNALS_NAME, externals='', repo_path=None, from_submodule=False, - sparse=''): + sparse='', nested=False): # pylint: disable=too-many-branches """Create a config section with autofilling some items and handling optional items. @@ -270,8 +290,11 @@ def create_section(self, repo_type, name, tag='', branch='', # pylint: disable=R0913 self._config.add_section(name) if not from_submodule: - self._config.set(name, ExternalsDescription.PATH, - os.path.join(path, name)) + if nested: + self._config.set(name, ExternalsDescription.PATH, path) + else: + self._config.set(name, ExternalsDescription.PATH, + os.path.join(path, name)) self._config.set(name, ExternalsDescription.PROTOCOL, ExternalsDescription.PROTOCOL_GIT) @@ -535,12 +558,26 @@ def setUp(self): self._test_id = self.id().split('.')[-1] + # find root + if os.path.exists(os.path.join(os.getcwd(), 'checkout_externals')): + root_dir = os.path.abspath(os.getcwd()) + else: + # maybe we are in a subdir, search up + root_dir = os.path.abspath(os.path.join(os.getcwd(), os.pardir)) + while os.path.basename(root_dir): + if os.path.exists(os.path.join(root_dir, 'checkout_externals')): + break + root_dir = os.path.dirname(root_dir) + + if not os.path.exists(os.path.join(root_dir, 'checkout_externals')): + raise RuntimeError('Cannot find checkout_externals') + # path to the executable - self._checkout = os.path.join('../checkout_externals') - self._checkout = os.path.abspath(self._checkout) + self._checkout = os.path.join(root_dir, 'checkout_externals') # directory where we have test repositories - self._bare_root = os.path.join(os.getcwd(), BARE_REPO_ROOT_NAME) + test_dir = os.path.join(root_dir, 'test') + self._bare_root = os.path.join(test_dir, BARE_REPO_ROOT_NAME) self._bare_root = os.path.abspath(self._bare_root) # set into the environment so var will be expanded in externals files @@ -671,10 +708,16 @@ def _check_simple_tag_empty(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_tag'.format(directory) self._check_generic_empty_default_required(tree, name) + def _check_nested_tag_empty(self, tree, name=EXTERNALS_NAME): + self._check_generic_empty_default_required(tree, name) + def _check_simple_tag_ok(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_tag'.format(directory) self._check_generic_ok_clean_required(tree, name) + def _check_nested_tag_ok(self, tree, name=EXTERNALS_NAME): + self._check_generic_ok_clean_required(tree, name) + def _check_simple_tag_dirty(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_tag'.format(directory) self._check_generic_ok_dirty_required(tree, name) @@ -687,10 +730,16 @@ def _check_simple_branch_empty(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_branch'.format(directory) self._check_generic_empty_default_required(tree, name) + def _check_nested_branch_empty(self, tree, name=EXTERNALS_NAME): + self._check_generic_empty_default_required(tree, name) + def _check_simple_branch_ok(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_branch'.format(directory) self._check_generic_ok_clean_required(tree, name) + def _check_nested_branch_ok(self, tree, name=EXTERNALS_NAME): + self._check_generic_ok_clean_required(tree, name) + def _check_simple_branch_modified(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_branch'.format(directory) self._check_generic_modified_ok_required(tree, name) @@ -699,10 +748,16 @@ def _check_simple_hash_empty(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_hash'.format(directory) self._check_generic_empty_default_required(tree, name) + def _check_nested_hash_empty(self, tree, name=EXTERNALS_NAME): + self._check_generic_empty_default_required(tree, name) + def _check_simple_hash_ok(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_hash'.format(directory) self._check_generic_ok_clean_required(tree, name) + def _check_nested_hash_ok(self, tree, name=EXTERNALS_NAME): + self._check_generic_ok_clean_required(tree, name) + def _check_simple_hash_modified(self, tree, directory=EXTERNALS_NAME): name = './{0}/simp_hash'.format(directory) self._check_generic_modified_ok_required(tree, name) @@ -754,6 +809,12 @@ def _check_container_simple_required_pre_checkout(self, overall, tree): self._check_simple_branch_empty(tree) self._check_simple_hash_empty(tree) + def _check_container_nested_required_pre_checkout(self, overall, tree, order): + self.assertEqual(overall, 0) + self._check_nested_tag_empty(tree, name=NESTED_NAME[order[0]]) + self._check_nested_branch_empty(tree, name=NESTED_NAME[order[1]]) + self._check_nested_hash_empty(tree, name=NESTED_NAME[order[2]]) + def _check_container_simple_required_checkout(self, overall, tree): # Note, this is the internal tree status just before checkout self.assertEqual(overall, 0) @@ -761,12 +822,25 @@ def _check_container_simple_required_checkout(self, overall, tree): self._check_simple_branch_empty(tree) self._check_simple_hash_empty(tree) + def _check_container_nested_required_checkout(self, overall, tree, order): + # Note, this is the internal tree status just before checkout + self.assertEqual(overall, 0) + self._check_nested_tag_empty(tree, name=NESTED_NAME[order[0]]) + self._check_nested_branch_empty(tree, name=NESTED_NAME[order[1]]) + self._check_nested_hash_empty(tree, name=NESTED_NAME[order[2]]) + def _check_container_simple_required_post_checkout(self, overall, tree): self.assertEqual(overall, 0) self._check_simple_tag_ok(tree) self._check_simple_branch_ok(tree) self._check_simple_hash_ok(tree) + def _check_container_nested_required_post_checkout(self, overall, tree, order): + self.assertEqual(overall, 0) + self._check_nested_tag_ok(tree, name=NESTED_NAME[order[0]]) + self._check_nested_branch_ok(tree, name=NESTED_NAME[order[1]]) + self._check_nested_hash_ok(tree, name=NESTED_NAME[order[2]]) + def _check_container_simple_required_out_of_sync(self, overall, tree): self.assertEqual(overall, 0) self._check_simple_tag_modified(tree) @@ -819,10 +893,15 @@ def _check_container_component_post_checkout(self, overall, tree): def _check_container_component_post_checkout2(self, overall, tree): self.assertEqual(overall, 0) - self._check_simple_opt_ok(tree) self._check_simple_tag_empty(tree) self._check_simple_branch_ok(tree) + def _check_container_component_post_checkout3(self, overall, tree): + self.assertEqual(overall, 0) + self.assertFalse("simp_opt" in tree) + self._check_simple_tag_ok(tree) + self._check_simple_branch_ok(tree) + def _check_container_full_post_checkout(self, overall, tree): self.assertEqual(overall, 0) self._check_simple_tag_ok(tree) @@ -959,6 +1038,37 @@ def test_container_simple_required(self): self.status_args) self._check_container_simple_required_post_checkout(overall, tree) + def test_container_nested_required(self): + """Verify that a container with nested subrepos + generates the correct initial status. + Tests over all possible permutations + """ + + orders = [[0, 1, 2], [1, 2, 0], [2, 0, 1], + [0, 2, 1], [2, 1, 0], [1, 0, 2]] + for n, order in enumerate(orders): + # create repo + dest_dir = os.path.join(os.environ[MANIC_TEST_TMP_REPO_ROOT], + self._test_id, "test"+str(n)) + under_test_dir = self.setup_test_repo(CONTAINER_REPO_NAME, + dest_dir_in=dest_dir) + self._generator.container_nested_required(under_test_dir, order) + + # status of empty repo + overall, tree = self.execute_cmd_in_dir(under_test_dir, + self.status_args) + self._check_container_nested_required_pre_checkout(overall, tree, order) + + # checkout + overall, tree = self.execute_cmd_in_dir(under_test_dir, + self.checkout_args) + self._check_container_nested_required_checkout(overall, tree, order) + + # status clean checked out + overall, tree = self.execute_cmd_in_dir(under_test_dir, + self.status_args) + self._check_container_nested_required_post_checkout(overall, tree, order) + def test_container_simple_optional(self): """Verify that container with an optional simple subrepos generates the correct initial status. @@ -1347,6 +1457,23 @@ def test_container_component(self): self.status_args) self._check_container_component_post_checkout2(overall, tree) + def test_container_exclude_component(self): + """Verify that exclude component checkout works + """ + # create the test repository + under_test_dir = self.setup_test_repo(CONTAINER_REPO_NAME) + + # create the top level externals file + self._generator.container_full(under_test_dir) + + # inital checkout, exclude simp_opt + checkout_args = ['--exclude', 'simp_opt'] + checkout_args.extend(self.checkout_args) + overall, tree = self.execute_cmd_in_dir(under_test_dir, checkout_args) + checkout_args.append("--status") + overall, tree = self.execute_cmd_in_dir(under_test_dir, checkout_args) + self._check_container_component_post_checkout3(overall, tree) + def test_mixed_simple(self): """Verify that a mixed use repo can serve as a 'full' container, pulling in a set of externals and a seperate set of sub-externals. @@ -1569,7 +1696,7 @@ def setUp(self): """ # Run the basic setup - super(TestSubrepoCheckout, self).setUp() + super().setUp() # create test repo # We need to do this here (rather than have a static repo) because # git submodules do not allow for variables in .gitmodules files @@ -1588,8 +1715,9 @@ def setUp(self): cwd = os.getcwd() fork_repo_dir = os.path.join(self._bare_root, SIMPLE_FORK_NAME) simple_repo_dir = os.path.join(self._bare_root, SIMPLE_REPO_NAME) - self._simple_ext_fork_name = SIMPLE_FORK_NAME.split('.')[0] - self._simple_ext_name = SIMPLE_REPO_NAME.split('.')[0] + self._simple_ext_fork_name = os.path.splitext(SIMPLE_FORK_NAME)[0] + self._simple_ext_name = os.path.join('sourc', + os.path.splitext(SIMPLE_REPO_NAME)[0]) os.chdir(self._repo_dir) # Add a branch with a subrepo cmd = ['git', 'branch', self._bare_branch_name, 'master'] @@ -1610,7 +1738,8 @@ def setUp(self): execute_subprocess(cmd) cmd = ['git', 'checkout', self._config_branch_name] execute_subprocess(cmd) - cmd = ['git', 'submodule', 'add', simple_repo_dir] + cmd = ['git', 'submodule', 'add', '--name', SIMPLE_REPO_NAME, + simple_repo_dir, self._simple_ext_name] execute_subprocess(cmd) # Checkout feature2 os.chdir(self._simple_ext_name) diff --git a/test/test_unit_externals_description.py b/test/test_unit_externals_description.py index 637f760ee5..0b1248f670 100644 --- a/test/test_unit_externals_description.py +++ b/test/test_unit_externals_description.py @@ -342,6 +342,40 @@ def setup_config(self): # NOTE(goldy, 2019-03) Should test other possible keywords such as # fetchRecurseSubmodules, ignore, and shallow + @staticmethod + def setup_dict_config(): + """Create the full container dictionary with simple and mixed use + externals + + """ + rdatat = {ExternalsDescription.PROTOCOL: 'git', + ExternalsDescription.REPO_URL: 'simple-ext.git', + ExternalsDescription.TAG: 'tag1'} + rdatab = {ExternalsDescription.PROTOCOL: 'git', + ExternalsDescription.REPO_URL: 'simple-ext.git', + ExternalsDescription.BRANCH: 'feature2'} + rdatam = {ExternalsDescription.PROTOCOL: 'git', + ExternalsDescription.REPO_URL: 'mixed-cont-ext.git', + ExternalsDescription.BRANCH: 'master'} + desc = {'simp_tag': {ExternalsDescription.REQUIRED: True, + ExternalsDescription.PATH: 'simp_tag', + ExternalsDescription.EXTERNALS: EMPTY_STR, + ExternalsDescription.REPO: rdatat}, + 'simp_branch' : {ExternalsDescription.REQUIRED: True, + ExternalsDescription.PATH: 'simp_branch', + ExternalsDescription.EXTERNALS: EMPTY_STR, + ExternalsDescription.REPO: rdatab}, + 'simp_opt': {ExternalsDescription.REQUIRED: False, + ExternalsDescription.PATH: 'simp_opt', + ExternalsDescription.EXTERNALS: EMPTY_STR, + ExternalsDescription.REPO: rdatat}, + 'mixed_req': {ExternalsDescription.REQUIRED: True, + ExternalsDescription.PATH: 'mixed_req', + ExternalsDescription.EXTERNALS: 'sub-ext.cfg', + ExternalsDescription.REPO: rdatam}} + + return desc + def test_cfg_v1_ok(self): """Test that a correct cfg v1 object is created by create_externals_description @@ -379,6 +413,49 @@ def test_dict(self): ext = create_externals_description(desc, model_format='dict') self.assertIsInstance(ext, ExternalsDescriptionDict) + def test_cfg_component_dict(self): + """Verify that create_externals_description works with a dictionary + """ + # create the top level externals file + desc = self.setup_dict_config() + # Check external with all repos + external = create_externals_description(desc, model_format='dict') + self.assertIsInstance(external, ExternalsDescriptionDict) + self.assertTrue('simp_tag' in external) + self.assertTrue('simp_branch' in external) + self.assertTrue('simp_opt' in external) + self.assertTrue('mixed_req' in external) + + def test_cfg_exclude_component_dict(self): + """Verify that exclude component checkout works with a dictionary + """ + # create the top level externals file + desc = self.setup_dict_config() + # Test an excluded repo + external = create_externals_description(desc, model_format='dict', + exclude=['simp_tag', + 'simp_opt']) + self.assertIsInstance(external, ExternalsDescriptionDict) + self.assertFalse('simp_tag' in external) + self.assertTrue('simp_branch' in external) + self.assertFalse('simp_opt' in external) + self.assertTrue('mixed_req' in external) + + def test_cfg_opt_component_dict(self): + """Verify that exclude component checkout works with a dictionary + """ + # create the top level externals file + desc = self.setup_dict_config() + # Test an excluded repo + external = create_externals_description(desc, model_format='dict', + components=['simp_tag', + 'simp_opt']) + self.assertIsInstance(external, ExternalsDescriptionDict) + self.assertTrue('simp_tag' in external) + self.assertFalse('simp_branch' in external) + self.assertTrue('simp_opt' in external) + self.assertFalse('mixed_req' in external) + def test_cfg_unknown_version(self): """Test that a runtime error is raised when an unknown file version is received From 67e4e2eb663fd6e30dd355fc739d9ab6d53cb81d Mon Sep 17 00:00:00 2001 From: Mariana Vertenstein Date: Sun, 15 Nov 2020 14:44:23 -0700 Subject: [PATCH 36/39] For now, don't set element mask when creating mesh file This is needed for mpi-serial tests --- src/cpl/nuopc/lnd_comp_nuopc.F90 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index 8e91d21949..f564646dc8 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -667,9 +667,16 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) mesh = ESMF_MeshCreate(lgrid, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! TODO: is the mask by default set to 1 if created from a grid? ! reset the global mask (which is 1) to the land/ocean mask - call ESMF_MeshSet(mesh, elementMask=mask, rc=rc) - if (ChkErr(rc,__LINE__,u_FILE_u)) return + ! + ! Currently, this call requires that the information has + ! already been added to the mesh during creation. For example, + ! you can only change the element mask information, if the mesh + ! was initially created with element masking. + !!! call ESMF_MeshSet(mesh, elementMask=mask, rc=rc) + !!! if (ChkErr(rc,__LINE__,u_FILE_u)) return + deallocate(mask) else From a5f21555cbd85b5f0af954585faf3c5f7cb432a7 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 16 Nov 2020 08:27:55 -0700 Subject: [PATCH 37/39] fix issue with inst_name --- src/biogeophys/UrbanTimeVarType.F90 | 16 ++++++++-------- src/cpl/mct/lnd_comp_mct.F90 | 5 ++--- src/cpl/nuopc/lnd_comp_nuopc.F90 | 6 +++--- src/main/ncdio_pio.F90.in | 7 ++++--- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/biogeophys/UrbanTimeVarType.F90 b/src/biogeophys/UrbanTimeVarType.F90 index c2d4aac3f3..7a907bb9b9 100644 --- a/src/biogeophys/UrbanTimeVarType.F90 +++ b/src/biogeophys/UrbanTimeVarType.F90 @@ -9,10 +9,10 @@ module UrbanTimeVarType use shr_log_mod , only : errMsg => shr_log_errMsg use abortutils , only : endrun use decompMod , only : bounds_type - use clm_varctl , only : iulog + use clm_varctl , only : iulog, inst_name use landunit_varcon , only : isturb_MIN, isturb_MAX use clm_varcon , only : spval - use LandunitType , only : lun + use LandunitType , only : lun use GridcellType , only : grc use mct_mod use shr_strdata_mod , only : shr_strdata_type @@ -34,10 +34,10 @@ module UrbanTimeVarType procedure, public :: Init ! Allocate and initialize urbantv procedure, public :: urbantv_init ! Initialize urban time varying stream procedure, public :: urbantv_interp ! Interpolate urban time varying stream - + end type urbantv_type - !----------------------------------------------------------------------- + !----------------------------------------------------------------------- character(15), private :: stream_var_name(isturb_MIN:isturb_MAX) character(len=*), parameter, private :: sourcefile = & @@ -56,7 +56,7 @@ subroutine Init(this, bounds, NLFilename) ! ! !ARGUMENTS: class(urbantv_type) :: this - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds character(len=*) , intent(in) :: NLFilename ! Namelist filename ! ! !LOCAL VARIABLES: @@ -116,11 +116,11 @@ subroutine urbantv_init(this, bounds, NLFilename) integer :: ifield ! field index integer :: stream_year_first_urbantv ! first year in urban tv stream to use integer :: stream_year_last_urbantv ! last year in urban tv stream to use - integer :: model_year_align_urbantv ! align stream_year_first_urbantv + integer :: model_year_align_urbantv ! align stream_year_first_urbantv ! with this model year integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_urbantv ! urban tv streams filename character(len=CL) :: urbantvmapalgo = 'nn' ! mapping alogrithm for urban ac character(len=CL) :: urbantv_tintalgo = 'linear' ! time interpolation alogrithm @@ -192,7 +192,7 @@ subroutine urbantv_init(this, bounds, NLFilename) call shr_strdata_create(this%sdat_urbantv,name="clmurbantv", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & diff --git a/src/cpl/mct/lnd_comp_mct.F90 b/src/cpl/mct/lnd_comp_mct.F90 index b5b46ca97e..1ae6b9f6b9 100644 --- a/src/cpl/mct/lnd_comp_mct.F90 +++ b/src/cpl/mct/lnd_comp_mct.F90 @@ -74,7 +74,7 @@ subroutine lnd_init_mct( EClock, cdata_l, x2l_l, l2x_l, NLFilename ) character(len=*), optional, intent(in) :: NLFilename ! Namelist filename to read ! ! !LOCAL VARIABLES: - integer :: LNDID ! Land identifyer + integer :: LNDID ! Land identifyer integer :: mpicom_lnd ! MPI communicator type(mct_gsMap), pointer :: GSMap_lnd ! Land model MCT GS map type(mct_gGrid), pointer :: dom_l ! Land model domain @@ -130,7 +130,6 @@ subroutine lnd_init_mct( EClock, cdata_l, x2l_l, l2x_l, NLFilename ) inst_name = seq_comm_name(LNDID) inst_index = seq_comm_inst(LNDID) inst_suffix = seq_comm_suffix(LNDID) - ! Initialize io log unit call shr_file_getLogUnit (shrlogunit) @@ -430,7 +429,7 @@ subroutine lnd_run_mct(EClock, cdata_l, x2l_l, l2x_l) nstep = get_nstep() caldayp1 = get_curr_calday(offset=dtime) if (nstep == 0) then - doalb = .false. + doalb = .false. else if (nstep == 1) then doalb = (abs(nextsw_cday- caldayp1) < 1.e-10_r8) else diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index 8e91d21949..af583f8c65 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -24,7 +24,7 @@ module lnd_comp_nuopc use domainMod , only : ldomain use controlMod , only : control_setNL use clm_varorb , only : eccen, obliqr, lambm0, mvelpp - use clm_varctl , only : inst_index, inst_suffix + use clm_varctl , only : inst_index, inst_suffix, inst_name use clm_varctl , only : single_column, clm_varctl_set, iulog use clm_varctl , only : nsrStartup, nsrContinue, nsrBranch use clm_varcon , only : re @@ -222,7 +222,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - + inst_name = 'LND' !---------------------------------------------------------------------------- ! advertise fields !---------------------------------------------------------------------------- @@ -366,7 +366,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer, pointer :: gindex(:) ! global index space for land and ocean points integer, pointer :: gindex_lnd(:) ! global index space for just land points integer, pointer :: gindex_ocn(:) ! global index space for just ocean points - integer, pointer :: mask(:) ! local land/ocean mask + integer, pointer :: mask(:) ! local land/ocean mask character(ESMF_MAXSTR) :: cvalue ! config data integer :: nlnd, nocn ! local size ofarrays integer :: g,n ! indices diff --git a/src/main/ncdio_pio.F90.in b/src/main/ncdio_pio.F90.in index 89bcd10836..4b7b75c82e 100644 --- a/src/main/ncdio_pio.F90.in +++ b/src/main/ncdio_pio.F90.in @@ -186,11 +186,12 @@ contains ! ! !USES: use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat + use clm_varctl , only : inst_name !----------------------------------------------------------------------- - PIO_subsystem => shr_pio_getiosys('LND') - io_type = shr_pio_getiotype('LND') - io_netcdf_format = shr_pio_getioformat('LND') + PIO_subsystem => shr_pio_getiosys(inst_name) + io_type = shr_pio_getiotype(inst_name) + io_netcdf_format = shr_pio_getioformat(inst_name) end subroutine ncd_pio_init !----------------------------------------------------------------------- From 451c995f83ee0946e1c7d37fd129088d54d54001 Mon Sep 17 00:00:00 2001 From: Jim Edwards Date: Mon, 16 Nov 2020 08:37:45 -0700 Subject: [PATCH 38/39] replace LND with inst_name --- src/biogeochem/SatellitePhenologyMod.F90 | 62 +++++++++++----------- src/biogeochem/ch4FInundatedStreamType.F90 | 33 ++++++------ src/biogeophys/SoilMoistureStreamMod.F90 | 46 ++++++++-------- src/cpl/nuopc/lnd_comp_nuopc.F90 | 1 + src/main/FireDataBaseType.F90 | 54 +++++++++---------- src/main/ndepStreamMod.F90 | 18 +++---- 6 files changed, 107 insertions(+), 107 deletions(-) diff --git a/src/biogeochem/SatellitePhenologyMod.F90 b/src/biogeochem/SatellitePhenologyMod.F90 index a0fb6d9b24..7b5aea35dd 100644 --- a/src/biogeochem/SatellitePhenologyMod.F90 +++ b/src/biogeochem/SatellitePhenologyMod.F90 @@ -4,8 +4,8 @@ module SatellitePhenologyMod !----------------------------------------------------------------------- ! !DESCRIPTION: - ! CLM Satelitte Phenology model (SP) ecosystem dynamics (phenology, vegetation). - ! Allow some subroutines to be used by the CLM Carbon Nitrogen model (CLMCN) + ! CLM Satelitte Phenology model (SP) ecosystem dynamics (phenology, vegetation). + ! Allow some subroutines to be used by the CLM Carbon Nitrogen model (CLMCN) ! so that DryDeposition code can get estimates of LAI differences between months. ! ! !USES: @@ -18,20 +18,20 @@ module SatellitePhenologyMod use decompMod , only : bounds_type use abortutils , only : endrun use clm_varctl , only : scmlat,scmlon,single_column - use clm_varctl , only : iulog, use_lai_streams + use clm_varctl , only : iulog, use_lai_streams, inst_name use clm_varcon , only : grlnd use controlMod , only : NLFilename use decompMod , only : gsmap_lnd_gdc2glo use domainMod , only : ldomain use fileutils , only : getavu, relavu - use PatchType , only : patch + use PatchType , only : patch use CanopyStateType , only : canopystate_type use WaterDiagnosticBulkType , only : waterdiagnosticbulk_type use perf_mod , only : t_startf, t_stopf use spmdMod , only : masterproc use spmdMod , only : mpicom, comp_id use mct_mod - use ncdio_pio + use ncdio_pio ! ! !PUBLIC TYPES: implicit none @@ -66,7 +66,7 @@ module SatellitePhenologyMod !----------------------------------------------------------------------- contains - + !----------------------------------------------------------------------- ! ! lai_init @@ -95,10 +95,10 @@ subroutine lai_init(bounds) integer :: i ! index integer :: stream_year_first_lai ! first year in Lai stream to use integer :: stream_year_last_lai ! last year in Lai stream to use - integer :: model_year_align_lai ! align stream_year_first_lai with + integer :: model_year_align_lai ! align stream_year_first_lai with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_lai ! lai stream filename to read character(len=CL) :: lai_mapalgo = 'bilinear' ! Mapping alogrithm character(len=CL) :: lai_tintalgo = 'linear' ! Time interpolation alogrithm @@ -153,9 +153,9 @@ subroutine lai_init(bounds) write(iulog,*) ' ' write(iulog,*) 'lai_stream settings:' - write(iulog,*) ' stream_year_first_lai = ',stream_year_first_lai - write(iulog,*) ' stream_year_last_lai = ',stream_year_last_lai - write(iulog,*) ' model_year_align_lai = ',model_year_align_lai + write(iulog,*) ' stream_year_first_lai = ',stream_year_first_lai + write(iulog,*) ' stream_year_last_lai = ',stream_year_last_lai + write(iulog,*) ' model_year_align_lai = ',model_year_align_lai write(iulog,*) ' stream_fldFileName_lai = ',trim(stream_fldFileName_lai) write(iulog,*) ' lai_tintalgo = ',trim(lai_tintalgo) @@ -169,8 +169,8 @@ subroutine lai_init(bounds) fldList = shr_string_listCreateField( numLaiFields, laiString ) call shr_strdata_create(sdat_lai,name="laidyn", & - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -182,7 +182,7 @@ subroutine lai_init(bounds) domFileName=trim(stream_fldFileName_lai), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -215,7 +215,7 @@ subroutine lai_advance( bounds ) ! ! !ARGUMENTS: implicit none - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: g, ig ! Indices @@ -257,7 +257,7 @@ subroutine lai_interp(bounds, canopystate_inst) ! ! !ARGUMENTS: implicit none - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds type(canopystate_type) , intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: @@ -298,7 +298,7 @@ subroutine SatellitePhenologyInit (bounds) use shr_infnan_mod, only : nan => shr_infnan_nan, assignment(=) ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: ier ! error code @@ -341,7 +341,7 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & use pftconMod, only : noveg, nbrdlf_dcd_brl_shrub ! ! !ARGUMENTS: - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds integer , intent(in) :: num_nolakep ! number of column non-lake points in patch filter integer , intent(in) :: filter_nolakep(bounds%endp-bounds%begp+1) ! patch filter for non-lake points type(waterdiagnosticbulk_type) , intent(in) :: waterdiagnosticbulk_inst @@ -354,14 +354,14 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & !----------------------------------------------------------------------- associate( & - frac_sno => waterdiagnosticbulk_inst%frac_sno_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1) - snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m) - tlai => canopystate_inst%tlai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index, no burying by snow + frac_sno => waterdiagnosticbulk_inst%frac_sno_col , & ! Input: [real(r8) (:) ] fraction of ground covered by snow (0 to 1) + snow_depth => waterdiagnosticbulk_inst%snow_depth_col , & ! Input: [real(r8) (:) ] snow height (m) + tlai => canopystate_inst%tlai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index, no burying by snow tsai => canopystate_inst%tsai_patch , & ! Output: [real(r8) (:) ] one-sided stem area index, no burying by snow elai => canopystate_inst%elai_patch , & ! Output: [real(r8) (:) ] one-sided leaf area index with burying by snow esai => canopystate_inst%esai_patch , & ! Output: [real(r8) (:) ] one-sided stem area index with burying by snow - htop => canopystate_inst%htop_patch , & ! Output: [real(r8) (:) ] canopy top (m) - hbot => canopystate_inst%hbot_patch , & ! Output: [real(r8) (:) ] canopy bottom (m) + htop => canopystate_inst%htop_patch , & ! Output: [real(r8) (:) ] canopy top (m) + hbot => canopystate_inst%hbot_patch , & ! Output: [real(r8) (:) ] canopy bottom (m) frac_veg_nosno_alb => canopystate_inst%frac_veg_nosno_alb_patch & ! Output: [integer (:) ] fraction of vegetation not covered by snow (0 OR 1) [-] ) @@ -402,7 +402,7 @@ subroutine SatellitePhenology(bounds, num_nolakep, filter_nolakep, & ! are less than 0.05, set equal to zero to prevent numerical ! problems associated with very small lai and sai. - ! snow burial fraction for short vegetation (e.g. grasses, crops) changes with vegetation height + ! snow burial fraction for short vegetation (e.g. grasses, crops) changes with vegetation height ! accounts for a 20% bending factor, as used in Lombardozzi et al. (2018) GRL 45(18), 9889-9897 ! NOTE: The following snow burial code is duplicated in CNVegStructUpdateMod. @@ -446,7 +446,7 @@ subroutine interpMonthlyVeg (bounds, canopystate_inst) use clm_time_manager, only : get_curr_date, get_step_size_real, get_nstep ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds type(canopystate_type), intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: @@ -504,12 +504,12 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) use shr_scam_mod, only : shr_scam_getCloseLatLon ! ! !ARGUMENTS: - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds type(canopystate_type), intent(inout) :: canopystate_inst ! ! !LOCAL VARIABLES: type(file_desc_t) :: ncid ! netcdf id - real(r8), pointer :: annlai(:,:) ! 12 months of monthly lai from input data set + real(r8), pointer :: annlai(:,:) ! 12 months of monthly lai from input data set real(r8), pointer :: mlai(:,:) ! lai read from input files real(r8):: closelat,closelon ! single column vars integer :: ier ! error code @@ -526,13 +526,13 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) character(len=32) :: subname = 'readAnnualVegetation' !----------------------------------------------------------------------- - annlai => canopystate_inst%annlai_patch + annlai => canopystate_inst%annlai_patch ! Determine necessary indices allocate(mlai(bounds%begg:bounds%endg,0:maxveg), stat=ier) if (ier /= 0) then - write(iulog,*)subname, 'allocation error ' + write(iulog,*)subname, 'allocation error ' call endrun(msg=errMsg(sourcefile, __LINE__)) end if @@ -578,7 +578,7 @@ subroutine readAnnualVegetation (bounds, canopystate_inst) else !! non-vegetated pft annlai(k,p) = 0._r8 end if - end do ! end of loop over patches + end do ! end of loop over patches enddo ! months loop @@ -605,7 +605,7 @@ subroutine readMonthlyVegetation (bounds, & use netcdf ! ! !ARGUMENTS: - type(bounds_type) , intent(in) :: bounds + type(bounds_type) , intent(in) :: bounds character(len=*) , intent(in) :: fveg ! file with monthly vegetation data integer , intent(in) :: months(2) ! months to be interpolated (1 to 12) type(canopystate_type), intent(inout) :: canopystate_inst diff --git a/src/biogeochem/ch4FInundatedStreamType.F90 b/src/biogeochem/ch4FInundatedStreamType.F90 index 12db0528f8..9d38ab8332 100644 --- a/src/biogeochem/ch4FInundatedStreamType.F90 +++ b/src/biogeochem/ch4FInundatedStreamType.F90 @@ -1,16 +1,15 @@ - module ch4FInundatedStreamType #include "shr_assert.h" - !----------------------------------------------------------------------- - ! !DESCRIPTION: + !----------------------------------------------------------------------- + ! !DESCRIPTION: ! Contains methods for reading in finundated streams file for methane code. ! ! !USES use shr_kind_mod , only: r8 => shr_kind_r8, CL => shr_kind_cl use spmdMod , only: mpicom, masterproc - use clm_varctl , only: iulog + use clm_varctl , only: iulog, inst_name use abortutils , only: endrun use decompMod , only: bounds_type use ch4varcon , only: finundation_mtd @@ -60,7 +59,7 @@ module ch4FInundatedStreamType !============================================================================== subroutine Init(this, bounds, NLFilename) - ! + ! ! Initialize the ch4 finundated stream object ! ! Uses: @@ -82,12 +81,12 @@ subroutine Init(this, bounds, NLFilename) ! arguments implicit none class(ch4finundatedstream_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! local variables integer :: ig, g ! Indices - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information type(shr_strdata_type) :: sdat ! input data stream integer :: index_ZWT0 = 0 ! Index of ZWT0 field integer :: index_F0 = 0 ! Index of F0 field @@ -110,8 +109,8 @@ subroutine Init(this, bounds, NLFilename) call clm_domain_mct (bounds, dom_clm) call shr_strdata_create(sdat,name=stream_name,& - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -123,7 +122,7 @@ subroutine Init(this, bounds, NLFilename) domFileName=trim(control%stream_fldFileName_ch4finundated), & domTvarName='time', & domXvarName='LONGXY' , & - domYvarName='LATIXY' , & + domYvarName='LATIXY' , & domAreaName='AREA', & domMaskName='LANDMASK', & filePath='', & @@ -190,7 +189,7 @@ end subroutine Init logical function UseStreams(this) ! ! !DESCRIPTION: - ! Return true if + ! Return true if ! ! !USES: ! @@ -200,9 +199,9 @@ logical function UseStreams(this) ! ! !LOCAL VARIABLES: if ( trim(control%stream_fldFileName_ch4finundated) == '' )then - UseStreams = .false. + UseStreams = .false. else - UseStreams = .true. + UseStreams = .true. end if end function UseStreams @@ -245,7 +244,7 @@ subroutine CalcFinundated(this, bounds, num_soilc, filter_soilc, soilhydrology_i waterdiagnosticbulk_inst, qflx_surf_lag_col, finundated ) ! ! !DESCRIPTION: - ! + ! ! Calculate finundated according to the appropriate methodology ! ! !USES: @@ -311,8 +310,8 @@ end subroutine CalcFinundated !============================================================================== subroutine ReadNML(this, bounds, NLFilename) - ! - ! Read the namelist data stream information. + ! + ! Read the namelist data stream information. ! ! Uses: use clm_time_manager , only : get_calendar @@ -327,7 +326,7 @@ subroutine ReadNML(this, bounds, NLFilename) ! arguments implicit none class(streamcontrol_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! local variables diff --git a/src/biogeophys/SoilMoistureStreamMod.F90 b/src/biogeophys/SoilMoistureStreamMod.F90 index edca4150f8..421d729f0b 100644 --- a/src/biogeophys/SoilMoistureStreamMod.F90 +++ b/src/biogeophys/SoilMoistureStreamMod.F90 @@ -23,7 +23,7 @@ module SoilMoistureStreamMod use shr_log_mod , only : errMsg => shr_log_errMsg use decompMod , only : bounds_type use abortutils , only : endrun - use clm_varctl , only : scmlat,scmlon,single_column + use clm_varctl , only : scmlat,scmlon,single_column, inst_name use clm_varctl , only : iulog, use_soil_moisture_streams use clm_varcon , only : grlnd use controlMod , only : NLFilename @@ -31,14 +31,14 @@ module SoilMoistureStreamMod use domainMod , only : ldomain use fileutils , only : getavu, relavu use LandunitType , only : lun - use ColumnType , only : col + use ColumnType , only : col use SoilStateType , only : soilstate_type use WaterStateBulkType, only : waterstatebulk_type use perf_mod , only : t_startf, t_stopf use spmdMod , only : masterproc use spmdMod , only : mpicom, comp_id use mct_mod - use ncdio_pio + use ncdio_pio ! ! !PUBLIC TYPES: implicit none @@ -54,7 +54,7 @@ module SoilMoistureStreamMod integer :: ism ! Soil moisture steram index integer, allocatable :: g_to_ig(:) ! Array matching gridcell index to data index logical :: soilm_ignore_data_if_missing ! If should ignore overridding a point with soil moisture data - ! from the streams file, if the streams file shows that point + ! from the streams file, if the streams file shows that point ! as missing (namelist item) ! ! !PRIVATE TYPES: @@ -64,7 +64,7 @@ module SoilMoistureStreamMod !----------------------------------------------------------------------- contains - + !----------------------------------------------------------------------- ! ! soil_moisture_init @@ -93,11 +93,11 @@ subroutine PrescribedSoilMoistureInit(bounds) integer :: i ! index integer :: stream_year_first_soilm ! first year in Ustar stream to use integer :: stream_year_last_soilm ! last year in Ustar stream to use - integer :: model_year_align_soilm ! align stream_year_first_soilm with + integer :: model_year_align_soilm ! align stream_year_first_soilm with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag integer :: soilm_offset ! Offset in time for dataset (sec) - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldfilename_soilm ! ustar stream filename to read character(len=CL) :: soilm_tintalgo = 'linear' ! Time interpolation alogrithm @@ -155,9 +155,9 @@ subroutine PrescribedSoilMoistureInit(bounds) write(iulog,*) ' ' write(iulog,*) 'soil_moisture_stream settings:' - write(iulog,*) ' stream_year_first_soilm = ',stream_year_first_soilm - write(iulog,*) ' stream_year_last_soilm = ',stream_year_last_soilm - write(iulog,*) ' model_year_align_soilm = ',model_year_align_soilm + write(iulog,*) ' stream_year_first_soilm = ',stream_year_first_soilm + write(iulog,*) ' stream_year_last_soilm = ',stream_year_last_soilm + write(iulog,*) ' model_year_align_soilm = ',model_year_align_soilm write(iulog,*) ' stream_fldfilename_soilm = ',trim(stream_fldfilename_soilm) write(iulog,*) ' soilm_tintalgo = ',trim(soilm_tintalgo) write(iulog,*) ' soilm_offset = ',soilm_offset @@ -177,10 +177,10 @@ subroutine PrescribedSoilMoistureInit(bounds) fldList = trim(soilmString) if (masterproc) write(iulog,*) 'fieldlist: ', trim(fldList) - + call shr_strdata_create(sdat_soilm,name="soil_moisture", & - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsMap_lnd2Dsoi_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -193,8 +193,8 @@ subroutine PrescribedSoilMoistureInit(bounds) domFileName=trim(stream_fldFileName_soilm), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & - domZvarName='levsoi' , & + domYvarName='lat' , & + domZvarName='levsoi' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -307,7 +307,7 @@ subroutine PrescribedSoilMoistureInterp(bounds, soilstate_inst, & SHR_ASSERT_FL( (lbound(sdat_soilm%avs(1)%rAttr,2) <= g_to_ig(bounds%begg) ), sourcefile, __LINE__) SHR_ASSERT_FL( (ubound(sdat_soilm%avs(1)%rAttr,2) >= g_to_ig(bounds%endg)+(nlevsoi-1)*size(g_to_ig) ), sourcefile, __LINE__) associate( & - dz => col%dz , & ! Input: [real(r8) (:,:) ] layer depth (m) + dz => col%dz , & ! Input: [real(r8) (:,:) ] layer depth (m) watsat => soilstate_inst%watsat_col , & ! Input: [real(r8) (:,:) ] volumetric soil water at saturation (porosity) h2osoi_liq => waterstatebulk_inst%h2osoi_liq_col , & ! Input/Output: [real(r8) (:,:) ] liquid water (kg/m2) h2osoi_ice => waterstatebulk_inst%h2osoi_ice_col , & ! Input/Output: [real(r8) (:,:) ] ice water (kg/m2) @@ -344,7 +344,7 @@ subroutine PrescribedSoilMoistureInterp(bounds, soilstate_inst, & do g = bounds%begg, bounds%endg ig = g_to_ig(g) do j = 1, nlevsoi - + !n = ig + (j-1)*size(g_to_ig) n = ig + (j-1)*size(g_to_ig) @@ -358,28 +358,28 @@ subroutine PrescribedSoilMoistureInterp(bounds, soilstate_inst, & end do end do - + do c = bounds%begc, bounds%endc ! ! Set variable for each gridcell/column combination ! g = col%gridcell(c) ig = g_to_ig(g) - + ! EBK Jan/2020, also check weights on gridcell (See https://github.com/ESCOMP/CTSM/issues/847) if ( (lun%itype(col%landunit(c)) == istsoil) .or. (lun%itype(col%landunit(c)) == istcrop) .and. & (col%wtgcell(c) /= 0._r8) ) then ! this is a 2d field (gridcell/nlevsoi) ! do j = 1, nlevsoi - + n = ig + (j-1)*size(g_to_ig) ! if soil water is zero, liq/ice fractions cannot be calculated if((h2osoi_liq(c, j) + h2osoi_ice(c, j)) > 0._r8) then - + ! save original soil moisture value h2osoi_vol_initial = h2osoi_vol(c,j) - + ! Check if the vegetated land mask from the dataset on the ! file is different if ( (h2osoi_vol_prs(g,j) == spval) .and. (h2osoi_vol_initial /= spval) )then @@ -413,7 +413,7 @@ subroutine PrescribedSoilMoistureInterp(bounds, soilstate_inst, & call endrun(subname // ':: ERROR h2osoil liquid plus ice is zero') endif enddo - endif + endif end do end associate diff --git a/src/cpl/nuopc/lnd_comp_nuopc.F90 b/src/cpl/nuopc/lnd_comp_nuopc.F90 index af583f8c65..112ccd72fa 100644 --- a/src/cpl/nuopc/lnd_comp_nuopc.F90 +++ b/src/cpl/nuopc/lnd_comp_nuopc.F90 @@ -223,6 +223,7 @@ subroutine InitializeAdvertise(gcomp, importState, exportState, clock, rc) call get_component_instance(gcomp, inst_suffix, inst_index, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return inst_name = 'LND' + !---------------------------------------------------------------------------- ! advertise fields !---------------------------------------------------------------------------- diff --git a/src/main/FireDataBaseType.F90 b/src/main/FireDataBaseType.F90 index 1e02033c95..ac7d28171f 100644 --- a/src/main/FireDataBaseType.F90 +++ b/src/main/FireDataBaseType.F90 @@ -11,7 +11,7 @@ module FireDataBaseType use shr_strdata_mod , only : shr_strdata_type, shr_strdata_create, shr_strdata_print use shr_strdata_mod , only : shr_strdata_advance use shr_log_mod , only : errMsg => shr_log_errMsg - use clm_varctl , only : iulog + use clm_varctl , only : iulog, inst_name use spmdMod , only : masterproc, mpicom, comp_id use fileutils , only : getavu, relavu use decompMod , only : gsmap_lnd_gdc2glo @@ -102,7 +102,7 @@ subroutine BaseFireInit( this, bounds, NLFilename ) ! ! !ARGUMENTS: class(fire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename !----------------------------------------------------------------------- @@ -130,7 +130,7 @@ subroutine FireInterp(this,bounds) ! ! !ARGUMENTS: class(fire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds !----------------------------------------------------------------------- if ( this%need_lightning_and_popdens() ) then @@ -157,16 +157,16 @@ subroutine hdm_init( this, bounds, NLFilename ) ! !ARGUMENTS: implicit none class(fire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! Namelist filename ! ! !LOCAL VARIABLES: integer :: stream_year_first_popdens ! first year in pop. dens. stream to use integer :: stream_year_last_popdens ! last year in pop. dens. stream to use - integer :: model_year_align_popdens ! align stream_year_first_hdm with + integer :: model_year_align_popdens ! align stream_year_first_hdm with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_popdens ! population density streams filename character(len=CL) :: popdensmapalgo = 'bilinear' ! mapping alogrithm for population density character(len=CL) :: popdens_tintalgo = 'nearest'! time interpolation alogrithm for population density @@ -212,9 +212,9 @@ subroutine hdm_init( this, bounds, NLFilename ) if (masterproc) then write(iulog,*) ' ' write(iulog,*) 'popdens_streams settings:' - write(iulog,*) ' stream_year_first_popdens = ',stream_year_first_popdens - write(iulog,*) ' stream_year_last_popdens = ',stream_year_last_popdens - write(iulog,*) ' model_year_align_popdens = ',model_year_align_popdens + write(iulog,*) ' stream_year_first_popdens = ',stream_year_first_popdens + write(iulog,*) ' stream_year_last_popdens = ',stream_year_last_popdens + write(iulog,*) ' model_year_align_popdens = ',model_year_align_popdens write(iulog,*) ' stream_fldFileName_popdens = ',stream_fldFileName_popdens write(iulog,*) ' popdens_tintalgo = ',popdens_tintalgo write(iulog,*) ' ' @@ -223,8 +223,8 @@ subroutine hdm_init( this, bounds, NLFilename ) call clm_domain_mct (bounds, dom_clm) call shr_strdata_create(this%sdat_hdm,name="clmhdm", & - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -236,7 +236,7 @@ subroutine hdm_init( this, bounds, NLFilename ) domFileName=trim(stream_fldFileName_popdens), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -259,7 +259,7 @@ subroutine hdm_init( this, bounds, NLFilename ) ptr_lnd=this%forc_hdm, default='inactive') end subroutine hdm_init - + !----------------------------------------------------------------------- subroutine hdm_interp( this, bounds) ! @@ -271,7 +271,7 @@ subroutine hdm_interp( this, bounds) ! ! !ARGUMENTS: class(fire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: g, ig @@ -292,7 +292,7 @@ subroutine hdm_interp( this, bounds) ig = ig+1 this%forc_hdm(g) = this%sdat_hdm%avs(1)%rAttr(1,ig) end do - + end subroutine hdm_interp !----------------------------------------------------------------------- @@ -313,16 +313,16 @@ subroutine lnfm_init( this, bounds, NLFilename ) ! !ARGUMENTS: implicit none class(fire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds character(len=*), intent(in) :: NLFilename ! ! !LOCAL VARIABLES: integer :: stream_year_first_lightng ! first year in Lightning stream to use integer :: stream_year_last_lightng ! last year in Lightning stream to use - integer :: model_year_align_lightng ! align stream_year_first_lnfm with + integer :: model_year_align_lightng ! align stream_year_first_lnfm with integer :: nu_nml ! unit for namelist file integer :: nml_error ! namelist i/o error flag - type(mct_ggrid) :: dom_clm ! domain information + type(mct_ggrid) :: dom_clm ! domain information character(len=CL) :: stream_fldFileName_lightng ! lightning stream filename to read character(len=CL) :: lightng_tintalgo = 'linear'! time interpolation alogrithm character(len=CL) :: lightngmapalgo = 'bilinear'! Mapping alogrithm @@ -368,9 +368,9 @@ subroutine lnfm_init( this, bounds, NLFilename ) if (masterproc) then write(iulog,*) ' ' write(iulog,*) 'light_stream settings:' - write(iulog,*) ' stream_year_first_lightng = ',stream_year_first_lightng - write(iulog,*) ' stream_year_last_lightng = ',stream_year_last_lightng - write(iulog,*) ' model_year_align_lightng = ',model_year_align_lightng + write(iulog,*) ' stream_year_first_lightng = ',stream_year_first_lightng + write(iulog,*) ' stream_year_last_lightng = ',stream_year_last_lightng + write(iulog,*) ' model_year_align_lightng = ',model_year_align_lightng write(iulog,*) ' stream_fldFileName_lightng = ',stream_fldFileName_lightng write(iulog,*) ' lightng_tintalgo = ',lightng_tintalgo write(iulog,*) ' ' @@ -379,8 +379,8 @@ subroutine lnfm_init( this, bounds, NLFilename ) call clm_domain_mct (bounds, dom_clm) call shr_strdata_create(this%sdat_lnfm,name="clmlnfm", & - pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_subsystem=pio_subsystem, & + pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -392,7 +392,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) domFileName=trim(stream_fldFileName_lightng), & domTvarName='time', & domXvarName='lon' , & - domYvarName='lat' , & + domYvarName='lat' , & domAreaName='area', & domMaskName='mask', & filePath='', & @@ -415,7 +415,7 @@ subroutine lnfm_init( this, bounds, NLFilename ) ptr_lnd=this%forc_lnfm, default='inactive') end subroutine lnfm_init - + !----------------------------------------------------------------------- subroutine lnfm_interp(this, bounds ) ! @@ -427,7 +427,7 @@ subroutine lnfm_interp(this, bounds ) ! ! !ARGUMENTS: class(fire_base_type) :: this - type(bounds_type), intent(in) :: bounds + type(bounds_type), intent(in) :: bounds ! ! !LOCAL VARIABLES: integer :: g, ig @@ -448,7 +448,7 @@ subroutine lnfm_interp(this, bounds ) ig = ig+1 this%forc_lnfm(g) = this%sdat_lnfm%avs(1)%rAttr(1,ig) end do - + end subroutine lnfm_interp end module FireDataBaseType diff --git a/src/main/ndepStreamMod.F90 b/src/main/ndepStreamMod.F90 index 3d79dfff04..4741e879ea 100644 --- a/src/main/ndepStreamMod.F90 +++ b/src/main/ndepStreamMod.F90 @@ -12,7 +12,7 @@ module ndepStreamMod use shr_strdata_mod, only: shr_strdata_print, shr_strdata_advance use mct_mod , only: mct_ggrid use spmdMod , only: mpicom, masterproc, comp_id, iam - use clm_varctl , only: iulog + use clm_varctl , only: iulog, inst_name use abortutils , only: endrun use fileutils , only: getavu, relavu use decompMod , only: bounds_type, ldecomp @@ -57,7 +57,7 @@ subroutine ndep_init(bounds, NLFilename) use shr_nl_mod , only : shr_nl_find_group_name use shr_log_mod , only : errMsg => shr_log_errMsg use shr_mpi_mod , only : shr_mpi_bcast - use decompMod , only : gsmap_lnd_gdc2glo + use decompMod , only : gsmap_lnd_gdc2glo ! ! arguments implicit none @@ -138,7 +138,7 @@ subroutine ndep_init(bounds, NLFilename) call shr_strdata_create(sdat,name="clmndep", & pio_subsystem=pio_subsystem, & - pio_iotype=shr_pio_getiotype('LND'), & + pio_iotype=shr_pio_getiotype(inst_name), & mpicom=mpicom, compid=comp_id, & gsmap=gsmap_lnd_gdc2glo, ggrid=dom_clm, & nxg=ldomain%ni, nyg=ldomain%nj, & @@ -301,7 +301,7 @@ subroutine clm_domain_mct(bounds, dom_clm, nlevels) ! Initialize mct domain type ! lat/lon in degrees, area in radians^2, mask is 1 (land), 0 (non-land) ! Note that in addition land carries around landfrac for the purposes of domain checking - ! + ! lsize = mct_gsMap_lsize(gsmap, mpicom) call mct_gGrid_init( GGrid=dom_clm, & CoordChars='lat:lon:hgt', OtherChars='area:aream:mask:frac', lsize=lsize ) @@ -338,7 +338,7 @@ subroutine clm_domain_mct(bounds, dom_clm, nlevels) data(i) = ldomain%lonc(g) end do end do - call mct_gGrid_importRattr(dom_clm,"lon",data,lsize) + call mct_gGrid_importRattr(dom_clm,"lon",data,lsize) do k = 1, nlevs do g = bounds%begg,bounds%endg @@ -346,7 +346,7 @@ subroutine clm_domain_mct(bounds, dom_clm, nlevels) data(i) = ldomain%latc(g) end do end do - call mct_gGrid_importRattr(dom_clm,"lat",data,lsize) + call mct_gGrid_importRattr(dom_clm,"lat",data,lsize) do k = 1, nlevs do g = bounds%begg,bounds%endg @@ -354,7 +354,7 @@ subroutine clm_domain_mct(bounds, dom_clm, nlevels) data(i) = ldomain%area(g)/(re*re) end do end do - call mct_gGrid_importRattr(dom_clm,"area",data,lsize) + call mct_gGrid_importRattr(dom_clm,"area",data,lsize) do k = 1, nlevs do g = bounds%begg,bounds%endg @@ -362,7 +362,7 @@ subroutine clm_domain_mct(bounds, dom_clm, nlevels) data(i) = real(ldomain%mask(g), r8) end do end do - call mct_gGrid_importRattr(dom_clm,"mask",data,lsize) + call mct_gGrid_importRattr(dom_clm,"mask",data,lsize) do k = 1, nlevs do g = bounds%begg,bounds%endg @@ -370,7 +370,7 @@ subroutine clm_domain_mct(bounds, dom_clm, nlevels) data(i) = real(ldomain%frac(g), r8) end do end do - call mct_gGrid_importRattr(dom_clm,"frac",data,lsize) + call mct_gGrid_importRattr(dom_clm,"frac",data,lsize) deallocate(data) deallocate(idata) From 1a4bdd2df3f27d56c16e4b689c095d25e385fa87 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Tue, 17 Nov 2020 11:10:19 -0700 Subject: [PATCH 39/39] Update ChangeLog --- doc/ChangeLog | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeSum | 1 + 2 files changed, 103 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index 5a08b657dd..cdb7e6fa8f 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,4 +1,106 @@ =============================================================== +Tag name: ctsm5.1.dev016 +Originator(s): mvertens (Mariana Vertenstein), jedwards (Jim Edwards), + sacks (Bill Sacks), erik (Erik Kluzek) +Date: Tue Nov 17 10:49:40 MST 2020 +One-line Summary: Updates for nuopc + +Purpose of changes +------------------ + +Various updates needed for NUOPC. + +Also adds mizuRoute as an external component. + + +Significant changes to scientifically-supported configurations +-------------------------------------------------------------- + +Does this tag change answers significantly for any of the following physics configurations? +(Details of any changes will be given in the "Answer changes" section below.) + + [Put an [X] in the box for any configuration with significant answer changes.] + +[ ] clm5_1 + +[ ] clm5_0 + +[ ] ctsm5_0-nwp + +[ ] clm4_5 + +Notes of particular relevance for users +--------------------------------------- + +Caveats for users (e.g., need to interpolate initial conditions): none + +Changes to CTSM's user interface (e.g., new/renamed XML or namelist variables): none + +Changes made to namelist defaults (e.g., changed parameter values): none + +Changes to the datasets (e.g., parameter, surface or initial files): none + +Substantial timing or memory changes: none + +Notes of particular relevance for developers: (including Code reviews and testing) +--------------------------------------------- +NOTE: Be sure to review the steps in README.CHECKLIST.master_tags as well as the coding style in the Developers Guide + +Caveats for developers (e.g., code that is duplicated that requires double maintenance): +- SoilMoistureStreamMod now is duplicated: the version used with mct is + still in src/biogeochem, but there is a new version used with nuopc + and the CDEPS data models in src/cpl/nuopc. The latter has just been + introduced for testing purposes. Eventually, once we switch everything + to use CDEPS, we'll remove this duplicated version. + +Changes to tests or testing: none + +CTSM testing: + + [PASS means all tests PASS and OK means tests PASS other than expected fails.] + + build-namelist tests: + + cheyenne - not run + + tools-tests (test/tools): + + cheyenne - not run + + PTCLM testing (tools/shared/PTCLM/test): + + cheyenne - not run + + python testing (see instructions in python/README.md; document testing done): + + (any machine) - not run + + regular tests (aux_clm): + + cheyenne ---- pass + izumi ------- pass + +If the tag used for baseline comparisons was NOT the previous tag, note that here: + + +Answer changes +-------------- + +Changes answers relative to baseline: NO + +Detailed list of changes +------------------------ + +List any externals directories updated (cime, rtm, mosart, cism, fates, etc.): +- Added mizuRoute (at 34723c2) +- cime: branch_tags/cime5.8.32_a01 -> branch_tags/cime5.8.32_a02 +- (Some other rearrangement of Externals files, but versions stayed the + same) + +Pull Requests that document the changes (include PR ids): none + +=============================================================== +=============================================================== Tag name: ctsm5.1.dev015 Originator(s): sacks (Bill Sacks) Date: Fri Nov 13 11:52:34 MST 2020 diff --git a/doc/ChangeSum b/doc/ChangeSum index b706eeea98..d31073d7f4 100644 --- a/doc/ChangeSum +++ b/doc/ChangeSum @@ -1,5 +1,6 @@ Tag Who Date Summary ============================================================================================================================ + ctsm5.1.dev016 multiple 11/17/2020 Updates for nuopc ctsm5.1.dev015 sacks 11/13/2020 A few small fixes ctsm5.1.dev014 dll/oles 11/07/2020 Grass/crop snow burial fraction fix, and some other fixes ctsm5.1.dev013 jedwards 11/04/2020 Allow pnetcdf for vector history files