From 6db47989d42644b33a07304b3eba50ed2c3292da Mon Sep 17 00:00:00 2001 From: huitang-earth Date: Sun, 11 Oct 2020 22:56:53 +0200 Subject: [PATCH] adapt the 'emerald_sites_tools' to produce inputdata for v2.0.0 and adapt namelist parameters to read these data --- bld/CLMBuildNamelist.pm | 4 +- bld/namelist_files/namelist_defaults_ctsm.xml | 111 +++++++++- .../lightning_site_clm5.ncl | 201 +++++++++++++++++ .../emerald_sites_tools/popden_site_clm5.ncl | 207 ++++++++++++++++++ .../tar_model_input_site.sh | 22 +- ...a.sh => workflow_setup_site_simulation.sh} | 31 ++- 6 files changed, 560 insertions(+), 16 deletions(-) create mode 100644 tools/emerald_sites_tools/lightning_site_clm5.ncl create mode 100644 tools/emerald_sites_tools/popden_site_clm5.ncl rename tools/emerald_sites_tools/{prepare_inputdata.sh => workflow_setup_site_simulation.sh} (84%) diff --git a/bld/CLMBuildNamelist.pm b/bld/CLMBuildNamelist.pm index 60d3de27d1..5af1375346 100755 --- a/bld/CLMBuildNamelist.pm +++ b/bld/CLMBuildNamelist.pm @@ -3237,7 +3237,7 @@ sub setup_logic_popd_streams { 'sim_year_range'=>$nl_flags->{'sim_year_range'}, 'cnfireson'=>$nl_flags->{'cnfireson'}); } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_popdens', 'phys'=>$nl_flags->{'phys'}, - 'cnfireson'=>$nl_flags->{'cnfireson'}, 'hgrid'=>"0.5x0.5", 'ssp_rcp'=>$nl_flags->{'ssp_rcp'} ); + 'cnfireson'=>$nl_flags->{'cnfireson'}, 'hgrid'=>$nl_flags->{'res'}, 'ssp_rcp'=>$nl_flags->{'ssp_rcp'} ); } else { # If bgc is NOT CN/CNDV or fire_method==nofire then make sure none of the popdens settings are set if ( defined($nl->get_value('stream_year_first_popdens')) || @@ -3299,7 +3299,7 @@ sub setup_logic_lightning_streams { 'sim_year_range'=>$nl_flags->{'sim_year_range'}); } add_default($opts, $nl_flags->{'inputdata_rootdir'}, $definition, $defaults, $nl, 'stream_fldfilename_lightng', 'use_cn'=>$nl_flags->{'use_cn'}, - 'hgrid'=>$nl_flags->{'light_res'} ); + 'hgrid'=>$nl_flags->{'res'} ); } else { # If bgc is NOT CN/CNDV then make sure none of the Lightng settings are set if ( defined($nl->get_value('stream_year_first_lightng')) || diff --git a/bld/namelist_files/namelist_defaults_ctsm.xml b/bld/namelist_files/namelist_defaults_ctsm.xml index c5bdca94c0..f85110b320 100644 --- a/bld/namelist_files/namelist_defaults_ctsm.xml +++ b/bld/namelist_files/namelist_defaults_ctsm.xml @@ -1260,11 +1260,34 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 0001 0001 -0001 -0001 + + +2000 +2000 + atm/datm7/NASA_LIS/clmforc.Li_2012_climo1995-2011.T62.lnfm_Total_c140423.nc atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc +atm/datm7/NASA_LIS/ALP1/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_ALP1.nc +atm/datm7/NASA_LIS/ALP2/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_ALP2.nc +atm/datm7/NASA_LIS/ALP3/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_ALP3.nc +atm/datm7/NASA_LIS/ALP4/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_ALP4.nc +atm/datm7/NASA_LIS/SUB1/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_SUB1.nc +atm/datm7/NASA_LIS/SUB2/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_SUB2.nc +atm/datm7/NASA_LIS/SUB3/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_SUB3.nc +atm/datm7/NASA_LIS/SUB4/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_SUB4.nc +atm/datm7/NASA_LIS/BOR1/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_BOR1.nc +atm/datm7/NASA_LIS/BOR2/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_BOR2.nc +atm/datm7/NASA_LIS/BOR3/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_BOR3.nc +atm/datm7/NASA_LIS/BOR4/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_BOR4.nc +atm/datm7/NASA_LIS/LYG/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_LYG.nc +atm/datm7/NASA_LIS/BUO/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_BUO.nc +atm/datm7/NASA_LIS/HAV/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_HAV.nc +atm/datm7/NASA_LIS/SKO/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_SKO.nc +atm/datm7/NASA_LIS/VIKE/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_VIKE.nc +atm/datm7/NASA_LIS/JOAS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_JOAS.nc +atm/datm7/NASA_LIS/LIAH/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_LIAH.nc +atm/datm7/NASA_LIS/FINN/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_FINN.nc atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc bilinear @@ -1278,6 +1301,49 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 nn nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn + +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn + + 2015 2100 @@ -1341,6 +1407,27 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 lnd/clm2/firedata/clmforc.Li_2018_SSP5_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc +lnd/clm2/firedata/ALP1/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_ALP1.nc +lnd/clm2/firedata/ALP2/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_ALP2.nc +lnd/clm2/firedata/ALP3/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_ALP3.nc +lnd/clm2/firedata/ALP4/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_ALP4.nc +lnd/clm2/firedata/SUB1/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_SUB1.nc +lnd/clm2/firedata/SUB2/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_SUB2.nc +lnd/clm2/firedata/SUB3/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_SUB3.nc +lnd/clm2/firedata/SUB4/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_SUB4.nc +lnd/clm2/firedata/BOR1/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_BOR1.nc +lnd/clm2/firedata/BOR2/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_BOR2.nc +lnd/clm2/firedata/BOR3/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_BOR3.nc +lnd/clm2/firedata/BOR4/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_BOR4.nc +lnd/clm2/firedata/LYG/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_LYG.nc +lnd/clm2/firedata/BUO/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_BUO.nc +lnd/clm2/firedata/HAV/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_HAV.nc +lnd/clm2/firedata/SKO/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_SKO.nc +lnd/clm2/firedata/VIKE/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_VIKE.nc +lnd/clm2/firedata/JOAS/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_JOAS.nc +lnd/clm2/firedata/LIAH/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_LIAH.nc +lnd/clm2/firedata/FINN/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_FINN.nc + lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202.nc lnd/clm2/firedata/clmforc.Li_2018_SSP1_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2100_c181205.nc @@ -1398,6 +1485,26 @@ lnd/clm2/surfdata_map/landuse.timeseries_ne30np4_hist_16pfts_Irrig_CMIP6_simyr18 nn nn nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn +nn 2015 diff --git a/tools/emerald_sites_tools/lightning_site_clm5.ncl b/tools/emerald_sites_tools/lightning_site_clm5.ncl new file mode 100644 index 0000000000..fcf91414f8 --- /dev/null +++ b/tools/emerald_sites_tools/lightning_site_clm5.ncl @@ -0,0 +1,201 @@ +; Create site/regional lightning data for the model platform +; The origional global file used by default is too large. +; This script is adapated from the original "aerdepregrid.ncl" used in early versions of CLM (see below the original statement) +; +;;##################################################### +;; Regrid CLM Aerosol-Deposition file (aerdep) to a new resolution. +;; Works for climatology monthly aerdep files. +;; Uses input environment variables to determine resolution and other +;; parameters to describe set of files to use. +;; Uses bld query to get input filenames. Also uses env variable CSMDATA for location +;; of input files. +;; +;; Erik Kluzek +;; Apr/10/2008 +;; $Id: aerdepregrid.ncl 28400 2011-05-16 05:46:46Z erik $ +;; $HeadURL; +;;###################################################### + +begin + ; =========================================================================================================== + ; + ; IMPORTANT NOTE: EDIT THE FOLLOWING TO CUSTOMIZE + ; Edit the following as needed to interpolate to a new resolution. + ; Input and output resolution + +;################ +;Setup begin +;################ + + plot_name=(/"ALP1","ALP2","ALP3","ALP4","SUB1","SUB2","SUB3","SUB4","BOR1","BOR2","BOR3","BOR4","LYG","BUO","HAV","SKO","VIKE","JOAS","LIAH","FINN"/) ; site name + +;SeedClim Sites: "ALP1","ALP2","ALP3","ALP4","SUB1","SUB2","SUB3","SUB4","BOR1","BOR2","BOR3","BOR4" +;Landpress Sites: "LYG","BUO","HAV","SKO" +;Three-D Sites: "VIKE","JOAS","LIAH" +;Finnmark Site: "FINN" + + do p=0,11,1 + + filename = "/cluster/shared/noresm/inputdata/atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825.nc" ; global lightning data file + filenameout = "/cluster/shared/noresm/inputdata_fates_platform/atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_"+plot_name(p)+".nc" ;output lightning data file for the site + gridfile = "/cluster/shared/noresm/inputdata_fates_platform/share/domains/"+plot_name(p)+"/domain.lnd."+plot_name(p)+".200422.nc" ;domain file for the site +;################ +;Setup end +;################ + + + ; Open files + print( "Interpolate from file: "+filename ); + if ( systemfunc("test -f "+filename+"; echo $?" ) .ne. 0 )then + print( "Input faerdep file does not exist or not found: "+filename ); + exit + end if + nc = addfile( filename, "r" ); + + print( "Use grid file: "+gridfile ); + if ( systemfunc("test -f "+gridfile+"; echo $?" ) .ne. 0 )then + print( "Input gridfile does not exist or not found: "+gridfile ); + exit + end if + ncg = addfile( gridfile, "r" ); + print( "Output file: "+filenameout ); + if ( systemfunc("test -f "+filenameout+"; echo $?" ) .eq. 0 )then + system( "/bin/rm -f "+filenameout ); + end if + nco = addfile( filenameout, "c" ); + ; + ; Define dimensions + ; + dimnames = (/ "time", "lat", "lon", "scalar"/); + latgg = tofloat(ncg->yc(:,0)); + longg = tofloat(ncg->xc(0,:)); + nlat = dimsizes( latgg ); + nlon = dimsizes( longg ); + ntime = getfilevardimsizes(nc,"time"); + dsizes = (/ ntime, nlat, nlon, 1 /); + is_unlim = (/ True, False, False, False/); + filedimdef( nco, dimnames, dsizes, is_unlim ); + print( "Number of times: "+ntime ); + ; + ; Define vars and add attributes from original file + ; + print( "Define vars" ); + vars = getfilevarnames( nc ); + print(vars) + i = dimsizes(vars) - 1 + do while ( i .ge. 0 ) + print( "Define "+vars(i) ); + filevardef ( nco, vars(i), typeof(nc->$vars(i)$), getfilevardims( nc, vars(i) ) ); + filevarattdef ( nco, vars(i), nc->$vars(i)$ ); + i = i - 1 + end do + fileattdef ( nco, nc ); + ; + ; Add global attributes to output file + ; + print( "Global attributes" ); + + nco@source = "Regrid from:"+filename; + nco@gridfile = gridfile; + nco@aerdepregridVersion = "$HeadURL: https://svn-ccsm-models.cgd.ucar.edu/clm2/branch_tags/cesm1_0_rel_tags/cesm1_0_3_n05_clm4_0_32/models/lnd/clm/tools/ncl_scripts/aerdepregrid.ncl $"; + nco@aerdepregridRevision = "$Id: aerdepregrid.ncl 28400 2011-05-16 05:46:46Z erik $"; + ; + ; Copy coordinate variables over + ; + nco->time= (/nc->time/); + nco->lon = (/longg/); + nco->lat = (/latgg/); + nco->EDGEW = tofloat( (/ncg->xv(0,0,0)/) ); + print(ncg->xv(0,0,0)) + nco->EDGES = tofloat( (/ncg->yv(0,0,0)/) ); + nco->EDGEN = tofloat( (/ncg->yv(0,0,1)/) ); + nco->EDGEE = tofloat( (/ncg->xv(0,0,2)/) ); + print(ncg->xv(0,0,2)) + nco->LATIXY = tofloat( (/ncg->yc/) ); + nco->LONGXY = tofloat( (/ncg->xc/) ); + lon = (/ nc->lon /); + lat = (/ nc->lat /); + lono = (/ nco->lon /); + lato = (/ nco->lat /); + + ; loop over variables + ; + if ( nlon .eq. 1 )then + Cyclic = False + else + dx = lono(1) - lono(0); + ; The last longitude should equal 360-(dx-first_longitude) + ; So for example if first_longitude=0, last will be 360-dx + ; If first_longitude=dx, last will be 360 + expLast = 360.0 - (dx - lono(0)); + if ( abs(lono(nlon-1) - expLast) .lt. 1.e-4 )then + Cyclic = True; + else + Cyclic = False + end if + end if + + print( "Cyclic grid: "+Cyclic ); + + do i = 0, dimsizes( vars )-1 + + vardimnames = getfilevardims( nc, vars(i) ); + ; + ; If variable is not one of the dimensions -- regrid it and write to output file + ; + if ( vars(i) .eq. "lnfm" )then + print( "Write variable: "+vars(i)+" to output file" ); + ; + ; If time dimension + ; + if ( vardimnames(0) .eq. "time" )then + do t = 0, ntime-1 + vart = (/nc->$vars(i)$(t,:,:)/); + varto = linint2 ( lon, lat, vart, Cyclic, lono, lato, 0 ); + if ( all(ismissing(varto(nlat-1,:))) )then + print( "Copy last latitude over" ); + varto(nlat-1,:) = varto(nlat-2,:); + end if + if ( any(ismissing(varto)) )then + print( "There are some missing values on output no="+num(ismissing(varto)) ); + exit + end if + nco->$vars(i)$(time|t,lat|:,lon|:) = (/varto/); + end do + ; + ; without time dimension + ; + else + var = (/nc->$vars(i)$/); + varo = linint2 ( lon, lat, var, Cyclic, lono, lato, 0 ); + if ( all(ismissing(varo(nlat-1,:))) )then + print( "Copy last latitude over" ); + varo(nlat-1,:) = varo(nlat-2,:); + end if + if ( any(ismissing(varo)) )then + print( "There are some missing values on output no="+num(ismissing(varo)) ); + exit + end if + nco->$vars(i)$ = (/varo/); + end if + end if + delete( vardimnames ); + + end do + if ( isvar("varto") )then + delete(varto); + end if + if ( isvar("vart") )then + delete(vart); + end if + if ( isvar("varo") )then + delete(varo); + end if + if ( isvar("var") )then + delete(var) + end if + + print( "================================================================================================" ); + print( "Successfully created output aerdep file: "+filenameout ); + end do +end diff --git a/tools/emerald_sites_tools/popden_site_clm5.ncl b/tools/emerald_sites_tools/popden_site_clm5.ncl new file mode 100644 index 0000000000..8a276f65df --- /dev/null +++ b/tools/emerald_sites_tools/popden_site_clm5.ncl @@ -0,0 +1,207 @@ +; Create site/regional population density data for the model platform +; The origional global file used by default is too large. +; This script is adapated from the original "aerdepregrid.ncl" used in early versions of CLM (see below the original statement) +; +;;##################################################### +;; Regrid CLM Aerosol-Deposition file (aerdep) to a new resolution. +;; Works for climatology monthly aerdep files. +;; Uses input environment variables to determine resolution and other +;; parameters to describe set of files to use. +;; Uses bld query to get input filenames. Also uses env variable CSMDATA for location +;; of input files. +;; +;; Erik Kluzek +;; Apr/10/2008 +;; $Id: aerdepregrid.ncl 28400 2011-05-16 05:46:46Z erik $ +;; $HeadURL; +;;###################################################### + +begin + ; =========================================================================================================== + ; + ; IMPORTANT NOTE: EDIT THE FOLLOWING TO CUSTOMIZE + ; Edit the following as needed to interpolate to a new resolution. + ; Input and output resolution + +;################ +;Setup begin +;################ + + plot_name=(/"ALP1","ALP2","ALP3","ALP4","SUB1","SUB2","SUB3","SUB4","BOR1","BOR2","BOR3","BOR4","LYG","BUO","HAV","SKO","VIKE","JOAS","LIAH","FINN"/) ; site name + +;SeedClim Sites: "ALP1","ALP2","ALP3","ALP4","SUB1","SUB2","SUB3","SUB4","BOR1","BOR2","BOR3","BOR4" +;Landpress Sites: "LYG","BUO","HAV","SKO" +;Three-D Sites: "VIKE","JOAS","LIAH" +;Finnmark Site: "FINN" + + do p=0,11,1 + + filename = "/cluster/shared/noresm/inputdata/lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202.nc" ; global urban data file + filenameout = "/cluster/shared/noresm/inputdata_fates_platform/lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_"+plot_name(p)+".nc" ;output urban data file for the site + gridfile = "/cluster/shared/noresm/inputdata_fates_platform/share/domains/"+plot_name(p)+"/domain.lnd."+plot_name(p)+".200422.nc" ;domain file for the site +;################ +;Setup end +;################ + + + ; Open files + print( "Interpolate from file: "+filename ); + if ( systemfunc("test -f "+filename+"; echo $?" ) .ne. 0 )then + print( "Input faerdep file does not exist or not found: "+filename ); + exit + end if + nc = addfile( filename, "r" ); + + print( "Use grid file: "+gridfile ); + if ( systemfunc("test -f "+gridfile+"; echo $?" ) .ne. 0 )then + print( "Input gridfile does not exist or not found: "+gridfile ); + exit + end if + ncg = addfile( gridfile, "r" ); + print( "Output file: "+filenameout ); + if ( systemfunc("test -f "+filenameout+"; echo $?" ) .eq. 0 )then + system( "/bin/rm -f "+filenameout ); + end if + nco = addfile( filenameout, "c" ); + ; + ; Define dimensions + ; + dimnames = (/ "time", "lat", "lon", "nv", "scalar"/); + latgg = tofloat(ncg->yc(:,0)); + longg = tofloat(ncg->xc(0,:)); + nlat = dimsizes( latgg ); + nlon = dimsizes( longg ); + ntime = getfilevardimsizes(nc,"time"); + dsizes = (/ ntime, nlat, nlon, 2, 1 /); + is_unlim = (/ True, False, False, False, False /); + filedimdef( nco, dimnames, dsizes, is_unlim ); + print( "Number of times: "+ntime ); + ; + ; Define vars and add attributes from original file + ; + print( "Define vars" ); + vars = getfilevarnames( nc ); + print(vars) + i = dimsizes(vars) - 1 + do while ( i .ge. 0 ) + print( "Define "+vars(i) ); + filevardef ( nco, vars(i), typeof(nc->$vars(i)$), getfilevardims( nc, vars(i) ) ); + filevarattdef ( nco, vars(i), nc->$vars(i)$ ); + i = i - 1 + end do + fileattdef ( nco, nc ); + ; + ; Add global attributes to output file + ; + print( "Global attributes" ); + + nco@source = "Regrid from:"+filename; + nco@gridfile = gridfile; + nco@aerdepregridVersion = "$HeadURL: https://svn-ccsm-models.cgd.ucar.edu/clm2/branch_tags/cesm1_0_rel_tags/cesm1_0_3_n05_clm4_0_32/models/lnd/clm/tools/ncl_scripts/aerdepregrid.ncl $"; + nco@aerdepregridRevision = "$Id: aerdepregrid.ncl 28400 2011-05-16 05:46:46Z erik $"; + ; + ; Copy coordinate variables over + ; + nco->year= (/nc->year/); + nco->time= (/nc->time/); + nco->lon = (/longg/); + nco->lat = (/latgg/); + nco->LON = (/longg/); + nco->LAT = (/latgg/); + nco->EDGEW = tofloat( (/ncg->xv(0,0,0)/) ); + print(ncg->xv(0,0,0)) + nco->EDGES = tofloat( (/ncg->yv(0,0,0)/) ); + nco->EDGEN = tofloat( (/ncg->yv(0,0,1)/) ); + nco->EDGEE = tofloat( (/ncg->xv(0,0,2)/) ); + print(ncg->xv(0,0,2)) + nco->LATIXY = tofloat( (/ncg->yc/) ); + nco->LONGXY = tofloat( (/ncg->xc/) ); + nco->LANDMASK = tofloat( (/ncg->mask/) ); + nco->time_bnds = (/nc->time_bnds/); + + lon = (/ nc->lon /); + lat = (/ nc->lat /); + lono = (/ nco->lon /); + lato = (/ nco->lat /); + + ; loop over variables + ; + if ( nlon .eq. 1 )then + Cyclic = False + else + dx = lono(1) - lono(0); + ; The last longitude should equal 360-(dx-first_longitude) + ; So for example if first_longitude=0, last will be 360-dx + ; If first_longitude=dx, last will be 360 + expLast = 360.0 - (dx - lono(0)); + if ( abs(lono(nlon-1) - expLast) .lt. 1.e-4 )then + Cyclic = True; + else + Cyclic = False + end if + end if + + print( "Cyclic grid: "+Cyclic ); + + do i = 0, dimsizes( vars )-1 + + vardimnames = getfilevardims( nc, vars(i) ); + ; + ; If variable is not one of the dimensions -- regrid it and write to output file + ; + if ( vars(i) .eq. "hdm" )then + print( "Write variable: "+vars(i)+" to output file" ); + ; + ; If time dimension + ; + if ( vardimnames(0) .eq. "time" )then + do t = 0, ntime-1 + vart = (/nc->$vars(i)$(t,:,:)/); + varto = linint2 ( lon, lat, vart, Cyclic, lono, lato, 0 ); + if ( all(ismissing(varto(nlat-1,:))) )then + print( "Copy last latitude over" ); + varto(nlat-1,:) = varto(nlat-2,:); + end if + if ( any(ismissing(varto)) )then + print( "There are some missing values on output no="+num(ismissing(varto)) ); + exit + end if + nco->$vars(i)$(time|t,lat|:,lon|:) = (/varto/); + end do + ; + ; without time dimension + ; + else + var = (/nc->$vars(i)$/); + varo = linint2 ( lon, lat, var, Cyclic, lono, lato, 0 ); + if ( all(ismissing(varo(nlat-1,:))) )then + print( "Copy last latitude over" ); + varo(nlat-1,:) = varo(nlat-2,:); + end if + if ( any(ismissing(varo)) )then + print( "There are some missing values on output no="+num(ismissing(varo)) ); + exit + end if + nco->$vars(i)$ = (/varo/); + end if + end if + delete( vardimnames ); + + end do + if ( isvar("varto") )then + delete(varto); + end if + if ( isvar("vart") )then + delete(vart); + end if + if ( isvar("varo") )then + delete(varo); + end if + if ( isvar("var") )then + delete(var) + end if + + print( "================================================================================================" ); + print( "Successfully created output aerdep file: "+filenameout ); + end do +end diff --git a/tools/emerald_sites_tools/tar_model_input_site.sh b/tools/emerald_sites_tools/tar_model_input_site.sh index a60f3102c9..57f0d81fba 100755 --- a/tools/emerald_sites_tools/tar_model_input_site.sh +++ b/tools/emerald_sites_tools/tar_model_input_site.sh @@ -6,19 +6,22 @@ date="200927" # DATE when the domain files were created. -plotname=(VIKE JOAS LIAH) # Plot name +plotname=(ALP1 ALP2 ALP3 ALP4 SUB1 SUB2 SUB3 SUB4 BOR1 BOR2 BOR3 BOR4 LYG BUO HAV SKO VIKE JOAS LIAH FINN) # Plot name #SeedClim Sites: ALP1 ALP2 ALP3 ALP4 SUB1 SUB2 SUB3 SUB4 BOR1 BOR2 BOR3 BOR4 #Landpress Sites: LYG BUO HAV SKO #Three-D Sites: VIKE JOAS LIAH #Finnmark Site: FINN -site_num="0 1 2" #0 1 2 3 4 5 6 7 8 9 10 11 +site_num="12 13 14 15 16 17 18 19" #0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 atm_forc="GSWP3v1" #GSWP3v1, COSMO6km (not ready yet), ERA5land (not ready yet) input_dir="/cluster/shared/noresm/inputdata_fates_platform" # input directory where the input data are kept. temp_dir=$HOME/inputdata_fates_platform # temporary directory for keeping the re-organized input data. +fates_para="fates_params_api.14.0.0_12pft_c200921.nc" +clm_para="clm5_params.c200402.nc" + ####################### # Setup end ####################### @@ -38,6 +41,9 @@ do mkdir -p inputdata/atm/datm7/${atm_forc}/${plotname[i]} cp ${input_dir}/atm/datm7/${atm_forc}/${plotname[i]}/*.nc ./inputdata/atm/datm7/${atm_forc}/${plotname[i]}/ + + mkdir -p inputdata/atm/datm7/NASA_LIS/${plotname[i]} + cp ${input_dir}/atm/datm7/NASA_LIS/clmforc.Li_2016_climo1995-2013.360x720.lnfm_Total_c160825_${plotname[i]}.nc ./inputdata/atm/datm7/NASA_LIS/${plotname[i]}/ mkdir -p inputdata/share/domains/${plotname[i]} cp ${input_dir}/share/domains/${plotname[i]}/domain.lnd.${plotname[i]}.${date}.nc ./inputdata/share/domains/${plotname[i]}/ @@ -46,16 +52,20 @@ do cp ${input_dir}/lnd/clm2/surfdata_map/${plotname[i]}/surfdata_${plotname[i]}_simyr2000.nc ./inputdata/lnd/clm2/surfdata_map/${plotname[i]}/ mkdir -p inputdata/lnd/clm2/urbandata/${plotname[i]} - cp ${input_dir}/lnd/clm2/urbandata/CLM50_tbuildmax_Oleson_2016_0.9x1.25_simyr1849-2106_c160923_${plotname[i]}.nc ./inputdata/lnd/clm2/urbandata/${plotname[i]}/ + cp ${input_dir}/lnd/clm2/urbandata/CLM50_tbuildmax_Oleson_2016_0.9x1.25_simyr1849-2106_c160923_${plotname[i]}.nc ./inputdata/lnd/clm2/urbandata/${plotname[i]}/ + + mkdir -p inputdata/lnd/clm2/firedata/${plotname[i]}/ + cp ${input_dir}/lnd/clm2/firedata/clmforc.Li_2017_HYDEv3.2_CMIP6_hdm_0.5x0.5_AVHRR_simyr1850-2016_c180202_${plotname[i]}.nc ./inputdata/lnd/clm2/firedata/${plotname[i]}/ mkdir -p inputdata/lnd/clm2/snicardata cp ${input_dir}/lnd/clm2/snicardata/*.nc ./inputdata/lnd/clm2/snicardata mkdir -p inputdata/lnd/clm2/paramdata - cp ${input_dir}/lnd/clm2/paramdata/*.nc ./inputdata/lnd/clm2/paramdata/ + cp ${input_dir}/lnd/clm2/paramdata/${fates_para} ./inputdata/lnd/clm2/paramdata/ + cp ${input_dir}/lnd/clm2/paramdata/${clm_para} ./inputdata/lnd/clm2/paramdata/ - tar -cvf inputdata_version1.0.0_${plotname[i]}.tar inputdata - mv inputdata_version1.0.0_${plotname[i]}.tar ${input_dir}/ + tar -cvf inputdata_version2.0.0_${plotname[i]}.tar inputdata + mv inputdata_version2.0.0_${plotname[i]}.tar ${input_dir}/ rm -r inputdata diff --git a/tools/emerald_sites_tools/prepare_inputdata.sh b/tools/emerald_sites_tools/workflow_setup_site_simulation.sh similarity index 84% rename from tools/emerald_sites_tools/prepare_inputdata.sh rename to tools/emerald_sites_tools/workflow_setup_site_simulation.sh index 09601fa5a8..2707c675cb 100755 --- a/tools/emerald_sites_tools/prepare_inputdata.sh +++ b/tools/emerald_sites_tools/workflow_setup_site_simulation.sh @@ -6,10 +6,12 @@ #SBATCH --ntasks=1 #SBATCH --time=07:00:00 -date="200927" # Need to be the same as the running date +# "creat_mapping" need extra large memory and long time (several hours) to finish. Thus, it is bettter to be run in a queue system (This is why the batch configuration is provided at the begining.) + +date="200927" # Date when you create the inputdata. input_dir="/cluster/shared/noresm/inputdata_fates_platform" # home folder for storing the inputdata for each site. input_raw="/cluster/shared/noresm/inputdata" # home folder for storing the raw date required by surface data file -version ="version1.0.0" # version of inputdata +version ="version2.0.0" # version of inputdata ######### SeedClim Sites #plotlat=(61.0243 60.8231 60.8328 60.9335 60.8203 60.8760 61.0866 60.5445 61.0355 60.8803 60.6652 60.6901) @@ -31,16 +33,23 @@ plotlat=(69.341088) plotlon=(25.293524) plotname=(FINN) -creat_script="T" # T or F, switch for creating script grid or not -creat_domain="T" # T or F, switch for creating domain file + +######### Switch for all the steps related to setting a site simulation. +######### Set all "creat_****" switches to "T" to create inputdata for the site simulation +######### Set "tar_input" to "T" to wrap up all the inputdata to a tar file +######### Set "run_***" to "T" to run the site simulation + +creat_script="F" # T or F, switch for creating script grid or not +creat_domain="F" # T or F, switch for creating domain file creat_mapping="F" # T or F, switch for creating mapping file creat_surfdat="F" # T or F, switch for creating surface data file creat_aero="F" # T or F, switch for creating aerosol depostion file for each site. If "F", model will use global data as input. creat_topo="F" # T or F, switch for creating topography file for each site. If "F", model will use global data as input. creat_urb="F" # T or F, switch for creating urban data file for each site. If "F", model will use global data as input. +creat_fire="F" # T or F, switch for creating fire data file for each site. If "F", model will use global data as input. creat_atm="F" # T or F, switch for creating atmospheric forcing. tar_input="F" # T or F, switch for tar all the input data required for each site. -run_case="F" # T or F, switch for running many clm experiments automatically. "T" can only be used when all the inputdata are ready!!!! +run_case="F" # T or F, switch for running site simulations automatically. "T" can only be used when all the inputdata are ready!!!! run_case_first="F" # T or F, swtich for creating, building and submitting short test runs run_case_second="F" # T or F, swtich for running long experiments @@ -124,7 +133,6 @@ fi ######## Creating aerosol depostion file for each site -tar_input="F" if [ ${creat_aero} == "T" ] then module purge @@ -154,6 +162,17 @@ then ncl urbandata_site_clm5.ncl fi +######## Creating fire input data file for each site. This is required in release v2.0.0. +if [ ${creat_fire} == "T" ] +then + module purge + module load NCL/6.6.2-intel-2019b + cd ~/ctsm/tools/emerald_sites_tools + #### You need to modify the settings in "lightning_site_clm5.ncl" and "popden_site_clm5.ncl" before doing the following command. See detailed instructions in the file. + ncl lightning_site_clm5.ncl + ncl popden_site_clm5.ncl +fi + ######## Creating urban data file for each site if [ ${creat_atm} == "T" ] then