source: BOL/LMDZ_Setup/script_SIMU @ 4796

Last change on this file since 4796 was 4796, checked in by asima, 4 months ago

The usual combination 5MPI * 8OMP per node crashes now with messages :

srun: warning: can't honor --ntasks-per-node set to 5 ... Ignoring --ntasks-per-node.
run: error: Unable to create step for job ...: More processors requested than permitted

(strangely enough, it still runs for 4MPI * 10OMP per node)

Solution adopted (and some comments added) : comment out "--ntasks-per-node=..."

For the record, other solutions that keep "--ntasks-per-node=..." :
--> add "--nodes=..." (=ntasks/ntasks-per-node)
--> or, replace "nthreads=8 ; export OMP_NUM_THREADS=$nthreads"

by "export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK"

(Not easy to have a job for HPC that could work, one day, on a PC as well...)

File size: 14.6 KB
Line 
1#!/bin/bash
2#
3#SBATCH --job-name=NOM_SIMU         # nom du job
4#SBATCH -A groupe@cpu
5# Nombre de processus MPI :
6#SBATCH --ntasks=8
7##### number of MPI processes per node : 40(procs/node on Jean-Zay) / cpus-per-task (ex : =5 for 8 OMP)
8####SBATCH --ntasks-per-node=5    # if specified, also add "#SBATCH --nodes= ..."  with nodes=ntasks/(ntasks-per-node)
9# nombre de threads OpenMP
10#SBATCH --cpus-per-task=8
11# de Slurm "multithread" fait bien reference a l'hyperthreading.
12#SBATCH --hint=nomultithread       # 1 thread par coeur physique (pas d'hyperthreading)
13#SBATCH --time=00:30:00            # Temps d execution maximum demande (HH:MM:SS)
14#SBATCH --output=outNOM_SIMU%j     # Nom du fichier de sortie
15#SBATCH --error=outNOM_SIMU%j      # Nom du fichier d'erreur (ici commun avec la sortie)
16#
17# To submit to test queue ; "time" (above) must be max 30 min
18# #SBATCH --qos=qos_cpu-dev
19
20set -ex
21
22# Number of MPI processes :
23ntasks=8
24# number of OpenMP threads 
25nthreads=8 
26export OMP_NUM_THREADS=$nthreads # for Jean-Zay it would be recommendend to use :
27#       export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
28# private memory for each thread
29export OMP_STACKSIZE=800M
30# Binding
31export OMP_PLACES=cores
32
33simul=NOM_SIMU
34ulimit -s unlimited
35#### reste ada  : export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/smplocal/pub/NetCDF/4.1.3/lib:/smplocal/pub/HDF5/1.8.9/seq/lib
36
37
38reseau_local=0
39#veget=y
40veget=CMIP6
41if [ $veget = NONE ] ; then VEGET=n ; else VEGET=y ; fi 
42
43isotopes=n
44# If isotopes=y, initialisation_iso will be changed to 0 in iso.def after the 1st run period, to read isotopes in restart files
45
46# Choice of aerosols : n / clim / spla
47aerosols=clim
48stopsim=201101
49ok_guide=y   # y/n guidage ou non
50climato=1
51orchidee_rev=5004
52
53echo '##############################################################'
54echo '# Gestion des repertoires de lancement                                 '
55echo '##############################################################'
56
57# Repertoires de la simulation
58SCRATCHD=$SCRATCH
59STORED=$STORE
60MAINDIR=LMDZOR96x95x79
61SIMU_dir=$MAINDIR/$simul
62SIMUDIR=$STORED/$SIMU_dir
63
64# Repertoires de travail
65WWORKD=$SCRATCHD/$SIMU_dir$$
66mkdir -p $WWORKD
67cd $WWORKD
68SCRIPTDIR=$SCRATCHD/$MAINDIR
69
70cp $STORED/$MAINDIR/lmdz_env.sh . ; . lmdz_env.sh
71ERADIR=$STORED/$MAINDIR/GUIDE
72if [ "$aerosols" = "spla" ] ; then ERA10mDIR=$STORED/$MAINDIR/ERA10m ; fi
73LIMITDIR=$STORED/$MAINDIR/LIMIT
74SPLADIR=$STORED/$MAINDIR/INPUT_SPLA
75DEFDIR=$SIMUDIR/DEF
76
77GET='ln -s'
78PUT='mv '
79
80
81echo '##################################################################'
82echo 'Gestion des mois et annees'
83echo '##################################################################'
84
85$GET $SIMUDIR/etat
86year=`tail -1 etat | awk ' { print $1 } ' | cut -c1-4`
87month=`tail -1 etat | awk ' { print $1 } ' | cut -c5-`
88echo year $year month $month
89
90if [ "$month" = "" ] ; then
91   paran=1
92   ym=$year
93   next=`expr $ym + 1`
94else
95   paran=0
96   if [ $month = 12 ] ; then
97      nextmonth=1
98      nextyear=`expr $year + 1`
99   else
100      nextmonth=`expr $month + 1`
101      nextyear=$year
102   fi
103   if [ `echo $nextmonth | wc -m` = 2  ] ; then
104      nextmonth=0$nextmonth
105   fi
106   ym=$year$month
107   next=$nextyear$nextmonth
108fi
109
110
111echo ym $ym
112echo mois ancien  : $ym
113echo mois nouveau : $next
114
115INI=${SPLADIR}/INITIAL
116PERIOD=${SPLADIR}/PERIOD00${month}/SUB
117
118echo '#################################################################'
119echo 'Modification de run.def et gcm.def pour prendre en compte la duree du'
120echo 'du mois en question.'
121echo 'le dayref est modifie pour tricher avec le calendrier (ecrit pour'
122echo 'une annee de 260 jours dans le modele).'
123echo 'On passe donc comme jour de reference le numero du jour du mois dans'
124echo 'une annee en 360 jours.'
125echo '#################################################################'
126
127# Choix du calendrier
128#AS: La condition if "$climato" = "0" suffit, car "$ok_guide" = "y" est interdit avec $climato" = "1" dans setup.sh (exit ligne 160)
129##calend=earth_360d
130##if [ "$ok_guide" = "y" -o "$climato" = "0" ] ; then calend=gregorian ; fi
131if [ "$climato" = "0" ] ; then calend=gregorian ; else calend=earth_360d ; fi
132bisextile=0
133if [ $(( $year % 4 )) = 0 -a $calend = gregorian ] ; then bisextile=1 ; fi
134if [ $paran = 0 ] ; then
135   if [ "$calend" = "gregorian" ] ; then
136      ndays=( 31 28 31 30 31 30 31 31 30 31 30 31 )
137      if [ $bisextile = 1 ] ; then ndays[1]=29 ; fi
138   else
139      ndays=( 30 30 30 30 30 30 30 30 30 30 30 30 )
140   fi
141   #Constants with a leading 0 are interpreted as octal numbers.
142   # You can remove the leading zero by parameter expansion: hour=${hour#0}
143
144   nday=${ndays[(( ${month#0} - 1 ))]}
145   ndayh=$nday
146   dayref=1 ; mm=1 ; while [ $mm -lt ${month#0} ] ; do
147    (( dayref = $dayref + ${ndays[(( $mm - 1 ))]} )) ; (( mm = $mm + 1 )) ; done
148else
149   dayref=1
150   if [ "$calend" = "gregorian" ] ; then
151      if [ $bisextile = 0 ] ; then nday=365 ; else nday=366 ; fi
152   else
153      nday=360 ; ndayh=30
154   fi
155fi
156
157echo CALENDRIER $calend : longueur du mois vrai $year $month $nday dayref=$dayref
158
159
160echo '####################################################################'
161echo '# On va chercher les fichiers necessaires a la simulation'
162echo '####################################################################'
163#Reminder : we are in $WWORKD = $SCRATCHD/$SIMU_dir = $SCRATCHD/$MAINDIR/$simul
164
165echo DEFDIR $DEFDIR
166echo SIMUDIR $SIMUDIR
167echo simul $simul
168
169if [ $reseau_local = 0 ] ; then mkdir DEF ; cd DEF ; $GET $DEFDIR/* . ; cd .. ; fi
170
171cp -f DEF/* .
172#---The following changes in .def files will only be visible in the running directory (on SCRATCH if $reseau_local = 0)
173# They concern variables that change during runtime : nday, dayref, anneeref, ndayh
174# The other "sed" were totally or partially moved in setup.sh, to be done in $MAINDIR/DEF/*.def, before creating $MAINDIR/$SIMU (more transparent)
175#sed -e 's/ok_guide=.*.$/ok_guide='$ok_guide'/' DEF/guide.def >| guide.def
176#sed -e 's/nday=.*.$/nday='$nday'/' -e 's/dayref=.*.$/dayref='${dayref}'/' -e 's/calend=.*.$/calend='$calend'/' -e 's/anneeref=.*.$/anneeref='$year'/' DEF/run.def >| run.def
177
178#=====!!!!!!!!====!!!!!!====!!!!+++====!!!!!!====!!!!!!!=====!!!!!!====z!!!====!!!!========!!!!!========!!!
179##POUR que des TESTS soyent tres RAPIDES (pour ex, verifier fichiers input), ON FORCE nday=1 jour  !!!
180#nday=1
181#=====!!!!!!!!====!!!!!!====!!!!+++====!!!!!!====!!!!!!!=====!!!!!!====z!!!====!!!!========!!!!!========!!!
182
183sed -e 's/nday=.*.$/nday='$nday'/' -e 's/dayref=.*.$/dayref='${dayref}'/' -e 's/anneeref=.*.$/anneeref='$year'/' DEF/run.def >| run.def
184sed -e 's/phys_out_filetimesteps=[[:space:]]*[0-9][0-9]day/phys_out_filetimesteps=  '$ndayh'day/'  DEF/config.def >| config.def
185#--- End of *.def changes in the $WWORKD only
186
187${GET} $SIMUDIR/start.$ym.nc start.nc
188${GET} $SIMUDIR/startphy.$ym.nc startphy.nc
189if [ $climato = 1 ] ; then
190   ${GET} $LIMITDIR/limit.nc limit.nc
191else
192   ${GET} $LIMITDIR/limit.$year.nc limit.nc
193fi
194
195
196echo '####################################################################'
197echo '# Imports des fichiers aerosols si flag_aerosol>0 dans config.def, '
198echo '# et si dans setup.sh on a "aerosols=clim" ou "aerosols=spla". '
199echo '# NOTE: Si "aerosols=n" dans setup.sh, script_SIMU met flag_aerosol=0 et on tourne SANS aerosols' 
200echo '####################################################################'
201if [ "`grep 'flag_aerosol=' config.def | head -1 | cut -d= -f2`" != 0 ] ; then
202  if [ $aerosols = clim ] ; then
203    # if [ $climato = 1 ] ; then suf=clim ; else suf=$year ; fi
204    suf=clim
205    # Le script pourrait être sophistique pour prendre des aerosols interannuels
206    ${GET} $LIMITDIR/aerosols.$suf.nc aerosols$year.nc
207    if [ ! -f aerosols1980.nc ] ; then ${GET} $LIMITDIR/aerosols.$suf.nc aerosols1980.nc ; fi
208    ${GET} $LIMITDIR/aerosols.nat.nc aerosols.nat.nc
209  fi
210
211  ## Ca doit etre la meme liste de fichiers rapatriee par setup.sh dans $LMDZ_Init/SPLA_Init
212  ## et interpolee (setup.sh aussi) dans $SPLADIR
213  if [ $aerosols = spla ] ; then 
214    inputf="wth.dat cly.dat donnees_lisa.nc SOILSPEC.data \
215                carbon_emissions.nc sulphur_emissions_antro.nc  \
216                sulphur_emissions_nat.nc  sulphur_emissions_volc.nc"
217    for file in $inputf ; do ${GET} $INI/$file . ; done
218
219    change="dust.nc "
220    for file in $change ; do ${GET} $PERIOD/$file . ; done
221
222    # Le calcul d'emissions de sels marins utilise les vents ERA-10m interpoles sur grille_s (lonv,latu) avec le script era2gcm_uv10m.sh
223    # NB : GET=ln -s ; ERA10mDIR contient lui-meme le lien ERA10m vers le repertoire des vents interpoles $REA_uv10m (REA=ERA5, ERAI ou OPERA)
224    ventl="u10m.nc v10m.nc"
225    for file in $ventl ; do ${GET} $ERA10mDIR/${year}/${month}/$file . ; done
226  fi
227fi
228
229#----------------------------------------
230# Noveaux forcages a activer a l'avenir
231#   (commentes en attendant) :
232#----------------------------------------
233#for file in climoz_LMDZ.nc solarforcing.nc  taulwstrat.2D.nc  tauswstrat.2D.nc ; do
234#   ${GET} $LIMITDIR/$file $file
235#done
236#----------------------------------------
237
238${GET} $SIMUDIR/gcm.e gcm.e ; chmod  +x gcm.e
239
240
241if [ $VEGET = y ] ; then
242    set +e ; for t in stomate sechiba ; do cp $SIMUDIR/start_$t.$ym.nc ${t}_rest_in.nc ; done ; set -e
243    if [ "`grep RIVER_ROUTING orchidee.def |grep -i y`" ] ; then
244      set +e ; ln -s $LMDZ_Init/routing_simple.nc . ; ln -s $LMDZ_Init/routing.nc .
245               cp $SIMUDIR/start_routing.$ym.nc routing_start.nc ; set -e
246    fi
247
248#For Orchidee trunk (post-CMIP6), orchidee_pft.def must be copied in addition to orchidee.def
249    \cp -f DEF/orchidee*.def .
250
251# Test sur sechiba_rest_in.nc,
252#  supposant que les restarts pour sechiba, stomate, et routing le cas echeant,
253#  sont soit tous dispo, soit tous absents
254    if [ ! -f sechiba_rest_in.nc ] ; then
255       echo '#########################################################'
256       echo Autoinitialisation d orchidee au besoin
257       echo '#########################################################'
258       get="ln -s $LMDZ_Init/"
259       for file in cartepente2d_15min.nc \
260          lai2D.nc soils_param.nc soil_bulk_and_ph.nc alb_bg_modisopt_2D_ESA_v2.nc reftemp.nc ; do ${get}$file ; done
261
262       ln -sf alb_bg_modisopt_2D_ESA_v2.nc alb_bg.nc
263
264       echo ATTENTION : ON UTILISE LES FICHIERS DE L ANNEE 2000
265       ${get}PFTmap_15PFT.v1_2000.nc PFTmap.nc
266       ${get}woodharvest_2000.nc woodharvest.nc
267
268       sed -e 's/^SECHIBA_restart_in.*./SECHIBA_restart_in=NONE/' \
269           -e 's/^STOMATE_RESTART_FILEIN.*./STOMATE_RESTART_FILEIN=NONE/' \
270           -i orchidee.def
271
272      if [ $veget = 7994 ] ; then
273         get="ln -s $LMDZ_Init/"
274         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
275      fi
276
277    fi
278
279fi
280
281
282echo '#################################################################'
283echo    'Repertoire contenant les fichiers de reanalyses'
284echo '#################################################################'
285
286if [ "$ok_guide" = "y" ] ; then
287   \rm -f u.nc v.nc T.nc hur.nc
288   if [ -f u.nc ] ; then
289      echo PROBLEME D EFFACEMENT DES FICHIERS DE REANALYSES
290      exit
291   fi
292   for var in u v T hur ; do $GET $ERADIR/$year/$month/$var.nc $var.nc ; done
293   echo Fin du rapatriement des fichiers de guidage
294fi
295
296echo '##################################################################'
297echo    'liste des fichiers avant le lancement de la simulation'
298echo '##################################################################'
299ls -lrt
300#diff DEF ./
301
302echo '##################################################################'
303echo    'Lancement de la simulation'
304echo '##################################################################'
305
306time $run $ntasks ./gcm.e > listing
307if [ ! -f restartphy.nc ] ; then
308echo PROBLEME PAS DE FICHIER RESTARTPHY
309exit
310fi
311
312echo '##################################################################'
313echo     'sauvegarde des fichiers de sortie'
314echo '##################################################################'
315
316# listing
317${PUT} listing ${SIMUDIR}/list$ym
318# if the listing for Orchidee is also needed, then uncomment the following line :
319#if [ $VEGET = y ] ; then ${PUT} out_orchidee_0000.0000 ${SIMUDIR}/out_orchidee$ym ; fi
320
321# restart(s)
322${PUT} restart.nc ${SIMUDIR}/start.$next.nc
323${PUT} restartphy.nc ${SIMUDIR}/startphy.$next.nc
324if [ $VEGET = y ] ; then for t in sechiba stomate ; do
325    f=${t}_rest_out.nc ; if [ -f $f ] ; then ${PUT} $f ${SIMUDIR}/start_$t.$next.nc ; fi ; done 
326    f=routing_restart.nc ; if [ -f $f ] ; then ${PUT} $f ${SIMUDIR}/start_routing.$next.nc ; fi
327fi
328
329# fichiers "histoires"
330# Si on tourne avec xios (et type="one_file") au lieu de ioipsl, on n'a pas besoin de rebuild, on doit juste copier les fichiers
331liste_out="histmth histday histhf histmthCOSP Xhistins XhistLES sechiba_history sechiba_history_4dim sechiba_out_2 stomate_history stomate_ipcc_history diag_routing dynzon"
332xios_used=0
333
334for fileout in $liste_out ; do
335  if [ -f  $fileout.nc ] ; then 
336     ${PUT} $fileout.nc ${SIMUDIR}/$fileout.$ym.nc
337     xios_used=1
338  fi
339done
340
341if [ $xios_used = 0 ] ; then
342  $GET $SIMUDIR/reb.sh
343  chmod +x reb.sh
344  ./reb.sh $ym $SIMUDIR $liste_out
345fi
346
347if [ -f guide_ins.nc ] ; then ${PUT} guide_ins.nc ${SIMUDIR}/guide_ins.$ym.nc ; fi
348
349echo '##################################################################'
350echo     'preparation et lancement de la simulation suivante'
351echo '##################################################################'
352
353# Gestion du fichier etat de controle de la simulation
354echo $ym OK >> etat
355echo $next a faire >> etat
356# ${PUT} etat $SIMUDIR/etat # Pas necessaire car etat est un lien vers $SIMUDIR/etat
357
358# set initialisation_iso to 0 for next run to read isotopes from restart files
359if [ $isotopes = y ] ; then
360   sed -i 's/^initialisation_iso=.*.$/initialisation_iso=0/' $SIMUDIR/DEF/iso.def
361fi
362set +e ; \rm out* sec* sta* list* rest* gcm.e aer* ; set -e
363
364# Arret si on est arrive au bout
365if [ $next =  $stopsim ] ; then
366   echo 'On arrive au bout, simulation next:'$next', stopsim:'$stopsim
367   # Cas particulier ou on veut chainer plusieurs simulations multi annuelles.
368   # pour le tuning automatique.
369   # Ici on passe de SCM_1-019 a SCM_1-029
370   if [ "${simul:0:3}" = "SCM" ] ; then
371      pre="SCM_1-"
372      num=`echo $simul | sed -e 's/'$pre'//'`
373      # (( num = $num + 10 )) change a cause d un probleme avec 008
374      num=`echo $num | awk ' { print $1 + 10 } '`
375      num=`printf "%03d\n" $num`
376      simul_new=$pre$num
377      cd $SCRIPTDIR
378      if [ $num -le 250 ] ; then
379         sed -e 's/^simul=.*.$/simul='$simul_new'/' -e 's/^\# @ job_nam.*.=.*.$/\# @ job_name = '$simul_new'/' tmp_$simul >| tmp_$simul_new
380         sbatch tmp_$simul_new
381      fi
382   fi
383   exit
384fi
385
386
387echo '##################################################################'
388echo      'lancement de la simulation suivante tmp_'$simul' depuis :'
389echo '##################################################################'
390pwd
391
392
393cd $SCRIPTDIR
394sbatch tmp_$simul
Note: See TracBrowser for help on using the repository browser.