source: trunk/LMDZ.MARS/deftank/spirit/run_month1 @ 3766

Last change on this file since 3766 was 3766, checked in by jbclement, 5 weeks ago

Mars PCM:
Cleaning and improvement of robustness for "run0" and "run_month1" scripts with file checks and clearer errors.
JBC

File size: 2.8 KB
Line 
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
17source ../trunk/LMDZ.COMMON/arch.env
18# Number of threads to use (must be the same as "#SBATCH --cpus-per-task=" above)
19export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
20export OMP_STACKSIZE=400M
21#
22########################################################################
23set -exv
24ls -al
25trap 'echo -e "Error at line $LINENO!"' ERR
26
27# Set starting month and ending month below:
28num_now=1
29num_end=12
30num_previous=$(( num_now - 1 ))
31
32echo "$num_previous" > num_run
33# next month number
34num_next=$(( num_now + 1 ))
35# true (i.e. modulo 12) month number
36true_num=$(( num_now % 12 ))
37
38# Check if required files exist
39\rm -f  error; touch error
40
41if [ ! -f run.def.ref ]; then
42  echo "Error: file \"run.def.ref\" not found in current directory!" > error
43  exit 1
44fi
45
46if [ ! -x run0 ]; then
47  echo "Error: file \"run0\" not found or not executable in current directory!" > error
48  exit 1
49fi
50
51if [ ! -f run_month$num_now ]; then
52  echo "Error: file \"run_month${num_now}\" not found in current directory!" > error
53  exit 1
54fi
55
56# Run model depending on current month
57case $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 ;;
71esac
72
73# Launch job for next month
74if (( 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
80fi
Note: See TracBrowser for help on using the repository browser.