#!/bin/bash # Partition to run on: #MSUB -q rome # project to run on #MSUB -A gen10391 # disks to use #MSUB -m scratch,work,store # Job name #MSUB -r run_month1 # Job standard output: #MSUB -o run_month1.%I # Job standard error: #MSUB -e run_month1.%I # number of OpenMP threads c #MSUB -c 5 # number of MPI tasks n #MSUB -n 24 # number of nodes to use N #MSUB -N 1 # max job run time T (in seconds) #MSUB -T 43200 # request exclusive use of the node (128 cores) #MSUB -x ## Script to run chained simulations ## (uses script "run0" and reference file "run.def.ref") ## Set values of "num_now" and "num_end" in the script below ## to set initial month # and final month # of the simulation # A few parameters that might need be changed depending on your setup: # Path to the arch.env to source source ../trunk/LMDZ.COMMON/arch.env # Number of threads to use (must be the same as "#MSUB -c" above) export OMP_NUM_THREADS=5 export OMP_STACKSIZE=400M # ######################################################################## set -exv ls -al trap 'echo -e "Error at line $LINENO!"' ERR # Set starting month and ending month below: num_now=1 num_end=12 num_previous=$(( num_now - 1 )) echo "$num_previous" > num_run # next month number num_next=$(( num_now + 1 )) # true (i.e. modulo 12) month number true_num=$(( num_now % 12 )) # Check if required files exist \rm -f error; touch error if [ ! -f run.def.ref ]; then echo "Error: file \"run.def.ref\" not found in current directory!" > error exit 1 fi if [ ! -x run0 ]; then echo "Error: file \"run0\" not found or not executable in current directory!" > error exit 1 fi if [ ! -f run_month$num_now ]; then echo "Error: file \"run_month${num_now}\" not found in current directory!" > error exit 1 fi # Run model depending on current month case $true_num in 1 ) sed s/9999/61/ run.def.ref > run.def ; ./run0 >> error ;; #1 2 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;; #2 3 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;; #3 4 ) sed s/9999/65/ run.def.ref > run.def ; ./run0 >> error ;; #4 5 ) sed s/9999/60/ run.def.ref > run.def ; ./run0 >> error ;; #5 6 ) sed s/9999/54/ run.def.ref > run.def ; ./run0 >> error ;; #6 7 ) sed s/9999/50/ run.def.ref > run.def ; ./run0 >> error ;; #7 8 ) sed s/9999/46/ run.def.ref > run.def ; ./run0 >> error ;; #8 9 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;; #9 10 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;; #10 11 ) sed s/9999/51/ run.def.ref > run.def ; ./run0 >> error ;; #11 0 ) sed s/9999/56/ run.def.ref > run.def ; ./run0 >> error ;; #12 * ) echo "Error: Invalid value of true_num ($true_num)" ; exit 1 ;; esac # Launch job for next month if (( num_next <= num_end )) ; then cp -f run_month$num_now tmp sed -e "s@run_month${num_now}@run_month${num_next}@" \ -e "s@num_now=${num_now}@num_now=${num_next}@" tmp > run_month$num_next rm tmp ccc_msub run_month$num_next fi