source: trunk/libIGCM/AA_job @ 929

Last change on this file since 929 was 929, checked in by sdipsl, 11 years ago

machine cleanup
whitespace cleanup

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