Ignore:
Timestamp:
May 15, 2025, 6:26:24 PM (6 weeks ago)
Author:
jbclement
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.MARS/deftank/adastra/run_month1

    r3033 r3766  
    44#SBATCH --constraint=GENOA
    55#SBATCH --nodes=1
    6 #SBATCH --ntasks-per-node=24 
     6#SBATCH --ntasks-per-node=24
    77#SBATCH --cpus-per-task=4
    88#SBATCH --threads-per-core=1 # --hint=nomultithread
    99#SBATCH --exclusive
    1010#SBATCH --output=run_month1_%A.out
    11 #SBATCH --time=01:25:00 
     11#SBATCH --time=01:25:00
    1212
    13 
     13## Script to run chained simulations
     14## (uses script "run0" and reference file "run.def.ref")
     15## Set values of "num_now" and "num_end" in the script below
     16## to set initial month # and final month # of the simulation
    1417
    1518# A few parameters that might need be changed depending on your setup:
    1619# Path to the arch.env to source
    1720source ../trunk/LMDZ.COMMON/arch.env
    18 # Number of threads to use (must be the same as "#SBATCH --cpus-per-task=" above) 
    19 export OMP_NUM_THREADS=4
     21# Number of threads to use (must be the same as "#SBATCH --cpus-per-task=" above)
     22export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
    2023export OMP_STACKSIZE=400M
     24#
     25########################################################################
     26set -exv
     27ls -al
     28trap 'echo -e "Error at line $LINENO!"' ERR
    2129
    22 set -xv
    23 ls -al
    24 
    25 ## set starting month and ending month below:
     30# Set starting month and ending month below:
    2631num_now=1
    2732num_end=12
    28 (( num_previous = $num_now - 1 ))
     33num_previous=$(( num_now - 1 ))
    2934
    3035echo "$num_previous" > num_run
    3136# next month number
    32 (( num_next = $num_now + 1 ))
     37num_next=$(( num_now + 1 ))
    3338# true (i.e. modulo 12) month number
    34 (( true_num = $num_now % 12 ))
     39true_num=$(( num_now % 12 ))
    3540
     41# Check if required files exist
    3642\rm -f  error; touch error
    3743
     44if [ ! -f run.def.ref ]; then
     45  echo "Error: file \"run.def.ref\" not found in current directory!" > error
     46  exit 1
     47fi
     48
     49if [ ! -x run0 ]; then
     50  echo "Error: file \"run0\" not found or not executable in current directory!" > error
     51  exit 1
     52fi
     53
     54if [ ! -f run_month$num_now ]; then
     55  echo "Error: file \"run_month${num_now}\" not found in current directory!" > error
     56  exit 1
     57fi
     58
     59# Run model depending on current month
    3860case $true_num in
    39   1 ) sed s/9999/61/ run.def.ref > run.def ; run0 >> error ;;    #1
    40   2 ) sed s/9999/66/ run.def.ref > run.def ; run0 >> error ;;    #2
    41   3 ) sed s/9999/66/ run.def.ref > run.def ; run0 >> error ;;    #3
    42   4 ) sed s/9999/65/ run.def.ref > run.def ; run0 >> error ;;    #4
    43   5 ) sed s/9999/60/ run.def.ref > run.def ; run0 >> error ;;    #5
    44   6 ) sed s/9999/54/ run.def.ref > run.def ; run0 >> error ;;    #6
    45   7 ) sed s/9999/50/ run.def.ref > run.def ; run0 >> error ;;    #7
    46   8 ) sed s/9999/46/ run.def.ref > run.def ; run0 >> error ;;    #8
    47   9 ) sed s/9999/47/ run.def.ref > run.def ; run0 >> error ;;    #9
    48  10 ) sed s/9999/47/ run.def.ref > run.def ; run0 >> error ;;    #10
    49  11 ) sed s/9999/51/ run.def.ref > run.def ; run0 >> error ;;    #11
    50   0 ) sed s/9999/56/ run.def.ref > run.def ; run0 >> error ;;    #12
    51   * ) echo "error" ;;
     61  1 ) sed s/9999/61/ run.def.ref > run.def ; ./run0 >> error ;;    #1
     62  2 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;;    #2
     63  3 ) sed s/9999/66/ run.def.ref > run.def ; ./run0 >> error ;;    #3
     64  4 ) sed s/9999/65/ run.def.ref > run.def ; ./run0 >> error ;;    #4
     65  5 ) sed s/9999/60/ run.def.ref > run.def ; ./run0 >> error ;;    #5
     66  6 ) sed s/9999/54/ run.def.ref > run.def ; ./run0 >> error ;;    #6
     67  7 ) sed s/9999/50/ run.def.ref > run.def ; ./run0 >> error ;;    #7
     68  8 ) sed s/9999/46/ run.def.ref > run.def ; ./run0 >> error ;;    #8
     69  9 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;;    #9
     70 10 ) sed s/9999/47/ run.def.ref > run.def ; ./run0 >> error ;;    #10
     71 11 ) sed s/9999/51/ run.def.ref > run.def ; ./run0 >> error ;;    #11
     72  0 ) sed s/9999/56/ run.def.ref > run.def ; ./run0 >> error ;;    #12
     73  * ) echo "Error: Invalid value of true_num ($true_num)" ; exit 1 ;;
    5274esac
    5375
    54 # launch job for next month
    55 if (( $num_next <= $num_end )) ; then
     76# Launch job for next month
     77if (( num_next <= num_end )) ; then
    5678  cp -f run_month$num_now tmp
    5779  sed -e "s@run_month${num_now}@run_month${num_next}@" \
    5880      -e "s@num_now=${num_now}@num_now=${num_next}@" tmp > run_month$num_next
    5981  rm tmp
    60  
    6182  sbatch run_month$num_next
    6283fi
Note: See TracChangeset for help on using the changeset viewer.