Ignore:
Timestamp:
Jul 2, 2024, 6:05:01 PM (5 months ago)
Author:
jbclement
Message:

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

Location:
trunk/LMDZ.COMMON/libf/evolution
Files:
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/changelog.txt

    r3389 r3391  
    392392== 25/06/2024 == JBC
    393393Correction to r3387 for the time limit stopping criterion.
     394
     395== 02/07/2024 == JBC
     396Addition of the possiblity to launch the 1D model in the launching script + correction of small errors.
  • trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh

    r3386 r3391  
    2222# Set the number of PCM runs between each PEM run:
    2323nPCM=2
     24
     25# Set the dimension of the model (1 = "1D"; other values = "3D"):
     26dim=3
    2427########################################################################
    2528
     
    4548    checklaunch
    4649    initlaunch
    47     cyclelaunch $nPCM_ini
     50    cyclelaunch $dim $nPCM_ini
    4851
    4952else
     
    5558        date
    5659        read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
    57         cyclelaunch $nPCM
     60        cyclelaunch $dim $nPCM
    5861
    5962    # Starting a relaunch
     
    113116        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
    114117        if [ $relaunch = "PCM" ]; then
    115             relaunchPCM
     118            relaunchPCM $dim
    116119        else
    117             relaunchPEM
     120            relaunchPEM $dim
    118121        fi
    119122
     
    124127        echo "This is a continuation of the previous PEM run."
    125128        date
    126         submitPEM
     129        submitPEM $dim
    127130
    128131    # Default case: error
  • trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh

    r3387 r3391  
    2626# To check if SLURM is the job scheduler
    2727function is_slurm() {
    28     if [ ! -x $(command -v squeue) ]; then
     28    if ! command -v squeue &> /dev/null; then
    2929        echo "Error: the job scheduler is not SLURM on $machine!"
    3030        echo "You need to adapt the script to your case."
     
    3939    LC_NUMERIC=en_US.UTF-8
    4040
    41     is_slurm
     41    if [ $dim -ne 1 ]; then # 3D model works only with SLURM for now (because of time limit)
     42        islurm
     43    fi
    4244    if [ -v n_mars_years ] && [ ! -z "$n_mars_years" ]; then
    4345        if [ $n_mars_years -lt 1 ]; then
     
    6264        errlaunch
    6365    fi
    64     if [ ! -f "jobPCM.slurm" ]; then
    65         echo "Error: file \"jobPCM.slurm\" does not exist in $dir!"
    66         errlaunch
    67     fi
    68     if [ ! -f "jobPEM.slurm" ]; then
    69         echo "Error: file \"$jobPEM.slurm\" does not exist in $dir!"
     66    if [ ! -f "PCMrun.job" ]; then
     67        echo "Error: file \"PCMrun.job\" does not exist in $dir!"
     68        errlaunch
     69    fi
     70    if [ ! -f "PEMrun.job" ]; then
     71        echo "Error: file \"PEMrun.job\" does not exist in $dir!"
    7072        errlaunch
    7173    fi
     
    142144
    143145# To submit the PCM runs
    144 # arg1: number of PCM runs to launch
    145 # arg2: local number of the PCM run from which to start (optional)
     146# arg1: model dimension
     147# arg2: number of PCM runs to launch
     148# arg3: local number of the PCM run from which to start (optional)
    146149submitPCM() {
    147     find . -type f -name "jobPCM*.slurm" ! -name "jobPCM.slurm" -delete
     150    find . -type f -name "PCMrun*.job" ! -name "PCMrun.job" -delete
    148151    ii=1
    149     if [ ! -z $2 ]; then
    150         ii=$2
     152    if [ ! -z $3 ]; then
     153        ii=$3
    151154    fi
    152155    if [ $i_myear -lt $n_myear ]; then
    153         echo "Run PCM $iPCM: call $ii/$1..."
    154         cp jobPCM.slurm jobPCM${iPCM}.slurm
    155         sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" jobPCM${iPCM}.slurm
    156         sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc -l)/" jobPCM${iPCM}.slurm
    157         jobID=$(sbatch --parsable jobPCM${iPCM}.slurm)
    158         # Create a file to cancel the dependent jobs of the cycle
    159         echo "#!/bin/bash" > kill_launchPEM.sh
    160         chmod +x kill_launchPEM.sh
    161         echo "scancel" $jobID >> kill_launchPEM.sh
     156        echo "Run PCM $iPCM: call $ii/$2..."
     157        if [ $1 -eq 1 ]; then # 1D model
     158            sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc -l)/" PCMrun.job
     159            ./PCMrun.job
     160        else # 3D model
     161            cp PCMrun.job PCMrun${iPCM}.job
     162            sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" PCMrun${iPCM}.job
     163            sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc -l)/" PCMrun${iPCM}.job
     164            jobID=$(sbatch --parsable PCMrun${iPCM}.job)
     165            # Create a file to cancel the dependent jobs of the cycle
     166            echo "#!/bin/bash" > kill_launchPEM.sh
     167            chmod +x kill_launchPEM.sh
     168            echo "scancel" $jobID >> kill_launchPEM.sh
     169        fi
    162170        ((iPCM++))
    163171        ((i_myear++))
     
    166174        endlaunch
    167175    fi
    168     for ((i = $ii; i <= $1; i++)); do
     176    for ((i = $ii; i <= $2; i++)); do
    169177        if [ $i_myear -lt $n_myear ]; then
    170             echo "Run PCM $iPCM: call $i/$1..."
    171             cp jobPCM.slurm jobPCM${iPCM}.slurm
    172             sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" jobPCM${iPCM}.slurm
    173             sed -i "s/^k=[0-9]\+$/k=$(echo "$i + 2 - $nPCM_ini" | bc -l)/" jobPCM${iPCM}.slurm
    174             jobID=$(sbatch --parsable --dependency=afterok:${jobID} jobPCM${iPCM}.slurm)
    175             echo "scancel" $jobID >> kill_launchPEM.sh
     178            echo "Run PCM $iPCM: call $i/$2..."
     179            if [ $1 -eq 1 ]; then # 1D model
     180                sed -i "s/^k=[0-9]\+$/k=$(echo "$i + 2 - $nPCM_ini" | bc -l)/" PCMrun.job
     181                ./PCMrun.job
     182            else # 3D model
     183                cp PCMrun.job PCMrun${iPCM}.job
     184                sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPCM}/" PCMrun${iPCM}.job
     185                sed -i "s/^k=[0-9]\+$/k=$(echo "$i + 2 - $nPCM_ini" | bc -l)/" PCMrun${iPCM}.job
     186                jobID=$(sbatch --parsable --dependency=afterok:${jobID} PCMrun${iPCM}.job)
     187                echo "scancel" $jobID >> kill_launchPEM.sh
     188            fi
    176189            ((iPCM++))
    177190            ((i_myear++))
     
    183196
    184197# To submit the PEM run
     198# arg1: model dimension
    185199submitPEM() {
    186200    if [ $i_myear -lt $n_myear ]; then
    187201        echo "Run PEM $iPEM"
    188         sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" jobPEM.slurm
    189         jobID=$(sbatch --parsable jobPEM.slurm)
    190         # Create a file to cancel the dependent jobs of the cycle
    191         echo "#!/bin/bash" > kill_launchPEM.sh
    192         chmod +x kill_launchPEM.sh
    193         echo "scancel" $jobID >> kill_launchPEM.sh
     202        if [ $1 -eq 1 ]; then # 1D model
     203            ./PEMrun.job
     204        else # 3D model
     205            sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" PEMrun.job
     206            jobID=$(sbatch --parsable PEMrun.job)
     207            # Create a file to cancel the dependent jobs of the cycle
     208            echo "#!/bin/bash" > kill_launchPEM.sh
     209            chmod +x kill_launchPEM.sh
     210            echo "scancel" $jobID >> kill_launchPEM.sh
     211        fi
    194212    else
    195213        endlaunch
     
    198216
    199217# To make one cycle of PCM and PEM runs
    200 # arg1: number of PCM runs to launch
    201 # arg2: local number of the PCM run from which to start (optional)
     218# arg1: model dimension
     219# arg2: number of PCM runs to launch
     220# arg3: local number of the PCM run from which to start (optional)
    202221cyclelaunch() {
    203222    # PCM runs
    204     submitPCM $1 $2
     223    submitPCM $1 $2 $3
    205224
    206225    # PEM run
    207226    if [ $i_myear -lt $n_myear ]; then
    208227        echo "Run PEM $iPEM"
    209         sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" jobPEM.slurm
    210         jobID=$(sbatch --parsable --dependency=afterok:${jobID} jobPEM.slurm)
    211         echo "scancel" $jobID >> kill_launchPEM.sh
     228        if [ $1 -eq 1 ]; then # 1D model
     229            ./PEMrun.job
     230        else # 3D model
     231            sed -i -E "s/(#SBATCH --job-name=[^0-9]*[0-9]*[^0-9]*)[0-9]+$/\1${iPEM}/" PEMrun.job
     232            jobID=$(sbatch --parsable --dependency=afterok:${jobID} PEMrun.job)
     233            echo "scancel" $jobID >> kill_launchPEM.sh
     234        fi
    212235    else
    213236        endlaunch
     
    241264
    242265# To relaunch from PCM run
     266# arg1: model dimension
    243267relaunchPCM() {
    244268    iPCM=$(($irelaunch + 1))
     
    269293        if [ $irelaunch -eq $(($nPCM_ini - 1)) ]; then
    270294            cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc
    271             cyclelaunch $nPCM_ini $irelaunch
     295            cyclelaunch $1 $nPCM_ini $iPCM
    272296        elif [ $irelaunch -eq $nPCM_ini ]; then
    273297            cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
    274298            cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc
    275             submitPEM # The next job is a PEM run
     299            submitPEM $1 # The next job is a PEM run
    276300        else
    277             cyclelaunch $nPCM_ini $iPCM
     301            cyclelaunch $1 $nPCM_ini $iPCM
    278302        fi
    279303    else
     
    292316            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
    293317            cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc
    294             cyclelaunch $nPCM $il
     318            cyclelaunch $1 $nPCM $il
    295319        elif [ $il -eq 0 ]; then
    296320            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $nPCM))
     
    298322            cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
    299323            cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc
    300             submitPEM # The next job is a PEM run
     324            submitPEM $1 # The next job is a PEM run
    301325        else
    302326            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $il))
    303327            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
    304             cyclelaunch $nPCM $il
     328            cyclelaunch $1 $nPCM $il
    305329        fi
    306330    fi
     
    308332
    309333# To relaunch from PEM run
     334# arg1: model dimension
    310335relaunchPEM() {
    311336    iPEM=$irelaunch
     
    332357        cp starts/restart1D_postPEM${irelaunch}.txt start1D.txt
    333358    fi
    334     cyclelaunch $nPCM
    335 }
     359    cyclelaunch $1 $nPCM
     360}
Note: See TracChangeset for help on using the changeset viewer.