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