source: tags/libIGCM_v2.2/AA_job

Last change on this file was 988, checked in by sdipsl, 10 years ago

heads up handy option

  • Property licence set to
    The following licence information concerns ONLY the libIGCM tools
    ==================================================================

    Copyright © Centre National de la Recherche Scientifique CNRS
    Commissariat à l'Énergie Atomique CEA

    libIGCM : Library for Portable Models Computation of IGCM Group.

    IGCM Group is the french IPSL Global Climate Model Group.

    This library is a set of shell scripts and functions whose purpose is
    the management of the initialization, the launch, the transfer of
    output files, the post-processing and the monitoring of datas produce
    by any numerical program on any plateforme.

    This software is governed by the CeCILL license under French law and
    abiding by the rules of distribution of free software. You can use,
    modify and/ or redistribute the software under the terms of the CeCILL
    license as circulated by CEA, CNRS and INRIA at the following URL
    "http://www.cecill.info".

    As a counterpart to the access to the source code and rights to copy,
    modify and redistribute granted by the license, users are provided only
    with a limited warranty and the software's author, the holder of the
    economic rights, and the successive licensors have only limited
    liability.

    In this respect, the user's attention is drawn to the risks associated
    with loading, using, modifying and/or developing or reproducing the
    software by the user in light of its specific status of free software,
    that may mean that it is complicated to manipulate, and that also
    therefore means that it is reserved for developers and experienced
    professionals having in-depth computer knowledge. Users are therefore
    encouraged to load and test the software's suitability as regards their
    requirements in conditions enabling the security of their systems and/or
    data to be ensured and, more generally, to use and operate it in the
    same conditions as regards security.

    The fact that you are presently reading this means that you have had
    knowledge of the CeCILL license and that you accept its terms.
  • Property svn:keywords set to Revision Author Date
File size: 19.0 KB
Line 
1#-Q- curie #!/bin/ksh
2#-Q- curie ######################
3#-Q- curie ## CURIE   TGCC/CEA ##
4#-Q- curie ######################
5#-Q- curie #MSUB -r ::Jobname::       # nom de la requete
6#-Q- curie #MSUB -o Script_Output_::Jobname::.000001    # nom du fichier de sortie
7#-Q- curie #MSUB -e Script_Output_::Jobname::.000001    # nom du fichier de sortie
8#-Q- curie #MSUB -eo
9#-Q- curie #MSUB -n ::JobNumProcTot:: # reservation des processeurs pour le job
10#-Q- curie #MSUB -T 86400             # Limite temps (en secondes)
11#-Q- curie #MSUB -q standard
12#-Q- curie #MSUB -A ::default_project::
13#-Q- curie BATCH_NUM_PROC_TOT=$BRIDGE_MSUB_NPROC
14#-Q- curie set +x
15#-Q- ada #!/bin/ksh
16#-Q- ada # ######################
17#-Q- ada # ##  ADA       IDRIS ##
18#-Q- ada # ######################
19#-Q- ada # Nom de la requete
20#-Q- ada # @ job_name = ::Jobname::
21#-Q- ada # Type de travail
22#-Q- ada # @ job_type = parallel
23#-Q- ada # Fichier de sortie standard
24#-Q- ada # @ output = Script_Output_::Jobname::.000001
25#-Q- ada # Fichier de sortie erreur (le meme)
26#-Q- ada # @ error = Script_Output_::Jobname::.000001
27#-Q- ada # Nombre de processus demandes
28#-Q- ada # @ total_tasks = ::JobNumProcTot::
29#-Q- ada # @ environment = "BATCH_NUM_PROC_TOT=::JobNumProcTot::"
30#-Q- ada # Temps CPU max. par processus MPI hh:mm:ss
31#-Q- ada # @ wall_clock_limit = 1:00:00
32#-Q- ada # Nombre de taches OpenMP/pthreads par processus MPI
33#-Q- ada ### @ parallel_threads = 4
34#-Q- ada # Fin de l entete
35#-Q- ada # @ queue
36#-Q- lxiv8 ######################
37#-Q- lxiv8 ## OBELIX      LSCE ##
38#-Q- lxiv8 ######################
39#-Q- lxiv8 #PBS -N ::Jobname::
40#-Q- lxiv8 #PBS -m a
41#-Q- lxiv8 #PBS -j oe
42#-Q- lxiv8 #PBS -q medium
43#-Q- lxiv8 #PBS -o Script_Output_::Jobname::.000001
44#-Q- lxiv8 #PBS -S /bin/ksh
45#-Q- lxiv8 #PBS -v BATCH_NUM_PROC_TOT=::JobNumProcTot::
46#-Q- lxiv8 #PBS -l nodes=1:ppn=::JobNumProcTot::
47#-Q- default #!/bin/ksh
48#-Q- default ##################
49#-Q- default ## DEFAULT HOST ##
50#-Q- default ##################
51#-Q- default #For MPI use, uncomment next line :
52#-Q- default #BATCH_NUM_PROC_TOT=::JobNumProcTot::
53
54#**************************************************************
55# Author: Sebastien Denvil
56# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr
57# $Revision::                                          $ Revision of last commit
58# $Author::                                            $ Author of last commit
59# $Date::                                              $ Date of last commit
60# IPSL (2006)
61#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
62#
63#**************************************************************
64
65#set -eu
66#set -vx
67
68date
69echo
70echo "#######################################"
71echo "#       ANOTHER GREAT SIMULATION      #"
72echo "#######################################"
73echo
74
75#D--------------------------------------------------------------------==
76#D-
77#D-                      Job to launch IGCM models
78#D-
79#D--------------------------------------------------------------------==
80#D-
81
82MODIPSL=::modipsl::
83libIGCM=${MODIPSL}/libIGCM
84
85#D--------------------------------------------------------------------==
86#D- -1. PLACE FOR USER MODIFICATION
87#D-     - Job Verbosity
88#D-     - PeriodNb
89#D-     - Experience type : DEB(ug), DEV(elopment), RUN
90#D--------------------------------------------------------------------==
91
92#D- Task type (computing or post-processing)
93TaskType=computing
94#D- Increased verbosity (1, 2, 3)
95Verbosity=3
96#D- Experience type : DEB(ug), DEV(elopment), RUN (default)
97JobType=RUN
98#D- Number of execution in one job
99PeriodNb=1
100#-Q- sx9mercure PeriodNb=60
101
102#D-
103#D- --------------------------------------------------------------------------------------------------#
104#D-                          ! OPTIONNAL FEATURES /!\ USE WITH CARE !                                 #
105#D- --------------------------------------------------------------------------------------------------#
106
107
108#D- Low level debug : to bypass lib test checks and stack construction
109#D- Default=true
110#D-
111DEBUG_debug=false
112
113#D- Messaging : all activities and call stacks will be sent to ipsl servers
114#D- If true will imply DEBUG_debug=true
115#D- Default=false
116#D-
117BigBrother=false
118
119#D- Set DEBUG_sys to false to disable output calls of function
120#D- true when JobType=DEB # means DEB(ug)
121#D-
122#DEBUG_sys=false
123
124#D- Define running directory
125#D- Default=${TMPDIR} ie temporary batch directory
126#D-
127#RUN_DIR_PATH=/workdir/or/scratchdir/of/this/machine
128
129#D- Define submit directory
130#D- Default= where you launch qsub (variable from scheduler)
131#D-
132#SUBMIT_DIR=$( pwd )
133
134#D- Define input file root directory
135#D- Default=/IGCMG/common/account/of/this/machine
136#D-
137#R_IN=/u/rech/por/rpor111/DATA
138
139#D- Turn in dry run mode ? (0,1,2,3)
140#D- Default=0
141#D-
142#DRYRUN=3
143#D-# YOU HAVE TO COMPILE YOUR EXE FILES to USE DRYRUN MODE !
144#D-# -------------------------------------------------------------------------------------
145#D-# | DRYRUN=  |  Date computations, | sys_Get    |  Exe    | sys_Put_Out; sys_Put_Rest |
146#D-# |          |  Cp/Exe/param/files |            |         |                           |
147#D-# |          |  Chmod Qsub         |            |         |                           |
148#D-# -------------------------------------------------------------------------------------
149#D-# |    0     |       yes           |    yes     |  yes    |      yes                  |
150#D-# -------------------------------------------------------------------------------------
151#D-# |    1     |       yes           |    yes     |  yes    |      no                   |
152#D-# -------------------------------------------------------------------------------------
153#D-# |    2     |       yes           |    yes     |  no     |      no                   |
154#D-# -------------------------------------------------------------------------------------
155#D-# |    3     |       yes           |    no      |  no     |      no                   |
156#D-# -------------------------------------------------------------------------------------
157
158#D-
159# --------------------------------------------------------------------------------------------------#
160#D- ! END OF OPTIONNAL FEATURES /!\ DO NOT MODIFY ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING #
161# --------------------------------------------------------------------------------------------------#
162
163#D-
164#D--------------------------------------------------------------------==
165#D- 0. SYSTEM ENVIRONMENT
166#D-    - Define variables for Number of processors
167#D-    - Define MPI variables
168#D-    - Define batch scheduler variables
169#D-    - Source IGCM Library
170#D-    - Get RESOLution in .resol file (temporary)
171#D--------------------------------------------------------------------==
172
173#---------------------------------------------------------------------==
174
175. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
176. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
177. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
178#-------
179. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
180. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
181. ${libIGCM}/libIGCM_comp/libIGCM_comp.ksh
182. ${libIGCM}/libIGCM_post/libIGCM_post.ksh
183#-------
184( ${DEBUG_debug} ) && IGCM_debug_Check
185( ${DEBUG_debug} ) && IGCM_card_Check
186( ${DEBUG_debug} ) && IGCM_date_Check
187
188#--------------------------------------------------------------------==
189
190#-- Resolution FLAG for oasis input
191#RESOL="ORCA2xLMD9671"
192[ -f ${SUBMIT_DIR}/../.resol ] && RESOL=$(head -1 ${SUBMIT_DIR}/../.resol)
193#-- Chemistrie FLAG to ease chemistries configurations management
194#CHEM="AER"
195[ -f ${SUBMIT_DIR}/../.chimie ] && eval $(grep CHEM ${SUBMIT_DIR}/../.chimie)
196
197#D-
198#D--------------------------------------------------------------------==
199#D- 1. INITIALIZE CONFIGURATION
200#D-    - Simulation configuration
201#D-    - Simulation parameters
202#D-    - Execution parameter
203#D-    - Define input files directory
204#D-    - Read or initialize CumulPeriod
205#D-    - run.card
206#D---------------------------------------------------------------------==
207IGCM_config_Initialize
208
209# --------------------------------------------------------------------==
210# Define, create and cd RUN_DIR
211# --------------------------------------------------------------------==
212RUN_DIR=${RUN_DIR_PATH}/${config_UserChoices_JobName}.${$}
213IGCM_sys_MkdirWork ${RUN_DIR}
214IGCM_sys_Cd ${RUN_DIR}
215
216# ------------------------------------------------------------------
217# Test if all was right before proceeding further
218# ------------------------------------------------------------------
219IGCM_debug_Verif_Exit
220
221#D-
222#D---------------------------------------------------------------------==
223#D- 2. INITIALIZE ALL COMPONENT OF THE CONFIGURATION
224#D-    - Define component executable
225#D-    - Define Write Frequency by component "1M" "1D" ...
226#D-    - Source ${comp}.driver
227#D-    - Define Storage Places by component
228#D-    - ${comp}_Initialize :
229#D-    - Patterns to sed
230#D-    - Variables from namelist
231#D---------------------------------------------------------------------==
232IGCM_comp_Initialize
233
234#D-
235#D---------------------------------------------------------------------==
236#D- 3. PERFORM GENERAL VERIFICATION
237#D-    - Verify compatibility of period length, write frequencies, ...
238#D-    - Verify compatibility of rebuild choices and post-process choices
239#D-    - Will stop here if something is wrong
240#D---------------------------------------------------------------------==
241IGCM_config_Check
242
243# ------------------------------------------------------------------
244# Test if all was right before entering the period loop
245# ------------------------------------------------------------------
246IGCM_debug_Verif_Exit
247
248# ------------------------------------------------------------------
249# Activate BigBrother so as to supervise this simulation
250# ------------------------------------------------------------------
251IGCM_debug_ActivateBigBro
252
253#D-
254#D---------------------------------------------------------------------==
255#D- 4. ENTER THE DEEP EXECUTION LOOP
256#D-    ! FASTEN YOUR SEAT BELTS PLEASE. !
257#D-    !   WE WILL CROSS TURBULENCES.   !
258#D---------------------------------------------------------------------==
259
260Period=1
261
262PeriodContinue=false
263if [ ${Period} -le ${PeriodNb} ]; then
264  PeriodContinue=true
265fi
266while ( ${PeriodContinue} ) ; do
267
268  echo
269  echo "Starting iteration ${Period} / ${PeriodNb}"
270
271  #D-
272  # ------------------------------------------------------------------
273  #D-   4.1 COMPUTE AND DEFINE DATE INFORMATION.
274  #D-       - ${PeriodDateBegin}
275  #D-       - ${PeriodDateEnd}
276  #D-       - ${CumulPeriod}
277  #D-       - ${DatesPeriod}=${PeriodDateBegin}_${PeriodDateEnd}
278  #D-       - ${PeriodLength} => JOURS=31 , 28, 29, 30 ; MOIS=0 ; ANS=0
279  #D-       - update run.card value
280  # ------------------------------------------------------------------
281  IGCM_config_PeriodStart
282
283  #D-
284  # ------------------------------------------------------------------
285  #D-   4.2 BEGIN COMPUTATION ONLY IF NEEDED
286  # ------------------------------------------------------------------
287  if [ ${SimulationLengthInDays} -gt ${ExperienceLengthInDays} ] ; then
288    IGCM_debug_Print 1 "break because '${SimulationLengthInDays} -gt ${ExperienceLengthInDays}' : ${SimulationLengthInDays} -gt ${ExperienceLengthInDays}"
289    break ;
290  fi
291
292  #D-
293  # ------------------------------------------------------------------
294  #D-   4.3 CALL OPTIONNAL FUNCTION WITHIN DRIVER
295  #D-       - to set special variables used in lists (Param, Init or Bc).
296  # ------------------------------------------------------------------
297  IGCM_comp_PeriodStart
298
299  #D-
300  # ------------------------------------------------------------------
301  #D-   4.4 GET PARAMETERS TEXT FILES UPDATED BY JOB
302  #D-       - (.def, namelist ...)
303  #D-       - READ AND USE BY GCM AT EACH EXECUTION.
304  # ------------------------------------------------------------------
305  IGCM_comp_GetInputParametersFiles
306
307  #D-
308  # ------------------------------------------------------------------
309  #D-   4.5 GET INITIAL STATE
310  #D-       - (Etat0, carteveg,relief...)
311  #D-       - NECESSARY ONLY IF CumulPeriod= (=> NUMERO) == 1
312  #D-       - AND ???_Restart=NO
313  #D-       - READ AND USE BY GCM FOR ONLY ONE EXECUTION.
314  # ------------------------------------------------------------------
315  IGCM_comp_GetInputInitialStateFiles
316
317  #D-
318  # ------------------------------------------------------------------
319  #D-   4.6 GET BOUNDARIES CONDITIONS
320  #D-       - (SST, WIND[X,Y,Z], LAI ...)
321  #D-       - READ AND USE BY GCM AT EACH EXECUTION.
322  # ------------------------------------------------------------------
323  IGCM_comp_GetInputBoundaryFiles
324
325  #D-
326  # ------------------------------------------------------------------
327  #D-   4.7 GET SmoothFiles CONDITIONS
328  #D-       - (SST, WIND[X,Y,Z], LAI ...)
329  #D-       - READ AND USE BY GCM AT EACH EXECUTION
330  #D-       - Do not change at each ${Period}
331  # ------------------------------------------------------------------
332  IGCM_comp_GetInputSmoothFiles
333
334  #D-
335  # ------------------------------------------------------------------
336  #D-   4.8 GET RESTART FILES
337  #D-       - (restartphy.nc, orca_restart.nc ...)
338  #D-       - READ AND USE BY GCM AT EACH EXECUTION.
339  #D-
340  #D-       - IF A COMPONENT DO NOT RESTART FROM PREVIOULSY COMPUTED RESTART
341  #D-       - ONLY IF CumulPeriod= (=> NUMERO) == 1
342  #D-       - MUST EXECUTE CREATE ETAT0_LIMIT (TYPICALLY LMDZ AND ./create_etat0_limit.e)
343  #D-
344  #D-       - IF CumulPeriod == 1
345  #D-       - AND A COMPONENT RESTART FROM PREVIOULSY COMPUTED RESTART
346  #D-       - MUST BRING THIS RESTART IN ${RUN_DIR_PATH}
347  #D-
348  #D-       - ELSE BRING RESTART FROM ${JobName} IN ${RUN_DIR_PATH}
349  # ------------------------------------------------------------------
350  IGCM_comp_GetInputRestartFiles
351
352  # ------------------------------------------------------------------
353  # Test if all was right before Update
354  # ------------------------------------------------------------------
355  IGCM_debug_Verif_Exit
356
357  #D-
358  # ------------------------------------------------------------------
359  #D-   4.9 ACTIVATE RUNNING ENVIRONNEMENT VARIABLES
360  # ------------------------------------------------------------------
361  IGCM_sys_activ_variables
362
363  #D-
364  # ------------------------------------------------------------------
365  #D-   4.10 UPDATE ParametersFiles
366  #D-        - (.def, namelist ...)
367  #D-        - with current value of (ORCA_NIT00, ORCA_LRSTAR, RAZ_DATE, ...)
368  # ------------------------------------------------------------------
369  IGCM_comp_Update
370
371  # ------------------------------------------------------------------
372  # Test if all was right before execution
373  # ------------------------------------------------------------------
374  IGCM_debug_Verif_Exit
375
376  #D-
377  #D---------------------------------------------------------------------==
378  #D- 5. EXECUTION
379  #D---------------------------------------------------------------------==
380
381  echo
382  echo "#######################################"
383  echo "#      DIR BEFORE RUN EXECUTION       #"
384  echo "#######################################"
385  echo
386  ls -lrt
387
388  echo "========================================================================"
389  if [ ${DRYRUN} -le 1 ] ; then
390    REAL_DATE_INIT=$( date )
391    echo                                                                                   > ${Exe_Output}
392    echo "#######################################"                                        >> ${Exe_Output}
393    echo "EXECUTION of : ${EXECUTION}"
394    echo "EXECUTION of : ${EXECUTION}"                                                    >> ${Exe_Output}
395    echo                                                                                  >> ${Exe_Output}
396    typeset RET
397    RUN_DATE_BEGIN=$( date '+%Y-%m-%dT%H:%M:%S' )
398    ${EXECUTION}  >> ${Exe_Output} 2>&1
399    RET=$?
400    RUN_DATE_END=$( date '+%Y-%m-%dT%H:%M:%S' )
401    if [ ${RET} -gt 0 ] ; then
402      echo "Return code of executable :" ${RET}
403      IGCM_debug_Exit "EXECUTABLE"
404      IGCM_sys_Mkdir ${SUBMIT_DIR}/Debug
405      IGCM_sys_Cp ${Exe_Output} ${SUBMIT_DIR}/Debug/${PREFIX}_${Exe_Output}_error
406      ExecutionFail=true
407    fi
408    echo                                            >> ${Exe_Output}
409    echo "#######################################"  >> ${Exe_Output}
410    echo "libIGCM RunDateBegin=${RUN_DATE_BEGIN}"   >> ${Exe_Output}
411    echo "libIGCM RunDateEnd=${RUN_DATE_END}"       >> ${Exe_Output}
412    echo                                            >> ${Exe_Output}
413  else
414    echo "EXECUTION of : ${EXECUTION} simulated for DRYRUN = " $DRYRUN
415    echo "EXECUTION of : ${EXECUTION} simulated for DRYRUN = " $DRYRUN > ${Exe_Output}
416    if ( $DEBUG_debug ) ; then
417      echo "FOR EXECUTION DRYRUN mode = " $DRYRUN >> stack
418    fi
419  fi
420  echo "========================================================================"
421
422  echo
423  echo "#######################################"
424  echo "#       DIR AFTER RUN EXECUTION       #"
425  echo "#######################################"
426  echo
427  ls -lrt
428
429  #D-
430  #D---------------------------------------------------------------------==
431  #D- 6. POST EXECUTION OPERATIONS
432  #D---------------------------------------------------------------------==
433
434  #D-
435  # ------------------------------------------------------------------
436  #D-   6.1. DESACTIVATE RUNNING ENVIRONNEMENT VARIABLES
437  # ------------------------------------------------------------------
438  IGCM_sys_desactiv_variables
439
440  #D-
441  # ------------------------------------------------------------------
442  #D-   6.2. SAVE OUTPUTS
443  #D-        - On archive/storage machine
444  #D-        - netcdf outputs, restarts and text files of models
445  # ------------------------------------------------------------------
446  IGCM_comp_Finalize
447
448  # ------------------------------------------------------------------
449  # Test if all was right after Finalize
450  # ------------------------------------------------------------------
451  IGCM_debug_Verif_Exit
452
453  #D-
454  # ------------------------------------------------------------------
455  #D-   6.3. CONFIGURE POST-PROCESSING
456  #D-        - asynchronous post-treatment (Level 0) when necessary (rebuild/pack)
457  #D-        - classic post-treatment      (Level 1) when necessary (TimeSeries/Seasonal)
458  # ------------------------------------------------------------------
459  IGCM_post_Configure
460
461  #D-
462  # ------------------------------------------------------------------
463  #D-   6.4. SUBMIT POST-PROCESSING
464  #D-        - remote rebuild or/and post-treatment process if necessary
465  # ------------------------------------------------------------------
466  IGCM_post_Submit
467
468  #D-
469  # ------------------------------------------------------------------
470  #D-   6.5. FINALYZE CURRENT LOOP AND PREPARE NEXT ONE
471  #D-        - Manage executable size to save only different binary
472  #D-        - Write in run.card user, system and elapse time
473  #D-        - Check that everything went well ! No ? then we stop.
474  #D-        - Determine next computed period
475  # ------------------------------------------------------------------
476  IGCM_config_PeriodEnd
477
478  echo "Ending iteration ${Period}"
479  (( Period = Period + 1 ))
480
481  # End loop if date end is reached
482  if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then
483    break ;
484  fi
485
486  PeriodContinue=false
487  if [ ${Period} -le ${PeriodNb} ]; then
488    PeriodContinue=true
489  fi
490done
491
492#D-
493#D---------------------------------------------------------------------==
494#D- 7. SUBMIT NEXT JOB OR SEND MAIL IF SIMULATION IS OVER.
495#D---------------------------------------------------------------------==
496IGCM_config_Finalize
497
498date
Note: See TracBrowser for help on using the repository browser.