Changeset 4956 for BOL/LMDZ_Setup_amaury


Ignore:
Timestamp:
Jun 3, 2024, 1:06:29 PM (6 months ago)
Author:
abarral
Message:

(WIP) continue refactoring setup.sh
fix env vars

Location:
BOL/LMDZ_Setup_amaury
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • BOL/LMDZ_Setup_amaury/interp_aerosols.sh

    r4615 r4956  
    66
    77year=$1
    8 echo Dans interp_aerosols.sh year= $year
     8echo "Dans interp_aerosols.sh year= $year"
    99
    1010# Extraction d'un fichier de grille physique a partir de grilles_gcm.nc
     
    1212
    1313\rm -rf tmp*nc
    14 if [ 0 = 0 ] ; then
    15 imp1=`ncdump -h grilles_gcm.nc | grep lonv | head -1 | awk ' { print $3 } '`
    16 echo $imp1
    17 (( imm1 = $imp1 - 2 ))
    18 echo $imm1
    19 ncks -d lonv,0,$imm1 grilles_gcm.nc -v phis -O grille_phys.nc
    20 ncrename -v lonv,lon -v latu,lat -d lonv,lon -d latu,lat -O grille_phys.nc
    21 ncap2 -s "lon=-360.+lon" grille_phys.nc -O tmp.nc
    22 \mv -f tmp.nc grille_phys.nc
    23 #exit
     14if [[ 0 = 0 ]]; then
     15  imp1=$(ncdump -h grilles_gcm.nc | grep lonv | head -1 | awk ' { print $3 } ')
     16  echo "$imp1"
     17  (( imm1 = imp1 - 2 ))
     18  echo "$imm1"
     19  ncks -d "lonv,0,$imm1" grilles_gcm.nc -v phis -O grille_phys.nc
     20  ncrename -v lonv,lon -v latu,lat -d lonv,lon -d latu,lat -O grille_phys.nc
     21  ncap2 -s "lon=-360.+lon" grille_phys.nc -O tmp.nc
     22  \mv -f tmp.nc grille_phys.nc
     23  #exit 1
    2424fi
    2525
     
    2828
    2929orig=aerosols${year}_from_inca.nc
    30 ln -s $LMDZ_Init/$orig
     30ln -s "$LMDZ_INIT/$orig" .
    3131
    3232
     
    3535
    3636# Un cdo direct ne marche pas. Il faut donner la liste des variables ...
    37 vars="" ; for var in `ncdump -h $orig | grep float | sed -e 's/^.*.float //' | cut -d'(' -f1 | sed -e 's/ ;//' -e /lat/d -e /lon/d` ; do  vars="$vars,$var" ; done
     37vars=""
     38for var in $(ncdump -h "$orig" | grep float | sed -e 's/^.*.float //' | cut -d'(' -f1 | sed -e 's/;//' -e /lat/d -e /lon/d); do
     39  vars="$vars,$var"
     40done
    3841
    39 echo cdo remapcon,grille_phys.nc -selvar$vars $orig tmp.nc
    40 cdo remapcon,grille_phys.nc -selvar$vars $orig tmp.nc
     42echo cdo remapcon,grille_phys.nc "-selvar$vars" "$orig" tmp.nc
     43cdo remapcon,grille_phys.nc "-selvar$vars" "$orig" tmp.nc
    4144#ncks -v ps,ap,b,presnivs $orig -A tmp.nc
    42 nccopy -k classic tmp.nc aerosols.${year}.nc
     45nccopy -k classic tmp.nc "aerosols.$year.nc"
  • BOL/LMDZ_Setup_amaury/lmdz_env.sh

    r4955 r4956  
    3535                #    * On peut aussi ne pas installer les scripts a la racine de STORE,
    3636                #        mais dans STORED=$STORE/your_folder
    37     SIMRESDIR=$STORE
    38     SIMRUNTOPDIR="$SCRATCH/LMDZ_Setup"
     37    SIMRUNBASEDIR="$SCRATCH/LMDZ_Setup"
    3938    LMDZD=$WORK
    4039    NB_MPI_MAX=2000
     
    4746
    4847    ;;
    49   *)  # TODO mettre clairement dans ce paragraphe une doc de chaque param
     48  *) echo "WARNING: RUNNING THIS SCRIPT ON A LOCAL COMPUTER IS DISCOURAGED (lacklusted cpus and memory)"
     49    local_env_dir="/home/abarral/PycharmProjects/installLMDZ/LMDZ_Setup"; if [[ ! -d $local_env_dir ]]; then echo "STOP: local_env_dir $local_env_dir not found, either you are running on an unsupported cluster, or you haven't edited lmdz_env.sh properly"; exit 1; fi  # Can't use $(pwd) since this script gets copied and ran from several locations
    5050    ARCH="local-gfortran-parallel"
    51 #    submit=". "
    52 #    run="mpirun -np "
    53     SIMRUNTOPDIR="/tmp/SCRATCH/LMDZ_Setup/"  # Where the simulations will be executed  # TODO Change name if it's actually the SIMRUNDIR
    54     SIMRESDIR=~"/TMP/LMDZ_Setup"  # Where to store the relevant outputs of the simulations
    55     LMDZD="$(pwd)/LMDZD"  # Where the sources will be downloaded and compiled
    56     LMDZ_INIT="$(pwd)/LMDZ_Init"  # Where to store shared files used for initialisation
    57     NB_MPI_MAX=999999  # Max number of MPI cores
    58     NB_OMP_MAX=999999  # Max number of OMP threads
     51    SIMRUNBASEDIR="/tmp/SCRATCH/"  # Where the simulations will be executed ($SIMRUNBASEDIR/LMDZ_Setup/...)
     52    LMDZD="$local_env_dir/LMDZD"  # Where the sources will be downloaded and compiled
     53    LMDZ_INIT="$local_env_dir/LMDZ_Init"  # Where to store shared files used for initialisation
     54    NB_MPI_MAX=2  # Max number of MPI cores
     55    NB_OMP_MAX=1  # Max number of OMP threads
    5956    GROUPE=""  # the group to execute the job as
    60     RUNCMD="mpirun -n" # command to run a job, as $runcmd <nprocs> <script>
    61     SUBMITCMD="mpirun"  # command to sumbit a job, as $submitcmd <script>
     57    RUNCMD="mpirun -np" # command to run a job, as $runcmd <nprocs> <script>
     58    SUBMITCMD="."  # command to sumbit a job, as $submitcmd <script>
     59    ;;
    6260esac
    63 
    64 
    65 #echo LMDZ_Init dans lmdz_env $LMDZ_Init
  • BOL/LMDZ_Setup_amaury/script_SIMU

    r4955 r4956  
    1919
    2020set -ex
     21set +u  # Amaury 06/24: for local use (no $SLURM_CPUS_PER_TASK) - should be removed if we ever rewrite this whole legacy script properly...
    2122
    2223# Number of MPI processes :
    2324ntasks=8
     25# number of OpenMP threads
     26nthreads=8
     27export OMP_NUM_THREADS=$nthreads
    2428
    2529# For Jean-Zay (replacing the next 3 lines, commented out)
    26 export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
    27 ## number of OpenMP threads 
    28 ##nthreads=8
    29 ##export OMP_NUM_THREADS=$nthreads
     30#export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
    3031
    3132# private memory for each thread
     
    133134if [ "$climato" = "0" ] ; then calend=gregorian ; else calend=earth_360d ; fi
    134135bisextile=0
    135 if [ $(( $year % 4 )) = 0 -a $calend = gregorian ] ; then bisextile=1 ; fi
     136if [[ $(( year % 4 )) = 0 && $calend = gregorian ]] ; then bisextile=1 ; fi
    136137if [ $paran = 0 ] ; then
    137138   if [ "$calend" = "gregorian" ] ; then
     
    211212  fi
    212213
    213   ## Ca doit etre la meme liste de fichiers rapatriee par setup.sh dans $LMDZ_Init/SPLA_Init
     214  ## Ca doit etre la meme liste de fichiers rapatriee par setup.sh dans $LMDZ_INIT/SPLA_Init
    214215  ## et interpolee (setup.sh aussi) dans $SPLADIR
    215216  if [ $aerosols = spla ] ; then
     
    244245    set +e ; for t in stomate sechiba ; do cp $SIMUDIR/start_$t.$ym.nc ${t}_rest_in.nc ; done ; set -e
    245246    if [ "`grep RIVER_ROUTING orchidee.def |grep -i y`" ] ; then
    246       set +e ; ln -s $LMDZ_Init/routing_simple.nc . ; ln -s $LMDZ_Init/routing.nc .
     247      set +e ; ln -s $LMDZ_INIT/routing_simple.nc . ; ln -s $LMDZ_INIT/routing.nc .
    247248               cp $SIMUDIR/start_routing.$ym.nc routing_start.nc ; set -e
    248249    fi
     
    258259       echo "Autoinitialisation d'orchidee au besoin"
    259260       echo '#########################################################'
    260        get="ln -s $LMDZ_Init/"
     261       get="ln -s $LMDZ_INIT/"
    261262       for file in cartepente2d_15min.nc \
    262263          lai2D.nc soils_param.nc soil_bulk_and_ph.nc alb_bg_modisopt_2D_ESA_v2.nc reftemp.nc ; do ${get}$file ; done
     
    273274
    274275      if [ $veget = 7994 ] ; then
    275          get="ln -s $LMDZ_Init/"
     276         get="ln -s $LMDZ_INIT/"
    276277         for file in ndep_nhx.nc ndep_noy.nc nfert_cropland.nc nfert_pasture.nc nmanure_cropland.nc nmanure_pasture.nc bnf.nc ; do ${get}$file ; done
    277278      fi
     
    306307echo '##################################################################'
    307308
    308 time $run $ntasks ./gcm.e > listing
     309time $RUNCMD $ntasks ./gcm.e > listing
    309310if [ ! -f restartphy.nc ] ; then
    310311echo PROBLEME PAS DE FICHIER RESTARTPHY
  • BOL/LMDZ_Setup_amaury/setup.sh

    r4955 r4956  
    374374
    375375function setup_simu {
     376  SIMRUNTOPDIR="$SIMRUNBASEDIR/$(basename "$local")"
    376377  SIMRUNDIR=$SIMRUNTOPDIR
    377378  mkdir -p "$SIMRUNDIR"
     
    437438  -e "s/cpus-per-task=.*.$/cpus-per-task=$omp/" \
    438439  -e "s/nthreads=.*./nthreads=$omp/" \
    439   -e "s/MAINDIR=.*.$/MAINDIR=$(basename "$SIMRUNTOPDIR")/" \
    440   -e "s:STORED=.*.*:STORED=$SIMRESDIR:" \
    441   -e "s:SCRATCHD=.*.*:SCRATCHD=$(dirname "$SIMRUNTOPDIR"):" \
     440  -e "s/MAINDIR=.*.$/MAINDIR=$(basename "$local")/" \
     441  -e "s:STORED=.*.*:STORED=$(dirname $local):" \
     442  -e "s:SCRATCHD=.*.*:SCRATCHD=$SIMRUNBASEDIR:" \
    442443  -e "s/stopsim=.*.$/stopsim=$stopsim/" \
    443444  -e "s/^veget=.*.$/veget=$veget/" \
     
    537538function run_sim_or_init {
    538539  cd "$local"
     540
    539541  if [[ $init = 1 ]]; then
    540542    #####################################################################
     
    634636
    635637# ANCIEN MULTI STEP   interp )
    636 if [ $aerosols = clim ]; then
    637 cp $local/interp_aerosols.sh .; chmod +x interp_aerosols.sh
    638 # Les aerosols de l'annee 2000 ont ete remplaces par "9999" qui pointe vers un fichier moyen sur 1995-2014
    639 #for year in 2000 1850; do  ./interp_aerosols.sh \$year; done
    640 #mv aerosols.2000.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc
    641 for year in 9999 1850; do ./interp_aerosols.sh \$year; done
    642 mv aerosols.9999.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc
     638if [[ $aerosols = clim ]]; then
     639  cp $local/interp_aerosols.sh .; chmod +x interp_aerosols.sh
     640  # Les aerosols de l'annee 2000 ont été remplacés par "9999" qui pointe vers un fichier moyen sur 1995-2014
     641  #for year in 2000 1850; do  ./interp_aerosols.sh \$year; done
     642  #mv aerosols.2000.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc
     643  for year in 9999 1850; do ./interp_aerosols.sh \$year; done
     644  mv aerosols.9999.nc aerosols.clim.nc; mv aerosols.1850.nc aerosols.nat.nc
    643645fi
    644646
Note: See TracChangeset for help on using the changeset viewer.