Ignore:
Timestamp:
Feb 16, 2026, 11:41:37 AM (2 weeks ago)
Author:
jbclement
Message:

PEM:
Modify the PEM semantics to standardize file/functions/variable names and avoid ambiguity: workflow = repetion of cycles; cycle = PCM phase + PEM phase; PCM phase = 2+ PCM runs of 1 year each, PEM phase = 1 PEM run of 'x' years.
JBC

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/deftank/pem_workflow.sh

    r4071 r4072  
    11#!/bin/bash
    22########################################################################
    3 #### Launching script for a chained simulation of PEM and PCM runs  ####
     3#### Workflow script for a chained simulation of PEM and PCM runs  #####
    44########################################################################
    55# This script can take an argument:
    66#     1) None: to start a simulation from scratch;
    7 #     2) 're': to relaunch a simulation from a starting point (interactive prompt).
     7#     2) 're': to resume a simulation from a starting point (interactive prompt).
    88########################################################################
    99set -e
     
    1919
    2020# Set the number of initial PCM years (>= 2):
    21 nPCM_ini=3
     21n_pcm_runs_ini=3
    2222
    2323# Set the number of PCM years between each PEM run (>= 2):
    24 nPCM=2
     24n_pcm_runs=2
    2525
    26 # 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:
    27 mode=1
     26# Set the execution 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:
     27exec_mode=1
    2828########################################################################
    2929
     
    3232machine=`hostname`
    3333user=`whoami`
    34 if [ ! -f "lib_launchPEM.sh" ]; then
    35     echo "Error: file \"lib_launchPEM.sh\" does not exist in $dir!"
     34if [ ! -f "pem_workflow_lib.sh" ]; then
     35    echo "Error: file \"pem_workflow_lib.sh\" does not exist in $dir!"
    3636    echo "It can be found in the PEM deftank."
    3737    exit 1
    3838fi
    3939
    40 source lib_launchPEM.sh
    41 export mode
     40source pem_workflow_lib.sh
     41export exec_mode
    4242
    4343if [ $# -eq 0 ]; then
    4444    # Starting from scratch
    45     echo "The launching script is starting!"
    46     echo "The output file is \"launchPEM.log\"."
    47     exec > launchPEM.log 2>&1
    48     echo "Beginning of the launching script for the PEM simulation."
     45    echo "The PEM workflow is starting!"
     46    echo "The output file is \"pem_workflow.log\"."
     47    exec > pem_workflow.log 2>&1
     48    echo "Beginning of log file for the PEM workflow."
    4949    date
    50     checklaunch
    51     initlaunch
    52     cyclelaunch $mode $nPCM_ini
     50    check_workflow
     51    ini_workflow
     52    submit_cycle $exec_mode $n_pcm_runs_ini
    5353
    5454else
    5555    # Starting a new cycle
    5656    if [ $1 = "new" ]; then
    57         exec >> launchPEM.log 2>&1
     57        exec >> pem_workflow.log 2>&1
    5858        echo
    59         echo "This is a new cycle for the PEM simulation."
     59        echo "This is a new cycle of the PEM worflow."
    6060        date
    61         if [ $mode -ne 0 ]; then
    62             job_scheduler
     61        if [ $exec_mode -ne 0 ]; then
     62            detect_scheduler
    6363            if command -v squeue &> /dev/null; then
    6464                unset SLURM_MEM_PER_CPU SLURM_MEM_PER_GPU SLURM_MEM_PER_NODE
    6565            fi
    6666        fi
    67         read i_year n_year r_plnt2earth_yr iPCM iPEM nPCM nPCM_ini < launchPEM.info
    68         cyclelaunch $mode $nPCM
     67        read n_yr_sim ntot_yr_sim r_plnt2earth_yr i_pcm_run i_pem_run n_pcm_runs n_pcm_runs_ini < pem_workflow.sts
     68        submit_cycle $exec_mode $n_pcm_runs
    6969
    70     # Starting a relaunch
     70    # Starting a resume
    7171    elif [ $1 = "re" ]; then
    72         if [ ! -f "launchPEM.info" ]; then
    73             echo "Error: file \"launchPEM.info\" does not exist in $dir!"
    74             echo "It is necessary to relaunch a PEM simulation."
    75             errlaunch
     72        if [ ! -f "pem_workflow.sts" ]; then
     73            echo "Error: file \"pem_workflow.sts\" does not exist in $dir!"
     74            echo "It is necessary to resume the PEM workflow."
     75            abort_workflow
    7676        fi
    77         echo "The relaunch is initialized with a previous successful run to be specified."
     77        echo "The resumption is initialized with a previous successful run to be specified."
    7878        while true; do
    79             echo "Do you want to relaunch from a 'PCM' or 'PEM' run?"
    80             read relaunch
    81             if [ $relaunch = "PCM" ] || [ $relaunch = "PEM" ]; then
     79            echo "Do you want to resume from a 'PCM' or 'PEM' run?"
     80            read run_resume
     81            if [ $run_resume = "PCM" ] || [ $run_resume = "PEM" ]; then
    8282                break
    8383            else
     
    8585            fi
    8686        done
    87         read i_year n_year_old r_plnt2earth_yr iPCM iPEM nPCM_old nPCM_ini_old < launchPEM.info
     87        read n_yr_sim n_year_old r_plnt2earth_yr i_pcm_run i_pem_run nPCM_old nPCM_ini_old < pem_workflow.sts
    8888        while true; do
    89             if [ $relaunch = "PCM" ]; then
     89            if [ $run_resume = "PCM" ]; then
    9090                echo "What is the number of the PCM run?"
    91                 echo "It should be between 1 and $(( $((iPCM - 1)) > 1 ? $((iPCM - 1)) : 1 ))."
    92                 read irelaunch
    93                 if [ 1 -le $irelaunch ] && [ $irelaunch -le $(( $((iPCM - 1)) > 1 ? $((iPCM - 1)) : 1 )) ]; then
     91                echo "It should be between 1 and $(( $((i_pcm_run - 1)) > 1 ? $((i_pcm_run - 1)) : 1 ))."
     92                read i_resume
     93                if [ 1 -le $i_resume ] && [ $i_resume -le $(( $((i_pcm_run - 1)) > 1 ? $((i_pcm_run - 1)) : 1 )) ]; then
    9494                    break
    9595                else
     
    9898            else
    9999                echo "What is the number of the PEM run?"
    100                 echo "It should be between 1 and $(( $((iPEM - 1)) > 1 ? $((iPEM - 1)) : 1 ))."
    101                 read irelaunch
    102                 if [ 1 -le $irelaunch ] && [ $irelaunch -le $(( $((iPEM - 1)) > 1 ? $((iPEM - 1)) : 1 )) ]; then
     100                echo "It should be between 1 and $(( $((i_pem_run - 1)) > 1 ? $((i_pem_run - 1)) : 1 ))."
     101                read i_resume
     102                if [ 1 -le $i_resume ] && [ $i_resume -le $(( $((i_pem_run - 1)) > 1 ? $((i_pem_run - 1)) : 1 )) ]; then
    103103                    break
    104104                else
     
    107107            fi
    108108        done
    109         exec >> launchPEM.log 2>&1
     109        exec >> pem_workflow.log 2>&1
    110110        echo
    111         echo "This is a relaunch for the PEM simulation from the run \"$relaunch $irelaunch\"."
     111        echo "This is a resumption for the PEM workflow from the run \"$run_resume $i_resume\"."
    112112        date
    113         checklaunch
    114         convertyears
    115         if [ $nPCM_ini -ne $nPCM_ini_old ]; then
    116             echo "The number of initial PCM years has been modified from $nPCM_ini_old to $nPCM_ini."
     113        check_workflow
     114        convert_earth2plnt_years
     115        if [ $n_pcm_runs_ini -ne $nPCM_ini_old ]; then
     116            echo "The number of initial PCM years has been modified from $nPCM_ini_old to $n_pcm_runs_ini."
    117117        fi
    118         if [ $nPCM -ne $nPCM_old ]; then
    119             echo "The number of PCM years between each PEM run has been modified from $nPCM_old to $nPCM."
     118        if [ $n_pcm_runs -ne $nPCM_old ]; then
     119            echo "The number of PCM years between each PEM run has been modified from $nPCM_old to $n_pcm_runs."
    120120        fi
    121         if [ "$(echo "$n_year != $n_year_old" | bc)" -eq 1 ]; then
    122             echo "The number of initial PCM years has been modified from $n_year_old to $n_year."
     121        if [ "$(echo "$ntot_yr_sim != $n_year_old" | bc)" -eq 1 ]; then
     122            echo "The number of initial PCM years has been modified from $n_year_old to $ntot_yr_sim."
    123123        fi
    124         sed -i "1s/.*/$i_year $n_year $r_plnt2earth_yr $iPCM $iPEM $nPCM $nPCM_ini/" launchPEM.info
    125         if [ -f "kill_launchPEM.sh" ]; then
    126             ./kill_launchPEM.sh
     124        sed -i "1s/.*/$n_yr_sim $ntot_yr_sim $r_plnt2earth_yr $i_pcm_run $i_pem_run $n_pcm_runs $n_pcm_runs_ini/" pem_workflow.sts
     125        if [ -f "kill_pem_workflow.sh" ]; then
     126            ./kill_pem_workflow.sh
    127127        fi
    128         if [ $relaunch = "PCM" ]; then
    129             relaunchPCM $mode
     128        if [ $run_resume = "PCM" ]; then
     129            resume_from_pcm_run $exec_mode
    130130        else
    131             relaunchPEM $mode
     131            resume_from_pem_run $exec_mode
    132132        fi
    133133
    134134    # Continuing the PEM run
    135135    elif [ $1 = "cont" ]; then
    136         exec >> launchPEM.log 2>&1
     136        exec >> pem_workflow.log 2>&1
    137137        echo
    138138        echo "This is a continuation of the previous PEM run."
    139139        date
    140         submitPEM $mode
     140        submit_pem_phase $exec_mode
    141141
    142142    # Default case: error
    143143    else
    144         echo "Error: given argument '$1' for the launching script is unknown!"
    145         errlaunch
     144        echo "Error: given argument '$1' for the PEM workflow script is unknown!"
     145        abort_workflow
    146146    fi
    147147fi
Note: See TracChangeset for help on using the changeset viewer.