source: trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh @ 3387

Last change on this file since 3387 was 3386, checked in by jbclement, 19 months ago

PEM:

  • Correction for the initialization in 1D due to the change of 'ecritphy' into 'outputs_per_sol' in r3369.
  • Correction in the condition to check the normal end of a PCM/PEM run in "jobP*M.slurm" files.
  • Correction of files cleaning in the launching script.
  • Improvement of the launching script to take into account the modification of parameters for a relaunch.

JBC

  • Property svn:executable set to *
File size: 4.6 KB
Line 
1#!/bin/bash
2########################################################################
3#### Launching script for a chained simulation of PEM and PCM runs  ####
4########################################################################
5# This script can take an argument:
6#   - If there is no argument, then the script initiates a PEM simulation from scratch.
7#   - If the argument is 're', then the script relaunches an existing PEM simulation.
8#     It will ask for parameters to know the starting point that you want to.
9########################################################################
10
11
12########################################################################
13# Modify here the parameters for the simulation
14###############################################
15# Set the number of years to be simulated, either Martian or Earth years:
16n_mars_years=100
17#n_earth_years=300
18
19# Set the number of initial PCM runs:
20nPCM_ini=3
21
22# Set the number of PCM runs between each PEM run:
23nPCM=2
24########################################################################
25
26
27dir=`pwd`
28machine=`hostname`
29user=`whoami`
30if [ ! -f "lib_launchPEM.sh" ]; then
31    echo "Error: file \"lib_launchPEM.sh\" does not exist in $dir!"
32    echo "It can be found in the PEM deftank."
33    exit 1
34fi
35
36source lib_launchPEM.sh
37
38if [ $# -eq 0 ]; then
39    # Starting from scratch
40    echo "The launching script is starting!"
41    echo "The output file is \"log_launchPEM.txt\"."
42    exec > log_launchPEM.txt 2>&1
43    echo "Beginning of the launching script for the PEM simulation."
44    date
45    checklaunch
46    initlaunch
47    cyclelaunch $nPCM_ini
48
49else
50    # Starting a new cycle
51    if [ $1 = "new" ]; then
52        exec >> log_launchPEM.txt 2>&1
53        echo
54        echo "This is a new cycle for the PEM simulation."
55        date
56        read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
57        cyclelaunch $nPCM
58
59    # Starting a relaunch
60    elif [ $1 = "re" ]; then
61        if [ ! -f "info_PEM.txt" ]; then
62            echo "Error: file \"info_PEM.txt\" does not exist in $dir!"
63            echo "It is necessary to relaunch a PEM simulation."
64            errlaunch
65        fi
66        echo "The relaunch is initialized with a specific previous successful run."
67        while true; do
68            echo "Do you want to relaunch from a 'PCM' or 'PEM' run?"
69            read relaunch
70            if [ $relaunch = "PCM" ] || [ $relaunch = "PEM" ]; then
71                break
72            else
73                echo "Invalid input. Please enter 'PCM' or 'PEM'."
74            fi
75        done
76        read i_myear n_myear_old convert_years iPCM iPEM nPCM_old nPCM_ini_old < info_PEM.txt
77        while true; do
78            if [ $relaunch = "PCM" ]; then
79                echo "What is the number of the PCM run?"
80                echo "It should be between 1 and $((iPCM - 1))."
81                read irelaunch
82                if [ 0 -lt $irelaunch ] && [ $irelaunch -lt $iPCM ]; then
83                    break
84                else
85                    echo "Invalid input. Please enter a valid PCM run number."
86                fi
87            else
88                echo "What is the number of the PEM run?"
89                echo "It should be between 1 and $((iPEM - 1))."
90                read irelaunch
91                if [ 0 -lt $irelaunch ] && [ $irelaunch -lt $iPEM ]; then
92                    break
93                else
94                    echo "Invalid input. Please enter a valid PEM run number."
95                fi
96            fi
97        done
98        exec >> log_launchPEM.txt 2>&1
99        echo
100        echo "This is a relaunch for the PEM simulation from the run $relaunch$irelaunch."
101        date
102        checklaunch
103        convertyears
104        if [ $nPCM_ini -ne $nPCM_ini_old ]; then
105            echo "The number of initial PCM runs has been modified from $nPCM_ini_old to $nPCM_ini."
106        fi
107        if [ $nPCM -ne $nPCM_old ]; then
108            echo "The number of PCM runs between each PEM run has been modified from $nPCM_old to $nPCM."
109        fi
110        if [ $n_myear -ne $n_myear_old ]; then
111            echo "The number of initial PCM runs has been modified from $n_myear_old to $n_myear."
112        fi
113        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
114        if [ $relaunch = "PCM" ]; then
115            relaunchPCM
116        else
117            relaunchPEM
118        fi
119
120    # Continuing the PEM run
121    elif [ $1 = "cont" ]; then
122        exec >> log_launchPEM.txt 2>&1
123        echo
124        echo "This is a continuation of the previous PEM run."
125        date
126        submitPEM
127
128    # Default case: error
129    else
130        echo "Error: given argument '$1' for the launching script is unknown!"
131        errlaunch
132    fi
133fi
Note: See TracBrowser for help on using the repository browser.