| 1 | #!/bin/bash |
|---|
| 2 | #SBATCH --job-name=run_year1 |
|---|
| 3 | #SBATCH --account=cin0391 |
|---|
| 4 | #SBATCH --constraint=GENOA |
|---|
| 5 | #SBATCH --nodes=1 |
|---|
| 6 | #SBATCH --ntasks-per-node=24 |
|---|
| 7 | #SBATCH --cpus-per-task=8 |
|---|
| 8 | #SBATCH --threads-per-core=1 # --hint=nomultithread |
|---|
| 9 | #SBATCH --exclusive |
|---|
| 10 | #SBATCH --output=run_year1_%A.out |
|---|
| 11 | #SBATCH --time=16:00:00 |
|---|
| 12 | |
|---|
| 13 | ## Script to run chained simulations |
|---|
| 14 | ## (uses script "run0" and reference file "run.def.ref") |
|---|
| 15 | ## Set values of "num_now" and "num_end" in the script below |
|---|
| 16 | ## to set initial year # and final year # of the simulation |
|---|
| 17 | |
|---|
| 18 | # A few parameters that might need be changed depending on your setup: |
|---|
| 19 | # Path to the arch.env to source |
|---|
| 20 | source ../trunk/LMDZ.COMMON/arch.env |
|---|
| 21 | # Number of threads to use (must be the same as "#SBATCH --cpus-per-task=" above) |
|---|
| 22 | export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK |
|---|
| 23 | export OMP_STACKSIZE=400M |
|---|
| 24 | # |
|---|
| 25 | ######################################################################## |
|---|
| 26 | set -exv |
|---|
| 27 | ls -al |
|---|
| 28 | trap 'echo -e "Error at line $LINENO!"' ERR |
|---|
| 29 | |
|---|
| 30 | # Set starting year and ending year below: |
|---|
| 31 | num_now=1 |
|---|
| 32 | num_end=10 |
|---|
| 33 | num_previous=$(( num_now - 1 )) |
|---|
| 34 | |
|---|
| 35 | echo "$num_previous" > num_run |
|---|
| 36 | # next year number |
|---|
| 37 | num_next=$(( num_now + 1 )) |
|---|
| 38 | |
|---|
| 39 | # Check if required files exist |
|---|
| 40 | \rm -f error; touch error |
|---|
| 41 | |
|---|
| 42 | if [ ! -f run.def.ref ]; then |
|---|
| 43 | echo "Error: file \"run.def.ref\" not found in current directory!" > error |
|---|
| 44 | exit 1 |
|---|
| 45 | fi |
|---|
| 46 | |
|---|
| 47 | if [ ! -x run0 ]; then |
|---|
| 48 | echo "Error: file \"run0\" not found or not executable in current directory!" > error |
|---|
| 49 | exit 1 |
|---|
| 50 | fi |
|---|
| 51 | |
|---|
| 52 | if [ ! -f run_year$num_now ]; then |
|---|
| 53 | echo "Error: file \"run_year${num_now}\" not found in current directory!" > error |
|---|
| 54 | exit 1 |
|---|
| 55 | fi |
|---|
| 56 | |
|---|
| 57 | # Run model for a year (669 sols) |
|---|
| 58 | sed s/9999/669/ run.def.ref > run.def ; ./run0 >> error |
|---|
| 59 | |
|---|
| 60 | # Launch job for next year |
|---|
| 61 | if (( num_next <= num_end )) ; then |
|---|
| 62 | cp -f run_year$num_now tmp |
|---|
| 63 | sed -e "s@run_year${num_now}@run_year${num_next}@" \ |
|---|
| 64 | -e "s@num_now=${num_now}@num_now=${num_next}@" tmp > run_year$num_next |
|---|
| 65 | rm tmp |
|---|
| 66 | sbatch run_year$num_next |
|---|
| 67 | fi |
|---|