[3033] | 1 | #!/bin/bash |
---|
| 2 | #SBATCH --job-name=run_month1 |
---|
| 3 | #SBATCH --account=cin0391 |
---|
| 4 | #SBATCH --constraint=GENOA |
---|
| 5 | #SBATCH --nodes=1 |
---|
[3766] | 6 | #SBATCH --ntasks-per-node=24 |
---|
[3817] | 7 | #SBATCH --cpus-per-task=8 |
---|
[3033] | 8 | #SBATCH --threads-per-core=1 # --hint=nomultithread |
---|
| 9 | #SBATCH --exclusive |
---|
| 10 | #SBATCH --output=run_month1_%A.out |
---|
[3766] | 11 | #SBATCH --time=01:25:00 |
---|
[3033] | 12 | |
---|
[3766] | 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 month # and final month # of the simulation |
---|
[3033] | 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 |
---|
[3766] | 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 |
---|
[3033] | 23 | export OMP_STACKSIZE=400M |
---|
[3766] | 24 | # |
---|
| 25 | ######################################################################## |
---|
| 26 | set -exv |
---|
[3033] | 27 | ls -al |
---|
[3766] | 28 | trap 'echo -e "Error at line $LINENO!"' ERR |
---|
[3033] | 29 | |
---|
[3766] | 30 | # Set starting month and ending month below: |
---|
[3033] | 31 | num_now=1 |
---|
| 32 | num_end=12 |
---|
[3766] | 33 | num_previous=$(( num_now - 1 )) |
---|
[3033] | 34 | |
---|
| 35 | echo "$num_previous" > num_run |
---|
| 36 | # next month number |
---|
[3766] | 37 | num_next=$(( num_now + 1 )) |
---|
[3033] | 38 | # true (i.e. modulo 12) month number |
---|
[3766] | 39 | true_num=$(( num_now % 12 )) |
---|
[3033] | 40 | |
---|
[3766] | 41 | # Check if required files exist |
---|
[3033] | 42 | \rm -f error; touch error |
---|
| 43 | |
---|
[3766] | 44 | if [ ! -f run.def.ref ]; then |
---|
| 45 | echo "Error: file \"run.def.ref\" not found in current directory!" > error |
---|
| 46 | exit 1 |
---|
| 47 | fi |
---|
| 48 | |
---|
| 49 | if [ ! -x run0 ]; then |
---|
| 50 | echo "Error: file \"run0\" not found or not executable in current directory!" > error |
---|
| 51 | exit 1 |
---|
| 52 | fi |
---|
| 53 | |
---|
| 54 | if [ ! -f run_month$num_now ]; then |
---|
| 55 | echo "Error: file \"run_month${num_now}\" not found in current directory!" > error |
---|
| 56 | exit 1 |
---|
| 57 | fi |
---|
| 58 | |
---|
| 59 | # Run model depending on current month |
---|
[3033] | 60 | case $true_num in |
---|
[3766] | 61 | 1 ) sed s/9999/61/ run.def.ref > run.def ; ./run0 >> error ;; #1 |
---|
| 62 | 2 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;; #2 |
---|
| 63 | 3 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;; #3 |
---|
| 64 | 4 ) sed s/9999/65/ run.def.ref > run.def ; ./run0 >> error ;; #4 |
---|
| 65 | 5 ) sed s/9999/60/ run.def.ref > run.def ; ./run0 >> error ;; #5 |
---|
| 66 | 6 ) sed s/9999/54/ run.def.ref > run.def ; ./run0 >> error ;; #6 |
---|
| 67 | 7 ) sed s/9999/50/ run.def.ref > run.def ; ./run0 >> error ;; #7 |
---|
| 68 | 8 ) sed s/9999/46/ run.def.ref > run.def ; ./run0 >> error ;; #8 |
---|
| 69 | 9 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;; #9 |
---|
| 70 | 10 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;; #10 |
---|
| 71 | 11 ) sed s/9999/51/ run.def.ref > run.def ; ./run0 >> error ;; #11 |
---|
| 72 | 0 ) sed s/9999/56/ run.def.ref > run.def ; ./run0 >> error ;; #12 |
---|
| 73 | * ) echo "Error: Invalid value of true_num ($true_num)" ; exit 1 ;; |
---|
[3033] | 74 | esac |
---|
| 75 | |
---|
[3766] | 76 | # Launch job for next month |
---|
| 77 | if (( num_next <= num_end )) ; then |
---|
[3033] | 78 | cp -f run_month$num_now tmp |
---|
| 79 | sed -e "s@run_month${num_now}@run_month${num_next}@" \ |
---|
| 80 | -e "s@num_now=${num_now}@num_now=${num_next}@" tmp > run_month$num_next |
---|
| 81 | rm tmp |
---|
| 82 | sbatch run_month$num_next |
---|
| 83 | fi |
---|