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
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ jobs:
timeout-minutes: 5
steps:
- name: Clone repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install Poetry
run: pipx install poetry==2.0.0
run: pipx install poetry==2.3.2

- name: Install Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "3.12"

Expand Down
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.14.0
rev: v3.16.0
hooks:
- id: reorder-python-imports
args: [--application-directories=.:src, --py39-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
rev: v2.3.3
hooks:
- id: autoflake
args: ["--remove-unused-variables"]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.8
rev: v0.15.5
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
args: [--line-length=79]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.1.0
rev: 26.3.1
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/PyCQA/flake8
rev: 7.2.0
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/fpgmaas/deptry.git
rev: 0.23.0
rev: 0.24.0
hooks:
- id: deptry
entry: deptry
Expand Down
83 changes: 63 additions & 20 deletions launcers/all_statics/generate_mer_statics.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,50 +1,93 @@
#!/bin/bash

set -e

OUTPUTDIR="/dev/shm/miotest"

BATHYTOOLSDIR="/home/spiani/projects/bathytools"
MITGCMINPUTSDIR="/home/spiani/projects/mitgcm_inputs"

DOMAINS_REG="NAD SAD ION SIC TYR LIG SAR GOT GSN"
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

DOMAINS="NAD SAD ION SIC TYR LIG SAR GOT"
DOMAINS="$DOMAINS HGT GOT CON PES LAM PAN NAP GAE FOL CAG ISO"
mkdir -p "${OUTPUTDIR}"

mkdir -p ${OUTPUTDIR}
process_domain () {
set -e
domain=$1

for domain in ${DOMAINS}
do
domaindir=${OUTPUTDIR}/${domain}
mkdir ${domaindir}
rm -rf "${domaindir}"
mkdir -p "${domaindir}"

echo
echo "----------^^^----------- DOMAIN ${domain} ----------^^^-----------"
echo

cd $BATHYTOOLSDIR
# Check where is the correct configuration file for the domain (in the mer_domains
# directory or in the mer_domains/high_reso dir)
# Setta SPONGE
if [[ " $DOMAINS_HR " =~ " $domain " ]]; then
SPONGE=10
else
SPONGE=16
fi

cd "$BATHYTOOLSDIR"

domain_descriptor="$BATHYTOOLSDIR/mer_domains/${domain,,}.yaml"
if [ ! -f "${domain_descriptor}" ]; then
domain_descriptor="$BATHYTOOLSDIR/mer_domains/high_reso/${domain,,}.yaml"
fi

# Run bathytools
poetry run bathytools -c ${domain_descriptor} -o ${domaindir} --mer
poetry run bathytools -c "${domain_descriptor}" -o "${domaindir}" --mer

# Generate fluxes.tar.gz
cd ${MITGCMINPUTSDIR}
poetry run mitgcm_inputs FLUXES -m ${domaindir}/meshmask.nc -o ${domaindir}/fluxes.tar.gz
cd "$MITGCMINPUTSDIR"

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

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

# Check if this domain has rivers to write the rbcs command line options
rpositions=${domaindir}/rivers_positions.json
rcustom=${BATHYTOOLSDIR}/mer_domains/rivers/${domain}.json
rbcs_options=""
ob_indices_options=""

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 [ -f "${rcustom}" ]; then
rbcs_options="${rbcs_options} -d ${rcustom}"
fi
fi

echo poetry run mitgcm_inputs rbcs -m ${domaindir}/meshmask.nc -o ${domaindir} ${rbcs_options}
poetry run mitgcm_inputs rbcs -m ${domaindir}/meshmask.nc -o ${domaindir} ${rbcs_options}
done
poetry run mitgcm_inputs ob_indices \
-m "${domaindir}/meshmask.nc" \
-s "$SPONGE" \
-o "${domaindir}/rivers_open_boundaries.txt" \
-n "${domaindir}/nudging_indices.txt" \
${ob_indices_options}

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

}

export -f process_domain
export OUTPUTDIR BATHYTOOLSDIR MITGCMINPUTSDIR DOMAINS_HR

if command -v parallel >/dev/null 2>&1; then
parallel --lb --tag --halt soon,fail=1 -j ${MAXJOBS} process_domain ::: ${DOMAINS}
else
echo "GNU parallel not found, falling back to serial execution." >&2
for domain in $DOMAINS
do
process_domain "$domain"
done
fi
Loading