source: trunk/LMDZ.COMMON/libf/evolution/deftank/PCMrun.job @ 4066

Last change on this file since 4066 was 4065, checked in by jbclement, 2 weeks ago

PEM:
Major refactor following the previous ones (r3989 and r3991) completing the large structural reorganization and cleanup of the PEM codebase. This revision introduces newly designed modules, standardizes interfaces with explicit ini/end APIs and adds native NetCDF I/O together with explicit PCM/PEM adapters. In detail:

  • Some PEM models were corrected or improved:
    • Frost/perennial ice semantics are clarified via renaming;
    • Soil temperature remapping clarified, notably by removing the rescaling of temperature deviation;
    • Geothermal flux for the PCM is computed based on the PEM state;
  • New explicit PEM/PCM adapters ("set_*"/"build4PCM_*") to decouple PEM internal representation from PCM file layouts and reconstruct consistent fields returned to the PCM;
  • New explicit build/teardown routines that centralize allocation and initialization ordering, reducing accidental use of uninitialized data and making the model lifecycle explicit;
  • Add native read/write helpers for NetCDF that centralize all low-level NetCDF interactions with major improvements (and more simplicity) compared to legacy PEM/PCM I/O (see the modules "io_netcdf" and "output"). They support reading, creation and writing of "diagevol.nc" (renamed from "diagpem.nc") and start/restart files;
  • Provide well-focused modules ("numerics"/"maths"/"utility"/"display") to host commonly-used primitives:
    • "numerics" defines numerical types and constants for reproducibility, portability across compilers and future transitions (e.g. quadruple precision experiments);
    • "display" provides a single controlled interface for runtime messages, status output and diagnostics, avoiding direct 'print'/'write' to enable silent mode, log redirection, and MPI-safe output in the future.
    • "utility" (new module) hosts generic helpers used throughout the code (e.g. "int2str" or "real2str");
  • Add modules "clim_state_init"/"clim_state_rec" which provide robust read/write logic for "start/startfi/startpem", including 1D fallbacks, mesh conversions and dimension checks. NetCDF file creation is centralized and explicit. Restart files are now self-consistent and future-proof, requiring changes only to affected variables;
  • Add module "atmosphere" which computes pressure fields, reconstructs potential temperature and air mass. It also holds the whole logic to define sigma or hybrid coordinates for altitudes;
  • Add module "geometry" to centrilize dimensions logic and grid conversions routines (including 2 new ones "dyngrd2vect"/"vect2dyngrd");
  • Add module "slopes" to isolate slopes handling;
  • Add module "surface" to isolate surface management. Notably, albedo and emissivity are now fully reconstructed following the PCM settings;
  • Add module "allocation" to check the dimension initialization and centrilize allocation/deallocation;
  • Finalize module decomposition and renaming to consolidate domain-based modules, purpose-based routines and physics/process-based variables;
  • The main program now drives a clearer sequence of conceptual steps (initialization / reading / evolution / update / build / writing) and fails explicitly instead of silently defaulting;
  • Ice table logic is made restart-safe;
  • 'Open'/'read' intrinsic logic is made safe and automatic;
  • Improve discoverability and standardize the data handling (private vs protected vs public);
  • Apply consistent documentation/header style already introduced;
  • Update deftank scripts to reflect new names and launch wrappers;

This revision is a structural milestone aiming to be behavior-preserving where possible. It has been tested via compilation and short integration runs. However, due to extensive renames, moves, and API changes, full validation is still ongoing.
Note: the revision includes one (possibly two) easter egg hidden in the code for future archaeologists of the PEM. No physics were harmed.
JBC

  • Property svn:executable set to *
File size: 2.5 KB
Line 
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=24
8#SBATCH --cpus-per-task=8
9#SBATCH --threads-per-core=1 # --hint=nomultithread
10### Job information
11#SBATCH --job-name=jobPCM0
12#SBATCH --output=jobPCM_%j.out
13#SBATCH --time=4:00:00
14
15########################################################################
16# Modify here the parameters depending on your setup
17####################################################
18# Path to the arch.env to source:
19source ../trunk/LMDZ.COMMON/arch.env
20
21# Number of threads to use (must be the same as "#SBATCH --cpus-per-task=" above)
22export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
23export OMP_STACKSIZE=400M
24
25# Name of executable for the PCM:
26exePCM="gcm_64x48x32_phymars_para.e"
27
28# Execution command:
29exe_cmd="srun --ntasks-per-node=${SLURM_NTASKS_PER_NODE} --cpu-bind=none --mem-bind=none --label -- ./adastra_cpu_binding.sh ./$exePCM"
30########################################################################
31
32
33ulimit -s unlimited
34
35# Running the PCM
36read i_year n_year r_plnt2earth_yr iPCM iPEM nPCM nPCM_ini < launchPEM.info
37echo "Run \"PCM $iPCM\" is starting."
38cp run_PCM.def run.def
39eval "$exe_cmd > run.log 2>&1"
40if [ ! -f "restartfi.nc" ] || ! (tail -n 100 run.log | grep -iq "everything is cool!"); then # Check if it ended abnormally
41    echo "Error: the run \"PCM $iPCM\" crashed!"
42    if [ $mode -ne 0 ]; then
43        echo "Be careful: there may be dependent jobs remaining in the queue! You can cancel them by executing the script \"kill_launchPEM.sh\"."
44    fi
45    exit 1
46fi
47
48# Copy data files and prepare the next run
49mv run.log logs/runPCM${iPCM}.log
50if [ -f "diagfi.nc" ]; then
51    mv diagfi.nc diags/diagfi${iPCM}.nc
52fi
53if [ -f "diagsoil.nc" ]; then
54    mv diagsoil.nc diags/diagsoil${iPCM}.nc
55fi
56if [ -f "stats.nc" ]; then
57    mv stats.nc diags/stats${iPCM}.nc
58fi
59k=0
60if [ $(echo "$k > 0" | bc) -eq 1 ]; then # Only the last 2 years are taken for the PEM
61    cp Xoutdaily4pem.nc Xoutdaily4pem_Y${k}.nc
62    cp Xoutyearly4pem.nc Xoutyearly4pem_Y${k}.nc
63fi
64mv Xoutdaily4pem.nc diags/Xoutdaily4pem${iPCM}.nc
65mv Xoutyearly4pem.nc diags/Xoutyearly4pem${iPCM}.nc
66cp restartfi.nc starts/restartfi${iPCM}.nc
67mv restartfi.nc startfi.nc
68if [ -f "restart.nc" ]; then
69    cp restart.nc starts/restart${iPCM}.nc
70    mv restart.nc start.nc
71elif [ -f "restart1D.txt" ]; then
72    cp restart1D.txt starts/restart1D${iPCM}.txt
73    mv restart1D.txt start1D.txt
74fi
75((iPCM++))
76sed -i "1s/.*/$i_year $n_year $r_plnt2earth_yr $iPCM $iPEM $nPCM $nPCM_ini/" launchPEM.info
Note: See TracBrowser for help on using the repository browser.