From 663d707297bbd74b67d522c35945fe7ae5197520 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 15 Sep 2023 12:35:25 -0600 Subject: [PATCH 01/14] Add pctocn to fsurdat files made by mksurfdata_esmf --- tools/mksurfdata_esmf/README | 4 +-- tools/mksurfdata_esmf/src/mkfileMod.F90 | 3 ++ tools/mksurfdata_esmf/src/mksurfdata.F90 | 35 +++++++++++++++++------- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/tools/mksurfdata_esmf/README b/tools/mksurfdata_esmf/README index 55ce09dd61..4be45e83d1 100644 --- a/tools/mksurfdata_esmf/README +++ b/tools/mksurfdata_esmf/README @@ -69,10 +69,10 @@ Building the executable (working in tools/mksurfdata_esmf) ======================= Running for a single submission: ======================= -# Work in the ctsm_py environment, which requires the following steps: +# Work in the ctsm_pylib environment, which requires the following steps: > module unload python; module load conda > cd ../..; ./py_env_create -> conda activate ctsm_py; cd tools/mksurfdata_esmf +> conda activate ctsm_pylib; cd tools/mksurfdata_esmf # to generate your target namelist: > ./gen_mksurfdata_namelist.py --help # for example try --res 1.9x2.5 --start-year 1850 --end-year 1850: diff --git a/tools/mksurfdata_esmf/src/mkfileMod.F90 b/tools/mksurfdata_esmf/src/mkfileMod.F90 index 335a9a508b..1072c4710b 100644 --- a/tools/mksurfdata_esmf/src/mkfileMod.F90 +++ b/tools/mksurfdata_esmf/src/mkfileMod.F90 @@ -456,6 +456,9 @@ subroutine mkfile_define_vars(pioid, dynlanduse) end if + call mkpio_def_spatial_var(pioid=pioid, varname='PCT_OCEAN', xtype=xtype, & + long_name='percent ocean', units='unitless') + call mkpio_def_spatial_var(pioid=pioid, varname='LAKEDEPTH', xtype=xtype, & long_name='lake depth', units='m') diff --git a/tools/mksurfdata_esmf/src/mksurfdata.F90 b/tools/mksurfdata_esmf/src/mksurfdata.F90 index ace3999f0f..6a7f3d168f 100644 --- a/tools/mksurfdata_esmf/src/mksurfdata.F90 +++ b/tools/mksurfdata_esmf/src/mksurfdata.F90 @@ -162,6 +162,7 @@ program mksurfdata real(r8), allocatable :: pctlak(:) ! percent of grid cell that is lake real(r8), allocatable :: pctlak_max(:) ! maximum percent of grid cell that is lake real(r8), allocatable :: pctwet(:) ! percent of grid cell that is wetland + real(r8), allocatable :: pctocn(:) ! percent of grid cell that is ocean real(r8), allocatable :: pctgla(:) ! percent of grid cell that is glacier integer , allocatable :: urban_region(:) ! urban region ID real(r8), allocatable :: pcturb(:) ! percent of grid cell that is urbanized (total across all urban classes) @@ -429,6 +430,12 @@ program mksurfdata call mkwetlnd(mksrf_fwetlnd_mesh, mksrf_fwetlnd, mesh_model, pctwet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error in calling mkwetlnd') + ! Initialize pctocn to zero. + ! Traditionally we have set pctwet = 100 at ocean points rather than + ! setting a pctocn. We now set pctocn = 100 at ocean points in + ! subroutine normalize_and_check_landuse. No regridding required. + allocate ( pctocn(lsize_o)); pctocn(:) = 0._r8 + ! ----------------------------------- ! Make glacier fraction [pctgla] from [fglacier] dataset ! ----------------------------------- @@ -648,6 +655,10 @@ program mksurfdata call mkfile_output(pioid, mesh_model, 'PCT_WETLAND', pctwet, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error in in mkfile_output for pctwet') + if (root_task) write(ndiag, '(a)') trim(subname)//" writing out PCT_OCEAN" + call mkfile_output(pioid, mesh_model, 'PCT_OCEAN', pctocn, rc=rc) + if (ChkErr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error in in mkfile_output for pctocn') + if (root_task) write(ndiag, '(a)') trim(subname)//" writing PCT_NATVEG" call get_pct_l2g_array(pctnatpft, pctnatveg) call mkfile_output(pioid, mesh_model, 'PCT_NATVEG', pctnatveg, rc=rc) @@ -1171,7 +1182,7 @@ subroutine normalize_and_check_landuse(ns_o) if (pct_land < 1.e-6_r8) then ! If we have essentially 0 land area, set land area to exactly 0 and put all - ! area in wetlands (to simulate ocean). Note that, based on the formulation + ! area in pctocn. Note that, based on the formulation ! for pct_land above, this should only arise if the non-natveg landunits ! already have near-zero area (and the natveg landunit should also have ! near-zero area in this case, because its area should be no greater than the @@ -1184,7 +1195,8 @@ subroutine normalize_and_check_landuse(ns_o) pctlak(n) = 0._r8 pcturb(n) = 0._r8 pctgla(n) = 0._r8 - pctwet(n) = 100._r8 + pctwet(n) = 0._r8 + pctocn(n) = 100._r8 ! the only asignment of non-zero ocean else ! Fill the rest of the land area with natveg, then renormalize landunits so ! that they are expressed as percent of the land area rather than percent of @@ -1222,12 +1234,12 @@ subroutine normalize_and_check_landuse(ns_o) ! Confirm that we have done the rescaling correctly: now the sum of all landunits ! should be 100% within tol_loose suma = pctlak(n) + pctwet(n) + pctgla(n) + pcturb(n) + pctcft(n)%get_pct_l2g() - suma = suma + pctnatpft(n)%get_pct_l2g() + suma = suma + pctnatpft(n)%get_pct_l2g() + pctocn(n) if (abs(suma - 100._r8) > tol_loose) then write(6,*) subname, ' ERROR: landunits do not sum to 100%' - write(6,*) 'n, suma, pctlak, pctwet, pctgla, pcturb, pctnatveg, pctcrop = ' + write(6,*) 'n, suma, pctlak, pctwet, pctgla, pcturb, pctnatveg, pctcrop, pctocn = ' write(6,*) n, suma, pctlak(n), pctwet(n), pctgla(n), pcturb(n), & - pctnatpft(n)%get_pct_l2g(), pctcft(n)%get_pct_l2g() + pctnatpft(n)%get_pct_l2g(), pctcft(n)%get_pct_l2g(), pctocn(n) call shr_sys_abort() end if @@ -1248,7 +1260,10 @@ subroutine normalize_and_check_landuse(ns_o) call pctcft(n)%remove_small_cover(toosmallPFT, nsmall) nsmall_tot = nsmall_tot + nsmall - suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n) + ! Include pctocn in suma but do not include in the + ! renormalization. When pctocn /= 0, it is 100, and + ! all other terms are 0. + suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n) + pctocn(n) suma = suma + pctnatpft(n)%get_pct_l2g() + pctcft(n)%get_pct_l2g() if ( abs(suma - 100.0_r8) > 2.0*epsilon(suma) )then pctlak(n) = pctlak(n) * 100._r8/suma @@ -1299,12 +1314,12 @@ subroutine normalize_and_check_landuse(ns_o) end if suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n) + pctcft(n)%get_pct_l2g() - suma = suma + pctnatpft(n)%get_pct_l2g() + suma = suma + pctnatpft(n)%get_pct_l2g() + pctocn(n) if ( abs(suma-100._r8) > 1.e-10_r8) then - write (6,*) subname, ' error: sum of pctlak, pctwet,', & + write (6,*) subname, ' error: sum of pctocn, pctlak, pctwet,', & 'pcturb, pctgla, pctnatveg and pctcrop is NOT equal to 100' - write (6,*)'n,pctlak,pctwet,pcturb,pctgla,pctnatveg,pctcrop,sum= ', & - n,pctlak(n),pctwet(n),pcturb(n),pctgla(n),& + write (6,*)'n,pctcon,pctlak,pctwet,pcturb,pctgla,pctnatveg,pctcrop,sum= ', & + n,pctocn(n),pctlak(n),pctwet(n),pcturb(n),pctgla(n),& pctnatpft(n)%get_pct_l2g(),pctcft(n)%get_pct_l2g(), suma call shr_sys_abort() end if From 1054dbf49e8a266d5d0f4766578044a63368914a Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 15 Sep 2023 16:38:17 -0600 Subject: [PATCH 02/14] Add pctocn to surfrdMod, NOT TESTED --- src/main/surfrdMod.F90 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/surfrdMod.F90 b/src/main/surfrdMod.F90 index 3a3c892c58..dece33386f 100644 --- a/src/main/surfrdMod.F90 +++ b/src/main/surfrdMod.F90 @@ -390,6 +390,7 @@ subroutine surfrd_special(begg, endg, ncid, ns) real(r8),pointer :: pctgla(:) ! percent of grid cell is glacier real(r8),pointer :: pctlak(:) ! percent of grid cell is lake real(r8),pointer :: pctwet(:) ! percent of grid cell is wetland + real(r8),pointer :: pctocn(:) ! percent of grid cell is ocean real(r8),pointer :: pcturb(:,:) ! percent of grid cell is urbanized integer ,pointer :: urban_region_id(:) real(r8),pointer :: pcturb_tot(:) ! percent of grid cell is urban (sum over density classes) @@ -403,6 +404,7 @@ subroutine surfrd_special(begg, endg, ncid, ns) allocate(pctgla(begg:endg)) allocate(pctlak(begg:endg)) allocate(pctwet(begg:endg)) + allocate(pctocn(begg:endg)) allocate(pcturb(begg:endg,numurbl)) allocate(pcturb_tot(begg:endg)) allocate(urban_region_id(begg:endg)) @@ -412,6 +414,10 @@ subroutine surfrd_special(begg, endg, ncid, ns) ! Obtain non-grid surface properties of surface dataset other than percent patch + call ncd_io(ncid=ncid, varname='PCT_OCEAN', flag='read', data=pctocn, & + dim1name=grlnd, readvar=readvar) + if (.not. readvar) call endrun( msg=' ERROR: PCT_OCEAN NOT on surfdata file'//errMsg(sourcefile, __LINE__)) + call ncd_io(ncid=ncid, varname='PCT_WETLAND', flag='read', data=pctwet, & dim1name=grlnd, readvar=readvar) if (.not. readvar) call endrun( msg=' ERROR: PCT_WETLAND NOT on surfdata file'//errMsg(sourcefile, __LINE__)) @@ -512,7 +518,7 @@ subroutine surfrd_special(begg, endg, ncid, ns) call CheckUrban(begg, endg, pcturb(begg:endg,:), subname) - deallocate(pctgla,pctlak,pctwet,pcturb,pcturb_tot,urban_region_id,pctspec) + deallocate(pctgla,pctlak,pctwet,pctocn,pcturb,pcturb_tot,urban_region_id,pctspec) end subroutine surfrd_special From b9bdb7705460c3f1920122dfd163d487d3873985 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 15 Sep 2023 16:42:18 -0600 Subject: [PATCH 03/14] Add PCT_OCEAN to various tools and tests that will expect it --- python/ctsm/modify_input_files/modify_fsurdat.py | 2 ++ python/ctsm/site_and_regional/single_point_case.py | 1 + python/ctsm/test/test_sys_fsurdat_modifier.py | 2 +- python/ctsm/test/test_unit_singlept_data_surfdata.py | 12 ++++++++++++ .../test/testinputs/modify_fsurdat_1x1mexicocity.cfg | 1 + .../test/testinputs/modify_fsurdat_opt_sections.cfg | 1 + tools/contrib/modify_singlept_site | 1 + 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/python/ctsm/modify_input_files/modify_fsurdat.py b/python/ctsm/modify_input_files/modify_fsurdat.py index 9b3760e303..6fa3701acc 100644 --- a/python/ctsm/modify_input_files/modify_fsurdat.py +++ b/python/ctsm/modify_input_files/modify_fsurdat.py @@ -351,6 +351,7 @@ def zero_nonveg(self): self.setvar_lev0("PCT_WETLAND", 0) self.setvar_lev0("PCT_URBAN", 0) self.setvar_lev0("PCT_GLACIER", 0) + self.setvar_lev0("PCT_OCEAN", 0) def setvar_lev0(self, var, val): """ @@ -421,6 +422,7 @@ def set_idealized(self): self.setvar_lev0("PCT_LAKE", pct_not_nat_veg) self.setvar_lev0("PCT_URBAN", pct_not_nat_veg) self.setvar_lev0("PCT_GLACIER", pct_not_nat_veg) + self.setvar_lev0("PCT_OCEAN", pct_not_nat_veg) self.setvar_lev0("PCT_NATVEG", pct_nat_veg) for lev in self.file.nlevsoi: diff --git a/python/ctsm/site_and_regional/single_point_case.py b/python/ctsm/site_and_regional/single_point_case.py index 0508891a89..163820456e 100644 --- a/python/ctsm/site_and_regional/single_point_case.py +++ b/python/ctsm/site_and_regional/single_point_case.py @@ -421,6 +421,7 @@ def modify_surfdata_atpoint(self, f_orig): f_mod["PCT_WETLAND"][:, :] = 0.0 f_mod["PCT_URBAN"][:, :, :] = 0.0 f_mod["PCT_GLACIER"][:, :] = 0.0 + f_mod["PCT_OCEAN"][:, :] = 0.0 if self.dom_pft is not None: max_dom_pft = max(self.dom_pft) diff --git a/python/ctsm/test/test_sys_fsurdat_modifier.py b/python/ctsm/test/test_sys_fsurdat_modifier.py index 72d38732cf..7bd57ce8af 100755 --- a/python/ctsm/test/test_sys_fsurdat_modifier.py +++ b/python/ctsm/test/test_sys_fsurdat_modifier.py @@ -215,7 +215,7 @@ def test_opt_sections(self): np.testing.assert_array_equal(fsurdat_out_data.PCT_CROP, zero0d) np.testing.assert_array_equal(fsurdat_out_data.PCT_LAKE, zero0d) np.testing.assert_array_equal(fsurdat_out_data.PCT_WETLAND, zero0d) - np.testing.assert_array_equal(fsurdat_out_data.PCT_LAKE, zero0d) + np.testing.assert_array_equal(fsurdat_out_data.PCT_OCEAN, zero0d) np.testing.assert_array_equal(fsurdat_out_data.PCT_GLACIER, zero0d) np.testing.assert_array_equal(fsurdat_out_data.PCT_URBAN, pct_urban) np.testing.assert_array_equal(fsurdat_out_data.LAKEDEPTH, one0d * 200.0) diff --git a/python/ctsm/test/test_unit_singlept_data_surfdata.py b/python/ctsm/test/test_unit_singlept_data_surfdata.py index 9623975452..427cbac6da 100755 --- a/python/ctsm/test/test_unit_singlept_data_surfdata.py +++ b/python/ctsm/test/test_unit_singlept_data_surfdata.py @@ -106,6 +106,12 @@ class TestSinglePointCaseSurfaceNoCrop(unittest.TestCase): coords={"lsmlat": lsmlat, "lsmlon": lsmlon}, attrs={"long_name": "percent wetland", "units": "unitless"}, ), + "PCT_OCEAN": xr.DataArray( + data=np.random.rand(1, 1), + dims=["lsmlat", "lsmlon"], + coords={"lsmlat": lsmlat, "lsmlon": lsmlon}, + attrs={"long_name": "percent ocean", "units": "unitless"}, + ), "PCT_URBAN": xr.DataArray( data=np.random.rand(1, 1, 3), dims=["lsmlat", "lsmlon", "numurbl"], @@ -656,6 +662,12 @@ class TestSinglePointCaseSurfaceCrop(unittest.TestCase): coords={"lsmlat": lsmlat, "lsmlon": lsmlon}, attrs={"long_name": "percent wetland", "units": "unitless"}, ), + "PCT_OCEAN": xr.DataArray( + data=np.random.rand(1, 1), + dims=["lsmlat", "lsmlon"], + coords={"lsmlat": lsmlat, "lsmlon": lsmlon}, + attrs={"long_name": "percent ocean", "units": "unitless"}, + ), "PCT_URBAN": xr.DataArray( data=np.random.rand(1, 1, 3), dims=["lsmlat", "lsmlon", "numurbl"], diff --git a/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg b/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg index a4118a3255..a854ebcc53 100644 --- a/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg +++ b/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg @@ -36,6 +36,7 @@ PCT_NATVEG= 0.0 PCT_GLACIER= 0.0 PCT_WETLAND= 0.0 PCT_LAKE = 0.0 +PCT_OCEAN = 0.0 # Section with a list of variables to prcoess [modify_fsurdat_variable_list] diff --git a/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg b/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg index c068c5d851..38e7a529f0 100644 --- a/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg +++ b/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg @@ -33,6 +33,7 @@ PCT_CROP = 0.0 PCT_LAKE = 0.0 PCT_GLACIER = 0.0 PCT_WETLAND = 0.0 +PCT_OCEAN = 0.0 # NOTE: PCT_URBAN must be a list of three floats that sum to the total urban area PCT_URBAN = 100.0 0.0 0.0 diff --git a/tools/contrib/modify_singlept_site b/tools/contrib/modify_singlept_site index 46c1bcda1a..df89f6fb73 100755 --- a/tools/contrib/modify_singlept_site +++ b/tools/contrib/modify_singlept_site @@ -231,6 +231,7 @@ if create_surfdata: f2['PCT_WETLAND'] = 0. f2['PCT_URBAN'] = 0. f2['PCT_GLACIER'] = 0. + f2['PCT_OCEAN'] = 0. #-- Overwrite global data with raw data ---------------------------- f2['LONGXY'] = plon From 099fb360dfb8555aa46fc627e9fb3a5c3ee94c46 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sat, 16 Sep 2023 15:33:49 -0600 Subject: [PATCH 04/14] Corrections in surfrdMod for error checks to pass --- src/main/surfrdMod.F90 | 20 ++++++++++++++------ tools/mksurfdata_esmf/src/mksurfdata.F90 | 7 ++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/surfrdMod.F90 b/src/main/surfrdMod.F90 index dece33386f..368e3264a4 100644 --- a/src/main/surfrdMod.F90 +++ b/src/main/surfrdMod.F90 @@ -481,9 +481,9 @@ subroutine surfrd_special(begg, endg, ncid, ns) topo_glc_mec(:,:) = max(topo_glc_mec(:,:), 0._r8) - pctspec = pctwet + pctlak + pcturb_tot + pctgla + pctspec = pctwet + pctlak + pcturb_tot + pctgla + pctocn - ! Error check: glacier, lake, wetland, urban sum must be less than 100 + ! Error check: sum of glacier, lake, wetland, urban, ocean must be < 100 found = .false. do nl = begg,endg @@ -503,15 +503,23 @@ subroutine surfrd_special(begg, endg, ncid, ns) do nl = begg,endg - wt_lunit(nl,istdlak) = pctlak(nl)/100._r8 + wt_lunit(nl,istdlak) = pctlak(nl) / 100._r8 - wt_lunit(nl,istwet) = pctwet(nl)/100._r8 + ! Until ctsm5.1 we would label ocean points as wetland in fsurdat + ! files. Starting with ctsm5.2 we label ocean points as ocean + ! (always 100%) and wetland points as wetland. Here we merge them + ! again to keep model behavior unchanged for now. + if (pctocn(nl) > 100._r8 - 1.e-04_r8) then + wt_lunit(nl,istwet) = pctocn(nl) / 100._r8 + else + wt_lunit(nl,istwet) = pctwet(nl) / 100._r8 + end if - wt_lunit(nl,istice) = pctgla(nl)/100._r8 + wt_lunit(nl,istice) = pctgla(nl) / 100._r8 do n = isturb_MIN, isturb_MAX dens_index = n - isturb_MIN + 1 - wt_lunit(nl,n) = pcturb(nl,dens_index) / 100._r8 + wt_lunit(nl,n) = pcturb(nl,dens_index) / 100._r8 end do end do diff --git a/tools/mksurfdata_esmf/src/mksurfdata.F90 b/tools/mksurfdata_esmf/src/mksurfdata.F90 index 6a7f3d168f..c40fee5c47 100644 --- a/tools/mksurfdata_esmf/src/mksurfdata.F90 +++ b/tools/mksurfdata_esmf/src/mksurfdata.F90 @@ -431,9 +431,10 @@ program mksurfdata if (ChkErr(rc,__LINE__,u_FILE_u)) call shr_sys_abort('error in calling mkwetlnd') ! Initialize pctocn to zero. - ! Traditionally we have set pctwet = 100 at ocean points rather than - ! setting a pctocn. We now set pctocn = 100 at ocean points in - ! subroutine normalize_and_check_landuse. No regridding required. + ! Until ctsm5.1 we set pctwet = 100 at ocean points rather than + ! setting a pctocn. Starting with ctsm5.2, we set pctocn = 100 at + ! ocean points in subroutine normalize_and_check_landuse. + ! No regridding required. allocate ( pctocn(lsize_o)); pctocn(:) = 0._r8 ! ----------------------------------- From 11a754241c2f3ec3c0bb1a510c780065f7c160ab Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Sun, 17 Sep 2023 09:58:39 -0600 Subject: [PATCH 05/14] Simpler use of pctocn in surfrdMod --- src/main/surfrdMod.F90 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/surfrdMod.F90 b/src/main/surfrdMod.F90 index 368e3264a4..1d07229b3b 100644 --- a/src/main/surfrdMod.F90 +++ b/src/main/surfrdMod.F90 @@ -509,11 +509,7 @@ subroutine surfrd_special(begg, endg, ncid, ns) ! files. Starting with ctsm5.2 we label ocean points as ocean ! (always 100%) and wetland points as wetland. Here we merge them ! again to keep model behavior unchanged for now. - if (pctocn(nl) > 100._r8 - 1.e-04_r8) then - wt_lunit(nl,istwet) = pctocn(nl) / 100._r8 - else - wt_lunit(nl,istwet) = pctwet(nl) / 100._r8 - end if + wt_lunit(nl,istwet) = (pctocn(nl) + pctwet(nl)) / 100._r8 wt_lunit(nl,istice) = pctgla(nl) / 100._r8 From 83bc76f4f9a1808ab365ab7c24d81bef3c42a1df Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 23 Oct 2023 15:50:03 -0600 Subject: [PATCH 06/14] Introduce istocn = 3 and related code --- src/biogeophys/EnergyFluxType.F90 | 16 ++++------------ src/main/landunit_varcon.F90 | 9 +++++---- src/main/surfrdMod.F90 | 9 ++++----- src/main/surfrdUtilsMod.F90 | 19 +++++++------------ 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/biogeophys/EnergyFluxType.F90 b/src/biogeophys/EnergyFluxType.F90 index 685663b83d..2e709596a1 100644 --- a/src/biogeophys/EnergyFluxType.F90 +++ b/src/biogeophys/EnergyFluxType.F90 @@ -170,7 +170,7 @@ subroutine InitAllocate(this, bounds) ! ! !USES: use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=) - use clm_varpar , only : nlevsno, nlevgrnd, nlevlak + use clm_varpar , only : nlevgrnd implicit none ! ! !ARGUMENTS: @@ -287,7 +287,7 @@ subroutine InitHistory(this, bounds, is_simple_buildtemp, is_prog_buildtemp) ! ! !USES: use shr_infnan_mod , only : nan => shr_infnan_nan, assignment(=) - use clm_varpar , only : nlevsno, nlevgrnd + use clm_varpar , only : nlevgrnd use clm_varctl , only : use_cn, use_hydrstress use histFileMod , only : hist_addfld1d, hist_addfld2d, no_snow_normal use ncdio_pio , only : ncd_inqvdlen @@ -700,13 +700,8 @@ subroutine InitCold(this, bounds, t_grnd_col, is_simple_buildtemp, is_prog_build ! ! !USES: use shr_kind_mod , only : r8 => shr_kind_r8 - use shr_const_mod , only : SHR_CONST_TKFRZ - use clm_varpar , only : nlevsoi, nlevgrnd, nlevsno, nlevlak, nlevurb - use clm_varcon , only : denice, denh2o, sb - use landunit_varcon , only : istwet, istsoil, istdlak - use column_varcon , only : icol_road_imperv, icol_roof, icol_sunwall - use column_varcon , only : icol_shadewall, icol_road_perv - use clm_varctl , only : use_vancouver, use_mexicocity + use clm_varpar , only : nlevgrnd + use clm_varcon , only : sb implicit none ! ! !ARGUMENTS: @@ -936,7 +931,6 @@ subroutine InitAccBuffer (this, bounds) ! !USES use accumulMod , only : init_accum_field use clm_time_manager , only : get_step_size_real - use shr_const_mod , only : SHR_CONST_CDAY, SHR_CONST_TKFRZ ! ! !ARGUMENTS: class(energyflux_type) :: this @@ -964,7 +958,6 @@ subroutine InitAccVars(this, bounds) ! is read in and the accumulation buffer is obtained) ! ! !USES - use accumulMod , only : init_accum_field, extract_accum_field use clm_time_manager , only : get_nstep use clm_varctl , only : nsrest, nsrStartup use abortutils , only : endrun @@ -994,7 +987,6 @@ end subroutine InitAccVars subroutine UpdateAccVars (this, bounds) ! ! USES - use shr_const_mod , only : SHR_CONST_CDAY, SHR_CONST_TKFRZ use clm_time_manager , only : get_step_size, get_nstep, is_end_curr_day, get_curr_date use accumulMod , only : update_accum_field, extract_accum_field, accumResetVal use abortutils , only : endrun diff --git a/src/main/landunit_varcon.F90 b/src/main/landunit_varcon.F90 index 36eccb7001..0483b50182 100644 --- a/src/main/landunit_varcon.F90 +++ b/src/main/landunit_varcon.F90 @@ -18,9 +18,10 @@ module landunit_varcon integer, parameter, public :: istsoil = 1 !soil landunit type (natural vegetation) integer, parameter, public :: istcrop = 2 !crop landunit type - ! Landunit 3 currently unused (used to be non-multiple elevation class glacier type: - ! istice, and landunit 4 was istice_mec; now they are combined into a single landunit - ! type, 4) + integer, parameter, public :: istocn = 3 !ocean landunit type + ! Landunit 3 used to be non-multiple elevation class glacier type, istice + ! Landunit 4 was istice_mec; now landunit 4 and old landunit 3 are combined + ! into landunit 4 integer, parameter, public :: istice = 4 !land ice landunit type integer, parameter, public :: istdlak = 5 !deep lake landunit type (now used for all lakes) integer, parameter, public :: istwet = 6 !wetland landunit type (swamp, marsh, etc.) @@ -118,7 +119,7 @@ subroutine set_landunit_names landunit_names(istsoil) = 'vegetated_or_bare_soil' landunit_names(istcrop) = 'crop' - landunit_names(istcrop+1) = unused + landunit_names(istocn) = 'ocean' landunit_names(istice) = 'landice' landunit_names(istdlak) = 'deep_lake' landunit_names(istwet) = 'wetland' diff --git a/src/main/surfrdMod.F90 b/src/main/surfrdMod.F90 index 1d07229b3b..bbd4639828 100644 --- a/src/main/surfrdMod.F90 +++ b/src/main/surfrdMod.F90 @@ -370,7 +370,7 @@ subroutine surfrd_special(begg, endg, ncid, ns) ! ! !USES: use clm_varpar , only : maxpatch_glc, nlevurb - use landunit_varcon , only : isturb_MIN, isturb_MAX, istdlak, istwet, istice + use landunit_varcon , only : isturb_MIN, isturb_MAX, istdlak, istwet, istice, istocn use clm_instur , only : wt_lunit, urban_valid, wt_glc_mec, topo_glc_mec use UrbanParamsType , only : CheckUrban ! @@ -507,10 +507,9 @@ subroutine surfrd_special(begg, endg, ncid, ns) ! Until ctsm5.1 we would label ocean points as wetland in fsurdat ! files. Starting with ctsm5.2 we label ocean points as ocean - ! (always 100%) and wetland points as wetland. Here we merge them - ! again to keep model behavior unchanged for now. - wt_lunit(nl,istwet) = (pctocn(nl) + pctwet(nl)) / 100._r8 - + ! (always 100%) and wetland points as wetland. + wt_lunit(nl,istwet) = pctwet(nl) / 100._r8 + wt_lunit(nl,istocn) = pctocn(nl) / 100._r8 wt_lunit(nl,istice) = pctgla(nl) / 100._r8 do n = isturb_MIN, isturb_MAX diff --git a/src/main/surfrdUtilsMod.F90 b/src/main/surfrdUtilsMod.F90 index 95303322a4..78d90a9357 100644 --- a/src/main/surfrdUtilsMod.F90 +++ b/src/main/surfrdUtilsMod.F90 @@ -117,14 +117,15 @@ end subroutine renormalize subroutine apply_convert_ocean_to_land(wt_lunit, begg, endg) ! ! !DESCRIPTION: - ! Apply the conversion of ocean points to land, by changing all "wetland" points to - ! natveg; typically this will result in these points becoming bare ground. + ! Convert ocean points to land by changing ocean to natveg; + ! typically these points will become bare ground. ! - ! The motivation for doing this is to avoid the negative runoff that sometimes comes + ! Originally ocean points were assigned to wetland, so the motivation for + ! for this subroutine was to avoid the negative runoff that sometimes comes ! from wetlands. ! ! !USES: - use landunit_varcon, only : istsoil, istwet, max_lunit + use landunit_varcon, only : istsoil, istocn, max_lunit ! ! !ARGUMENTS: integer, intent(in) :: begg ! Beginning grid cell index @@ -138,15 +139,9 @@ subroutine apply_convert_ocean_to_land(wt_lunit, begg, endg) character(len=*), parameter :: subname = 'apply_convert_ocean_to_land' !----------------------------------------------------------------------- - ! BUG(wjs, 2022-10-27, ESCOMP/CTSM#1886) Ideally we would distinguish between ocean - ! vs. true wetland points on the surface dataset; for now oceans are included in the - ! wetland area on the surface dataset, so we convert all wetlands to land. (Typically - ! there are no true/inland wetlands on the surface dataset, so this is currently okay, - ! but this would become a problem if we started having inland wetlands on the surface - ! dataset again.) do g = begg, endg - wt_lunit(g,istsoil) = wt_lunit(g,istsoil) + wt_lunit(g,istwet) - wt_lunit(g,istwet) = 0._r8 + wt_lunit(g,istsoil) = wt_lunit(g,istsoil) + wt_lunit(g,istocn) + wt_lunit(g,istocn) = 0._r8 end do end subroutine apply_convert_ocean_to_land From 9ee78503d9d6e3deebad3a5f05bf36d397678848 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Fri, 27 Oct 2023 15:53:52 -0600 Subject: [PATCH 07/14] Merge suma lines that need not be separate --- tools/mksurfdata_esmf/src/mksurfdata.F90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/mksurfdata_esmf/src/mksurfdata.F90 b/tools/mksurfdata_esmf/src/mksurfdata.F90 index c40fee5c47..c814c98fee 100644 --- a/tools/mksurfdata_esmf/src/mksurfdata.F90 +++ b/tools/mksurfdata_esmf/src/mksurfdata.F90 @@ -1234,8 +1234,8 @@ subroutine normalize_and_check_landuse(ns_o) ! Confirm that we have done the rescaling correctly: now the sum of all landunits ! should be 100% within tol_loose - suma = pctlak(n) + pctwet(n) + pctgla(n) + pcturb(n) + pctcft(n)%get_pct_l2g() - suma = suma + pctnatpft(n)%get_pct_l2g() + pctocn(n) + suma = pctlak(n) + pctwet(n) + pctgla(n) + pcturb(n) + pctocn(n) + & + pctcft(n)%get_pct_l2g() + pctnatpft(n)%get_pct_l2g() if (abs(suma - 100._r8) > tol_loose) then write(6,*) subname, ' ERROR: landunits do not sum to 100%' write(6,*) 'n, suma, pctlak, pctwet, pctgla, pcturb, pctnatveg, pctcrop, pctocn = ' @@ -1264,8 +1264,8 @@ subroutine normalize_and_check_landuse(ns_o) ! Include pctocn in suma but do not include in the ! renormalization. When pctocn /= 0, it is 100, and ! all other terms are 0. - suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n) + pctocn(n) - suma = suma + pctnatpft(n)%get_pct_l2g() + pctcft(n)%get_pct_l2g() + suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n) + pctocn(n) + & + pctnatpft(n)%get_pct_l2g() + pctcft(n)%get_pct_l2g() if ( abs(suma - 100.0_r8) > 2.0*epsilon(suma) )then pctlak(n) = pctlak(n) * 100._r8/suma pctwet(n) = pctwet(n) * 100._r8/suma @@ -1314,8 +1314,8 @@ subroutine normalize_and_check_landuse(ns_o) call shr_sys_abort() end if - suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n) + pctcft(n)%get_pct_l2g() - suma = suma + pctnatpft(n)%get_pct_l2g() + pctocn(n) + suma = pctlak(n) + pctwet(n) + pcturb(n) + pctgla(n) + pctocn(n) + & + pctcft(n)%get_pct_l2g() + pctnatpft(n)%get_pct_l2g() if ( abs(suma-100._r8) > 1.e-10_r8) then write (6,*) subname, ' error: sum of pctocn, pctlak, pctwet,', & 'pcturb, pctgla, pctnatveg and pctcrop is NOT equal to 100' From 0d7264a81aff47da5049dd8f745b226d88e35047 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 31 Oct 2023 15:46:02 -0600 Subject: [PATCH 08/14] Remove comment that referred to past code history --- src/main/landunit_varcon.F90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/landunit_varcon.F90 b/src/main/landunit_varcon.F90 index 0483b50182..001fe95a06 100644 --- a/src/main/landunit_varcon.F90 +++ b/src/main/landunit_varcon.F90 @@ -19,9 +19,6 @@ module landunit_varcon integer, parameter, public :: istsoil = 1 !soil landunit type (natural vegetation) integer, parameter, public :: istcrop = 2 !crop landunit type integer, parameter, public :: istocn = 3 !ocean landunit type - ! Landunit 3 used to be non-multiple elevation class glacier type, istice - ! Landunit 4 was istice_mec; now landunit 4 and old landunit 3 are combined - ! into landunit 4 integer, parameter, public :: istice = 4 !land ice landunit type integer, parameter, public :: istdlak = 5 !deep lake landunit type (now used for all lakes) integer, parameter, public :: istwet = 6 !wetland landunit type (swamp, marsh, etc.) From c4420db00bd47e19b56871e460847c3fac52fb82 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 7 Nov 2023 12:38:03 -0700 Subject: [PATCH 09/14] Updates for ./run_ctsm_py_tests --sys and --unit to pass --- .../modify_input_files/fsurdat_modifier.py | 2 +- .../ctsm/modify_input_files/modify_fsurdat.py | 6 ++--- python/ctsm/test/test_sys_fsurdat_modifier.py | 27 ++++++++----------- python/ctsm/test/test_sys_mesh_modifier.py | 6 ++--- .../ctsm/test/test_unit_fsurdat_modifier.py | 10 +++---- python/ctsm/test/test_unit_modify_fsurdat.py | 2 +- python/ctsm/test/test_unit_subset_data.py | 4 +-- python/ctsm/test/testinputs/default_data.cfg | 12 ++++----- .../modify_fsurdat_1x1mexicocity.cfg | 14 +++++----- .../modify_fsurdat_opt_sections.cfg | 2 +- .../test/testinputs/modify_fsurdat_short.cfg | 4 +-- .../modify_fsurdat_template.cfg | 2 +- tools/site_and_regional/default_data.cfg | 12 ++++----- 13 files changed, 49 insertions(+), 54 deletions(-) diff --git a/python/ctsm/modify_input_files/fsurdat_modifier.py b/python/ctsm/modify_input_files/fsurdat_modifier.py index 492fa74230..a511fcfddc 100644 --- a/python/ctsm/modify_input_files/fsurdat_modifier.py +++ b/python/ctsm/modify_input_files/fsurdat_modifier.py @@ -110,7 +110,7 @@ def read_cfg_subgrid(config, cfg_path, numurbl=3): subgrid_settings = {} var_list = config.options(section) - valid_list = ["pct_natveg", "pct_crop", "pct_lake", "pct_glacier", "pct_wetland", "pct_urban"] + valid_list = ["pct_natveg", "pct_crop", "pct_lake", "pct_glacier", "pct_wetland", "pct_urban","pct_ocean"] varsum = 0 for var in var_list: if valid_list.count(var) == 0: diff --git a/python/ctsm/modify_input_files/modify_fsurdat.py b/python/ctsm/modify_input_files/modify_fsurdat.py index 6fa3701acc..919c42098c 100644 --- a/python/ctsm/modify_input_files/modify_fsurdat.py +++ b/python/ctsm/modify_input_files/modify_fsurdat.py @@ -264,7 +264,7 @@ def check_varlist(self, settings, allow_uppercase_vars=False): ) if len(val) != dim1: abort( - "Variable " + varname + " is of the wrong size. It should be = " + str(dim1) + "Variable " + varname + " is " + str(len(val)) + ". It should be = " + str(dim1) ) return settings_return @@ -397,8 +397,8 @@ def set_idealized(self): max_sat_area = 0 # max saturated area std_elev = 0 # standard deviation of elevation slope = 0 # mean topographic slope - pftdata_mask = 1 landfrac_pft = 1 + landfrac_mksurfdata = 1 # if pct_nat_veg had to be set to less than 100, then each special # landunit would have to receive a unique pct value rather than the # common value used here in pct_not_nat_veg = 0 @@ -415,8 +415,8 @@ def set_idealized(self): self.setvar_lev0("SLOPE", slope) self.setvar_lev0("zbedrock", zbedrock) self.setvar_lev0("SOIL_COLOR", soil_color) - self.setvar_lev0("PFTDATA_MASK", pftdata_mask) self.setvar_lev0("LANDFRAC_PFT", landfrac_pft) + self.setvar_lev0("LANDFRAC_MKSURFDATA", landfrac_mksurfdata) self.setvar_lev0("PCT_WETLAND", pct_not_nat_veg) self.setvar_lev0("PCT_CROP", pct_not_nat_veg) self.setvar_lev0("PCT_LAKE", pct_not_nat_veg) diff --git a/python/ctsm/test/test_sys_fsurdat_modifier.py b/python/ctsm/test/test_sys_fsurdat_modifier.py index 7bd57ce8af..b4559d1867 100755 --- a/python/ctsm/test/test_sys_fsurdat_modifier.py +++ b/python/ctsm/test/test_sys_fsurdat_modifier.py @@ -45,7 +45,7 @@ def setUp(self): self._testinputs_path = testinputs_path self._fsurdat_in = os.path.join( testinputs_path, - "surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214.nc", + "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc", ) self._tempdir = tempfile.mkdtemp() self._cfg_file_path = os.path.join(self._tempdir, "modify_fsurdat.cfg") @@ -76,9 +76,7 @@ def test_short_config(self): self._cfg_file_path = os.path.join(self._testinputs_path, "modify_fsurdat_short.cfg") sys.argv = ["fsurdat_modifier", self._cfg_file_path] parser = fsurdat_modifier_arg_process() - fsurdat_out = ( - "ctsm/test/testinputs/surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214_out.nc" - ) + fsurdat_out = os.path.join(self._testinputs_path, "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.out.nc") if os.path.exists(fsurdat_out): os.remove(fsurdat_out) fsurdat_modifier(parser) @@ -134,14 +132,14 @@ def test_opt_sections(self): self._cfg_file_path = os.path.join(self._testinputs_path, "modify_fsurdat_opt_sections.cfg") outfile = os.path.join( self._tempdir, - "surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214_output_urban.nc", + "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_output_urban.nc", ) sys.argv = [ "fsurdat_modifier", self._cfg_file_path, "-i", os.path.join( - self._testinputs_path, "surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214.nc" + self._testinputs_path, "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc" ), "-o", outfile, @@ -180,12 +178,9 @@ def test_opt_sections(self): lev2_two = np.empty((2, 3, 5, 5)) lev2_two[0, :, :, :] = 200.0 lev2_two[1, :, :, :] = 100.0 - lev2_five = np.empty((5, 3, 5, 5)) - lev2_five[0, :, :, :] = 1.0 - lev2_five[1, :, :, :] = 2.0 - lev2_five[2, :, :, :] = 3.0 - lev2_five[3, :, :, :] = 4.0 - lev2_five[4, :, :, :] = 5.0 + lev2_ten = np.empty((10, 3, 5, 5)) + for x in range(10): + lev2_ten[x, :, :, :] = x + 1 lev1 = np.array( [ [ @@ -221,7 +216,7 @@ def test_opt_sections(self): np.testing.assert_array_equal(fsurdat_out_data.LAKEDEPTH, one0d * 200.0) np.testing.assert_array_equal(fsurdat_out_data.T_BUILDING_MIN, lev1) np.testing.assert_array_equal(fsurdat_out_data.ALB_ROOF_DIR, lev2_two) - np.testing.assert_array_equal(fsurdat_out_data.TK_ROOF, lev2_five) + np.testing.assert_array_equal(fsurdat_out_data.TK_ROOF, lev2_ten) def test_1x1_mexicocity(self): """ @@ -232,15 +227,15 @@ def test_1x1_mexicocity(self): ) expectfile = os.path.join( self._testinputs_path, - "surfdata_1x1_mexicocityMEX_hist_16pfts_Irrig_CMIP6_simyr2000_c221206_modified.nc", + "surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103_modified.nc", ) outfile = os.path.join( self._tempdir, - "surfdata_1x1_mexicocityMEX_hist_16pfts_Irrig_CMIP6_simyr2000_c221206_modified.nc", + "surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103_modified.nc", ) infile = os.path.join( self._testinputs_path, - "surfdata_1x1_mexicocityMEX_hist_16pfts_Irrig_CMIP6_simyr2000_c221206.nc", + "surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103.nc", ) sys.argv = [ "fsurdat_modifier", diff --git a/python/ctsm/test/test_sys_mesh_modifier.py b/python/ctsm/test/test_sys_mesh_modifier.py index 0889a505ba..b44605db26 100755 --- a/python/ctsm/test/test_sys_mesh_modifier.py +++ b/python/ctsm/test/test_sys_mesh_modifier.py @@ -46,7 +46,7 @@ def setUp(self): testinputs_path = os.path.join(path_to_ctsm_root(), "python/ctsm/test/testinputs") fsurdat_in = os.path.join( testinputs_path, - "surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214.nc", + "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc", ) self._tempdir = tempfile.mkdtemp() self._cfg_file_path = os.path.join(self._tempdir, "modify_mesh_mask.cfg") @@ -96,8 +96,8 @@ def setUp(self): self._lon_dimname = fsurdat_in_data[self._lat_varname].dims[1] ncap2_cmd = ( - "ncap2 -A -v -s 'mod_lnd_props=PFTDATA_MASK' " - + "-A -v -s 'landmask=PFTDATA_MASK' " + "ncap2 -A -v -s 'mod_lnd_props=LANDFRAC_MKSURFDATA' " + + "-A -v -s 'landmask=LANDFRAC_MKSURFDATA' " + f"-A -v -s {self._lat_varname}={self._lat_varname} " + f"-A -v -s {self._lon_varname}={self._lon_varname} " + f"{fsurdat_in} {self._landmask_file}" diff --git a/python/ctsm/test/test_unit_fsurdat_modifier.py b/python/ctsm/test/test_unit_fsurdat_modifier.py index 0ea862a8e4..8c13e2eb19 100755 --- a/python/ctsm/test/test_unit_fsurdat_modifier.py +++ b/python/ctsm/test/test_unit_fsurdat_modifier.py @@ -44,13 +44,9 @@ def setUp(self): self._testinputs_path = testinputs_path self._fsurdat_in = os.path.join( testinputs_path, - "surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214.nc", + "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc", ) self._tempdir = tempfile.mkdtemp() - self._fsurdat_in = os.path.join( - testinputs_path, - "surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214.nc", - ) self._fsurdat_out = os.path.join(self._tempdir, "fsurdat_out.nc") sys.argv = [ "fsurdat_modifier", @@ -133,6 +129,7 @@ def test_read_subgrid_allglacier(self): self.config.set(section, "pct_urban", "0. 0. 0.") self.config.set(section, "pct_lake", "0.") self.config.set(section, "pct_wetland", "0.") + self.config.set(section, "pct_ocean", "0.") self.config.set(section, "pct_glacier", "100.") self.config.set(section, "pct_natveg", "0.") self.config.set(section, "pct_crop", "0.") @@ -146,6 +143,7 @@ def test_read_subgrid_allspecial(self): self.config.set(section, "pct_urban", "0. 0. 0.") self.config.set(section, "pct_lake", "25.") self.config.set(section, "pct_wetland", "35.") + self.config.set(section, "pct_ocean", "0.") self.config.set(section, "pct_glacier", "40.") self.config.set(section, "pct_natveg", "0.") self.config.set(section, "pct_crop", "0.") @@ -159,6 +157,7 @@ def test_read_subgrid_allurban(self): self.config.set(section, "pct_urban", "100.0 0.0 0.0") self.config.set(section, "pct_lake", "0.") self.config.set(section, "pct_wetland", "0.") + self.config.set(section, "pct_ocean", "0.") self.config.set(section, "pct_glacier", "0.") self.config.set(section, "pct_natveg", "0.") self.config.set(section, "pct_crop", "0.") @@ -218,6 +217,7 @@ def test_subgrid_notsumtohundred(self): self.config.set(section, "pct_urban", "0. 0. 0.") self.config.set(section, "pct_lake", "0.") self.config.set(section, "pct_wetland", "0.") + self.config.set(section, "pct_ocean", "0.") self.config.set(section, "pct_glacier", "0.") self.config.set(section, "pct_natveg", "0.") self.config.set(section, "pct_crop", "0.") diff --git a/python/ctsm/test/test_unit_modify_fsurdat.py b/python/ctsm/test/test_unit_modify_fsurdat.py index a075035b73..f41563a5c3 100755 --- a/python/ctsm/test/test_unit_modify_fsurdat.py +++ b/python/ctsm/test/test_unit_modify_fsurdat.py @@ -389,7 +389,7 @@ def test_check_varlist_lists_wrongsizes(self): lev1list = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0] settings = {"var_lev1": lev1list} with self.assertRaisesRegex( - SystemExit, "Variable var_lev1 is of the wrong size. It should be" + SystemExit, "Variable var_lev1 is " + str(len(lev1list)) + ". It should be" ): self.modify_fsurdat.check_varlist(settings) diff --git a/python/ctsm/test/test_unit_subset_data.py b/python/ctsm/test/test_unit_subset_data.py index fd9aef631d..3041d58897 100755 --- a/python/ctsm/test/test_unit_subset_data.py +++ b/python/ctsm/test/test_unit_subset_data.py @@ -46,7 +46,7 @@ def test_inputdata_setup_files_basic(self): files = setup_files(self.args, self.defaults, self.cesmroot) self.assertEqual( files["fsurf_in"], - "surfdata_0.9x1.25_hist_16pfts_Irrig_CMIP6_simyr2000_c190214.nc", + "surfdata_0.9x1.25_hist_16pfts_CMIP6_1850-2015_c231031.nc", "fsurf_in filename not whats expected", ) self.assertEqual( @@ -134,7 +134,7 @@ def test_check_args_outsurfdat_fails_without_overwrite(self): outfile = os.path.join( os.getcwd(), "ctsm/test/testinputs/", - "surfdata_1x1_mexicocityMEX_hist_16pfts_Irrig_CMIP6_simyr2000_c221206.nc", + "surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103.nc", ) self.assertTrue(os.path.exists(outfile), str(outfile) + " outfile should exist") diff --git a/python/ctsm/test/testinputs/default_data.cfg b/python/ctsm/test/testinputs/default_data.cfg index 7e841dca54..2ec453967f 100644 --- a/python/ctsm/test/testinputs/default_data.cfg +++ b/python/ctsm/test/testinputs/default_data.cfg @@ -15,14 +15,14 @@ precname = CLMGSWP3v1.Precip tpqwname = CLMGSWP3v1.TPQW [surfdat] -dir = lnd/clm2/surfdata_map/release-clm5.0.18 -surfdat_16pft = surfdata_0.9x1.25_hist_16pfts_Irrig_CMIP6_simyr2000_c190214.nc -surfdat_78pft = surfdata_0.9x1.25_hist_78pfts_CMIP6_simyr2000_c190214.nc +dir = lnd/clm2/surfdata_esmf/ctsm5.2.0 +surfdat_16pft = surfdata_0.9x1.25_hist_16pfts_CMIP6_1850-2015_c231031.nc +surfdat_78pft = surfdata_0.9x1.25_hist_78pfts_CMIP6_1850-2015_c231031.nc [landuse] -dir = lnd/clm2/surfdata_map/release-clm5.0.18 -landuse_16pft = landuse.timeseries_0.9x1.25_hist_16pfts_Irrig_CMIP6_simyr1850-2015_c190214.nc -landuse_78pft = landuse.timeseries_0.9x1.25_hist_78pfts_CMIP6_simyr1850-2015_c190214.nc +dir = lnd/clm2/surfdata_esmf/ctsm5.2.0 +landuse_16pft = landuse.timeseries_0.9x1.25_hist_16_CMIP6_1850-2015_c231031.nc +landuse_78pft = landuse.timeseries_0.9x1.25_hist_78_CMIP6_1850-2015_c231031.nc [domain] file = share/domains/domain.lnd.fv0.9x1.25_gx1v7.151020.nc diff --git a/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg b/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg index a854ebcc53..f9ddccfd2f 100644 --- a/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg +++ b/python/ctsm/test/testinputs/modify_fsurdat_1x1mexicocity.cfg @@ -71,13 +71,13 @@ ALB_ROOF_DIF = 0.2 0.2 ALB_WALL_DIR = 0.25 0.25 ALB_WALL_DIF = 0.25 0.25 -# Variabls on nlevurb which is 5 -TK_ROOF = 0.20 0.93 0.93 0.03 0.16 -TK_WALL = 0.88 0.88 0.88 0.88 0.88 -TK_IMPROAD = 0.82 0.82 2.10 2.10 2.10 -CV_ROOF = 1760000.0 1500000.0 1500000.0 250000.0 870000.0 -CV_WALL = 1540000.0 1540000.0 1540000.0 1540000.0 1540000.0 -CV_IMPROAD = 1740000.0 1740000.0 2000000.0 2000000.0 2000000.0 +# Variabls on nlevurb which is 10 +TK_ROOF = 0.20 0.93 0.93 0.03 0.16 0.20 0.93 0.93 0.03 0.16 +TK_WALL = 0.88 0.88 0.88 0.88 0.88 0.88 0.88 0.88 0.88 0.88 +TK_IMPROAD = 0.82 0.82 2.10 2.10 2.10 0.82 0.82 2.10 2.10 2.10 +CV_ROOF = 1760000.0 1500000.0 1500000.0 250000.0 870000.0 1760000.0 1500000.0 1500000.0 250000.0 870000.0 +CV_WALL = 1540000.0 1540000.0 1540000.0 1540000.0 1540000.0 1540000.0 1540000.0 1540000.0 1540000.0 1540000.0 +CV_IMPROAD = 1740000.0 1740000.0 2000000.0 2000000.0 2000000.0 1740000.0 1740000.0 2000000.0 2000000.0 2000000.0 # Natural and Crop PFT's don't really need to be set, since they have zero area, but # it looks better to do so diff --git a/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg b/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg index 38e7a529f0..ea3699970d 100644 --- a/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg +++ b/python/ctsm/test/testinputs/modify_fsurdat_opt_sections.cfg @@ -49,4 +49,4 @@ CANYON_HWR = 200.00 150.0 100. HT_ROOF = 200.0 150.0 100. T_BUILDING_MIN = 200 150.0 100. ALB_ROOF_DIR = 200. 100. -TK_ROOF = 1. 2. 3. 4. 5. +TK_ROOF = 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. diff --git a/python/ctsm/test/testinputs/modify_fsurdat_short.cfg b/python/ctsm/test/testinputs/modify_fsurdat_short.cfg index 74c6639899..222259a251 100644 --- a/python/ctsm/test/testinputs/modify_fsurdat_short.cfg +++ b/python/ctsm/test/testinputs/modify_fsurdat_short.cfg @@ -1,7 +1,7 @@ [modify_fsurdat_basic_options] -fsurdat_in = ctsm/test/testinputs/surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214.nc -fsurdat_out = ctsm/test/testinputs/surfdata_5x5_amazon_16pfts_Irrig_CMIP6_simyr2000_c171214_out.nc +fsurdat_in = ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc +fsurdat_out = ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.out.nc idealized = False process_subgrid_section = False diff --git a/tools/modify_input_files/modify_fsurdat_template.cfg b/tools/modify_input_files/modify_fsurdat_template.cfg index 3661784521..6923ee1cb9 100644 --- a/tools/modify_input_files/modify_fsurdat_template.cfg +++ b/tools/modify_input_files/modify_fsurdat_template.cfg @@ -29,8 +29,8 @@ fsurdat_out = FILL_THIS_IN # defaults, then set this to True. Hardwired values are as follows: # zbedrock = 10 # SLOPE = 0 -# PFTDATA_MASK = 1 # LANDFRAC_PFT = 1 +# LANDFRAC_MKSURFDATA = 1 # PCT_NATVEG = 100 other landunits 0 # PCT_SAND = 43 corresponds to loam # PCT_CLAY = 18 corresponds to loam diff --git a/tools/site_and_regional/default_data.cfg b/tools/site_and_regional/default_data.cfg index 7e841dca54..ba75580b9d 100644 --- a/tools/site_and_regional/default_data.cfg +++ b/tools/site_and_regional/default_data.cfg @@ -15,14 +15,14 @@ precname = CLMGSWP3v1.Precip tpqwname = CLMGSWP3v1.TPQW [surfdat] -dir = lnd/clm2/surfdata_map/release-clm5.0.18 -surfdat_16pft = surfdata_0.9x1.25_hist_16pfts_Irrig_CMIP6_simyr2000_c190214.nc -surfdat_78pft = surfdata_0.9x1.25_hist_78pfts_CMIP6_simyr2000_c190214.nc +dir = lnd/clm2/surfdata_esmf/ctsm5.2.0 +surfdat_16pft = surfdata_0.9x1.25_hist_16pfts_CMIP6_1850-2015_c231103.nc +surfdat_78pft = surfdata_0.9x1.25_hist_78pfts_CMIP6_1850-2015_c231031.nc [landuse] -dir = lnd/clm2/surfdata_map/release-clm5.0.18 -landuse_16pft = landuse.timeseries_0.9x1.25_hist_16pfts_Irrig_CMIP6_simyr1850-2015_c190214.nc -landuse_78pft = landuse.timeseries_0.9x1.25_hist_78pfts_CMIP6_simyr1850-2015_c190214.nc +dir = lnd/clm2/surfdata_esmf/ctsm5.2.0 +landuse_16pft = landuse.timeseries_0.9x1.25_hist_16_CMIP6_1850-2015_c231103.nc +landuse_78pft = landuse.timeseries_0.9x1.25_hist_78_CMIP6_1850-2015_c231031.nc [domain] file = share/domains/domain.lnd.fv0.9x1.25_gx1v7.151020.nc From d42b32c7d33799761d0d4ec54bef6fcee97926f9 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 7 Nov 2023 17:25:14 -0700 Subject: [PATCH 10/14] Add convert_ocean_to_land = .true. to MKSURFDATAESMF test for PASS --- cime_config/SystemTests/mksurfdataesmf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cime_config/SystemTests/mksurfdataesmf.py b/cime_config/SystemTests/mksurfdataesmf.py index af783850ba..d4f74788c9 100644 --- a/cime_config/SystemTests/mksurfdataesmf.py +++ b/cime_config/SystemTests/mksurfdataesmf.py @@ -128,4 +128,5 @@ def _modify_user_nl(self): """ append_to_user_nl_files(caseroot = self._get_caseroot(), component = "clm", - contents = "fsurdat = '{}'".format(self._fsurdat_nc)) + contents = "fsurdat = '{}'".format(self._fsurdat_nc) + "\n" + + "convert_ocean_to_land = .true.") From a0d014fae9550dd9ffbc934abd29ef16176f8208 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 7 Nov 2023 17:56:23 -0700 Subject: [PATCH 11/14] Black reformatging --- python/ctsm/modify_input_files/fsurdat_modifier.py | 10 +++++++++- python/ctsm/modify_input_files/modify_fsurdat.py | 7 ++++++- python/ctsm/test/test_sys_fsurdat_modifier.py | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/python/ctsm/modify_input_files/fsurdat_modifier.py b/python/ctsm/modify_input_files/fsurdat_modifier.py index a511fcfddc..8f63339c2b 100644 --- a/python/ctsm/modify_input_files/fsurdat_modifier.py +++ b/python/ctsm/modify_input_files/fsurdat_modifier.py @@ -110,7 +110,15 @@ def read_cfg_subgrid(config, cfg_path, numurbl=3): subgrid_settings = {} var_list = config.options(section) - valid_list = ["pct_natveg", "pct_crop", "pct_lake", "pct_glacier", "pct_wetland", "pct_urban","pct_ocean"] + valid_list = [ + "pct_natveg", + "pct_crop", + "pct_lake", + "pct_glacier", + "pct_wetland", + "pct_urban", + "pct_ocean", + ] varsum = 0 for var in var_list: if valid_list.count(var) == 0: diff --git a/python/ctsm/modify_input_files/modify_fsurdat.py b/python/ctsm/modify_input_files/modify_fsurdat.py index 919c42098c..13495d8b10 100644 --- a/python/ctsm/modify_input_files/modify_fsurdat.py +++ b/python/ctsm/modify_input_files/modify_fsurdat.py @@ -264,7 +264,12 @@ def check_varlist(self, settings, allow_uppercase_vars=False): ) if len(val) != dim1: abort( - "Variable " + varname + " is " + str(len(val)) + ". It should be = " + str(dim1) + "Variable " + + varname + + " is " + + str(len(val)) + + ". It should be = " + + str(dim1) ) return settings_return diff --git a/python/ctsm/test/test_sys_fsurdat_modifier.py b/python/ctsm/test/test_sys_fsurdat_modifier.py index b4559d1867..ce498692ed 100755 --- a/python/ctsm/test/test_sys_fsurdat_modifier.py +++ b/python/ctsm/test/test_sys_fsurdat_modifier.py @@ -76,7 +76,9 @@ def test_short_config(self): self._cfg_file_path = os.path.join(self._testinputs_path, "modify_fsurdat_short.cfg") sys.argv = ["fsurdat_modifier", self._cfg_file_path] parser = fsurdat_modifier_arg_process() - fsurdat_out = os.path.join(self._testinputs_path, "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.out.nc") + fsurdat_out = os.path.join( + self._testinputs_path, "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.out.nc" + ) if os.path.exists(fsurdat_out): os.remove(fsurdat_out) fsurdat_modifier(parser) From 42e6796dc6045c6fd0bf4eacee0b48979e7ddbf4 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Tue, 7 Nov 2023 17:59:37 -0700 Subject: [PATCH 12/14] Update .git-blame-ignore-revs --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index a3795e4c6b..e30f3ada55 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -7,3 +7,4 @@ e44dc469439e02e9ee582dab274d890ebdfab104 b88e1cd1b28e3609684c79a2ec0e88f26cfc362b 51c102c5df2e0ef971b5f8eeeb477567899af63a 7dacad70e74e2ec97f6492d4e7a3cb5dd498bcd7 +a0d014fae9550dd9ffbc934abd29ef16176f8208 From f5325109cbda286d1b0c8dc5491a04a6ff499480 Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 13 Nov 2023 14:59:50 -0700 Subject: [PATCH 13/14] Correct accidental line-delete from resolving conflicts --- python/ctsm/test/test_sys_fsurdat_modifier.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/ctsm/test/test_sys_fsurdat_modifier.py b/python/ctsm/test/test_sys_fsurdat_modifier.py index a1a29b9423..ce498692ed 100755 --- a/python/ctsm/test/test_sys_fsurdat_modifier.py +++ b/python/ctsm/test/test_sys_fsurdat_modifier.py @@ -45,6 +45,7 @@ def setUp(self): self._testinputs_path = testinputs_path self._fsurdat_in = os.path.join( testinputs_path, + "surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc", ) self._tempdir = tempfile.mkdtemp() self._cfg_file_path = os.path.join(self._tempdir, "modify_fsurdat.cfg") From 960e951f2244c84a6bcf3de1fcf8a8c667a1797f Mon Sep 17 00:00:00 2001 From: Samuel Levis Date: Mon, 13 Nov 2023 15:21:19 -0700 Subject: [PATCH 14/14] New surfdata_1x1 and 5x5 files in /testinputs --- ...urfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103.nc | 3 +++ ...x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103_modified.nc | 3 +++ .../surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc | 3 +++ ...fdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified.nc | 3 +++ ...amazon_hist_16pfts_CMIP6_2000_c231031_modified_with_crop.nc | 3 +++ 5 files changed, 15 insertions(+) create mode 100644 python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103.nc create mode 100644 python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103_modified.nc create mode 100644 python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc create mode 100644 python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified.nc create mode 100644 python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified_with_crop.nc diff --git a/python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103.nc b/python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103.nc new file mode 100644 index 0000000000..ae21f4f6f8 --- /dev/null +++ b/python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103.nc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eee6618ad3cb7893a12570895c8e85ac70de540bc569e801ead871d00193029e +size 27908 diff --git a/python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103_modified.nc b/python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103_modified.nc new file mode 100644 index 0000000000..d6091aa096 --- /dev/null +++ b/python/ctsm/test/testinputs/surfdata_1x1_mexicocityMEX_hist_16pfts_CMIP6_2000_c231103_modified.nc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6ad9d750e176cbc19afa709dfd05557086254570d240fa801c2e9c8b600d2f12 +size 28332 diff --git a/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc b/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc new file mode 100644 index 0000000000..54b7bef1b6 --- /dev/null +++ b/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031.nc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a0b39750baeb06add72002f0fc2540096b9876bb12d27a1c8d2ec2a5a11f83fd +size 260864 diff --git a/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified.nc b/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified.nc new file mode 100644 index 0000000000..d2de87f751 --- /dev/null +++ b/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified.nc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dd3aa2c1400ee44e59132fc7dd3c1f62bb654810ac0c0d67f76f092f1a62a3de +size 259264 diff --git a/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified_with_crop.nc b/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified_with_crop.nc new file mode 100644 index 0000000000..3afe8b1803 --- /dev/null +++ b/python/ctsm/test/testinputs/surfdata_5x5_amazon_hist_16pfts_CMIP6_2000_c231031_modified_with_crop.nc @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5a7584a6344d482d5f047159d8bcc499575dcf87a1b6cd2014312f53245767d7 +size 259184