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=1 |
---|
8 | #SBATCH --ntasks=1 |
---|
9 | #SBATCH --cpus-per-task=1 |
---|
10 | ###SBATCH --exclusive |
---|
11 | #SBATCH --output=jobPEM_%j.out |
---|
12 | #SBATCH --time=24:00:00 |
---|
13 | #SBATCH --mem=29000M |
---|
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 | # Argument for the PEM execution (for SLURM: "$SLURM_JOB_ID" | for PBD/TORQUE: "$PBS_JOBID" | "" when the script is not run as a job): |
---|
26 | arg_pem="$SLURM_JOB_ID" |
---|
27 | ######################################################################## |
---|
28 | |
---|
29 | |
---|
30 | ulimit -s unlimited |
---|
31 | |
---|
32 | # Reshaping PCM data with XIOS |
---|
33 | echo "Reshaping PCM data with XIOS is starting." |
---|
34 | ./$exeReshape |
---|
35 | if [ ! -f "data_PCM_Y1.nc" ] || [ ! -f "data_PCM_Y2.nc" ]; then # Check if it ended abnormally |
---|
36 | echo "Error: the reshaping executable crashed!" |
---|
37 | exit 1 |
---|
38 | fi |
---|
39 | |
---|
40 | # Running the PEM |
---|
41 | read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt |
---|
42 | echo "Run PEM $iPEM is starting." |
---|
43 | cp run_PEM.def run.def |
---|
44 | eval "./$exePEM $arg_pem > out_runPEM${iPEM} 2>&1" |
---|
45 | if [ ! -f "restartfi.nc" ] || ! (tail -n 100 out_runPEM${iPEM} | grep -iq "so far, so good!"); then # Check if it ended abnormally |
---|
46 | echo "Error: the run PEM $iPEM crashed!" |
---|
47 | exit 1 |
---|
48 | fi |
---|
49 | |
---|
50 | # Copy data files and prepare the next run |
---|
51 | mv out_runPEM${iPEM} out_PEM/run${iPEM} |
---|
52 | if [ -f "diagpem.nc" ]; then |
---|
53 | mv diagpem.nc diags/diagpem${iPEM}.nc |
---|
54 | fi |
---|
55 | if [ -f "diagsoilpem.nc" ]; then |
---|
56 | mv diagsoilpem.nc diags/diagsoilpem${iPEM}.nc |
---|
57 | fi |
---|
58 | cp restartpem.nc starts/restartpem${iPEM}.nc |
---|
59 | mv restartpem.nc startpem.nc |
---|
60 | cp restartfi.nc starts/restartfi_postPEM${iPEM}.nc |
---|
61 | mv restartfi.nc startfi.nc |
---|
62 | if [ -f "restart.nc" ]; then |
---|
63 | cp restart.nc starts/restart_postPEM${iPEM}.nc |
---|
64 | mv restart.nc start.nc |
---|
65 | elif [ -f "restart1D.txt" ]; then |
---|
66 | cp restart1D.txt starts/restart1D_postPEM${iPEM}.txt |
---|
67 | mv restart1D.txt start1D.txt |
---|
68 | fi |
---|
69 | |
---|
70 | # Launch the next cycle |
---|
71 | #if [ "$(awk 'END{print $NF}' info_PEM.txt)" -eq 7 ]; then |
---|
72 | # read i_myear n_myear convert_years iPCM iPEM nPCM nPCM_ini < info_PEM.txt |
---|
73 | # ./launchPEM.sh cont # Continue the PEM run if it stopped because of job time limit |
---|
74 | #else |
---|
75 | ./launchPEM.sh new |
---|
76 | #fi |
---|