Changeset 4072 for trunk/LMDZ.COMMON/libf/evolution/deftank/pem_workflow.sh
- Timestamp:
- Feb 16, 2026, 11:41:37 AM (2 weeks ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/deftank/pem_workflow.sh
r4071 r4072 1 1 #!/bin/bash 2 2 ######################################################################## 3 #### Launching script for a chained simulation of PEM and PCM runs####3 #### Workflow script for a chained simulation of PEM and PCM runs ##### 4 4 ######################################################################## 5 5 # This script can take an argument: 6 6 # 1) None: to start a simulation from scratch; 7 # 2) 're': to re launcha simulation from a starting point (interactive prompt).7 # 2) 're': to resume a simulation from a starting point (interactive prompt). 8 8 ######################################################################## 9 9 set -e … … 19 19 20 20 # Set the number of initial PCM years (>= 2): 21 n PCM_ini=321 n_pcm_runs_ini=3 22 22 23 23 # Set the number of PCM years between each PEM run (>= 2): 24 n PCM=224 n_pcm_runs=2 25 25 26 # Set the launchingmode (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=126 # 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: 27 exec_mode=1 28 28 ######################################################################## 29 29 … … 32 32 machine=`hostname` 33 33 user=`whoami` 34 if [ ! -f " lib_launchPEM.sh" ]; then35 echo "Error: file \" lib_launchPEM.sh\" does not exist in $dir!"34 if [ ! -f "pem_workflow_lib.sh" ]; then 35 echo "Error: file \"pem_workflow_lib.sh\" does not exist in $dir!" 36 36 echo "It can be found in the PEM deftank." 37 37 exit 1 38 38 fi 39 39 40 source lib_launchPEM.sh41 export mode40 source pem_workflow_lib.sh 41 export exec_mode 42 42 43 43 if [ $# -eq 0 ]; then 44 44 # Starting from scratch 45 echo "The launching scriptis starting!"46 echo "The output file is \" launchPEM.log\"."47 exec > launchPEM.log 2>&148 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." 49 49 date 50 check launch51 ini tlaunch52 cyclelaunch $mode $nPCM_ini50 check_workflow 51 ini_workflow 52 submit_cycle $exec_mode $n_pcm_runs_ini 53 53 54 54 else 55 55 # Starting a new cycle 56 56 if [ $1 = "new" ]; then 57 exec >> launchPEM.log 2>&157 exec >> pem_workflow.log 2>&1 58 58 echo 59 echo "This is a new cycle for the PEM simulation."59 echo "This is a new cycle of the PEM worflow." 60 60 date 61 if [ $ mode -ne 0 ]; then62 job_scheduler61 if [ $exec_mode -ne 0 ]; then 62 detect_scheduler 63 63 if command -v squeue &> /dev/null; then 64 64 unset SLURM_MEM_PER_CPU SLURM_MEM_PER_GPU SLURM_MEM_PER_NODE 65 65 fi 66 66 fi 67 read i_year n_year r_plnt2earth_yr iPCM iPEM nPCM nPCM_ini < launchPEM.info68 cyclelaunch $mode $nPCM67 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 69 69 70 # Starting a re launch70 # Starting a resume 71 71 elif [ $1 = "re" ]; then 72 if [ ! -f " launchPEM.info" ]; then73 echo "Error: file \" launchPEM.info\" does not exist in $dir!"74 echo "It is necessary to re launch a PEM simulation."75 errlaunch72 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 76 76 fi 77 echo "The re launchis initialized with a previous successful run to be specified."77 echo "The resumption is initialized with a previous successful run to be specified." 78 78 while true; do 79 echo "Do you want to re launchfrom a 'PCM' or 'PEM' run?"80 read r elaunch81 if [ $r elaunch = "PCM" ] || [ $relaunch= "PEM" ]; then79 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 82 82 break 83 83 else … … 85 85 fi 86 86 done 87 read i_year n_year_old r_plnt2earth_yr iPCM iPEM nPCM_old nPCM_ini_old < launchPEM.info87 read n_yr_sim n_year_old r_plnt2earth_yr i_pcm_run i_pem_run nPCM_old nPCM_ini_old < pem_workflow.sts 88 88 while true; do 89 if [ $r elaunch= "PCM" ]; then89 if [ $run_resume = "PCM" ]; then 90 90 echo "What is the number of the PCM run?" 91 echo "It should be between 1 and $(( $((i PCM - 1)) > 1 ? $((iPCM- 1)) : 1 ))."92 read i relaunch93 if [ 1 -le $i relaunch ] && [ $irelaunch -le $(( $((iPCM - 1)) > 1 ? $((iPCM- 1)) : 1 )) ]; then91 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 94 94 break 95 95 else … … 98 98 else 99 99 echo "What is the number of the PEM run?" 100 echo "It should be between 1 and $(( $((i PEM - 1)) > 1 ? $((iPEM- 1)) : 1 ))."101 read i relaunch102 if [ 1 -le $i relaunch ] && [ $irelaunch -le $(( $((iPEM - 1)) > 1 ? $((iPEM- 1)) : 1 )) ]; then100 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 103 103 break 104 104 else … … 107 107 fi 108 108 done 109 exec >> launchPEM.log 2>&1109 exec >> pem_workflow.log 2>&1 110 110 echo 111 echo "This is a re launch 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\"." 112 112 date 113 check launch114 convert years115 if [ $n PCM_ini -ne $nPCM_ini_old ]; then116 echo "The number of initial PCM years has been modified from $nPCM_ini_old to $n PCM_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." 117 117 fi 118 if [ $n PCM-ne $nPCM_old ]; then119 echo "The number of PCM years between each PEM run has been modified from $nPCM_old to $n PCM."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." 120 120 fi 121 if [ "$(echo "$n _year!= $n_year_old" | bc)" -eq 1 ]; then122 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." 123 123 fi 124 sed -i "1s/.*/$ i_year $n_year $r_plnt2earth_yr $iPCM $iPEM $nPCM $nPCM_ini/" launchPEM.info125 if [ -f "kill_ launchPEM.sh" ]; then126 ./kill_ launchPEM.sh124 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 127 127 fi 128 if [ $r elaunch= "PCM" ]; then129 re launchPCM $mode128 if [ $run_resume = "PCM" ]; then 129 resume_from_pcm_run $exec_mode 130 130 else 131 re launchPEM $mode131 resume_from_pem_run $exec_mode 132 132 fi 133 133 134 134 # Continuing the PEM run 135 135 elif [ $1 = "cont" ]; then 136 exec >> launchPEM.log 2>&1136 exec >> pem_workflow.log 2>&1 137 137 echo 138 138 echo "This is a continuation of the previous PEM run." 139 139 date 140 submit PEM $mode140 submit_pem_phase $exec_mode 141 141 142 142 # Default case: error 143 143 else 144 echo "Error: given argument '$1' for the launchingscript is unknown!"145 errlaunch144 echo "Error: given argument '$1' for the PEM workflow script is unknown!" 145 abort_workflow 146 146 fi 147 147 fi
Note: See TracChangeset
for help on using the changeset viewer.
