Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,15 @@ if (not $waccm_phys) {
add_default($nl, 'p_bot_for_radmrg');
}

# Check TUV-X configuration
my $tuvx_active = $nl->get_value('tuvx_active');
if ($tuvx_active =~ /$TRUE/) {
Comment thread
fvitt marked this conversation as resolved.
Outdated
my $tuvx_config = $cfg->get('tuvx');
if (!$tuvx_config) {
die "$ProgName - ERROR: must use -tuvx CAM configure flag \n";
}
}

# Solar irradiance

# First check that solar_const and solar_irrad_data_file are not both defined
Expand Down
3 changes: 3 additions & 0 deletions bld/config_files/definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ Option to turn on waccmx thermosphere/ionosphere extension: 0 => no, 1 => yes
<entry id="ext_co2_cool" valid_values="0,1" value="0">
Option to turn on extended non-LTE CO2 cooling: 0 => no, 1 => yes
</entry>
<entry id="tuvx" valid_values="0,1" value="0">
Option to build TUV-X library: 0 => no, 1 => yes
</entry>
<entry id="ionosphere" valid_values="none,wxie" value="none">
Ionosphere model used in WACCMX.
</entry>
Expand Down
15 changes: 14 additions & 1 deletion bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ OPTIONS
-psubcols <n> Maximum number of sub-columns in a run - set to 1 if not using sub-columns (default)
-rad <name> Specify the radiation package [rrtmg | rrtmgp | rrtmgp_gpu | camrt]
-silhs Switch on SILHS.
-tuvx Switch to build TUV-X library
-usr_mech_infile Path and file name of the user supplied chemistry mechanism file.
-waccm_phys Switch enables the use of WACCM physics in any chemistry configuration.
The user does not need to set this if one of the waccm chemistry options
Expand Down Expand Up @@ -305,6 +306,7 @@ GetOptions(
"waccm_phys" => \$opts{'waccm_phys'},
"waccmx" => \$opts{'waccmx'},
"ext_co2_cool" => \$opts{'ext_co2_cool'},
"tuvx" => \$opts{'tuvx'},
) or usage();

# Give usage message.
Expand Down Expand Up @@ -717,6 +719,12 @@ if (defined $opts{'ext_co2_cool'}) {
}
my $ext_co2_cool = $cfg_ref->get('ext_co2_cool');

# TUV-x option
if (defined $opts{'tuvx'}) {
$cfg_ref->set('tuvx', $opts{'tuvx'});
}
my $tuvx = $cfg_ref->get('tuvx');

#-----------------------------------------------------------------------------------------------

# Prognostic species package(s)
Expand Down Expand Up @@ -1788,6 +1796,11 @@ if ($ext_co2_cool) {
$cfg_cppdefs .= ' -DEXT_CO2_COOL';
}

# TUV-X
if ($tuvx) {
$cfg_cppdefs .= ' -DTUVX';
}

# PIO
my $pio2_build = (defined $opts{'pio2'}) ? 1 : 0;

Expand Down Expand Up @@ -1864,7 +1877,7 @@ if ($cosp) {
$ldflags .= " -L$cosp_libdir -lrttov13_wrapper -lrttov13_mw_scatt -lrttov13_brdf_atlas -lrttov13_emis_atlas -lrttov13_other -lrttov13_parallel -lrttov13_coef_io -lrttov13_hdf -lrttov13_main ";
$cfg_ref->set('ldflags', $ldflags);
print "Adding rttov libraries as dependencies in ldflags.\n";
}
}
# Create the COSP Makefile from a template and copy it into the cosp bld directory
if ($print) { print "creating $cosp_libdir/Makefile\n"; }
write_cosp_makefile("$cfgdir/../src/physics/cosp2/Makefile.in", "$cosp_libdir/Makefile");
Expand Down
116 changes: 62 additions & 54 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -232,60 +232,68 @@ def _build_tuvx(caseroot, libroot, bldroot):
# Builds the TUV-x library and updates the case variables used to set the
# include paths and linked libraries

with Case(caseroot) as case:
bldpath = os.path.join(bldroot, "tuv-x")
if not os.path.exists(bldpath):
os.makedirs(bldpath)
srcpath = os.path.abspath(os.path.join(case.get_value("SRCROOT"), \
"libraries", "tuv-x", ""))
logger.info("Building TUV-x in {} from source in {}\n".format(bldpath, srcpath))

arg_dict = _cmake_default_args(caseroot)
cmake_args = "-DCMAKE_VERBOSE_MAKEFILE=ON "
if case.get_value("MPILIB") != "mpi-serial":
cmake_args += "-DTUVX_ENABLE_MPI:BOOL=TRUE "
cmake_args += "-DCMAKE_BUILD_TYPE=Debug "
cmake_args += "-DCMAKE_Fortran_COMPILER=mpif90 "
cmake_args += "-DCMAKE_C_COMPILER=mpicc "
cmake_args += "-DCMAKE_CXX_COMPILER=mpicxx "
cmake_args += "-DCMAKE_Fortran_COMPILER_WORKS=1 "
cmake_args += "-DCMAKE_C_COMPILER_WORKS=1 "
cmake_args += "-DCMAKE_CXX_COMPILER_WORKS=1 "
if (case.get_value("MACH") == "izumi") :
cmake_args += f"-DCMAKE_PREFIX_PATH={arg_dict['NETCDF_PATH']} "
cmake_args += f"-DCMAKE_IGNORE_PATH={os.environ.get('PYTHONHOME')} "
if (case.get_value("MACH") == "izumi") and (case.get_value('COMPILER') == "nag") :
cmake_args += "-DCMAKE_Fortran_FLAGS='-C=all -g ' "
else :
cmake_args += f"-DCMAKE_Fortran_FLAGS='{arg_dict['FFLAGS']}' "
cmake_args += f"-DCMAKE_INSTALL_PREFIX='{libroot}' "
cmake_args += "-DTUVX_ENABLE_TESTS=OFF "
cmake_args += "-DTUVX_ENABLE_COVERAGE=OFF "
cmake_args += "-DTUVX_BUILD_CLI=OFF "
cmake_args += f"-DTUVX_INSTALL_INCLUDE_DIR='{_tuvx_include_dir(libroot)}' "
cmake_args += f"-DTUVX_INSTALL_MOD_DIR='{_tuvx_include_dir(libroot)}' "
cmake_args += srcpath

_run_cmd(f"cmake {cmake_args}", bldpath)
_run_cmd(case.get_value('GMAKE'), bldpath)
_run_cmd(f"{case.get_value('GMAKE')} install", bldpath)

# add TUV-x to include paths
incldir = os.environ.get('USER_INCLDIR')
if incldir is None:
incldir = ''
os.environ['USER_INCLDIR'] = incldir + \
f" -I{_tuvx_include_dir(libroot)} "

# create symlink to library in folder CIME expects libraries to be in
dst = os.path.join(libroot, "libtuvx.a")
if os.path.isfile(dst):
os.remove(dst)
os.symlink(_tuvx_lib_path(libroot), dst)
dst = os.path.join(libroot, "libyaml-cpp.a")
if os.path.isfile(dst):
os.remove(dst)
os.symlink(_yaml_cpp_lib_path(libroot), dst)
with Case(caseroot, read_only=False) as case:
config_opts = case.get_value("CAM_CONFIG_OPTS")
Comment thread
fvitt marked this conversation as resolved.
if "-tuvx" in config_opts:
bldpath = os.path.join(bldroot, "tuv-x")
if not os.path.exists(bldpath):
os.makedirs(bldpath)
srcpath = os.path.abspath(os.path.join(case.get_value("SRCROOT"), \
"libraries", "tuv-x", ""))
logger.info("Building TUV-x in {} from source in {}\n".format(bldpath, srcpath))

arg_dict = _cmake_default_args(caseroot)
cmake_args = "-DCMAKE_VERBOSE_MAKEFILE=ON "
if case.get_value("MPILIB") != "mpi-serial":
cmake_args += "-DTUVX_ENABLE_MPI:BOOL=TRUE "
cmake_args += "-DCMAKE_BUILD_TYPE=Debug "
cmake_args += "-DCMAKE_Fortran_COMPILER=mpif90 "
cmake_args += "-DCMAKE_C_COMPILER=mpicc "
cmake_args += "-DCMAKE_CXX_COMPILER=mpicxx "
cmake_args += "-DCMAKE_Fortran_COMPILER_WORKS=1 "
cmake_args += "-DCMAKE_C_COMPILER_WORKS=1 "
cmake_args += "-DCMAKE_CXX_COMPILER_WORKS=1 "
cmake_args += "-DCMAKE_DISABLE_FIND_PACKAGE_yaml-cpp=1 "
if (case.get_value("MACH") == "izumi") :
cmake_args += f"-DCMAKE_PREFIX_PATH={arg_dict['NETCDF_PATH']} "
if (case.get_value("MACH") == "izumi") and (case.get_value('COMPILER') == "nag") :
cmake_args += "-DCMAKE_Fortran_FLAGS='-C=all -g ' "
else :
cmake_args += f"-DCMAKE_Fortran_FLAGS='{arg_dict['FFLAGS']}' "
cmake_args += f"-DCMAKE_INSTALL_PREFIX='{libroot}' "
cmake_args += "-DTUVX_ENABLE_TESTS=OFF "
cmake_args += "-DTUVX_ENABLE_COVERAGE=OFF "
cmake_args += "-DTUVX_BUILD_CLI=OFF "
cmake_args += f"-DTUVX_INSTALL_INCLUDE_DIR='{_tuvx_include_dir(libroot)}' "
cmake_args += f"-DTUVX_INSTALL_MOD_DIR='{_tuvx_include_dir(libroot)}' "
cmake_args += srcpath

_run_cmd(f"cmake {cmake_args}", bldpath)
_run_cmd(case.get_value('GMAKE'), bldpath)
_run_cmd(f"{case.get_value('GMAKE')} install", bldpath)

# add TUV-x to include paths
incldir = os.environ.get('USER_INCLDIR')
if incldir is None:
incldir = ''
os.environ['USER_INCLDIR'] = incldir + \
f" -I{_tuvx_include_dir(libroot)} "

# create symlink to library in folder CIME expects libraries to be in
dst = os.path.join(libroot, "libtuvx.a")
if os.path.isfile(dst):
os.remove(dst)
os.symlink(_tuvx_lib_path(libroot), dst)
dst = os.path.join(libroot, "libyaml-cpp.a")
if os.path.isfile(dst):
os.remove(dst)
os.symlink(_yaml_cpp_lib_path(libroot), dst)

# Add TUVX to CAM linked library list:
linked_libs = case.get_value("CAM_LINKED_LIBS",
subgroup="build_component_cam")
tuvx_link_opts = " -ltuvx -lyaml-cpp"
case.set_value("CAM_LINKED_LIBS", linked_libs + tuvx_link_opts)
Comment thread
jimmielin marked this conversation as resolved.
Outdated
Comment thread
fvitt marked this conversation as resolved.
Outdated

###############################################################################
def _tuvx_include_dir(libroot):
Expand Down
12 changes: 7 additions & 5 deletions cime_config/buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def buildnml(case, caseroot, compname):
"Gregorian calendar (modifier _cG) cannot be used with spinup compset \n {}".format(COMPSET)
)

tuvx_data_src = os.path.join(srcroot, "libraries", "tuv-x", "data")
if '-tuvx' in CAM_CONFIG_OPTS:
tuvx_data_src = os.path.join(srcroot, "libraries", "tuv-x", "data")

testsrc = os.path.join(srcroot, "components", "cam")
if os.path.exists(testsrc):
Expand Down Expand Up @@ -237,10 +238,11 @@ def buildnml(case, caseroot, compname):
shutil.copy(file1,file2)

# Copy TUV-x data to rundir
dest_data = os.path.join(rundir, "data")
if os.path.exists(dest_data):
shutil.rmtree(dest_data)
shutil.copytree(tuvx_data_src, dest_data)
if '-tuvx' in CAM_CONFIG_OPTS:
dest_data = os.path.join(rundir, "data")
if os.path.exists(dest_data):
shutil.rmtree(dest_data)
shutil.copytree(tuvx_data_src, dest_data)

###############################################################################
def _main_func():
Expand Down
2 changes: 1 addition & 1 deletion cime_config/config_component.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
<entry id="CAM_LINKED_LIBS">
<type>char</type>
<valid_values></valid_values>
<default_value>-ltuvx -lyaml-cpp -lstdc++</default_value>
<default_value>-lstdc++</default_value>
<group>build_component_cam</group>
<file>env_build.xml</file>
<desc>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
./xmlchange CAM_CONFIG_OPTS=" -phys cam4 -rad rrtmg -chem waccm_ma_sulfur -carma mixed_sulfate"
./xmlchange CAM_CONFIG_OPTS=" -phys cam4 -rad rrtmg -chem waccm_ma_sulfur -carma mixed_sulfate -tuvx"
./xmlchange ROF_NCPL=\$ATM_NCPL
./xmlchange GLC_NCPL=\$ATM_NCPL
./xmlchange RUN_STARTDATE="0001-01-01"
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./xmlchange --append CAM_CONFIG_OPTS="-tuvx"
./xmlchange ROF_NCPL=\$ATM_NCPL
./xmlchange GLC_NCPL=\$ATM_NCPL
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
./xmlchange ROF_NCPL=\$ATM_NCPL
./xmlchange CAM_CONFIG_OPTS="-phys cam6 -age_of_air_trcs -chem waccm_ma_mam4 -ext_co2_cool"
./xmlchange CAM_CONFIG_OPTS="-phys cam6 -age_of_air_trcs -chem waccm_ma_mam4 -ext_co2_cool -tuvx"
Loading
Loading