Ignore:
Timestamp:
Feb 12, 2024, 5:37:25 PM (17 months ago)
Author:
jbclement
Message:

PEM:

  • It is now possible to set the number of initial PCM calls independently of the number of "inter-PEM" PCM calls. It is useful to get a stable situation for the start of the simulation.
  • Correction of a bug: 'reshape_XIOS_output' treated the first two PCM runs instead of the last two. The numbering has been adapted in "launch_pem.sh" to get it right.
  • PEM outputs ("diagpem.nc" and "diagsoil_pem.nc") has been improved: 'Time' now evolves according to 'dt_pem' (usually year by year) and 'ecritpem' is a full variable of "time_evol_mod.F90".

JBC

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

Legend:

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

    r3210 r3214  
    1010ecritpem=1
    1111
     12# Number of initial PCM calls
     13nPCM_ini=4
     14
    1215# Number of GCM calls between each PEM call
    13 nGCM=2
     16nPCM=2
    1417
    1518# List of NetCDF files to concatenate
     
    3437
    3538# Loop to concatenate the NetCDF files
    36 newTime=$((nGCM + 1))
     39newTime=$((nPCM_ini + 1))
    3740for file in "${files[@]}"; do
    3841    # Extract the 'Time' variable into a temporary file
     
    6164        ncrcat -O $output_file $file -o $output_file
    6265    fi
    63     newTime=$((newTime + nGCM))
     66    newTime=$((newTime + nPCM))
    6467done
    6568
  • trunk/LMDZ.COMMON/libf/evolution/deftank/launch_pem.sh

    r3210 r3214  
    2525#---------- Modify here the number of years to be simulated ------------
    2626## set the number of years, either Martian or Earth years:
    27 n_mars_years=1000000
    28 #n_earth_years=1000000
     27n_mars_years=1000
     28#n_earth_years=300
     29
     30#------------- Modify here the number of initial PCM calls -------------
     31## set the number of initial PCM calls between each PEM call:
     32nPCM_ini=4
    2933
    3034#---------------- Modify here the number of PCM calls ------------------
     
    130134echo $i_myear $n_myear $convert_years > info_PEM.txt
    131135
     136#-------------------------- Initial PCM runs ---------------------------
     137cp run_PCM.def run.def
     138for ((i = 1; i <= $nPCM_ini; i++)); do
     139    echo "Run PCM $iPCM (initial): call $i/$nPCM_ini..."
     140    sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
     141    sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
     142    sbatch -W exePCM.sh
     143    if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
     144        echo "Error: the run PCM $iPCM crashed!"
     145        exit 1
     146    fi
     147    # Copy data files and prepare the next run
     148    mv out_runPCM${iPCM} out_PCM/run${iPCM}
     149    mv diagfi.nc diags/diagfi${iPCM}.nc
     150    if [ -f "diagsoil.nc" ]; then
     151        mv diagsoil.nc diags/diagsoil${iPCM}.nc
     152    fi
     153    if [ -f "stats.nc" ]; then
     154        mv stats.nc diags/stats${iPCM}.nc
     155    fi
     156    k=$(echo "$i + 2 - $nPCM_ini" | bc -l)
     157    if [$(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
     158        mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     159    else
     160        cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     161        mv Xdiurnalave.nc data2reshape_Y${k}.nc
     162    fi
     163    cp restartfi.nc starts/startfi${iPCM}.nc
     164    mv restartfi.nc startfi.nc
     165    if [ -f "restart.nc" ]; then
     166        cp restart.nc starts/restart${iPCM}.nc
     167        mv restart.nc start.nc
     168    elif [ -f "restart1D.txt" ]; then
     169        cp restart1D.txt starts/restart1D${iPCM}.txt
     170        mv restart1D.txt start1D.txt
     171    fi
     172    ((iPCM++))
     173    ((i_myear++))
     174    echo "Done!"
     175done
     176sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
     177
    132178#---------------------- Main loop to call PEM/PCM ----------------------
    133179while [ $i_myear -lt $n_myear ]; do
    134     #--- Loop to run PCM year by year
    135     cp run_PCM.def run.def
    136     for ((i = 1; i <= $nPCM; i++)); do
    137         echo "Run PCM $iPCM: call $i/$nPCM..."
    138         sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
    139         sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
    140         sbatch -W exePCM.sh
    141         if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
    142             echo "Error: the run PCM $iPCM has crashed!"
    143             exit 1
    144         fi
    145         # Copy data files and prepare the next run
    146         mv out_runPCM${iPCM} out_PCM/run${iPCM}
    147         mv diagfi.nc diags/diagfi${iPCM}.nc
    148         if [ -f "diagsoil.nc" ]; then
    149             mv diagsoil.nc diags/diagsoil${iPCM}.nc
    150         fi
    151         if [ -f "stats.nc" ]; then
    152             mv stats.nc diags/stats${iPCM}.nc
    153         fi
    154         cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
    155         mv Xdiurnalave.nc data2reshape${i}.nc
    156         cp restartfi.nc starts/startfi${iPCM}.nc
    157         mv restartfi.nc startfi.nc
    158         if [ -f "restart.nc" ]; then
    159             cp restart.nc starts/restart${iPCM}.nc
    160             mv restart.nc start.nc
    161         elif [ -f "restart1D.txt" ]; then
    162             cp restart1D.txt starts/restart1D${iPCM}.txt
    163             mv restart1D.txt start1D.txt
    164         fi
    165         ((iPCM++))
    166         ((i_myear++))
    167         echo "Done!"
    168     done
    169     sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
    170 
    171180    #--- Reshaping PCM data with XIOS
    172181    echo "Reshaping PCM data with XIOS..."
     
    185194    ./$exePEM > out_runPEM${iPEM} 2>&1
    186195    if [ ! -f "restartfi_evol.nc" ]; then # Check if run ended abnormally
    187         echo "Error: the run PEM $iPEM has crashed!"
     196        echo "Error: the run PEM $iPEM crashed!"
    188197        exit 1
    189198    fi
     
    191200    mv out_runPEM${iPEM} out_PEM/run${iPEM}
    192201    mv diagpem.nc diags/diagpem${iPEM}.nc
    193     mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc
     202    if [ -f "diagsoilpem.nc" ]; then
     203        mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc
     204    fi
    194205    cp restartpem.nc starts/startpem${iPEM}.nc
    195206    mv restartpem.nc startpem.nc
     
    206217    read i_myear n_myear convert_years < info_PEM.txt
    207218    echo "Done!"
     219
     220    #--- Loop to run PCM year by year
     221    cp run_PCM.def run.def
     222    for ((i = 1; i <= $nPCM; i++)); do
     223        echo "Run PCM $iPCM: call $i/$nPCM..."
     224        sed -i "s/#SBATCH --job-name=runPCM.*/#SBATCH --job-name=runPCM${iPCM}/" exePCM.sh
     225        sed -i "s/out_runPCM[0-9]\+/out_runPCM${iPCM}/" exePCM.sh
     226        sbatch -W exePCM.sh
     227        if [ ! -f "restartfi.nc" ]; then # Check if run ended abnormally
     228            echo "Error: the run PCM $iPCM crashed!"
     229            exit 1
     230        fi
     231        # Copy data files and prepare the next run
     232        mv out_runPCM${iPCM} out_PCM/run${iPCM}
     233        mv diagfi.nc diags/diagfi${iPCM}.nc
     234        if [ -f "diagsoil.nc" ]; then
     235            mv diagsoil.nc diags/diagsoil${iPCM}.nc
     236        fi
     237        if [ -f "stats.nc" ]; then
     238            mv stats.nc diags/stats${iPCM}.nc
     239        fi
     240        k=$(echo "$i + 2 - $nPCM" | bc -l)
     241        if [$(echo "$k < 1" | bc -l) -eq 1 ]; then # Only the last 2 years are taken for the PEM
     242            mv Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     243        else
     244            cp Xdiurnalave.nc diags/data2reshape${iPCM}.nc
     245            mv Xdiurnalave.nc data2reshape_Y${k}.nc
     246        fi
     247        cp restartfi.nc starts/startfi${iPCM}.nc
     248        mv restartfi.nc startfi.nc
     249        if [ -f "restart.nc" ]; then
     250            cp restart.nc starts/restart${iPCM}.nc
     251            mv restart.nc start.nc
     252        elif [ -f "restart1D.txt" ]; then
     253            cp restart1D.txt starts/restart1D${iPCM}.txt
     254            mv restart1D.txt start1D.txt
     255        fi
     256        ((iPCM++))
     257        ((i_myear++))
     258        echo "Done!"
     259    done
     260    sed -i "1s/.*/$i_myear $n_myear $convert_years/" info_PEM.txt
    208261done
    209262
     
    212265
    213266date
    214 echo "The launching script has terminated."
     267echo "The launching script ended."
Note: See TracChangeset for help on using the changeset viewer.