Changeset 3391 for trunk/LMDZ.COMMON/libf/evolution
- Timestamp:
- Jul 2, 2024, 6:05:01 PM (6 months ago)
- Location:
- trunk/LMDZ.COMMON/libf/evolution
- Files:
-
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/changelog.txt
r3389 r3391 392 392 == 25/06/2024 == JBC 393 393 Correction to r3387 for the time limit stopping criterion. 394 395 == 02/07/2024 == JBC 396 Addition 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 22 22 # Set the number of PCM runs between each PEM run: 23 23 nPCM=2 24 25 # Set the dimension of the model (1 = "1D"; other values = "3D"): 26 dim=3 24 27 ######################################################################## 25 28 … … 45 48 checklaunch 46 49 initlaunch 47 cyclelaunch $ nPCM_ini50 cyclelaunch $dim $nPCM_ini 48 51 49 52 else … … 55 58 date 56 59 read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt 57 cyclelaunch $ nPCM60 cyclelaunch $dim $nPCM 58 61 59 62 # Starting a relaunch … … 113 116 sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt 114 117 if [ $relaunch = "PCM" ]; then 115 relaunchPCM 118 relaunchPCM $dim 116 119 else 117 relaunchPEM 120 relaunchPEM $dim 118 121 fi 119 122 … … 124 127 echo "This is a continuation of the previous PEM run." 125 128 date 126 submitPEM 129 submitPEM $dim 127 130 128 131 # Default case: error -
trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh
r3387 r3391 26 26 # To check if SLURM is the job scheduler 27 27 function is_slurm() { 28 if [ ! -x $(command -v squeue) ]; then28 if ! command -v squeue &> /dev/null; then 29 29 echo "Error: the job scheduler is not SLURM on $machine!" 30 30 echo "You need to adapt the script to your case." … … 39 39 LC_NUMERIC=en_US.UTF-8 40 40 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 42 44 if [ -v n_mars_years ] && [ ! -z "$n_mars_years" ]; then 43 45 if [ $n_mars_years -lt 1 ]; then … … 62 64 errlaunch 63 65 fi 64 if [ ! -f " jobPCM.slurm" ]; then65 echo "Error: file \" jobPCM.slurm\" does not exist in $dir!"66 errlaunch 67 fi 68 if [ ! -f " jobPEM.slurm" ]; then69 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!" 70 72 errlaunch 71 73 fi … … 142 144 143 145 # 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) 146 149 submitPCM() { 147 find . -type f -name " jobPCM*.slurm" ! -name "jobPCM.slurm" -delete150 find . -type f -name "PCMrun*.job" ! -name "PCMrun.job" -delete 148 151 ii=1 149 if [ ! -z $ 2]; then150 ii=$ 2152 if [ ! -z $3 ]; then 153 ii=$3 151 154 fi 152 155 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 162 170 ((iPCM++)) 163 171 ((i_myear++)) … … 166 174 endlaunch 167 175 fi 168 for ((i = $ii; i <= $ 1; i++)); do176 for ((i = $ii; i <= $2; i++)); do 169 177 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 176 189 ((iPCM++)) 177 190 ((i_myear++)) … … 183 196 184 197 # To submit the PEM run 198 # arg1: model dimension 185 199 submitPEM() { 186 200 if [ $i_myear -lt $n_myear ]; then 187 201 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 194 212 else 195 213 endlaunch … … 198 216 199 217 # 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) 202 221 cyclelaunch() { 203 222 # PCM runs 204 submitPCM $1 $2 223 submitPCM $1 $2 $3 205 224 206 225 # PEM run 207 226 if [ $i_myear -lt $n_myear ]; then 208 227 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 212 235 else 213 236 endlaunch … … 241 264 242 265 # To relaunch from PCM run 266 # arg1: model dimension 243 267 relaunchPCM() { 244 268 iPCM=$(($irelaunch + 1)) … … 269 293 if [ $irelaunch -eq $(($nPCM_ini - 1)) ]; then 270 294 cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc 271 cyclelaunch $ nPCM_ini $irelaunch295 cyclelaunch $1 $nPCM_ini $iPCM 272 296 elif [ $irelaunch -eq $nPCM_ini ]; then 273 297 cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc 274 298 cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc 275 submitPEM # The next job is a PEM run299 submitPEM $1 # The next job is a PEM run 276 300 else 277 cyclelaunch $ nPCM_ini $iPCM301 cyclelaunch $1 $nPCM_ini $iPCM 278 302 fi 279 303 else … … 292 316 sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt 293 317 cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc 294 cyclelaunch $ nPCM $il318 cyclelaunch $1 $nPCM $il 295 319 elif [ $il -eq 0 ]; then 296 320 i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $nPCM)) … … 298 322 cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc 299 323 cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc 300 submitPEM # The next job is a PEM run324 submitPEM $1 # The next job is a PEM run 301 325 else 302 326 i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $il)) 303 327 sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt 304 cyclelaunch $ nPCM $il328 cyclelaunch $1 $nPCM $il 305 329 fi 306 330 fi … … 308 332 309 333 # To relaunch from PEM run 334 # arg1: model dimension 310 335 relaunchPEM() { 311 336 iPEM=$irelaunch … … 332 357 cp starts/restart1D_postPEM${irelaunch}.txt start1D.txt 333 358 fi 334 cyclelaunch $ nPCM335 } 359 cyclelaunch $1 $nPCM 360 }
Note: See TracChangeset
for help on using the changeset viewer.