Skip to content

Commit

Permalink
Added serial dockerfile and OLMT ensemble examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn P. Serbin committed Jun 13, 2023
1 parent 1d0dfbd commit 9e27bd1
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 11 deletions.
21 changes: 10 additions & 11 deletions docker/elm/elm_v2-for-ngee/Dockerfile_serial_multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# AMD64/ARM64 version
# ----------------------------------------------------------------------

FROM fasstsimulation/baseos:gcc850ompi316-serial_multiarch
FROM serbinsh/ngeearctic_elm_containers:baseos_gcc850ompi316-serial_multiarch
LABEL maintainer.name="Shawn P. Serbin" \
maintainer.email="[email protected]" \
author.name="Shawn P. Serbin" \
Expand All @@ -15,9 +15,8 @@ LABEL maintainer.name="Shawn P. Serbin" \
version.baseos="gcc8.5"

# where to get the ELM source code
ENV REPOSITORY_URL=https://github.com/FASSt-simulation/simulation_containers
ENV REPOSITORY_RAW_URL=https://raw.githubusercontent.com/FASSt-simulation/simulation_containers
ENV TOOLS_REPOSITORY_RAW_URL=https://raw.githubusercontent.com/FASSt-simulation/fasst_simulation_tools
ENV REPOSITORY_URL=https://github.com/TESTgroup-BNL/ngeearctic_elm_containers
ENV REPOSITORY_RAW_URL=https://raw.githubusercontent.com/TESTgroup-BNL/ngeearctic_elm_containers
ENV USER=modeluser

# Add new group, user, and user directory with user permissions
Expand Down Expand Up @@ -103,16 +102,16 @@ USER ${USER}
RUN cd /tools \
&& git -c http.sslVerify=false clone -b Arctic-userpft --single-branch https://github.com/dmricciuto/OLMT.git \
&& cd OLMT/ \
# add specific git commit as src - to try and stabilize changes and avoid new potential bugs
&& git reset --hard 'c208528360d59f46630ef94fe4a3a42cbfd3acab' \
# add specific git commit to version used in the October 2022 NGEE Arctic Modeling Workshop
&& git reset --hard '1b2a02c34deda8a2a796bb68325a87ddb3764c32' \
&& chown $USER:dockerusers -R /tools/OLMT \
&& chmod -R 777 /tools/OLMT

# Copy scripts into /scripts to make availible to users
RUN cd /scripts \
&& wget $TOOLS_REPOSITORY_RAW_URL/main/met_scripts/ngeearctic/download_elm_singlesite_forcing_data.sh \
&& wget $TOOLS_REPOSITORY_RAW_URL/main/elm_scripts/ngeearctic_elm_scripts/olmt_scripts/ngeearctic_site_fullrun_userdata_docker.sh \
&& wget $TOOLS_REPOSITORY_RAW_URL/main/elm_scripts/ngeearctic_elm_scripts/olmt_scripts/ngeearctic_ensemble_example_docker.sh \
&& wget $REPOSITORY_RAW_URL/main/scripts/met_scripts/ngeearctic/download_elm_singlesite_forcing_data.sh \
&& wget $REPOSITORY_RAW_URL/main/scripts/elm_scripts/olmt_scripts/ngeearctic_site_fullrun_userdata_docker.sh \
&& wget $REPOSITORY_RAW_URL/main/scripts/elm_scripts/olmt_scripts/ngeearctic_ensemble_example_docker.sh \
&& mv ngeearctic_site_fullrun_userdata_docker.sh OLMT_docker_example.sh \
&& mv ngeearctic_ensemble_example_docker.sh OLMT_ens_docker_example.sh \
&& chown $USER:dockerusers download_elm_singlesite_forcing_data.sh \
Expand All @@ -121,9 +120,9 @@ RUN cd /scripts \
&& chown $USER:dockerusers OLMT_ens_docker_example.sh \
&& chmod +x OLMT_docker_example.sh \
&& chmod +x OLMT_ens_docker_example.sh \
&& wget $TOOLS_REPOSITORY_RAW_URL/main/elm_scripts/ngeearctic_elm_scripts/olmt_scripts/param_list_example_kougarok \
&& wget $REPOSITORY_RAW_URL/main/scripts/elm_scripts/olmt_scripts/param_list_example_kougarok \
&& chown $USER:dockerusers param_list_example_kougarok \
&& wget $TOOLS_REPOSITORY_RAW_URL/main/elm_scripts/ngeearctic_elm_scripts/olmt_scripts/param_list_example_beo \
&& wget $REPOSITORY_RAW_URL/main/scripts/elm_scripts/olmt_scripts/param_list_example_beo \
&& chown $USER:dockerusers param_list_example_beo \
&& cd /

Expand Down
218 changes: 218 additions & 0 deletions scripts/elm_scripts/olmt_scripts/ngeearctic_ensemble_example_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
#!/bin/sh
# =======================================================================================
# Setup and run an ELM OLMT simulation for an NGEE Arctic site
#
#
# availible site names: kougarok, teller, council, beo
# =======================================================================================

cwd=$(pwd)
cd /tools/OLMT

# =======================================================================================
### Setup and run an example ELM OLMT ensemble simulation for a NGEE-Arctic research site
for i in "$@"
do
case $i in
-sn=*|--site_name=*)
site_name="${i#*=}"
shift # past argument=value
;;
-sg=*|--site_group=*)
site_group="${i#*=}"
shift # past argument=value
;;
-cp=*|--case_prefix=*)
case_prefix="${i#*=}"
shift # past argument=value
;;
-adsy=*|--ad_spinup_years=*)
ad_spinup_years="${i#*=}"
shift # past argument=value
;;
-fsy=*|--final_spinup_years=*)
final_spinup_years="${i#*=}"
shift # past argument=value
;;
-trsy=*|--transient_years=*)
transient_years="${i#*=}"
shift # past argument=value
;;
-tsp=*|--timestep=*)
timestep="${i#*=}"
shift # past argument=value
;;
-pl=*|--param_list=*)
param_list="${i#*=}"
shift # past argument=value
;;
-ne=*|--num_ens=*)
num_ens="${i#*=}"
shift # past argument=value
;;
-ng=*|--num_groups=*)
num_groups="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done
# =======================================================================================

# =======================================================================================
# Set defaults and print the selected options back to the screen before running
site_name="${site_name:-kougarok}"
site_group="${site_group:-NGEEArctic}"
case_prefix="${case_prefix:-OLMT_ens}"
ad_spinup_years="${ad_spinup_years:-200}"
final_spinup_years="${final_spinup_years:-600}"
transient_years="${transient_years:--1}"
timestep="${timestep:-1}"
param_list="${param_list:-/scripts/param_list_example_kougarok}"
num_ens="${num_ens:-6}"
num_groups="${num_groups:-3}"

# print back selected or set options to the user
echo " "
echo " "
echo "*************************** OLMT run options ***************************"
echo "Site Name = ${site_name}"
echo "Site Group = ${site_group}"
echo "Case Prefix = ${case_prefix}"
echo "Number of AD Spinup Simulation Years = ${ad_spinup_years}"
echo "Number of Final Spinup Simulation Years = ${final_spinup_years}"
echo "Number of Transient Simulation Years = ${transient_years}"
echo "Model Timestep = ${timestep}"
echo "Input parameter list = ${param_list}"
echo "Number of MCMC Ensembles = ${num_ens}"
echo "Number of MPI groups = ${num_groups}"
if [ ${transient_years} != -1 ]; then
sim_years="--nyears_ad_spinup ${ad_spinup_years} --nyears_final_spinup ${final_spinup_years} \
--nyears_transient ${transient_years}"
else
sim_years="--nyears_ad_spinup ${ad_spinup_years} --nyears_final_spinup ${final_spinup_years}"
fi
echo " "
# =======================================================================================

# =======================================================================================
# Set site codes for OLMT
if [ ${site_name} = beo ]; then
site_code="AK-BEOG"
elif [ ${site_name} = council ]; then
site_code="AK-CLG"
elif [ ${site_name} = kougarok ]; then
site_code="AK-K64G"
elif [ ${site_name} = teller ]; then
site_code="AK-TLG"
else
echo " "
echo "**** EXECUTION HALTED ****"
echo "Please select a Site Name from beo, council, kougarok, teller"
exit 0
echo " "
fi
echo "OLMT Site Code: ${site_code}"
# =======================================================================================

# =======================================================================================
# pause to show options before continuing
sleep 3
echo " "
echo " "
# =======================================================================================

# =======================================================================================
echo "Building ensemble simulations with OLMT source: "$(pwd)
echo "*****************************************************************"
echo " "
echo " "
echo "**** User OLMT run command: "
runcmd="python3 ./site_fullrun.py \
--site ${site_code} --sitegroup ${site_group} --caseidprefix ${case_prefix} \
${sim_years} --tstep ${timestep} --machine docker \
--compiler gnu --mpilib mpi-serial \
--cpl_bypass --gswp3 \
--model_root /E3SM \
--caseroot /output \
--ccsm_input /inputdata \
--runroot /output \
--spinup_vars \
--parm_list ${param_list} \
--mc_ensemble ${num_ens} \
--nopointdata \
--metdir /inputdata/atm/datm7/atm_forcing.datm7.GSWP3.0.5d.v2.c180716_NGEE-Grid/cpl_bypass_${site_name}-Grid \
--domainfile /inputdata/share/domains/domain.clm/domain.lnd.1x1pt_${site_name}-GRID_navy.nc \
--surffile /inputdata/lnd/clm2/surfdata_map/surfdata_1x1pt_${site_name}-GRID_simyr1850_c360x720_c171002.nc \
--landusefile /inputdata/lnd/clm2/surfdata_map/landuse.timeseries_1x1pt_${site_name}-GRID_simyr1850-2015_c180423.nc \
& sleep 10"
echo ${runcmd}
echo " "
echo " "

# create the OLMT run command
if python3 ./site_fullrun.py \
--site ${site_code} --sitegroup ${site_group} --caseidprefix ${case_prefix} \
${sim_years} --tstep ${timestep} --machine docker \
--compiler gnu --mpilib mpi-serial \
--cpl_bypass --gswp3 \
--model_root /E3SM \
--caseroot /output \
--ccsm_input /inputdata \
--runroot /output \
--spinup_vars \
--parm_list ${param_list} \
--mc_ensemble ${num_ens} \
--ng ${num_groups} \
--nopointdata \
--metdir /inputdata/atm/datm7/atm_forcing.datm7.GSWP3.0.5d.v2.c180716_NGEE-Grid/cpl_bypass_${site_name}-Grid \
--domainfile /inputdata/share/domains/domain.clm/domain.lnd.1x1pt_${site_name}-GRID_navy.nc \
--surffile /inputdata/lnd/clm2/surfdata_map/surfdata_1x1pt_${site_name}-GRID_simyr1850_c360x720_c171002.nc \
--landusefile /inputdata/lnd/clm2/surfdata_map/landuse.timeseries_1x1pt_${site_name}-GRID_simyr1850-2015_c180423.nc \
& sleep 10

then
wait

echo "DONE docker ELM runs !"

else
exit &?
fi

cd ${cwd}
sleep 2

#### Postprocess
# Copy the example parameter file to the OLMT ensemble output folder
cp ${param_list} /output/cime_run_dirs/UQ/${case_prefix}_${site_code}_ICB20TRCNPRDCTCBC/.
### Collapse transient simulation output into a single netCDF file
echo " "
echo " "
echo " "
echo "**** Postprocessing ELM output in:"
echo "/output/cime_run_dirs/UQ/${case_prefix}_${site_code}_ICB20TRCNPRDCTCBC/"
echo " "
echo " "
cd /output/cime_run_dirs/UQ/${case_prefix}_${site_code}_ICB20TRCNPRDCTCBC/
echo " "
echo "**** Concatenating netCDF output - Hang tight this will take awhile ****"
echo ${PWD}
for d in */ ; do
echo "Post-processing: $d"
cd /output/cime_run_dirs/UQ/${case_prefix}_${site_code}_ICB20TRCNPRDCTCBC/${d}
ncrcat --ovr *.h0.*.nc ELM_output.nc
chmod 777 ELM_output.nc
echo " "
done
echo " "
echo " "
echo "**** Concatenating netCDF output: DONE ****"
echo "**** OLMT Ensemble Simulation at ${site_name}: DONE ****"
echo " "
echo " "
echo " "
sleep 2
# =======================================================================================
12 changes: 12 additions & 0 deletions scripts/elm_scripts/olmt_scripts/param_list_example_beo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
flnr 11 0.02 0.20
flnr 12 0.02 0.20
vcmaxha 11 68000 77000
vcmaxha 12 68000 77000
jmaxha 11 48000 58000
jmaxha 12 48000 58000
roota_par 11 4 10
roota_par 12 6 15
mbbopt 11 1 13
mbbopt 12 1 13
slatop 11 0.009 0.045
slatop 12 0.009 0.045
12 changes: 12 additions & 0 deletions scripts/elm_scripts/olmt_scripts/param_list_example_kougarok
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
flnr 11 0.07 0.145
flnr 12 0.07 0.145
vcmaxha 11 68000 79000
vcmaxha 12 68000 79000
jmaxha 11 48000 58000
jmaxha 12 48000 58000
roota_par 11 4.0 10
roota_par 12 6 15
mbbopt 11 1 13
mbbopt 12 1 13
slatop 11 0.009 0.045
slatop 12 0.009 0.045

0 comments on commit 9e27bd1

Please sign in to comment.