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

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

PEM:

  • Correction of the process to balance the H2O flux from and into the atmosphere accross reservoirs: (i) computation of H2O amount going from/in the atmosphere is corrected (missing dt and wrong condition); (ii) computation of the scaling factor is corrected because we need to balance all the icetable/adsorbed/surface ice flux but it affects only sublimating/condensing surface ice flux; (iii) process of balancing is modified to be applied to every flux by scaling instead of applying it only to positive or negative flux by trimming; (iv) balance is now fully processed by the tendency before evolving the ice. This is done through dedicated subroutines.
  • Correction of ice conversion between the layering algorithm and PEM ice variables (density factor was missing).
  • Addition of H2O flux balance and related stopping criterion for the layering algorithm.
  • Few updates for files in the deftank to be in line with the wiki Planeto pages.

JBC

  • Property svn:executable set to *
File size: 5.7 KB
RevLine 
[3349]1#!/bin/bash
2########################################################################
3#### Launching script for a chained simulation of PEM and PCM runs  ####
4########################################################################
5# This script can take an argument:
[3938]6#     1) None: to start a simulation from scratch;
7#     2) 're': to relaunch a simulation from a starting point (interactive prompt).
[3349]8########################################################################
[3579]9set -e
10trap 'echo -e "\033[31mError: an issue occurred in the script on line $LINENO! Please review the command and try again.\033[0m"' ERR
[3349]11
12
13########################################################################
14# Modify here the parameters for the simulation
15###############################################
[3861]16# Set the number of years to be simulated, either Martian or Earth years (> 0):
[3498]17n_mars_years=100.
18#n_earth_years=300.
[3349]19
[3495]20# Set the number of initial PCM runs (>= 2):
[3349]21nPCM_ini=3
22
[3495]23# Set the number of PCM runs between each PEM run (>= 2):
[3349]24nPCM=2
[3391]25
[3938]26# Set the counting method for the number of years to be simulated (0 = "only PEM runs count"; any other values = "PCM runs are taken into account"). The former option is the usual one:
[3556]27counting=0
28
[3861]29# Set the launching mode (0 = "processing scripts"; any other values = "submitting jobs"). The former option is usually used to process the script on a local machine while the latter is used to submit jobs on a supercomputer with SLURM or PBS/TORQUE:
[3495]30mode=1
[3349]31########################################################################
32
33
34dir=`pwd`
35machine=`hostname`
36user=`whoami`
37if [ ! -f "lib_launchPEM.sh" ]; then
38    echo "Error: file \"lib_launchPEM.sh\" does not exist in $dir!"
39    echo "It can be found in the PEM deftank."
40    exit 1
41fi
42
43source lib_launchPEM.sh
[3556]44export counting mode
[3349]45
[3355]46if [ $# -eq 0 ]; then
47    # Starting from scratch
[3349]48    echo "The launching script is starting!"
[3851]49    echo "The output file is \"launchPEM.log\"."
50    exec > launchPEM.log 2>&1
[3349]51    echo "Beginning of the launching script for the PEM simulation."
52    date
53    checklaunch
54    initlaunch
[3556]55    cyclelaunch $mode $counting $nPCM_ini
[3355]56
[3349]57else
[3355]58    # Starting a new cycle
59    if [ $1 = "new" ]; then
[3851]60        exec >> launchPEM.log 2>&1
[3355]61        echo
[3349]62        echo "This is a new cycle for the PEM simulation."
63        date
[3495]64        if [ $mode -ne 0 ]; then
[3419]65            job_scheduler
[3639]66            if command -v squeue &> /dev/null; then
67                unset SLURM_MEM_PER_CPU SLURM_MEM_PER_GPU SLURM_MEM_PER_NODE
68            fi
[3419]69        fi
[3349]70        read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
[3556]71        cyclelaunch $mode $counting $nPCM
[3355]72
73    # Starting a relaunch
74    elif [ $1 = "re" ]; then
75        if [ ! -f "info_PEM.txt" ]; then
76            echo "Error: file \"info_PEM.txt\" does not exist in $dir!"
77            echo "It is necessary to relaunch a PEM simulation."
78            errlaunch
79        fi
[3926]80        echo "The relaunch is initialized with a previous successful run to be specified."
[3355]81        while true; do
82            echo "Do you want to relaunch from a 'PCM' or 'PEM' run?"
83            read relaunch
84            if [ $relaunch = "PCM" ] || [ $relaunch = "PEM" ]; then
85                break
86            else
87                echo "Invalid input. Please enter 'PCM' or 'PEM'."
88            fi
89        done
[3386]90        read i_myear n_myear_old convert_years iPCM iPEM nPCM_old nPCM_ini_old < info_PEM.txt
[3355]91        while true; do
92            if [ $relaunch = "PCM" ]; then
93                echo "What is the number of the PCM run?"
[3417]94                echo "It should be between 1 and $(( $((iPCM - 1)) > 1 ? $((iPCM - 1)) : 1 ))."
[3355]95                read irelaunch
[3417]96                if [ 1 -le $irelaunch ] && [ $irelaunch -le $(( $((iPCM - 1)) > 1 ? $((iPCM - 1)) : 1 )) ]; then
[3355]97                    break
98                else
99                    echo "Invalid input. Please enter a valid PCM run number."
100                fi
101            else
102                echo "What is the number of the PEM run?"
[3417]103                echo "It should be between 1 and $(( $((iPEM - 1)) > 1 ? $((iPEM - 1)) : 1 ))."
[3355]104                read irelaunch
[3417]105                if [ 1 -le $irelaunch ] && [ $irelaunch -le $(( $((iPEM - 1)) > 1 ? $((iPEM - 1)) : 1 )) ]; then
[3355]106                    break
107                else
108                    echo "Invalid input. Please enter a valid PEM run number."
109                fi
110            fi
111        done
[3851]112        exec >> launchPEM.log 2>&1
[3355]113        echo
[3634]114        echo "This is a relaunch for the PEM simulation from the run \"$relaunch $irelaunch\"."
[3355]115        date
116        checklaunch
[3386]117        convertyears
118        if [ $nPCM_ini -ne $nPCM_ini_old ]; then
119            echo "The number of initial PCM runs has been modified from $nPCM_ini_old to $nPCM_ini."
120        fi
121        if [ $nPCM -ne $nPCM_old ]; then
122            echo "The number of PCM runs between each PEM run has been modified from $nPCM_old to $nPCM."
123        fi
[3537]124        if [ "$(echo "$n_myear != $n_myear_old" | bc)" -eq 1 ]; then
[3386]125            echo "The number of initial PCM runs has been modified from $n_myear_old to $n_myear."
126        fi
127        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
[3419]128        if [ -f "kill_launchPEM.sh" ]; then
129            ./kill_launchPEM.sh
130        fi
[3355]131        if [ $relaunch = "PCM" ]; then
[3556]132            relaunchPCM $mode $counting
[3355]133        else
[3556]134            relaunchPEM $mode $counting
[3355]135        fi
[3363]136
137    # Continuing the PEM run
138    elif [ $1 = "cont" ]; then
[3851]139        exec >> launchPEM.log 2>&1
[3363]140        echo
141        echo "This is a continuation of the previous PEM run."
142        date
[3495]143        submitPEM $mode
[3363]144
145    # Default case: error
[3349]146    else
147        echo "Error: given argument '$1' for the launching script is unknown!"
148        errlaunch
149    fi
150fi
Note: See TracBrowser for help on using the repository browser.