Skip to content
Draft
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
36 changes: 36 additions & 0 deletions ctl/pre_ctl/pre_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,42 @@ echo "List of forcing files: "${listfrcfile[@]}

fi

####################
# PDAF
####################
if [[ "${modelid}" == *pdaf* ]]; then

parse_config_file ${conf_file} "pre_config_pdaf"

# ---------------------------------------------------------------------------
# Perturb atmospheric forcing
# ---------------------------------------------------------------------------
num_ensemble=${num_ensemble:-50}

if [[ "${modelid}" == *clm* ]]; then

lsmforcpertsrc_dir=${lsmforcpertsrc_dir:-${ctl_dir}/../src/eCLM_atmforcing/mkperturb}
eclmfrc_dir=${eclmfrc_dir:-${frc_dir}/eclm/forcing/}
pdaffrc_dir=${pdaffrc_dir:-${eclmfrc_dir}}

check_var_def pre_config_pdaf_env $(find ${lsmforcpertsrc_dir}/../ -type f -name "*sh") "Using environment file "

pyvenv_pre_config_pdaf=${pyvenv_pre_config_pdaf:-${ctl_dir}/virtualenvs/pyenv_pre_config_pdaf}

# load environment
source ${pre_config_pdaf_env}

# create virtual env if it does not exist yet
if [ ! -d "${pyvenv_pre_config_pdaf}" ]; then
echo "Virtual env not found at ${pyvenv_pre_config_pdaf}, installing "
python -m venv ${pyvenv_pre_config_pdaf}
source ${pyvenv_pre_config_pdaf}/bin/activate
pip install ${ctl_dir}/../src/eCLM_atmforcing/
deactivate
fi

fi # clm
fi # pdaf

if ${debugmode}; then

Expand Down
39 changes: 38 additions & 1 deletion ctl/pre_ctl/pre_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,44 @@ for yyyymm in "${listfrcfile[@]}"; do
done
unset yyyymm year month

fi
fi #eclm

if [[ "${modelid}" == *pdaf* ]]; then
if [[ "${modelid}" == *clm* ]]; then

cd "${lsmforcpertsrc_dir}"

# load environment
source ${pre_config_pdaf_env}
source ${pyvenv_pre_config_pdaf}/bin/activate

# list contain dates needed for forcing
for yyyymm in "${listfrcfile[@]}"; do
year="${yyyymm%%-*}"
month="${yyyymm#*-}"

(
exec srun --exclusive -n 1 python perturb_forcings.py \
--years "${year}" \
--months "${month}" \
--num-ensemble ${num_ensemble} \
--fdir ${eclmfrc_dir} \
--outdir ${pdaffrc_dir}
) &

# cap concurrent jobs at npnode (cores/tasks per node)
while (( $(jobs -rp | wc -l) >= npnode )); do
wait -n
done

done
wait
unset yyyymm year month
deactivate


fi #eclm
fi #pdaf

} # pre_run

Loading