Changeset 3355 for trunk/LMDZ.COMMON/libf/evolution/deftank
- Timestamp:
- Jun 3, 2024, 5:27:45 PM (7 months ago)
- Location:
- trunk/LMDZ.COMMON/libf/evolution/deftank
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh
r3349 r3355 36 36 source lib_launchPEM.sh 37 37 38 if [ $# -eq 0 ]; then # From scratch 38 if [ $# -eq 0 ]; then 39 # Starting from scratch 39 40 echo "The launching script is starting!" 40 41 echo "The output file is \"log_launchPEM.txt\"." … … 45 46 initlaunch 46 47 cyclelaunch $nPCM_ini 48 47 49 else 48 if [ $1 = "new" ]; then # New cycle 50 # Starting a new cycle 51 if [ $1 = "new" ]; then 49 52 exec >> log_launchPEM.txt 2>&1 53 echo 50 54 echo "This is a new cycle for the PEM simulation." 51 55 date 52 56 read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt 53 57 cyclelaunch $nPCM 54 elif [ $1 = "re" ]; then # Relaunch 55 echo "Case not coded yet!" 56 errlaunch 58 59 # Starting a relaunch 60 elif [ $1 = "re" ]; then 61 if [ ! -f "info_PEM.txt" ]; then 62 echo "Error: file \"info_PEM.txt\" does not exist in $dir!" 63 echo "It is necessary to relaunch a PEM simulation." 64 errlaunch 65 fi 66 while true; do 67 echo "Do you want to relaunch from a 'PCM' or 'PEM' run?" 68 read relaunch 69 if [ $relaunch = "PCM" ] || [ $relaunch = "PEM" ]; then 70 break 71 else 72 echo "Invalid input. Please enter 'PCM' or 'PEM'." 73 fi 74 done 75 read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt 76 echo $i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini 77 while true; do 78 if [ $relaunch = "PCM" ]; then 79 echo "What is the number of the PCM run?" 80 echo "It should be between 1 and $iPCM." 81 read irelaunch 82 if [ 0 -lt $irelaunch ] && [ $irelaunch -le $iPCM ]; then 83 break 84 else 85 echo "Invalid input. Please enter a valid PCM run number." 86 fi 87 else 88 echo "What is the number of the PEM run?" 89 echo "It should be between 1 and $((iPEM - 1))." 90 read irelaunch 91 if [ 0 -lt $irelaunch ] && [ $irelaunch -le $iPEM ]; then 92 break 93 else 94 echo "Invalid input. Please enter a valid PEM run number." 95 fi 96 fi 97 done 98 exec >> log_launchPEM.txt 2>&1 99 echo 100 echo "This is a relaunch for the PEM simulation from the run $relaunch$irelaunch." 101 date 102 checklaunch 103 if [ $relaunch = "PCM" ]; then 104 relaunchPCM 105 else 106 relaunchPEM 107 fi 57 108 else 58 109 echo "Error: given argument '$1' for the launching script is unknown!" -
trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh
r3354 r3355 124 124 i_myear=0 125 125 iPEM=1 126 ((iPCM = ($iPEM - 1)*$nPCM + 1))126 iPCM=1 127 127 cp startfi.nc starts/ 128 128 if [ -f "start.nc" ]; then … … 139 139 submitPCM() { 140 140 find . -type f -name "jobPCM*.slurm" ! -name "jobPCM.slurm" -delete 141 ii=1 142 if [ ! -z $2 ]; then 143 ii=$2 144 fi 141 145 if [ $i_myear -lt $n_myear ]; then 142 echo "Run PCM $iPCM: call 1/$1..."146 echo "Run PCM $iPCM: call $ii/$1..." 143 147 cp jobPCM.slurm jobPCM${iPCM}.slurm 144 148 sed -i "s/#SBATCH --job-name=jobPCM.*/#SBATCH --job-name=jobPCM${iPCM}/" jobPCM${iPCM}.slurm 145 149 sed -i "s/^k=[0-9]\+$/k=$(echo "3 - $nPCM_ini" | bc -l)/" jobPCM${iPCM}.slurm 146 150 jobID=$(sbatch --parsable jobPCM${iPCM}.slurm) 151 # Create a file to cancel the dependent jobs of the cycle 147 152 echo "#!/bin/bash" > kill_launchPEM.sh 148 153 chmod +x kill_launchPEM.sh … … 150 155 ((iPCM++)) 151 156 ((i_myear++)) 157 ((ii++)) 152 158 else 153 159 endlaunch 154 160 fi 155 for ((i = 2; i <= $1; i++)); do161 for ((i = $ii; i <= $1; i++)); do 156 162 if [ $i_myear -lt $n_myear ]; then 157 163 echo "Run PCM $iPCM: call $i/$1..." … … 172 178 submitPEM() { 173 179 if [ $i_myear -lt $n_myear ]; then 180 echo "Run PEM $iPEM" 181 sed -i "s/#SBATCH --job-name=jobPEM.*/#SBATCH --job-name=jobPEM${iPEM}/" jobPEM.slurm 182 jobID=$(sbatch --parsable jobPEM.slurm) 183 # Create a file to cancel the dependent jobs of the cycle 184 echo "#!/bin/bash" > kill_launchPEM.sh 185 chmod +x kill_launchPEM.sh 186 echo "scancel" $jobID >> kill_launchPEM.sh 187 else 188 endlaunch 189 fi 190 } 191 192 # To make one cycle of PCM and PEM runs 193 cyclelaunch() { 194 # PCM runs 195 submitPCM $1 $2 196 197 # PEM run 198 if [ $i_myear -lt $n_myear ]; then 199 echo "Run PEM $iPEM" 174 200 sed -i "s/#SBATCH --job-name=jobPEM.*/#SBATCH --job-name=jobPEM${iPEM}/" jobPEM.slurm 175 201 jobID=$(sbatch --parsable --dependency=afterok:${jobID} jobPEM.slurm) … … 180 206 } 181 207 182 # To make one cycle of PCM and PEM runs 183 cyclelaunch() { 184 # PCM runs 185 submitPCM $1 186 187 # PEM run 188 submitPEM 189 } 208 # To relaunch from PCM run 209 relaunchPCM() { 210 iPCM=$(($irelaunch + 1)) 211 cp starts/restartfi${irelaunch}.nc startfi.nc 212 if [ -f "starts/restart${irelaunch}.nc" ]; then 213 cp starts/restart${irelaunch}.nc start.nc 214 elif [ -f "starts/restart1D${irelaunch}.txt" ]; then 215 cp starts/restart1D${irelaunch}.txt start1D.txt 216 fi 217 if [ $irelaunch -le $nPCM_ini ]; then 218 # PCM relaunch during the initialization cycle 219 iPEM=1 220 i_myear=$irelaunch 221 sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt 222 if [ $irelaunch -eq $(($nPCM_ini - 1)) ]; then 223 cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc 224 cyclelaunch $nPCM_ini $irelaunch 225 elif [ $irelaunch -eq $nPCM_ini ]; then 226 cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc 227 cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc 228 submitPEM # The next job is a PEM run 229 else 230 cyclelaunch $nPCM_ini $iPCM 231 fi 232 else 233 # PCM relaunch during a cycle 234 iPEM=$(($irelaunch/$nPCM + 1)) 235 il=$(echo "($irelaunch - $nPCM_ini)%$nPCM" | bc -l) 236 i_myear=$(($(awk "NR==$(($iPEM + 1)) {print \$1}" "info_PEM.txt") + $il)) 237 sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt 238 cp starts/restartpem${iPEM}.nc startpem.nc 239 if [ $il -eq $(($nPCM - 1)) ]; then 240 cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc 241 cyclelaunch $nPCM $il 242 elif [ $il -eq $nPCM ]; then 243 cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc 244 cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc 245 submitPEM # The next job is a PEM run 246 else 247 cyclelaunch $nPCM $il 248 fi 249 fi 250 } 251 252 # To relaunch from PEM run 253 relaunchPEM() { 254 iPEM=$irelaunch 255 iPCM=$(($nPCM_ini + ($nPCM - 1)*$irelaunch + 1)) 256 i_myear=$(awk "NR==$(($iPEM + 1)) {print \$1}" "info_PEM.txt") 257 sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt 258 cp starts/restartpem${irelaunch}.nc startpem.nc 259 cp starts/restartfi_postPEM${irelaunch}.nc startfi.nc 260 if [ -f "starts/restart_postPEM${irelaunch}.nc" ]; then 261 cp starts/restart_postPEM${irelaunch}.nc start.nc 262 elif [ -f "starts/restart1D_postPEM${irelaunch}.txt" ]; then 263 cp starts/restart1D_postPEM${irelaunch}.txt start1D.txt 264 fi 265 cyclelaunch $nPCM 266 }
Note: See TracChangeset
for help on using the changeset viewer.