Ignore:
Timestamp:
Jun 10, 2024, 7:23:37 PM (7 months ago)
Author:
jbclement
Message:

PEM:
Correction of an error in "lib_launchPEM.sh" due to a miscalculated condition + Improvement of the relaunch which now cleans the unnecessary files.
JBC

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

Legend:

Unmodified
Added
Removed
  • trunk/LMDZ.COMMON/libf/evolution/deftank/launchPEM.sh

    r3363 r3365  
    7575        done
    7676        read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt
    77         echo $i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini
    7877        while true; do
    7978            if [ $relaunch = "PCM" ]; then
  • trunk/LMDZ.COMMON/libf/evolution/deftank/lib_launchPEM.sh

    r3355 r3365  
    206206}
    207207
     208# To clean files after the starting run of the relaunch
     209cleanfiles() {
     210    prefix=$1
     211    extension=$2
     212    if [ -z "$extension" ]; then
     213        for file in ${prefix}*; do
     214            num=${file#$prefix}
     215            if [[ $num =~ ^[0-9]+$ ]] && [ $num -gt $3 ]; then
     216                rm $file
     217            fi
     218        done
     219    else
     220        for file in ${prefix}*${extension}; do
     221            num=${file#$prefix}
     222            num=${num%$extension}
     223            if [[ $num =~ ^[0-9]+$ ]] && [ $num -gt $3 ]; then
     224                rm $file
     225            fi
     226        done
     227    fi
     228}
     229
    208230# To relaunch from PCM run
    209231relaunchPCM() {
    210232    iPCM=$(($irelaunch + 1))
     233    cleanfiles diags/diagfi .nc $irelaunch
     234    cleanfiles "out_PCM/run" "" $irelaunch
     235    cleanfiles starts/restart1D .txt $irelaunch
     236    cleanfiles starts/restart .nc $irelaunch
     237    cleanfiles starts/restartfi .nc $irelaunch
    211238    cp starts/restartfi${irelaunch}.nc startfi.nc
    212239    if [ -f "starts/restart${irelaunch}.nc" ]; then
     
    218245        # PCM relaunch during the initialization cycle
    219246        iPEM=1
     247        cleanfiles diags/diagpem .nc $iPEM
     248        cleanfiles "out_PEM/run" "" $iPEM
     249        cleanfiles starts/restart1D_postPEM .txt $iPEM
     250        cleanfiles starts/restart_postPEM .nc $iPEM
     251        cleanfiles starts/restartfi_postPEM .nc $iPEM
     252        cleanfiles starts/restartpem .nc $iPEM
    220253        i_myear=$irelaunch
    221254        sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
    222255        if [ $irelaunch -eq $(($nPCM_ini - 1)) ]; then
    223256            cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc
     257            cleanfiles diags/data2reshape .nc $irelaunch
    224258            cyclelaunch $nPCM_ini $irelaunch
    225         elif [ $irelaunch -eq $nPCM_ini ]; then
     259        elif [ $irelaunch -eq 0 ]; then
    226260            cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
    227261            cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc
     262            cleanfiles diags/data2reshape .nc $(($irelaunch - 1))
    228263            submitPEM # The next job is a PEM run
    229264        else
     265            cleanfiles diags/data2reshape .nc 0
    230266            cyclelaunch $nPCM_ini $iPCM
    231267        fi
    232268    else
    233269        # PCM relaunch during a cycle
    234         iPEM=$(($irelaunch/$nPCM + 1))
     270        iPEM=$((($irelaunch - $nPCM_ini)/$nPCM + 1))
    235271        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
     272        cleanfiles diags/diagpem .nc $iPEM
     273        cleanfiles "out_PEM/run" "" $iPEM
     274        cleanfiles starts/restart1D_postPEM .txt $iPEM
     275        cleanfiles starts/restart_postPEM .nc $iPEM
     276        cleanfiles starts/restartfi_postPEM .nc $iPEM
     277        cleanfiles starts/restartpem .nc $iPEM
    238278        cp starts/restartpem${iPEM}.nc startpem.nc
    239279        if [ $il -eq $(($nPCM - 1)) ]; then
     280            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $il))
     281            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
    240282            cp diags/data2reshape${irelaunch}.nc data2reshape_Y1.nc
     283            cleanfiles diags/data2reshape .nc $irelaunch
    241284            cyclelaunch $nPCM $il
    242         elif [ $il -eq $nPCM ]; then
     285        elif [ $il -eq 0 ]; then
     286            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $nPCM))
     287            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
    243288            cp diags/data2reshape$(($irelaunch - 1)).nc data2reshape_Y1.nc
    244289            cp diags/data2reshape${irelaunch}.nc data2reshape_Y2.nc
     290            cleanfiles diags/data2reshape .nc $(($irelaunch - 1))
    245291            submitPEM # The next job is a PEM run
    246292        else
     293            i_myear=$(($(awk "NR==$iPEM {print \$1}" "info_PEM.txt") + $il))
     294            sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
     295            cleanfiles diags/data2reshape .nc $irelaunch
    247296            cyclelaunch $nPCM $il
    248297        fi
     
    256305    i_myear=$(awk "NR==$(($iPEM + 1)) {print \$1}" "info_PEM.txt")
    257306    sed -i "1s/.*/$i_myear $n_myear $convert_years $iPCM $iPEM $nPCM $nPCM_ini/" info_PEM.txt
     307    cleanfiles diags/diagfi .nc $(($iPCM - 1))
     308    cleanfiles "out_PCM/run" "" $(($iPCM - 1))
     309    cleanfiles starts/restart1D .txt $(($iPCM - 1))
     310    cleanfiles starts/restart .nc $(($iPCM - 1))
     311    cleanfiles starts/restartfi .nc $(($iPCM - 1))
     312    cleanfiles diags/data2reshape .nc $(($iPCM - 1))
     313    cleanfiles diags/diagpem .nc $irelaunch
     314    cleanfiles "out_PEM/run" "" $irelaunch
     315    cleanfiles starts/restart1D_postPEM .txt $irelaunch
     316    cleanfiles starts/restart_postPEM .nc $irelaunch
     317    cleanfiles starts/restartfi_postPEM .nc $irelaunch
     318    cleanfiles starts/restartpem .nc $irelaunch
    258319    cp starts/restartpem${irelaunch}.nc startpem.nc
    259320    cp starts/restartfi_postPEM${irelaunch}.nc startfi.nc
Note: See TracChangeset for help on using the changeset viewer.