Skip to content
Merged
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
37 changes: 27 additions & 10 deletions launcers/all_statics/generate_mer_statics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

OUTPUTDIR="/dev/shm/miotest"
OUTPUTDIR="/dev/shm/mer_domains"

BATHYTOOLSDIR="/home/spiani/projects/bathytools"
MITGCMINPUTSDIR="/home/spiani/projects/mitgcm_inputs"
Expand All @@ -12,7 +12,8 @@ DOMAINS_HR="HGT GOR CON PES LAM PAN NAP GAE FOL CAG ISO"

DOMAINS="$DOMAINS_REG $DOMAINS_HR"

MAXJOBS=5 # numero massimo di domini processati in parallelo
MAXJOBS=7 # numero massimo di domini processati in parallelo
MER_FORMAT=true

mkdir -p "${OUTPUTDIR}"

Expand Down Expand Up @@ -42,14 +43,22 @@ process_domain () {
domain_descriptor="$BATHYTOOLSDIR/mer_domains/high_reso/${domain,,}.yaml"
fi

poetry run bathytools -c "${domain_descriptor}" -o "${domaindir}" --mer
MER_FLAG=""
if ${MER_FORMAT}; then
MER_FLAG="--mer"
fi
Comment on lines +46 to +49
poetry run bathytools -c "${domain_descriptor}" -o "${domaindir}" $MER_FLAG

cd "$MITGCMINPUTSDIR"

poetry run mitgcm_inputs FLUXES \
-m "${domaindir}/meshmask.nc" \
-o "${domaindir}/fluxes.tar.gz"

poetry run mitgcm_inputs exf_albedo \
-m "${domaindir}/meshmask.nc" \
-o "${domaindir}/exf_albedo.txt"

rpositions="${domaindir}/rivers_positions.json"
rcustom="${BATHYTOOLSDIR}/mer_domains/rivers/${domain}.json"

Expand All @@ -58,19 +67,27 @@ process_domain () {

if [ -f "$rpositions" ]; then
rbcs_options="-p $rpositions -r $BATHYTOOLSDIR/mer_domains/rivers/main.json"
ob_indices_options="-p $rpositions -r ${domaindir}/additional_variables.nc"
if ${MER_FORMAT}; then
ob_indices_options="-p $rpositions -r ${domaindir}/additional_variables.nc"
else
ob_indices_options="-p $rpositions -r ${domaindir}/meshmask.nc"
fi

if [ -f "${rcustom}" ]; then
rbcs_options="${rbcs_options} -d ${rcustom}"
fi

# If there are rivers we also build the cosmetic mask
poetry run mitgcm_inputs cosmetic_mask -m "${domaindir}/meshmask.nc" \
-r "${domaindir}/additional_variables.nc" \
-o "${domaindir}/cmeshmask.nc" --mer
# If there are rivers (and we run the mer format) we also build the cosmetic mask
if ${MER_FORMAT}; then
poetry run mitgcm_inputs cosmetic_mask -m "${domaindir}/meshmask.nc" \
-r "${domaindir}/additional_variables.nc" \
-o "${domaindir}/cmeshmask.nc" --mer
fi
else
# No rivers? Then the cosmetic mask is equal to the original mask
cp -av "${domaindir}/meshmask.nc" "${domaindir}/cmeshmask.nc"
if ${MER_FORMAT}; then
cp -av "${domaindir}/meshmask.nc" "${domaindir}/cmeshmask.nc"
fi
fi

poetry run mitgcm_inputs ob_indices \
Expand All @@ -88,7 +105,7 @@ process_domain () {
}

export -f process_domain
export OUTPUTDIR BATHYTOOLSDIR MITGCMINPUTSDIR DOMAINS_HR
export OUTPUTDIR BATHYTOOLSDIR MITGCMINPUTSDIR DOMAINS_HR MER_FORMAT

if command -v parallel >/dev/null 2>&1; then
parallel --lb --tag --halt soon,fail=1 -j ${MAXJOBS} process_domain ::: ${DOMAINS}
Expand Down
Loading