source: trunk/LMDZ.MARS/deftank/adastra/run0 @ 3817

Last change on this file since 3817 was 3817, checked in by emillour, 2 days ago

Mars PCM:
Move adastra_cpu_binding.sh to "adastra" subforlder of deftank.
And adapt scripts and README there.
EM

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#!/bin/bash
2########################################################################
3# Script to perform several chained LMD Mars GCM simulations
4# SET HERE the maximum total number of simulations
5
6nummax=1
7
8# Also, ensure that the gcm executable name is correct below:
9gcm=gcm_64x48x54_phymars_para.e
10#
11########################################################################
12set -x
13
14echo "---------------------------------------------------------"
15echo "Starting run0..."
16
17dir=`pwd`
18machine=`hostname`
19address=`whoami`
20
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
28# the value of the previously computed season
29# (defaults to 0 if file "num_run" does not exist)
30if [[ -r num_run ]] ; then
31  echo "Found file \"num_run\""
32  numold=`cat num_run`
33else
34  numold=0
35fi
36echo "numold is set to" $numold
37
38# Set value of current season
39numnew=$((numold + 1 ))
40echo "numnew is set to" $numnew
41
42# Look for initialization data files (exit if none found)
43if [[ ( -r start${numold}.nc  &&  -r startfi${numold}.nc ) ]] ; then
44   \cp -f start${numold}.nc start.nc
45   \cp -f startfi${numold}.nc startfi.nc
46else
47   if (( numold == 99999 )) ; then
48     echo "Error: no run because previous run crashed! (99999 in \"num_run\")"
49     exit 1
50   else
51     echo "Error: missing input files \"start${numold}.nc\" or \"startfi${numold}.nc\" in $dir!"
52     exit 1
53   fi
54fi
55
56
57# Run GCM using srun (no cpu binding... OK for MPI only)
58#srun --cpu-bind=threads --label -c${OMP_NUM_THREADS:=1} $gcm > lrun${numnew} 2>&1
59# Ideally using adequate cpu binding, especially if using mixed MPI/OpenMP on a full node
60srun --ntasks-per-node=${SLURM_NTASKS_PER_NODE} --cpu-bind=none --mem-bind=none --label -- ./adastra_cpu_binding.sh ./$gcm > lrun${numnew} 2>&1
61
62
63# Check if run ended normaly and copy datafiles
64if [[ ( -r restartfi.nc  &&  -r restart.nc ) ]] ; then
65  echo "Run seems to have ended normally."
66  \mv -f restartfi.nc startfi${numnew}.nc
67  \mv -f restart.nc start${numnew}.nc
68else
69  echo "Error: Run crashed or incomplete output!"
70  if [[ -r num_run ]] ; then
71    \mv -f num_run num_run.crash
72  else
73    echo "No file num_run to build \"num_run.crash\" from!"
74    # Impose a default value of 0 for num_run
75    echo 0 > num_run.crash
76  fi
77  echo 99999 > num_run
78############## To receive an Email message if the run crashes ########
79mail -s "Crash in GCM run" $address <<ENDMAIL
80The GCM run on $machine in $dir has just crashed.
81Check the output logs for more information.
82ENDMAIL
83#############################################
84  exit 1
85fi
86
87# Copy other datafiles that may have been generated
88if [[ -r diagfi.nc ]] ; then
89  \mv -f diagfi.nc diagfi${numnew}.nc
90fi
91if [[ -r diagsoil.nc ]] ; then
92  \mv -f diagsoil.nc diagsoil${numnew}.nc
93fi
94if [[ -r stats.nc ]] ; then
95  \mv -f stats.nc stats${numnew}.nc
96fi
97if [[ -f profiles.dat ]] ; then
98  \mv -f profiles.dat profiles${numnew}.dat
99  \mv -f profiles.hdr profiles${numnew}.hdr
100fi
101
102# Prepare things for upcoming runs by writing
103# value of computed season in file num_run
104echo $numnew > num_run
105
106# If we are over nummax : stop
107if (( $numnew + 1 > $nummax )) ; then
108  exit 0
109else
110  \cp -f run0 exe_mars
111  ./exe_mars
112fi
Note: See TracBrowser for help on using the repository browser.