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

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

PEM:
Correction for the launching script due to r3403: the job scheduler detection was missing in the case of a new cycle.
JBC

  • Property svn:executable set to *
File size: 5.0 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# Set the dimension of the model (1 = "1D"; other values = "3D"):
26dim=3
27########################################################################
28
29
30dir=`pwd`
31machine=`hostname`
32user=`whoami`
33if [ ! -f "lib_launchPEM.sh" ]; then
34    echo "Error: file \"lib_launchPEM.sh\" does not exist in $dir!"
35    echo "It can be found in the PEM deftank."
36    exit 1
37fi
38
39source lib_launchPEM.sh
40
41if [ $# -eq 0 ]; then
42    # Starting from scratch
43    echo "The launching script is starting!"
44    echo "The output file is \"log_launchPEM.txt\"."
45    exec > log_launchPEM.txt 2>&1
46    echo "Beginning of the launching script for the PEM simulation."
47    date
48    checklaunch
49    initlaunch
50    cyclelaunch $dim $nPCM_ini
51
52else
53    # Starting a new cycle
54    if [ $1 = "new" ]; then
55        exec >> log_launchPEM.txt 2>&1
56        echo
57        echo "This is a new cycle for the PEM simulation."
58        date
59        if [ $dim -ne 1 ]; then
60            job_scheduler
61        fi
62        read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
63        cyclelaunch $dim $nPCM
64
65    # Starting a relaunch
66    elif [ $1 = "re" ]; then
67        if [ ! -f "info_PEM.txt" ]; then
68            echo "Error: file \"info_PEM.txt\" does not exist in $dir!"
69            echo "It is necessary to relaunch a PEM simulation."
70            errlaunch
71        fi
72        echo "The relaunch is initialized with a specific previous successful run."
73        while true; do
74            echo "Do you want to relaunch from a 'PCM' or 'PEM' run?"
75            read relaunch
76            if [ $relaunch = "PCM" ] || [ $relaunch = "PEM" ]; then
77                break
78            else
79                echo "Invalid input. Please enter 'PCM' or 'PEM'."
80            fi
81        done
82        read i_myear n_myear_old convert_years iPCM iPEM nPCM_old nPCM_ini_old < info_PEM.txt
83        while true; do
84            if [ $relaunch = "PCM" ]; then
85                echo "What is the number of the PCM run?"
86                echo "It should be between 1 and $(( $((iPCM - 1)) > 1 ? $((iPCM - 1)) : 1 ))."
87                read irelaunch
88                if [ 1 -le $irelaunch ] && [ $irelaunch -le $(( $((iPCM - 1)) > 1 ? $((iPCM - 1)) : 1 )) ]; then
89                    break
90                else
91                    echo "Invalid input. Please enter a valid PCM run number."
92                fi
93            else
94                echo "What is the number of the PEM run?"
95                echo "It should be between 1 and $(( $((iPEM - 1)) > 1 ? $((iPEM - 1)) : 1 ))."
96                read irelaunch
97                if [ 1 -le $irelaunch ] && [ $irelaunch -le $(( $((iPEM - 1)) > 1 ? $((iPEM - 1)) : 1 )) ]; then
98                    break
99                else
100                    echo "Invalid input. Please enter a valid PEM run number."
101                fi
102            fi
103        done
104        exec >> log_launchPEM.txt 2>&1
105        echo
106        echo "This is a relaunch for the PEM simulation from the run $relaunch$irelaunch."
107        date
108        checklaunch
109        convertyears
110        if [ $nPCM_ini -ne $nPCM_ini_old ]; then
111            echo "The number of initial PCM runs has been modified from $nPCM_ini_old to $nPCM_ini."
112        fi
113        if [ $nPCM -ne $nPCM_old ]; then
114            echo "The number of PCM runs between each PEM run has been modified from $nPCM_old to $nPCM."
115        fi
116        if [ $n_myear -ne $n_myear_old ]; then
117            echo "The number of initial PCM runs has been modified from $n_myear_old to $n_myear."
118        fi
119        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
120        if [ -f "kill_launchPEM.sh" ]; then
121            ./kill_launchPEM.sh
122        fi
123        if [ $relaunch = "PCM" ]; then
124            relaunchPCM $dim
125        else
126            relaunchPEM $dim
127        fi
128
129    # Continuing the PEM run
130    elif [ $1 = "cont" ]; then
131        exec >> log_launchPEM.txt 2>&1
132        echo
133        echo "This is a continuation of the previous PEM run."
134        date
135        submitPEM $dim
136
137    # Default case: error
138    else
139        echo "Error: given argument '$1' for the launching script is unknown!"
140        errlaunch
141    fi
142fi
Note: See TracBrowser for help on using the repository browser.