Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
25 changes: 15 additions & 10 deletions soil_ic_2008_50m/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Initial conditions for soil, Jan 1, 2008

This artifact includes the data needed by the ClimaLand model to initialize
the soil model prognostic variables for Jan 1, 2008, after an
appropriate spin-up period. The soil domain is 50 m deep, with 15
elements, and
approximately 0.2x0.2 degrees resolution in the horizontal.
This artifact includes the data needed by the ClimaLand model to initialize the
soil model prognostic variables for Jan 1, 2008, after an appropriate spin-up
period. The soil domain is 50 m deep, with 15 elements, and approximately
0.2x0.2 degrees resolution in the horizontal.

We obtain this data by first running the ClimaLand model, forced by
ERA5 data from 2008, for two years continuously. The script to do this is:
ClimaLand.jl/experiments/long_runs/snowy_land.jl. The output saved
from this via monthly diagnostics is used as input for the
`create_artifacts.jl` script.
We obtain this data by first running the ClimaLand model, forced by ERA5 data
from 2008, for two years continuously. The script to do this is:
ClimaLand.jl/experiments/long_runs/snowy_land.jl. The output saved from this via
monthly diagnostics is used as input for the `create_artifacts.jl` script.

This can be be done by the running `bash run_snowy_land.sh <file_directory>
<true/false>, where the boolean refers to using CUDA or not. For instance, one
can change directory to where this `README.md` is located by `cd
soil_ic_2008_50_m` and run `bash run_snowy_land.sh . true` to start a snowy land
long run with CUDA. After the simulation is done running, the terminal will
print a file path for you to copy and use as an input for `create_artifacts.jl`.

Assume that this monthly diagnostic data is in the directory `filedir`.

Expand Down
2 changes: 1 addition & 1 deletion soil_ic_2008_50m/create_artifacts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function replace_nan_with_mean!(x)
end

outfilepath = joinpath(outdir, "soil_ic_2008_50m.nc")
ds = NCDataset(outfilepath, "c")
ds = NCDataset(outfilepath, "c")

for i in 1:length(var_attribs)
var_attrib = var_attribs[i]
Expand Down
62 changes: 62 additions & 0 deletions soil_ic_2008_50m/run_snowy_land.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# This script is largely based off of `run_water_conservation_exp.sh` in
# `water_conservation_test`.

# This script checks out a specific commit of the ClimaLand.jl GitHub
# repository, and uses it to run the snowy land simulation which is running
# `ClimaLand.jl/experiments/long_runs/snowy_land.jl`. After the simulation
# is completed, the script prints the file path of the diagnostics in the
# terminal. This is the argument to `create_artifacts.jl`. Note that this
# script requires juliaup to be installed.

# Inform the user that the script requires one input argument, if it is not
# provided
[[ $# -lt 2 ]] && echo "Error! Usage: $0 <sim_dir> <true/false>" && exit 0

output_dir=$1
use_cuda=$2

# Validate the second argument is true or false
if ! [[("$use_cuda" == "true") || ("$use_cuda" == "false")]]; then
echo "The second argument can only be true or false"
exit 0
fi

# Parse the input argument for the output directory
mkdir -p $output_dir

# Go into newly created directory
cd $output_dir

# Clone the ClimaLand.jl repository
git clone https://github.com/CliMA/ClimaLand.jl.git
cd ClimaLand.jl

# Checkout the commit that was used to create the spun up soil initial
# conditions
git -c advice.detachedHEAD=false checkout 797a9b78253c61e9973d1808877145ef5c301155
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the right commit?

It corresponds to this commit: CliMA/ClimaLand.jl@797a9b7


# Use the same version of Julia that the long run was done on
juliaup add 1.11.3
julia +1.11.3 --project -e 'using Pkg; Pkg.instantiate(;verbose=true)'
julia +1.11.3 --project -e 'using Pkg; Pkg.status()'
julia +1.11.3 --project=.buildkite -e 'using Pkg; Pkg.instantiate(;verbose=true)'
julia +1.11.3 --project=.buildkite -e 'using Pkg; Pkg.precompile()'

if "$use_cuda" == "true"
then
echo "Using CUDA"
export CLIMACOMMS_DEVICE="CUDA"
julia +1.11.3 --project=.buildkite -e 'using CUDA; CUDA.precompile_runtime()'
fi

julia +1.11.3 --project=.buildkite -e 'using Pkg; Pkg.status()'

echo "Running snowy land simulation, this might take a while"
julia +1.11.3 --color=yes --project=.buildkite experiments/long_runs/snowy_land.jl

# Print the output_active directory by finding the symbolic link and print the
# absolute path
echo "Copy the file path below and use it as the input for create_artifacts.jl:"
find . -type l -ls | head -n 1 | awk '{print $11}' | xargs readlink -f