| 1 | #!/bin/bash |
|---|
| 2 | #SBATCH --job-name=jobPEM1 |
|---|
| 3 | #SBATCH --account=cin0391 |
|---|
| 4 | ### GENOA nodes accommodate 96 cores |
|---|
| 5 | #SBATCH --constraint=GENOA |
|---|
| 6 | ### Number of Nodes to use |
|---|
| 7 | #SBATCH --nodes=4 # to run with enough memory |
|---|
| 8 | #SBATCH --ntasks-per-node=1 |
|---|
| 9 | #SBATCH --cpus-per-task=1 |
|---|
| 10 | #SBATCH --threads-per-core=1 # --hint=nomultithread |
|---|
| 11 | ###SBATCH --exclusive |
|---|
| 12 | #SBATCH --output=jobPEM_%A.out |
|---|
| 13 | #SBATCH --time=24:00:00 |
|---|
| 14 | |
|---|
| 15 | # A few parameters that might need to be changed depending on your setup |
|---|
| 16 | # Path to the arch.env to source: |
|---|
| 17 | source ../trunk/LMDZ.COMMON/arch.env |
|---|
| 18 | |
|---|
| 19 | # Name of executable for the PEM: |
|---|
| 20 | exePEM="pem_64x48x32_phymars_seq.e" |
|---|
| 21 | |
|---|
| 22 | # Name of executable for reshaping PCM data with XIOS: |
|---|
| 23 | exeReshape="reshape_XIOS_output_64x48x32_phymars_seq.e" |
|---|
| 24 | ######################################################################## |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | # Reshaping PCM data with XIOS |
|---|
| 28 | echo "Reshaping PCM data with XIOS is starting." |
|---|
| 29 | ./$exeReshape |
|---|
| 30 | if [ ! -f "data_PCM_Y1.nc" ] || [ ! -f "data_PCM_Y2.nc" ]; then # Check if it ended abnormally |
|---|
| 31 | echo "Error: the reshaping executable crashed!" |
|---|
| 32 | exit 1 |
|---|
| 33 | fi |
|---|
| 34 | |
|---|
| 35 | # Running the PEM |
|---|
| 36 | echo "Run PEM $iPEM is starting." |
|---|
| 37 | read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt |
|---|
| 38 | cp run_PEM.def run.def |
|---|
| 39 | ./$exePEM $SLURM_JOB_ID > out_runPEM${iPEM} 2>&1 |
|---|
| 40 | if [ ! -f "restartfi.nc" ] || ! (tail -n 1 out_runPEM${iPEM} | grep -iq "so far, so good!"); then # Check if it ended abnormally |
|---|
| 41 | echo "Error: the run PEM $iPEM crashed!" |
|---|
| 42 | exit 1 |
|---|
| 43 | fi |
|---|
| 44 | |
|---|
| 45 | # Copy data files and prepare the next run |
|---|
| 46 | mv out_runPEM${iPEM} out_PEM/run${iPEM} |
|---|
| 47 | if [ -f "diagpem.nc" ]; then |
|---|
| 48 | mv diagpem.nc diags/diagpem${iPEM}.nc |
|---|
| 49 | fi |
|---|
| 50 | if [ -f "diagsoilpem.nc" ]; then |
|---|
| 51 | mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc |
|---|
| 52 | fi |
|---|
| 53 | cp restartpem.nc starts/restartpem${iPEM}.nc |
|---|
| 54 | mv restartpem.nc startpem.nc |
|---|
| 55 | cp restartfi.nc starts/restartfi_postPEM${iPEM}.nc |
|---|
| 56 | mv restartfi.nc startfi.nc |
|---|
| 57 | if [ -f "restart.nc" ]; then |
|---|
| 58 | cp restart.nc starts/restart_postPEM${iPEM}.nc |
|---|
| 59 | mv restart.nc start.nc |
|---|
| 60 | elif [ -f "restart1D.txt" ]; then |
|---|
| 61 | cp restart1D.txt starts/restart1D_postPEM${iPEM}.txt |
|---|
| 62 | mv restart1D.txt start1D.txt |
|---|
| 63 | fi |
|---|
| 64 | |
|---|
| 65 | # Launch the next cycle |
|---|
| 66 | #if [ "$(awk 'END{print $NF}' info_PEM.txt)" -eq 7 ]; then |
|---|
| 67 | # read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt |
|---|
| 68 | # ./launchPEM.sh cont # Continue the PEM run if it stopped because of job time limit |
|---|
| 69 | #else |
|---|
| 70 | ./launchPEM.sh new |
|---|
| 71 | #fi |
|---|