https://docs.google.com/presentation/d/11SLZtjkZ1OIuCnYC4vnZ_uX4PntS-U6YgLSbQvkMd-U/edit?usp=sharing
https://colab.research.google.com/drive/1f5aKNJJ5mjy6OPRFBK2vCB_dP0gNzM_z?usp=sharing
For any bash script, you just need to run:
bash filename.sh
purpose: one liner to clean and recompile
file name: clean_and_compile.sh
#!/bin/bash
# can remove this line: (especially if you are cloning multiple versions of the same test case)
cd $HOME/dcmip2025_gw_break_fv3_C96
# necessary components (just taken from workflow):
./case.build --clean-all
qcmd -A UMIC0107 -q workshop -l walltime=01:00:00 -- ./case.build
This bash script will loop through different vertical resolutions, make a fresh copy of the test case with a unique output root folder, and update the necessary xml files. Then it will clean and recompile before running. Since it is difficult to rename the output file, I instead clone the test case for each experiment case and change the root directory for the output. Note that this will output your runs in different folders, which is less friendly if you are working with ncview to look at your data. This is because you will not be able to simultaneously compare experiment cases. Also, this is not a batch script, so you will need to stay logged on to the cluster while you wait for the model to recompile each time. The line that updates the resolution is borrowed from the page on Test Case 1. DISCLAIMER: this is relatively untested and currently being run by Isabella Dula and she will update to address any bugs. So far, this script has been able to successfully launch runs, but the outputs have not been inspected.
#!/bin/bash
# test conditions
vertical_resolutions=(88 120 207)
# folders
SRC_DIR=/glade/u/home/timand/CAM_6_4_082_21052025
CASE_DIR=/glade/u/home/timand/CAM_6_4_082_21052025/cases/
CASE_NAME=dcmip2025_gw_break_fv3_C96
# loop through and submit a job for each test case
for res in "${vertical_resolutions[@]}"; do
echo "=== Running test with $res vertical levels ==="
NEW_CASE_NAME=case1/vertical_exp_v4/n_levs_$res
echo ".... new case name: $NEW_CASE_NAME ...."
echo ".... copying and setting up test case ...."
$SRC_DIR/cime/scripts/create_clone --case /glade/u/home/$USER/$NEW_CASE_NAME --clone $CASE_DIR$CASE_NAME --cime-output-root /glade/work/$USER/dcmip25/case1/vertical_exp_v4
cd ~/$NEW_CASE_NAME
./case.setup
echo ".... changing vertical levels ...."
# change the number of vertical levels
./xmlchange --file env_build.xml --id CAM_CONFIG_OPTS --val "--phys held_suarez --analytic_ic --nlev=${res}"
# change job time (did 5 hours to be conservative, likely will need less)
./xmlchange JOB_WALLCLOCK_TIME=05:00:00 --subgroup case.run
# update name of file in name list
sed -i "s|^ncdata *=.*|ncdata = \"/glade/u/home/owhughes/vertical_grids/dcmip_vcoords_L"$res".nc\"|" user_nl_cam
# clean and recompile after making changes
echo "...... Cleaning and compiling. ......"
./case.build --clean-all
qcmd -A UMIC0107 -q workshop -l walltime=01:00:00 -- ./case.build
echo "...... Submitting case. ......"
./case.submit
done
This bash script will loop through various files to automate the regridding processes. I included a step that renames the files into something friendlier.
#!/bin/bash
# this routine automates regridding for several files at once.
# test conditions
vertical_resolutions=(88 120 207)
regrid_shell_func_path=$HOME/bash_scripts
native_grid=C96
latlon_grid=1x1
for res in "${vertical_resolutions[@]}"; do
echo "=== Regridding for vertical levels $res ==="
output_path=$WORK/dcmip25/case1/vertical_exp_v4/n_levs_$res/run/
cd $output_path
bash $regrid_shell_func_path/regrid.sh $native_grid $latlon_grid n_levs_$res.cam.h0i.0001-01-01-00000
bash $regrid_shell_func_path/regrid.sh $native_grid $latlon_grid n_levs_$res.cam.h1a.0001-01-01-00000
bash $regrid_shell_func_path/regrid.sh $native_grid $latlon_grid n_levs_$res.cam.h1i.0001-01-01-00000
mv "n_levs_$res.cam.h0i.0001-01-01-00000.regrid.1x1.nc" "h0i_1degree_$res_levels.nc"
mv "n_levs_$res.cam.h1a.0001-01-01-00000.regrid.1x1.nc" "h1a_1degree_$res_levels.nc"
mv "n_levs_$res.cam.h1i.0001-01-01-00000.regrid.1x1.nc" "h1i_1degree_$res_levels.nc"
done