Skip to content

Commit

Permalink
Merge remote-tracking branch 'slevis-lmwg/new_rawpftlai' into changel…
Browse files Browse the repository at this point in the history
…og_readme_update
  • Loading branch information
ekluzek committed Sep 12, 2024
2 parents 2f5bd73 + a4d105d commit 3c0bda1
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 108 deletions.
13 changes: 11 additions & 2 deletions bld/CLMBuildNamelist.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2506,8 +2506,9 @@ sub setup_logic_surface_dataset {
# consistent with it
# MUST BE AFTER: setup_logic_demand which is where flanduse_timeseries is set
#
my ($opts, $nl_flags, $definition, $defaults, $nl, $xmlvar_ref) = @_;
my ($opts_in, $nl_flags, $definition, $defaults, $nl, $xmlvar_ref) = @_;

my $opts = $opts_in;
$nl_flags->{'flanduse_timeseries'} = "null";
my $flanduse_timeseries = $nl->get_value('flanduse_timeseries');
if (defined($flanduse_timeseries)) {
Expand All @@ -2523,6 +2524,11 @@ sub setup_logic_surface_dataset {
if ($flanduse_timeseries ne "null" && &value_is_true($nl_flags->{'use_cndv'}) ) {
$log->fatal_error( "dynamic PFT's (setting flanduse_timeseries) are incompatible with dynamic vegetation (use_cndv=.true)." );
}
# Turn test option off for NEON until after XML is interpreted
my $test_files = $opts->{'test'};
if ( &value_is_true($nl_flags->{'neon'})) {
$opts->{'test'} = 0;
}
#
# Always get the crop version of the datasets now and let the code turn it into the form desired
# Provided this isn't with FATES on
Expand All @@ -2548,7 +2554,7 @@ sub setup_logic_surface_dataset {
'use_crop'=>$nl_flags->{'use_crop'} );
}
#
# Expand the XML variables for NEON cases so that NEONSITE will be used
# Expand the XML variables for NEON cases so that NEONSITE will be used and test for existence
#
if ( &value_is_true($nl_flags->{'neon'}) ) {
my $fsurdat = $nl->get_value($var);
Expand All @@ -2557,6 +2563,9 @@ sub setup_logic_surface_dataset {
my $group = $definition->get_group_name($var);
$nl->set_variable_value($group, $var, $newval);
$log->verbose_message( "This is a NEON site and the fsurdat file selected is: $newval" );
if ( $test_files and ($newval !~ /null|none/) and (! -f remove_leading_and_trailing_quotes($newval) ) ) {
$log->fatal_error("file not found: $var = $newval");
}
}
}
}
Expand Down
184 changes: 92 additions & 92 deletions bld/namelist_files/namelist_defaults_ctsm.xml

Large diffs are not rendered by default.

66 changes: 62 additions & 4 deletions bld/unit_testers/build-namelist_test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ sub make_env_run {
my %settings = @_;

# Set default settings
my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", LND_SETS_DUST_EMIS_DRV_FLDS=>"TRUE", NEONSITE=>"" );
my %env_vars = ( DIN_LOC_ROOT=>"MYDINLOCROOT", GLC_TWO_WAY_COUPLING=>"FALSE", LND_SETS_DUST_EMIS_DRV_FLDS=>"TRUE", NEONSITE=>"", PLUMBER2SITE=>"" );
# Set any settings that came in from function call
foreach my $item ( keys(%settings) ) {
$env_vars{$item} = $settings{$item};
Expand Down Expand Up @@ -163,10 +163,10 @@ sub cat_and_create_namelistinfile {
#
# Figure out number of tests that will run
#
my $ntests = 3349;
my $ntests = 3994;

if ( defined($opts{'compare'}) ) {
$ntests += 2007;
$ntests += 2437;
}
plan( tests=>$ntests );

Expand Down Expand Up @@ -393,9 +393,67 @@ sub cat_and_create_namelistinfile {
my $namelistfile = "temp.namelistinfile_$site";
&cat_and_create_namelistinfile( $neondefaultfile, $neonsitefile, $namelistfile );
#
# Now run the site for both bgc and non-FATES
#
foreach my $bgc ( "bgc", "fates") {
if ( ($bgc eq "bgc") or ($site ne "STER" and $site ne "KONA")) {
my $options = "--res CLM_USRDAT --clm_usr_name NEON --no-megan --bgc $bgc --use_case 2018_control --infile $namelistfile";
eval{ system( "$bldnml -envxml_dir . $options > $tempfile 2>&1 " ); };
is( $@, '', "options: $options" );
$cfiles->checkfilesexist( "$options", $mode );
$cfiles->shownmldiff( "default", $mode );
if ( defined($opts{'compare'}) ) {
$cfiles->doNOTdodiffonfile( "$tempfile", "$options", $mode );
$cfiles->dodiffonfile( "lnd_in", "$options", $mode );
$cfiles->comparefiles( "$options", $mode, $opts{'compare'} );
}
if ( defined($opts{'generate'}) ) {
$cfiles->copyfiles( "$options", $mode );
}
}
}
system( "/bin/rm $namelistfile" );
&cleanup();
}
print "\n===============================================================================\n";
print "Test the PLUMBER2 sites\n";
print "=================================================================================\n";
my $phys = "clm6_0";
$mode = "-phys $phys";
&make_config_cache($phys);
my $plumdir = "../../cime_config/usermods_dirs/PLUMBER2";
foreach my $site (
"AR-SLu", "AU-Emr", "AU-TTE", "CA-NS1", "CA-SF3", "CN-HaM", "DE-Obe", "ES-ES1", "FR-Gri", "IE-Dri", "IT-LMa", "IT-SRo", "RU-Fyo", "US-Aud", "US-Ho1", "US-Ne2", "US-Syv", "ZM-Mon",
"AT-Neu", "AU-Gin", "AU-Tum", "CA-NS2", "CH-Cha", "CN-Qia", "DE-Seh", "ES-ES2", "FR-Hes", "IT-Amp", "IT-Mal", "JP-SMF", "RU-Zot", "US-Bar", "US-KS2", "US-Ne3", "US-Ton",
"AU-ASM", "AU-GWW", "AU-Whr", "CA-NS4", "CH-Dav", "CZ-wet", "DE-SfN", "ES-LgS", "FR-LBr", "IT-BCi", "IT-MBo", "NL-Ca1", "SD-Dem", "US-Bkg", "US-Los", "US-NR1", "US-Tw4",
"AU-Cow", "AU-How", "AU-Wrr", "CA-NS5", "CH-Fru", "DE-Bay", "DE-Tha", "ES-LMa", "FR-Lq1", "IT-CA1", "IT-Noe", "NL-Hor", "SE-Deg", "US-Blo", "US-Me2", "US-PFa", "US-Twt",
"AU-Cpr", "AU-Lit", "AU-Ync", "CA-NS6", "CH-Oe1", "DE-Wet", "ES-VDA", "FR-Lq2", "IT-CA2", "IT-Non", "NL-Loo", "UK-Gri", "US-Bo1", "US-Me4", "US-Prr", "US-UMB",
"AU-Ctr", "AU-Otw", "BE-Bra", "CA-NS7", "CN-Cha", "DE-Geb", "DK-Fou", "FI-Hyy", "FR-Pue", "IT-CA3", "IT-PT1", "PL-wet", "UK-Ham", "US-Cop", "US-Me6", "US-SP1", "US-Var",
"AU-Cum", "AU-Rig", "BE-Lon", "CA-Qcu", "CN-Cng", "DE-Gri", "DK-Lva", "FI-Kaa", "GF-Guy", "IT-Col", "IT-Ren", "PT-Esp", "UK-PL3", "US-FPe", "US-MMS", "US-SP2", "US-WCr",
"AU-DaP", "AU-Rob", "BE-Vie", "CA-Qfo", "CN-Dan", "DE-Hai", "DK-Ris", "FI-Lom", "HU-Bug", "IT-Cpz", "IT-Ro1", "PT-Mi1", "US-AR1", "US-GLE", "US-MOz", "US-SP3", "US-Whs",
"AU-DaS", "AU-Sam", "BR-Sa3", "CA-SF1", "CN-Din", "DE-Kli", "DK-Sor", "FI-Sod", "ID-Pag", "IT-Isp", "IT-Ro2", "PT-Mi2", "US-AR2", "US-Goo", "US-Myb", "US-SRG", "US-Wkg",
"AU-Dry", "AU-Stp", "BW-Ma1", "CA-SF2", "CN-Du2", "DE-Meh", "DK-ZaH", "FR-Fon", "IE-Ca1", "IT-Lav", "IT-SR2", "RU-Che", "US-ARM", "US-Ha1", "US-Ne1", "US-SRM", "ZA-Kru"
) {
&make_env_run( PLUMBER2SITE=>"$site" );
#
# Concatonate default usermods and specific sitetogether expanding env variables while doing that
#
if ( ! -d "$plumdir/$site" ) {
print "PLUMBER2 directory is not there: $plumdir/$site\n";
die "ERROR:: PLUMBER2 site does not exist: $site\n";
}
my $plumdefaultfile = "$plumdir/defaults/user_nl_clm";
my $plumsitefile = "$plumdir/$site/user_nl_clm";
if ( ! -f $plumsitefile ) {
$plumsitefile = undef;
}
$ENV{'PLUMBER2'} = $site;
my $namelistfile = "temp.namelistinfile_$site";
&cat_and_create_namelistinfile( $plumdefaultfile, $plumsitefile, $namelistfile );
#
# Now run the site
#
my $options = "--res CLM_USRDAT --clm_usr_name NEON --no-megan --bgc bgc --use_case 2018_control --infile $namelistfile";
my $options = "--res CLM_USRDAT --clm_usr_name PLUMBER2 --no-megan --bgc sp --infile $namelistfile";
eval{ system( "$bldnml -envxml_dir . $options > $tempfile 2>&1 " ); };
is( $@, '', "options: $options" );
$cfiles->checkfilesexist( "$options", $mode );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ hillslope_transmissivity_method = 'LayerSum'
hillslope_pft_distribution_method = 'PftLowlandUpland'
hillslope_soil_profile_method = 'Uniform'

fsurdat = '$DIN_LOC_ROOT/lnd/clm2/testdata/surfdata_10x15_hist_2000_78pfts_c240216.synthetic_hillslopes.nc'
fsurdat = '$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/ctsm5.3.0/synthetic/surfdata_10x15_hist_2000_78pfts_c240905.synthetic_hillslopes3.nc'

use_ssre = .false.
3 changes: 0 additions & 3 deletions cime_config/usermods_dirs/NEON/FATES/defaults/user_nl_clm
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable
!----------------------------------------------------------------------------------

flanduse_timeseries = ' ' ! This isn't needed for a non transient case, but will be once we start using transient compsets
fsurdat = "$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/NEON/16PFT_mixed/surfdata_1x1_NEON_${NEONSITE}_hist_2000_16pfts_c240206.nc"

! h1 output stream
hist_fincl2 = 'FATES_AUTORESP','FCEV','FCTR','FGEV','FIRA','FSA','FSH','FATES_GPP','FATES_GPP_PF','H2OSOI',
'SNOW_DEPTH','TBOT','TSOI','SOILC_vr','FATES_NPP','FATES_NPP_PF','FATES_VEGC','FATES_VEGC_PF'
Expand Down
3 changes: 0 additions & 3 deletions cime_config/usermods_dirs/NEON/defaults/user_nl_clm
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
! Set glc_do_dynglacier with GLC_TWO_WAY_COUPLING env variable
!----------------------------------------------------------------------------------

flanduse_timeseries = ' ' ! This isn't needed for a non transient case, but will be once we start using transient compsets
fsurdat = "$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/NEON/surfdata_1x1_NEON_${NEONSITE}_hist_2000_78pfts_c240206.nc"

! h1 output stream
hist_fincl2 = 'AR','ELAI','FCEV','FCTR','FGEV','FIRA','FSA','FSH','GPP','H2OSOI',
'HR','SNOW_DEPTH','TBOT','TSOI','SOILC_vr','FV','NET_NMIN_vr'
Expand Down
2 changes: 1 addition & 1 deletion cime_config/usermods_dirs/PLUMBER2/defaults/user_nl_clm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
!----------------------------------------------------------------------------------

flanduse_timeseries = ' ' ! This isn't needed for a non transient case, but will be once we start using transient compsets
fsurdat = "$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/PLUMBER2/surfdata_1x1_PLUMBER2_${PLUMBER2SITE}_hist_2000_16pfts_c240326.nc"
fsurdat = "$DIN_LOC_ROOT/lnd/clm2/surfdata_esmf/PLUMBER2/ctsm5.3.0/surfdata_1x1_PLUMBER2_${PLUMBER2SITE}_hist_2000_16pfts_c240908.nc"

! custom namelist changes for each site / case
4 changes: 4 additions & 0 deletions tools/mksurfdata_esmf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ for example try --res 1.9x2.5 --start-year 1850 --end-year 1850:
make all-subset
```

As of 2024/9/12 one needs to generate NEON and PLUMBER2 fsurdat files by
running ./neon_surf_wrapper and ./plumber2_surf_wrapper manually in the
/tools/site_and_regional directory.

<!-- = -->
## NOTES
<!-- = -->
Expand Down
14 changes: 12 additions & 2 deletions tools/mksurfdata_esmf/src/mksoiltexMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ module mksoiltexMod
use mkutilsMod , only : chkerr
use mkdiagnosticsMod , only : output_diagnostics_index
use mkfileMod , only : mkfile_output
use mkvarctl , only : root_task, ndiag, spval
use mkvarctl , only : root_task, ndiag, spval, mpicom
use mkvarctl , only : unsetsoil
use mkvarpar , only : nlevsoi

implicit none
private ! By default make data private

#include <mpif.h>

public :: mksoiltex ! Set soil texture

integer :: mapunit_value_max
Expand Down Expand Up @@ -61,6 +63,7 @@ subroutine mksoiltex(file_mesh_i, file_mapunit_i, file_lookup_i, mesh_o, pioid_o
integer :: k,l,m,n
integer :: nlay ! number of soil layers
integer :: n_scid
integer :: mapunit_value_max_local
integer , allocatable :: mask_i(:)
real(r4), pointer :: dataptr(:)
integer :: mapunit ! temporary igbp soil mapunit
Expand Down Expand Up @@ -165,6 +168,8 @@ subroutine mksoiltex(file_mesh_i, file_mapunit_i, file_lookup_i, mesh_o, pioid_o
do ni = 1,ns_i
if (mapunit_i(ni) == 0.) then
mask_i(ni) = 0
else
mask_i(ni) = 1
end if
end do
call ESMF_MeshSet(mesh_i, elementMask=mask_i, rc=rc)
Expand Down Expand Up @@ -200,7 +205,12 @@ subroutine mksoiltex(file_mesh_i, file_mapunit_i, file_lookup_i, mesh_o, pioid_o

! Determine mapunit_value_max (set it as a module variable so that it can be
! accessible to gen_dominant_mapunit) - this is needed in the dynamic mask routine
mapunit_value_max = maxval(dataptr)
!
! Note that dataptr (obtained from the input field) contains just a subset of the
! source data, based on the source data decomposition. So we need an mpi_allreduce to
! determine the global maximum value of mapunit.
mapunit_value_max_local = maxval(dataptr)
call mpi_allreduce(mapunit_value_max_local, mapunit_value_max, 1, MPI_INTEGER, MPI_MAX, mpicom, rcode)

! Determine values in field_o
call ESMF_FieldGet(field_o, farrayptr=dataptr, rc=rc)
Expand Down

0 comments on commit 3c0bda1

Please sign in to comment.