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