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

Last change on this file since 3402 was 3391, checked in by jbclement, 18 months ago

PEM:
Addition of the possiblity to launch the 1D model in the launching script + correction of small errors.
JBC

  • Property svn:executable set to *
File size: 4.7 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        read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
60        cyclelaunch $dim $nPCM
61
62    # Starting a relaunch
63    elif [ $1 = "re" ]; then
64        if [ ! -f "info_PEM.txt" ]; then
65            echo "Error: file \"info_PEM.txt\" does not exist in $dir!"
66            echo "It is necessary to relaunch a PEM simulation."
67            errlaunch
68        fi
69        echo "The relaunch is initialized with a specific previous successful run."
70        while true; do
71            echo "Do you want to relaunch from a 'PCM' or 'PEM' run?"
72            read relaunch
73            if [ $relaunch = "PCM" ] || [ $relaunch = "PEM" ]; then
74                break
75            else
76                echo "Invalid input. Please enter 'PCM' or 'PEM'."
77            fi
78        done
79        read i_myear n_myear_old convert_years iPCM iPEM nPCM_old nPCM_ini_old < info_PEM.txt
80        while true; do
81            if [ $relaunch = "PCM" ]; then
82                echo "What is the number of the PCM run?"
83                echo "It should be between 1 and $((iPCM - 1))."
84                read irelaunch
85                if [ 0 -lt $irelaunch ] && [ $irelaunch -lt $iPCM ]; then
86                    break
87                else
88                    echo "Invalid input. Please enter a valid PCM run number."
89                fi
90            else
91                echo "What is the number of the PEM run?"
92                echo "It should be between 1 and $((iPEM - 1))."
93                read irelaunch
94                if [ 0 -lt $irelaunch ] && [ $irelaunch -lt $iPEM ]; then
95                    break
96                else
97                    echo "Invalid input. Please enter a valid PEM run number."
98                fi
99            fi
100        done
101        exec >> log_launchPEM.txt 2>&1
102        echo
103        echo "This is a relaunch for the PEM simulation from the run $relaunch$irelaunch."
104        date
105        checklaunch
106        convertyears
107        if [ $nPCM_ini -ne $nPCM_ini_old ]; then
108            echo "The number of initial PCM runs has been modified from $nPCM_ini_old to $nPCM_ini."
109        fi
110        if [ $nPCM -ne $nPCM_old ]; then
111            echo "The number of PCM runs between each PEM run has been modified from $nPCM_old to $nPCM."
112        fi
113        if [ $n_myear -ne $n_myear_old ]; then
114            echo "The number of initial PCM runs has been modified from $n_myear_old to $n_myear."
115        fi
116        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
117        if [ $relaunch = "PCM" ]; then
118            relaunchPCM $dim
119        else
120            relaunchPEM $dim
121        fi
122
123    # Continuing the PEM run
124    elif [ $1 = "cont" ]; then
125        exec >> log_launchPEM.txt 2>&1
126        echo
127        echo "This is a continuation of the previous PEM run."
128        date
129        submitPEM $dim
130
131    # Default case: error
132    else
133        echo "Error: given argument '$1' for the launching script is unknown!"
134        errlaunch
135    fi
136fi
Note: See TracBrowser for help on using the repository browser.