Ignore:
Timestamp:
May 15, 2025, 6:26:24 PM (3 months 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/run0

    r1005 r3766  
    11#!/bin/bash
    2 ###########################################################################
     2########################################################################
    33# Script to perform several chained LMD Mars GCM simulations
    44# SET HERE the maximum total number of simulations
     
    66nummax=1
    77
    8 ###########################################################################
    9 
     8# Also, ensure that the gcm executable name is correct below:
     9gcm=gcm.e
     10#
     11########################################################################
     12set -x
    1013
    1114echo "---------------------------------------------------------"
    12 echo "starting run0"
     15echo "Starting run0..."
    1316
    1417dir=`pwd`
     
    1619address=`whoami`
    1720
    18 # Look for file "num_run" which should contain
     21# Check if GCM executable exists and is executable
     22if [ ! -x $gcm ]; then
     23  echo "Error: file \"$gcm\" not found or not executable in $dir!"
     24  exit 1
     25fi
     26
     27# Look for file "num_run" which should contain
    1928# the value of the previously computed season
    2029# (defaults to 0 if file "num_run" does not exist)
    2130if [[ -r num_run ]] ; then
    22   echo "found file num_run"
     31  echo "Found file \"num_run\""
    2332  numold=`cat num_run`
    2433else
    2534  numold=0
    2635fi
    27 echo "numold is set to" ${numold}
     36echo "numold is set to" $numold
    2837
    29 
    30 # Set value of current season
    31 (( numnew = ${numold} + 1 ))
    32 echo "numnew is set to" ${numnew}
     38# Set value of current season
     39numnew=$((numold + 1 ))
     40echo "numnew is set to" $numnew
    3341
    3442# Look for initialization data files (exit if none found)
     
    3745   \cp -f startfi${numold}.nc startfi.nc
    3846else
    39    if (( ${numold} == 99999 )) ; then
    40     echo "No run because previous run crashed ! (99999 in num_run)"
    41     exit
     47   if (( numold == 99999 )) ; then
     48     echo "Error: no run because previous run crashed! (99999 in \"num_run\")"
     49     exit 1
    4250   else
    43    echo "Where is file start"${numold}".nc??"
    44    exit
     51     echo "Error: missing input files \"start${numold}.nc\" or \"startfi${numold}.nc\" in $dir!"
     52     exit 1
    4553   fi
    4654fi
     
    4856
    4957# Run GCM
    50 gcm.e > lrun${numnew}
     58./$gcm > lrun${numnew}
    5159
    5260
    5361# Check if run ended normaly and copy datafiles
    5462if [[ ( -r restartfi.nc  &&  -r restart.nc ) ]] ; then
    55   echo "Run seems to have ended normaly"
     63  echo "Run seems to have ended normally."
    5664  \mv -f restartfi.nc startfi${numnew}.nc
    5765  \mv -f restart.nc start${numnew}.nc
    5866else
     67  echo "Error: Run crashed or incomplete output!"
    5968  if [[ -r num_run ]] ; then
    6069    \mv -f num_run num_run.crash
    6170  else
    62     echo "No file num_run to build num_run.crash from !!"
     71    echo "No file num_run to build \"num_run.crash\" from!"
    6372    # Impose a default value of 0 for num_run
    6473    echo 0 > num_run.crash
    6574  fi
    66  echo 99999 > num_run
     75  echo 99999 > num_run
    6776############## To receive an Email message if the run crashes ########
    68 mail -s "crash run GCM" $address <<ENDMAIL
    69 The run on $machine in $dir has just crashed.
     77mail -s "Crash in GCM run" $address <<ENDMAIL
     78The GCM run on $machine in $dir has just crashed.
     79Check the output logs for more information.
    7080ENDMAIL
    71 ############################################""
    72  exit
     81#############################################
     82  exit 1
    7383fi
    7484
     
    90100# Prepare things for upcoming runs by writing
    91101# value of computed season in file num_run
    92 echo ${numnew} > num_run
     102echo $numnew > num_run
    93103
    94104# If we are over nummax : stop
    95105if (( $numnew + 1 > $nummax )) ; then
    96    exit
     106  exit 0
    97107else
    98    \cp -f run0 exe_mars
    99    ./exe_mars
    100 fi
    101 
    102 
     108  \cp -f run0 exe_mars
     109  ./exe_mars
     110fi
Note: See TracChangeset for help on using the changeset viewer.