Ignore:
Timestamp:
Apr 8, 2024, 2:25:58 PM (9 months ago)
Author:
jbclement
Message:

PEM:
Correction of "launch_pem.sh" in the deftank: the number of years to be simulated was not respected because of extra PCM runs at the end of the simulation due to the order of PCM/PEM runs inside the loop.
JBC

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

Legend:

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

    r3287 r3296  
    262262- Small correction to make the 3D PEM be able to compile.
    263263- Improvement of "launch_pem.sh": a file "kill_launch_pem.sh" is now automatically created which allows the user to kill the process of the launching script in case.
     264
     265== 08/04/2024 == JBC
     266Correction of "launch_pem.sh" in the deftank: the number of years to be simulated was not respected because of extra PCM runs at the end of the simulation due to the order of PCM/PEM runs inside the loop.
  • trunk/LMDZ.COMMON/libf/evolution/deftank/launch_pem.sh

    r3287 r3296  
    139139echo $i_myear $n_myear $convert_years > info_PEM.txt
    140140
    141 #-------------------------- Initial PCM runs ---------------------------
     141#---------------------------- Initial runs -----------------------------
     142#--- Initial PCM runs
    142143cp run_PCM.def run.def
    143144for ((i = 1; i <= $nPCM_ini; i++)); do
     
    181182sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
    182183
     184#--- Reshaping PCM data with XIOS
     185echo "Reshaping PCM data with XIOS..."
     186./$exeReshape
     187echo "Done!"
     188
     189#--- Running PEM
     190echo "Run PEM $iPEM..."
     191cp run_PEM.def run.def
     192mv startfi.nc startfi_evol.nc
     193if [ -f "start.nc" ]; then
     194    mv start.nc start_evol.nc
     195elif [ -f "start1D.txt" ]; then
     196    mv start1D.txt start1D_evol.txt
     197fi
     198./$exePEM > out_runPEM${iPEM} 2>&1
     199if [ ! -f "restartfi_evol.nc" ]; then # Check if run ended abnormally
     200    echo "Error: the run PEM $iPEM crashed!"
     201    exit 1
     202fi
     203# Copy data files and prepare the next run
     204mv out_runPEM${iPEM} out_PEM/run${iPEM}
     205mv diagpem.nc diags/diagpem${iPEM}.nc
     206if [ -f "diagsoilpem.nc" ]; then
     207    mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc
     208fi
     209cp restartpem.nc starts/startpem${iPEM}.nc
     210mv restartpem.nc startpem.nc
     211cp restartfi_evol.nc starts/startfi_postPEM${iPEM}.nc
     212mv restartfi_evol.nc startfi.nc
     213if [ -f "restart_evol.nc" ]; then
     214    cp restart_evol.nc starts/restart_postPEM${iPEM}.nc
     215    mv restart_evol.nc start.nc
     216elif [ -f "restart1D_evol.txt" ]; then
     217    cp restart1D_evol.txt starts/restart1D_postPEM${iPEM}.txt
     218    mv restart1D_evol.txt start1D.txt
     219fi
     220((iPEM++))
     221read i_myear n_myear convert_years < info_PEM.txt
     222echo "Done!"
     223
    183224#---------------------- Main loop to call PEM/PCM ----------------------
    184225while [ $i_myear -lt $n_myear ]; do
     226    #--- Loop to run PCM year by year
     227    cp run_PCM.def run.def
     228    for ((i = 1; i <= $nPCM; i++)); do
     229        echo "Run PCM $iPCM: call $i/$nPCM..."
     230        sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
     231        sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
     232        sbatch -W exePCM.sh
     233        if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
     234            echo "Error: the run PCM $iPCM crashed!"
     235            exit 1
     236        fi
     237        # Copy data files and prepare the next run
     238        mv out_runPCM${iPCM} out_PCM/run${iPCM}
     239        mv diagfi.nc diags/diagfi${iPCM}.nc
     240        if [ -f "diagsoil.nc" ]; then
     241            mv diagsoil.nc diags/diagsoil${iPCM}.nc
     242        fi
     243        if [ -f "stats.nc" ]; then
     244            mv stats.nc diags/stats${iPCM}.nc
     245        fi
     246        k=$(echo "$i + 2 - $nPCM" | bc -l)
     247        if [ $(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
     248            mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     249        else
     250            cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     251            mv Xdiurnalave.nc data2reshape_Y${k}.nc
     252        fi
     253        cp restartfi.nc starts/startfi${iPCM}.nc
     254        mv restartfi.nc startfi.nc
     255        if [ -f "restart.nc" ]; then
     256            cp restart.nc starts/restart${iPCM}.nc
     257            mv restart.nc start.nc
     258        elif [ -f "restart1D.txt" ]; then
     259            cp restart1D.txt starts/restart1D${iPCM}.txt
     260            mv restart1D.txt start1D.txt
     261        fi
     262        ((iPCM++))
     263        ((i_myear++))
     264        echo "Done!"
     265    done
     266    sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
     267
    185268    #--- Reshaping PCM data with XIOS
    186269    echo "Reshaping PCM data with XIOS..."
     
    222305    read i_myear n_myear convert_years < info_PEM.txt
    223306    echo "Done!"
    224 
    225     #--- Loop to run PCM year by year
    226     cp run_PCM.def run.def
    227     for ((i = 1; i <= $nPCM; i++)); do
    228         echo "Run PCM $iPCM: call $i/$nPCM..."
    229         sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
    230         sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
    231         sbatch -W exePCM.sh
    232         if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
    233             echo "Error: the run PCM $iPCM crashed!"
    234             exit 1
    235         fi
    236         # Copy data files and prepare the next run
    237         mv out_runPCM${iPCM} out_PCM/run${iPCM}
    238         mv diagfi.nc diags/diagfi${iPCM}.nc
    239         if [ -f "diagsoil.nc" ]; then
    240             mv diagsoil.nc diags/diagsoil${iPCM}.nc
    241         fi
    242         if [ -f "stats.nc" ]; then
    243             mv stats.nc diags/stats${iPCM}.nc
    244         fi
    245         k=$(echo "$i + 2 - $nPCM" | bc -l)
    246         if [ $(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
    247             mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
    248         else
    249             cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
    250             mv Xdiurnalave.nc data2reshape_Y${k}.nc
    251         fi
    252         cp restartfi.nc starts/startfi${iPCM}.nc
    253         mv restartfi.nc startfi.nc
    254         if [ -f "restart.nc" ]; then
    255             cp restart.nc starts/restart${iPCM}.nc
    256             mv restart.nc start.nc
    257         elif [ -f "restart1D.txt" ]; then
    258             cp restart1D.txt starts/restart1D${iPCM}.txt
    259             mv restart1D.txt start1D.txt
    260         fi
    261         ((iPCM++))
    262         ((i_myear++))
    263         echo "Done!"
    264     done
    265     sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
    266307done
    267308
Note: See TracChangeset for help on using the changeset viewer.