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