Changeset 5850 for BOL


Ignore:
Timestamp:
Oct 6, 2025, 5:38:06 PM (7 weeks ago)
Author:
fhourdin
Message:

Improved era2gcm.sh

Location:
BOL/LMDZ_Setup
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • BOL/LMDZ_Setup/era2gcm.sh

    r5848 r5850  
    11#!/bin/bash
    22
    3 #---------------------------------------------------------------------------
    4 #  Getting and interpolating reanalaysis on the LMDZ grid for nudging
    5 #---------------------------------------------------------------------------
    6 #
    7 #  Developed by LMDZ team :
    8 #    F. Hourdin, A. Sima et al.
    9 #
    10 #  2025/10/03 : factorizing the code. era2gcm_tuto.sh should be obsolete.
    11 #               u10m and v10m to be added optionnally to make
    12 #               era2gcm_uv10m.sh obsolete too
    13 #               Automatic access to reanalysis on lmdz.lmd.jussieu.fr
    14 #
    15 #
    16 #  NB: for "cleanest" guiding, the 1st step of the next month should be
    17 #     added at the end of each month.
    18 #     wget http://forge.ipsl.jussieu.fr/igcmg/browser/TOOLS/INTERP_NUDGE
     3. lmdz_env.sh
     4
     5set -eu
     6
     7#-----------------------------------------------------------------------------
     8#
     9#  Script for interpolating monthly ERA* files to the LMDZ grid;
     10#  it creates the folder structure required by the LMDZ_Setup scripts
     11#
     12#  NB: for "cleanest" guiding, the 1st step of the next month should be added at the end of each month.
     13#    If you need such precision, you should use the scripts here  - AND adjust "ERADIR" in script_SIMU !
     14#    wget http://forge.ipsl.jussieu.fr/igcmg/browser/TOOLS/INTERP_NUDGE
    1915#      documented on LMDZpedia (search for "Guidage" )
    2016#
    21 #---------------------------------------------------------------------------
     17#-----------------------------------------------------------------------------
    2218# Requires : netcdf, ferret, nco, cdo
    23 #---------------------------------------------------------------------------
    24 . lmdz_env.sh
    25 set -eu
    26 
    27 #---------------------------------------------------------------------------
     19#-----------------------------------------------------------------------------
     20
     21#------------------------------------------------
    2822# User choices
    29 #---------------------------------------------------------------------------
     23#------------------------------------------------
    3024# Periode :
    3125mth_i=200001
    32 mth_f=202012
     26mth_f=200212
    3327#
    3428vars="u v ta q"
     
    3933resol_rea=075
    4034
    41 #---------------------------------------------------------------------------
    42 # Paths
    43 #---------------------------------------------------------------------------
     35#------------------------------------------------
     36
    4437ERA5_PATH="/gpfsstore/rech/psl/rpsl376/ergon/ERA5/"
    4538ERAI_PATH="/gpfsstore/rech/psl/rpsl376/ergon/ERAI/"
     
    5245#@ADS SCRATCH=$SCRATCHDIR
    5346
     47set -u  # raise error if path if unset on machine
     48echo "Paths: $ERA5_PATH $ERAI_PATH $SCRATCH"
     49set +u
     50
    5451GRID_DIR=./INIT
    5552
    56 #---------------------------------------------------------------------------
     53#-----------------------------------------------------------------------------
    5754#Utilite du block suivant a re-examiner :
    58 #---------------------------------------------------------------------------
     55#-----------------------------------------------------------------------------
    5956#L'utilisateur a maintenant des choix a faire en plus de mth* : type de guidage, et "rea"
    6057# Alors c'est plus facile d'editer&modifier le script, puis lancer avec ./era2gcm.sh, que de donner tous les params
     
    135132   if [ ! -d $ANA_DIR ] ; then echo Directory $ANA_DIR does not exist ; exit 1 ; fi
    136133
    137    ########################################################################
     134   #################################################################################
    138135   # Loop on variables among u, v, ta, q
    139    ########################################################################
     136   #################################################################################
    140137
    141138   for var in $vars ; do
     
    153150        file_rea="$ANA_DIR/AN_PL/$an/$var.$an$mois.$suf.nc"
    154151
    155         ###################################################################
     152        ############################################################################
    156153        # Automatically downloading reanalysis if needed
    157         ###################################################################
     154        ############################################################################
    158155        if [ "$( echo $ERAI_PATH | grep 3DInputData )" != "" ] ; then
    159156             if [ ! -f $file_rea ] ; then
     
    164161             fi
    165162         fi
    166          ###################################################################
     163         ############################################################################
    167164         # Checking the avaibility of reanalysis native file
    168          ###################################################################
     165         ############################################################################
    169166         if [ ! -f $file_rea ] ; then echo Reanalysis file $file_rea missing ; exit 1 ; fi
    170167
    171          ###################################################################
     168         ############################################################################
    172169         # Special treatments
    173          ###################################################################
     170         ############################################################################
    174171         if [ "$rea" = "ERAI" ] ; then
    175172             # original data in "short" should be changed to "float" for ferret
    176              ncap2 -s $var'=float('$var')' $file_rea -O tmp.nc
     173             ncap2 -s $var'=float('$var')' $file_rea -O tmp_in.nc
    177174         elif [ "$rea" = "ERA5" -a $an -ge 2022 ] ; then
    178175             # Recent analysis available on a daily basis
    179              cdo selhour,0,6,12,18 $file_rea -O tmp.nc
     176             cdo selhour,0,6,12,18 $file_rea -O tmp_in.nc
    180177         else
    181              ln -sf $file_rea tmp.nc
    182          fi
    183 
    184          ###################################################################
     178             ln -sf $file_rea tmp_in.nc
     179         fi
     180
     181         ############################################################################
    185182         # Dimensions of horizontal grid
    186          ###################################################################
     183         ############################################################################
    187184         case $var in
    188185            v) imjm="i=1:$iip1,j=1:$jjm" ;;
     
    190187         esac
    191188
    192          ###################################################################
     189         ############################################################################
    193190         # Grid to be used from grilles_gcm.nc
    194          ###################################################################
     191         ############################################################################
    195192         case $var in
    196193            u|v) grid=grille_$var ;;
     
    198195         esac
    199196
    200          ###################################################################
     197         ############################################################################
    201198         # Interpolating with ferret
    202          ###################################################################
     199         ############################################################################
    203200         cat <<.........eod......... >| tmp.jnl
    204201         ! NB : Augmenter la memoire (plus de 512) peut faire planter
    205202         set memory/size=512
    206203         use "$GRID_FI"
    207          use tmp.nc
     204         use tmp_in.nc
    208205         define axis/t="1-${month}-${an}:00:00":"${nday}-${month}-${an}:18:00":6/units=hours thour
    209206         ! Pour regrid horizontal on utilise la variable grille_s(lonv,latu) du fichier grilles_gcm.nc
    210207         !! Alors il faut renommer la variable à la fin (ncrename), car le code cherche "UWND", "VWND".
    211          save/clobber/file="$out_file" $var[d=2,gxy=${grid}[d=1],$imjm,$t0,gt=thour@asn]
    212          repeat/$t1tn save/file="$out_file"/append $var[d=2,gxy=${grid}[d=1],$imjm,gt=thour@asn]
     208         save/clobber/file="tmp_out.nc" $var[d=2,gxy=${grid}[d=1],$imjm,$t0,gt=thour@asn]
     209         repeat/$t1tn save/file="tmp_out.nc"/append $var[d=2,gxy=${grid}[d=1],$imjm,gt=thour@asn]
    213210.........eod.........
    214211
     212         set +e
    215213         ferret -nojnl <<.........eod.........
    216214         go tmp.jnl
    217215         quit
     216         fi
    218217.........eod.........
    219 
    220         ###################################################################
     218         if [ $? != 0 ] ; then
     219            echo Something went wrong when running ferret with script tmp.jnl :
     220            cat tmp.jnl
     221            echo On $PWD
     222            exit 1
     223         else
     224            set -e
     225            mv tmp_out.nc $out_file
     226         fi
     227
     228        ############################################################################
    221229        # Changing variable names
    222         ###################################################################
     230        ############################################################################
    223231         case $var in
    224232            u) out_var=UWND ;;
     
    227235            ta) out_var=AIR
    228236         esac
    229          # ferret a ecrit $varu en majuscules,
    230          # l'equivalent en bash est ${varu^^}
    231          # (Note : inversement, ${varu,,} passe $varu de majuscules
    232          # en minuscules)
     237         #Ferret a ecrit $varu en majuscules, l'equivalent en bash est ${varu^^}
     238         #   (Note : inversement, ${varu,,} passe $varu de majuscules en minuscules)
    233239         ncrename -v ${var^^},$out_var $out_file
    234240     fi
     
    236242
    237243
    238    #########################################################################
     244   ############################################################################
    239245   # Updating month counter
    240    #########################################################################
     246   ############################################################################
    241247   echo AN MTH $an $mois
    242248   (( mth = $mth + 1 ))
  • BOL/LMDZ_Setup/main.sh

    r5604 r5850  
    2626version="20241018.trunk"
    2727version="20250327.trunk"
     28version="20251001.trunk -unstable"
    2829
    2930svn=""
  • BOL/LMDZ_Setup/setup.sh

    r5723 r5850  
    682682#@JZ# de Slurm "multithread" fait bien référence à l'hyperthreading.
    683683#@JZ#SBATCH --hint=nomultithread    # 1 thread par coeur physique (pas d'hyperthreading)
    684 #@JZ#SBATCH --time=00:10:00         # Temps d'exécution maximum demandé (HH:MM:SS)
     684#@JZ#SBATCH --time=01:00:00         # Temps d'exécution maximum demandé (HH:MM:SS)
    685685#@JZ#SBATCH --output=Init%j.out     # Nom du fichier de sortie
    686686#@JZ#SBATCH --error=Init%j.out      # Nom du fichier d'erreur (ici commun avec la sortie)
     
    692692#@SP#SBATCH --cpus-per-task=1
    693693#@SP#SBATCH --hint=nomultithread
    694 #@SP#SBATCH --time=00:10:00
     694#@SP#SBATCH --time=01:00:00
    695695#@SP#SBATCH --output=Init%j.out
    696696#@SP#SBATCH --error=Init%j.out
Note: See TracChangeset for help on using the changeset viewer.