source: trunk/LMDZ.MARS/deftank/occigen/run_month1

Last change on this file was 3766, checked in by jbclement, 3 months ago

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

File size: 3.0 KB
Line 
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
19source ../trunk/LMDZ.COMMON/arch.env
20# Environment setup for OpenMP:
21export I_MPI_DOMAIN=auto
22export I_MPI_PIN_RESPECT_CPUSET=0
23#Make sure that OMP_NUM_THREADS = cpus-per-task * KMP_HW_SUBSET
24export KMP_HW_SUBSET=1T
25export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK #C
26export OMP_STACKSIZE=400M
27export KMP_AFFINITY=granularity=fine,compact,1,0,verbose
28#
29########################################################################
30set -exv
31ls -al
32trap 'echo -e "Error at line $LINENO!"' ERR
33
34# Set starting month and ending month below:
35num_now=1
36num_end=12
37num_previous=$(( num_now - 1 ))
38
39echo "$num_previous" > num_run
40# next month number
41num_next=$(( num_now + 1 ))
42# true (i.e. modulo 12) month number
43true_num=$(( num_now % 12 ))
44
45# Check if required files exist
46\rm -f  error; touch error
47
48if [ ! -f run.def.ref ]; then
49  echo "Error: file \"run.def.ref\" not found in current directory!" > error
50  exit 1
51fi
52
53if [ ! -x run0 ]; then
54  echo "Error: file \"run0\" not found or not executable in current directory!" > error
55  exit 1
56fi
57
58if [ ! -f run_month$num_now ]; then
59  echo "Error: file \"run_month${num_now}\" not found in current directory!" > error
60  exit 1
61fi
62
63# Run model depending on current month
64case $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 ;;
78esac
79
80# Launch job for next month
81if (( 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
87fi
Note: See TracBrowser for help on using the repository browser.