| 1 | #!/bin/bash |
|---|
| 2 | #SBATCH --nodes=1 |
|---|
| 3 | #SBATCH --ntasks-per-node=24 |
|---|
| 4 | #SBATCH -J clim |
|---|
| 5 | #SBATCH --time=13:00:00 |
|---|
| 6 | #SBATCH --output run_month1.%j.out |
|---|
| 7 | ##SBATCH --mem=8GB |
|---|
| 8 | #SBATCH --constraint=[HSW24|BDW28] |
|---|
| 9 | #SBATCH --exclusive |
|---|
| 10 | |
|---|
| 11 | ## Script to run chained simulations on Occigen |
|---|
| 12 | ## (uses script "run0" and reference file "run.def.ref") |
|---|
| 13 | ## Set values of "num_now" and "num_end" in the script below |
|---|
| 14 | ## to set initial month # and final month # of the simulation |
|---|
| 15 | |
|---|
| 16 | # source the environment (you might need to adapt this path to your case) |
|---|
| 17 | source ../trunk/LMDZ.COMMON/arch/arch-X64_OCCIGEN.env |
|---|
| 18 | |
|---|
| 19 | set -xv |
|---|
| 20 | ls -al |
|---|
| 21 | |
|---|
| 22 | ## set starting month and ending month below: |
|---|
| 23 | num_now=1 |
|---|
| 24 | num_end=12 |
|---|
| 25 | (( num_previous = $num_now - 1 )) |
|---|
| 26 | |
|---|
| 27 | echo "$num_previous" > num_run |
|---|
| 28 | # next month number |
|---|
| 29 | (( num_next = $num_now + 1 )) |
|---|
| 30 | # true (i.e. modulo 12) month number |
|---|
| 31 | (( true_num = $num_now % 12 )) |
|---|
| 32 | |
|---|
| 33 | \rm -f error; touch error |
|---|
| 34 | |
|---|
| 35 | case $true_num in |
|---|
| 36 | 1 ) sed s/9999/61/ run.def.ref > run.def ; run0 >> error ;; #1 |
|---|
| 37 | 2 ) sed s/9999/66/ run.def.ref > run.def ; run0 >> error ;; #2 |
|---|
| 38 | 3 ) sed s/9999/66/ run.def.ref > run.def ; run0 >> error ;; #3 |
|---|
| 39 | 4 ) sed s/9999/65/ run.def.ref > run.def ; run0 >> error ;; #4 |
|---|
| 40 | 5 ) sed s/9999/60/ run.def.ref > run.def ; run0 >> error ;; #5 |
|---|
| 41 | 6 ) sed s/9999/54/ run.def.ref > run.def ; run0 >> error ;; #6 |
|---|
| 42 | 7 ) sed s/9999/50/ run.def.ref > run.def ; run0 >> error ;; #7 |
|---|
| 43 | 8 ) sed s/9999/46/ run.def.ref > run.def ; run0 >> error ;; #8 |
|---|
| 44 | 9 ) sed s/9999/47/ run.def.ref > run.def ; run0 >> error ;; #9 |
|---|
| 45 | 10 ) sed s/9999/47/ run.def.ref > run.def ; run0 >> error ;; #10 |
|---|
| 46 | 11 ) sed s/9999/51/ run.def.ref > run.def ; run0 >> error ;; #11 |
|---|
| 47 | 0 ) sed s/9999/56/ run.def.ref > run.def ; run0 >> error ;; #12 |
|---|
| 48 | * ) echo "error" ;; |
|---|
| 49 | esac |
|---|
| 50 | |
|---|
| 51 | # launch job for next month |
|---|
| 52 | if (( $num_next <= $num_end )) ; then |
|---|
| 53 | cp -f run_month$num_now tmp |
|---|
| 54 | sed -e "s@run_month${num_now}@run_month${num_next}@" \ |
|---|
| 55 | -e "s@num_now=${num_now}@num_now=${num_next}@" tmp > run_month$num_next |
|---|
| 56 | rm tmp |
|---|
| 57 | |
|---|
| 58 | sbatch run_month$num_next |
|---|
| 59 | fi |
|---|
| 60 | |
|---|