| 1 | #!/bin/bash |
|---|
| 2 | # Partition to run on: |
|---|
| 3 | #MSUB -q rome |
|---|
| 4 | # project to run on |
|---|
| 5 | #MSUB -A gen10391 |
|---|
| 6 | # disks to use |
|---|
| 7 | #MSUB -m scratch,work,store |
|---|
| 8 | # Job name |
|---|
| 9 | #MSUB -r run_month1 |
|---|
| 10 | # Job standard output: |
|---|
| 11 | #MSUB -o run_month1.%I |
|---|
| 12 | # Job standard error: |
|---|
| 13 | #MSUB -e run_month1.%I |
|---|
| 14 | # number of OpenMP threads c |
|---|
| 15 | #MSUB -c 5 |
|---|
| 16 | # number of MPI tasks n |
|---|
| 17 | #MSUB -n 24 |
|---|
| 18 | # number of nodes to use N |
|---|
| 19 | #MSUB -N 1 |
|---|
| 20 | # max job run time T (in seconds) |
|---|
| 21 | #MSUB -T 43200 |
|---|
| 22 | # request exclusive use of the node (128 cores) |
|---|
| 23 | #MSUB -x |
|---|
| 24 | |
|---|
| 25 | ## Script to run chained simulations |
|---|
| 26 | ## (uses script "run0" and reference file "run.def.ref") |
|---|
| 27 | ## Set values of "num_now" and "num_end" in the script below |
|---|
| 28 | ## to set initial month # and final month # of the simulation |
|---|
| 29 | |
|---|
| 30 | # A few parameters that might need be changed depending on your setup: |
|---|
| 31 | # Path to the arch.env to source |
|---|
| 32 | source ../trunk/LMDZ.COMMON/arch.env |
|---|
| 33 | # Number of threads to use (must be the same as "#MSUB -c" above) |
|---|
| 34 | export OMP_NUM_THREADS=5 |
|---|
| 35 | export OMP_STACKSIZE=400M |
|---|
| 36 | # |
|---|
| 37 | ######################################################################## |
|---|
| 38 | set -exv |
|---|
| 39 | ls -al |
|---|
| 40 | trap 'echo -e "Error at line $LINENO!"' ERR |
|---|
| 41 | |
|---|
| 42 | # Set starting month and ending month below: |
|---|
| 43 | num_now=1 |
|---|
| 44 | num_end=12 |
|---|
| 45 | num_previous=$(( num_now - 1 )) |
|---|
| 46 | |
|---|
| 47 | echo "$num_previous" > num_run |
|---|
| 48 | # next month number |
|---|
| 49 | num_next=$(( num_now + 1 )) |
|---|
| 50 | # true (i.e. modulo 12) month number |
|---|
| 51 | true_num=$(( num_now % 12 )) |
|---|
| 52 | |
|---|
| 53 | # Check if required files exist |
|---|
| 54 | \rm -f error; touch error |
|---|
| 55 | |
|---|
| 56 | if [ ! -f run.def.ref ]; then |
|---|
| 57 | echo "Error: file \"run.def.ref\" not found in current directory!" > error |
|---|
| 58 | exit 1 |
|---|
| 59 | fi |
|---|
| 60 | |
|---|
| 61 | if [ ! -x run0 ]; then |
|---|
| 62 | echo "Error: file \"run0\" not found or not executable in current directory!" > error |
|---|
| 63 | exit 1 |
|---|
| 64 | fi |
|---|
| 65 | |
|---|
| 66 | if [ ! -f run_month$num_now ]; then |
|---|
| 67 | echo "Error: file \"run_month${num_now}\" not found in current directory!" > error |
|---|
| 68 | exit 1 |
|---|
| 69 | fi |
|---|
| 70 | |
|---|
| 71 | # Run model depending on current month |
|---|
| 72 | case $true_num in |
|---|
| 73 | 1 ) sed s/9999/61/ run.def.ref > run.def ; ./run0 >> error ;; #1 |
|---|
| 74 | 2 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;; #2 |
|---|
| 75 | 3 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;; #3 |
|---|
| 76 | 4 ) sed s/9999/65/ run.def.ref > run.def ; ./run0 >> error ;; #4 |
|---|
| 77 | 5 ) sed s/9999/60/ run.def.ref > run.def ; ./run0 >> error ;; #5 |
|---|
| 78 | 6 ) sed s/9999/54/ run.def.ref > run.def ; ./run0 >> error ;; #6 |
|---|
| 79 | 7 ) sed s/9999/50/ run.def.ref > run.def ; ./run0 >> error ;; #7 |
|---|
| 80 | 8 ) sed s/9999/46/ run.def.ref > run.def ; ./run0 >> error ;; #8 |
|---|
| 81 | 9 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;; #9 |
|---|
| 82 | 10 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;; #10 |
|---|
| 83 | 11 ) sed s/9999/51/ run.def.ref > run.def ; ./run0 >> error ;; #11 |
|---|
| 84 | 0 ) sed s/9999/56/ run.def.ref > run.def ; ./run0 >> error ;; #12 |
|---|
| 85 | * ) echo "Error: Invalid value of true_num ($true_num)" ; exit 1 ;; |
|---|
| 86 | esac |
|---|
| 87 | |
|---|
| 88 | # Launch job for next month |
|---|
| 89 | if (( num_next <= num_end )) ; then |
|---|
| 90 | cp -f run_month$num_now tmp |
|---|
| 91 | sed -e "s@run_month${num_now}@run_month${num_next}@" \ |
|---|
| 92 | -e "s@num_now=${num_now}@num_now=${num_next}@" tmp > run_month$num_next |
|---|
| 93 | rm tmp |
|---|
| 94 | ccc_msub run_month$num_next |
|---|
| 95 | fi |
|---|