source: CONFIG_DEVT/IPSLCM6.2.2_ENSEMBLES/libIGCM/libIGCM_config/libIGCM_config.ksh @ 6204

Last change on this file since 6204 was 6204, checked in by aclsce, 22 months ago

First import of IPSLCM6.2.2_work_ENSEMBLES working configuration

File size: 57.8 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Sebastien Denvil, Martial Mancip
5# Contact: Sebastien.Denvil__at__ipsl.jussieu.fr Martial.Mancip__at__ipsl.jussieu.fr
6# $Revision:: 1546                                     $ Revision of last commit
7# $Author:: acosce                                     $ Author of last commit
8# $Date:: 2021-02-09 14:28:14 +0100 (Tue, 09 Feb 2021) $ Date of last commit
9# IPSL (2006)
10#  This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC
11#
12#**************************************************************
13
14#===================================
15function IGCM_config_CommonConfiguration
16{
17  IGCM_debug_PushStack "IGCM_config_CommonConfiguration" $@
18
19  # Debug Print :
20  [ ${Verbosity} -gt 0 ] && echo
21  IGCM_debug_Print 1 "IGCM_config_CommonConfiguration" $@
22
23  # config.card path
24  configCardPath=$1
25
26  #==================================
27  typeset option auxprint
28
29  #==================================
30  # Read UserChoices section:
31  [ ${Verbosity} -gt 0 ] && echo
32  IGCM_debug_Print 1 "DefineArrayFromOption  : config_UserChoices"
33
34  IGCM_card_DefineArrayFromSection ${configCardPath} UserChoices
35  for option in ${config_UserChoices[*]} ; do
36    IGCM_card_DefineVariableFromOption ${configCardPath} UserChoices ${option}
37    eval auxprint=\${config_UserChoices_${option}}
38    IGCM_debug_Print 3 "${option} : ${auxprint}"
39  done
40
41  # Set variables with shorter names on some variables which 
42  # are used in the executable name in config.card
43  ResolAtm=${config_UserChoices_ResolAtm}
44  ResolOce=${config_UserChoices_ResolOce}
45  ConfChem=${config_UserChoices_ConfChem}
46  OptMode=${config_UserChoices_OptMode}
47
48  #==================================
49  # Read Ensemble section:
50  [ ${Verbosity} -gt 0 ] && echo
51  IGCM_debug_Print 1 "DefineArrayFromOption  : config_Ensemble"
52
53  IGCM_card_DefineArrayFromSection ${configCardPath} Ensemble
54  for option in ${config_Ensemble[*]} ; do
55    IGCM_card_DefineVariableFromOption ${configCardPath} Ensemble ${option}
56    eval auxprint=\${config_Ensemble_${option}}
57    IGCM_debug_Print 3 "${option} : ${auxprint}"
58  done
59
60  #==================================
61  # Read Post section:
62  [ ${Verbosity} -gt 0 ] && echo
63  IGCM_debug_Print 1 "DefineArrayFromOption : config_Post"
64
65  IGCM_card_DefineArrayFromSection ${configCardPath} Post
66  for option in ${config_Post[*]} ; do
67    IGCM_card_DefineVariableFromOption ${configCardPath} Post ${option}
68    eval auxprint=\${config_Post_${option}}
69    IGCM_debug_Print 3 "${option} : ${auxprint}"
70  done
71  [ ${Verbosity} -gt 0 ] && echo
72
73  #==================================
74  # Define default value to keep compatibility with previous card: means before changes due to TGCC
75  # Apply some overrules to ensure proper usage of computing centres resources
76  #
77
78  # if RebuildFrequency is not define in config.card - we initilize it to NONE
79  if [ X${config_Post_RebuildFrequency} = X ] ; then
80      config_Post_RebuildFrequency=NONE
81  fi
82
83  if [ X${PackDefault} = Xtrue ] ; then
84    if [ X${config_UserChoices_SpaceName} = XTEST ]; then
85      # TEST simulations will not be packed and will stay on SCRATCHDIR filesystem
86      IGCM_debug_Print 1 "SpaceName=TEST. OVERRULE PackFrequency to NONE"
87      config_Post_PackFrequency=NONE
88    else
89      # Default to RebuildFrequency if nothing has been set up related to PackFrequency
90      [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency}
91    fi
92  else
93    # If we DO NOT apply pack in this computing center
94    config_Post_PackFrequency=NONE
95  fi
96
97  #====================================================
98  # Define ARCHIVE : Dedicated to large files
99  # Define STORAGE : Dedicated to small/medium files
100  # Define R_OUT   : Output tree located on ARCHIVE
101  # Define R_BUF   : Output tree located on STORAGE (files waiting treatment, or file lcoation when SpaceName=!PROD)
102  # Define R_FIG   : Output tree located on STORAGE hosting figures (monitoring and atlas, and/or small files)
103  # Define R_TMP   : A temporary space used by IGCM_debug_send_AMQP_msg__MAILTUNNEL. Must be persistent in between jobs
104  IGCM_sys_defineArchives
105
106  #====================================================
107  # R_SAVE : Job output directory
108  # R_BUFR : Job output buffered directory
109  # R_CMIP : Job output directory for CMIP6 standard files
110
111  if ( [ ! X${config_UserChoices_SpaceName} = X ] && [ ! X${config_UserChoices_ExperimentName} = X ] ) ; then
112    FreeName=$( echo ${config_UserChoices_JobName} | sed 's/.*_//' )
113    if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
114      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
115      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
116      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
117      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
118      R_CMIP=${CMIP6_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${FreeName}
119    else
120      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
121      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
122      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
123      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
124      R_CMIP=${CMIP6_BUF}/${config_UserChoices_TagName}/${config_UserChoices_SpaceName}/${config_UserChoices_ExperimentName}/${FreeName}
125    fi
126  else
127    if ( [ ! X${config_Ensemble_EnsembleName} = X ] && [ ! X${config_Ensemble_EnsembleDate} = X ] ) ; then
128      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
129      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
130      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
131      R_DODS=${config_UserChoices_TagName}/${config_Ensemble_EnsembleName}/${config_Ensemble_EnsembleDate}/${config_UserChoices_JobName}
132    else
133      R_SAVE=${R_OUT}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
134      R_FIGR=${R_FIG}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
135      R_BUFR=${R_BUF}/${config_UserChoices_TagName}/${config_UserChoices_JobName}
136      R_DODS=${config_UserChoices_TagName}/${config_UserChoices_JobName}
137    fi
138  fi
139
140  #====================================================
141  # Define R_OUT_KSH : Storage place for job output
142  # Define R_OUT_EXE : Storage place for binary used during simulation
143  R_OUT_KSH=${R_SAVE}/Out
144  R_OUT_EXE=${R_SAVE}/Exe
145
146  #====================================================
147  # Define R_BUF_KSH : Buffer place for job output
148  # Define R_BUF_EXE : Buffer place for binary used during simulation
149  R_BUF_KSH=${R_BUFR}/Out
150  R_BUF_EXE=${R_BUFR}/Exe
151
152  #====================================================
153  # Define REBUILD_DIR : where we store files needing rebuild process
154  REBUILD_DIR=${R_BUFR}/REBUILD
155  if [ ! X${TaskType} = Xchecking ] ; then
156    IGCM_sys_MkdirWork ${REBUILD_DIR}
157  fi
158
159  #====================================================
160  # DodsCopy : apply default value if not defined
161  if ( [ X${config_Post_DodsCopy} = X${NULL_STR} ] || [ X${config_Post_DodsCopy} = X ] ) ; then
162    config_Post_DodsCopy=TRUE
163  fi
164
165  #====================================================
166  # AtlasIPSL : apply default value if not defined
167  if ( [ X${config_Post_AtlasIPSL} = X${NULL_STR} ] || [ X${config_Post_AtlasIPSL} = X ] ) ; then
168    config_Post_AtlasIPSL=FALSE
169  fi
170
171  #====================================================
172  # ParserXIOS : apply default value if not defined
173  if ( [ X${config_Post_ParserXIOS} = X${NULL_STR} ] || [ X${config_Post_ParserXIOS} = X ] ) ; then
174    config_Post_ParserXIOS=FALSE
175  fi
176
177  #====================================================
178  # MetricsPCMDI : apply default value if not defined
179  if ( [ X${config_Post_MetricsPCMDI} = X${NULL_STR} ] || [ X${config_Post_MetricsPCMDI} = X ] ) ; then
180    config_Post_MetricsPCMDI=FALSE
181  fi
182
183  #====================================================
184  # IgnoreNonMonotonic : apply default value if not defined
185  if ( [ X${config_Post_IgnoreNonMonotonic} = X${NULL_STR} ] || [ X${config_Post_IgnoreNonMonotonic} = X ] ) ; then
186    config_Post_IgnoreNonMonotonic=FALSE
187  fi
188
189  #====================================================
190  # LightRestartPack : apply default value if not defined
191  if ( [ X${config_Post_LightRestartPack} = X${NULL_STR} ] || [ X${config_Post_LightRestartPack} = X ] ) ; then
192    config_Post_LightRestartPack=FALSE
193  fi
194
195  #====================================================
196  # dr2xmlIPSL : apply default value if not defined
197  if ( [ X${config_Post_dr2xmlIPSL} = X${NULL_STR} ] || [ X${config_Post_dr2xmlIPSL} = X ] ) ; then
198    config_Post_dr2xmlIPSL=FALSE
199  fi
200
201
202  #====================================================
203  # Define StackFileLocation : directory where we store stack files
204  # Define StackFileName : stack file containing call tree and instrumentation
205  # Stack file containing call tree will be stored there.
206  if ( $DEBUG_debug ) ; then
207    StackFileLocation=${StackFileLocation:=${R_BUF_KSH}}
208    [ ! -d ${StackFileLocation} ] && mkdir -p ${StackFileLocation}
209    if [ X${TaskType} = Xcomputing ]; then
210      StackFileName=computing.stack.$$
211    elif [ X${TaskType} = Xpost-processing ]; then
212      StackFileName=${Script_Post_Output}.stack.$$
213    elif [ X${TaskType} = Xchecking ]; then
214      StackFileName=checking.stack.$$
215    else
216      IGCM_debug_Exit "IGCM_config_CommonConfiguration unknown TaskType : ${TaskType}"
217      IGCM_debug_Verif_Exit
218    fi
219
220    # This boolean will trigger the filling of the stack
221    # Only now we know where things should be ...
222    # We don't fill the stack when we perform checking task
223    if [ ! X${TaskType} = Xchecking ] ; then
224      ActivateStackFilling=true
225    fi
226  fi
227
228  IGCM_debug_PopStack "IGCM_config_CommonConfiguration"
229}
230
231#===================================
232function IGCM_config_Initialize
233{
234  IGCM_debug_PushStack "IGCM_config_Initialize"
235
236  # Debug Print :
237  echo
238  IGCM_debug_Print 1 "IGCM_config_Initialize"
239
240  # Test modipsl tree existence.
241  IGCM_sys_TestDir ${MODIPSL}
242  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
243  IGCM_sys_TestDir ${libIGCM}
244  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
245  IGCM_sys_TestDir ${R_EXE}
246  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
247  IGCM_sys_TestDir ${SUBMIT_DIR}
248  [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir"
249
250  if ( $DEBUG_debug ) ; then
251    echo "Keep trace of inital SUBMIT_DIR : "
252    ls -lta ${SUBMIT_DIR}
253  fi
254
255  #==================================
256  # Read ListOfComponents section:
257  echo
258  IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents"
259
260  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card ListOfComponents
261  for comp in ${config_ListOfComponents[*]} ; do
262    IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/config.card ListOfComponents ${comp}
263  done
264  IGCM_debug_Print 3 ${config_ListOfComponents[*]}
265
266  #==================================
267  # Read Executable section:
268  IGCM_card_DefineArrayFromSection   ${SUBMIT_DIR}/config.card Executable
269
270  #==================================
271  # Read Restarts section:
272  # Restarts : Gerneral rule or local for each component.
273  echo
274  IGCM_debug_Print 1 "DefineArrayFromOption : config_Restarts"
275
276  IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/config.card Restarts
277  for option in ${config_Restarts[*]} ; do
278    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Restarts ${option}
279    eval auxprint=\${config_Restarts_${option}}
280    IGCM_debug_Print 3 "${option} : ${auxprint}"
281  done
282
283  #==================================
284  # Define Job Outputs Name
285  echo
286  IGCM_debug_Print 2 "Define Script_Output_Prefix and Exe_Output"
287  Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'}
288  IGCM_debug_Print 3 "Script_Output_Prefix = ${Script_Output_Prefix}"
289  Exe_Output=out_execution
290  IGCM_debug_Print 3 "Exe_Output           = ${Exe_Output}"
291
292  #===================================================================#
293  # Prepare variables available for ${COMP}.card and ${COMP}.driver   #
294  #             But available to any son functions                    #
295  #===================================================================#
296
297  # Convert yyyy-mm-dd date to gregorian yyyymmdd
298  DateBegin=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateBegin} )
299  DateEnd=$(   IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd}   )
300  EndYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateEnd ) / 1000 ))
301  EndYear_p1=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateEnd ) / 1000 + 1 ))
302
303
304  # Period Length In Days between DateBegin and DateEnd
305  (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 ))
306  if [ ${ExperienceLengthInDays} -lt 0 ] ; then
307    IGCM_debug_Print 1 "Problem with dates in config.card : ${DateEnd} < ${DateBegin} ! You must check that."
308    IGCM_debug_Exit "IGCM_config_Initialize" " Wrong Dates."
309    IGCM_debug_Verif_Exit
310  fi
311
312  # Day and Year of Initial State (Given in julian format)
313  InitDay=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) % 1000 ))
314  InitYear=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 ))
315  InitYear_m1=$(( $( IGCM_date_ConvertGregorianDateToJulian $DateBegin ) / 1000 - 1 ))
316
317  #================================================================#
318  #                  Test and Prepare directories                  #
319  #================================================================#
320
321  # ==> 4 kinds of input files :
322  #     1) R_INIT  : Initial State Files   (Etat0, carteveg)
323  #     2) R_BC    : Boundary Conditions   (Forcages, lai)
324  #     3) Parameters files (allready define through ${SUBMIT_DIR})
325  #     4) Restarts files   (allready define in IGCM_config_Initialize)
326
327  # Here we offer the possibility to redefine R_INIT, R_BC
328  # and PeriodNb through config.card
329  R_INIT=${config_UserChoices_R_INIT:=${R_IN}/INIT}
330  echo
331  IGCM_debug_Print 2 "(Re)Define R_INIT, R_BC and PeriodNb"
332  IGCM_debug_Print 3 "R_IN=${R_IN}"
333  IGCM_debug_Print 3 "R_INIT=${R_INIT}"
334  R_BC=${config_UserChoices_R_BC:=${R_IN}/BC}
335  IGCM_debug_Print 3  "R_BC=${R_BC}"
336  PeriodNb=${config_UserChoices_PeriodNb:=${PeriodNb}}
337  IGCM_debug_Print 3  "Loop in main Job with ${PeriodNb} period(s)"
338
339  # SD ADA SPECIFIC #
340  #      TO FIX     #
341  #IGCM_sys_TestDirArchive ${R_IN}
342  #[ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive"
343
344  if ( ${FirstInitialize} ) ; then
345    IGCM_sys_MkdirArchive   ${R_SAVE}
346    [ ! ${config_Post_PackFrequency} = NONE ] && IGCM_sys_Mkdir ${R_BUFR}
347  else
348    IGCM_sys_TestDirArchive ${R_SAVE}
349    [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive ${R_SAVE}"
350
351    if [ ! ${config_Post_PackFrequency} = NONE ] ; then
352      IGCM_sys_TestDir ${R_BUFR}
353      [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDir ${R_BUFR}"
354    fi
355
356    # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal"
357    IGCM_config_StateCheck
358
359    # And EXIT if not OK
360    IGCM_debug_Verif_Exit
361  fi
362
363  #====================================================
364  # Experience type : DEB(ug), DEV(elopment), RUN
365  if [ X${JobType} != XRUN ] ; then
366    echo
367    echo "===================================================="
368    echo "libIGCM JOB is NOT in RUN type mode."
369    echo "!! OUTPUT files will NOT be PROTECTED !!"
370    echo "Be carefull : you can ERASE the result of this job !"
371
372    case ${JobType} in
373    DEB)
374      echo "DEBUG mode : activation of 'set -vx' mode."
375      echo "DEBUG mode : no protection for output files."
376      echo "DEBUG mode : if active force asynchronous rebuild frequency to PeriodLength frequency."
377      ;;
378    DEV)
379      echo "DEVelopment mode : no protection for output files."
380      echo "DEVelopment mode : if active force asynchronous rebuild frequency to PeriodLength frequency."
381      ;;
382    esac
383
384    if ( [ X${config_Post_RebuildFrequency} != XNONE ] && [ ${DRYRUN} -eq 0 ] ) ; then
385      if [ X${config_Post_RebuildFrequency} != X${config_UserChoices_PeriodLength} ] ; then
386        echo "------------"
387        echo "WARNING : Job is NOT in RUN mode then we will force REBUILD Frequency"
388        echo "          to PeriodLength : ${config_UserChoices_PeriodLength}"
389        echo "------------"
390        config_Post_RebuildFrequency=${config_UserChoices_PeriodLength}
391      fi
392    fi
393    echo "===================================================="
394    echo
395  fi
396
397  IGCM_debug_PopStack "IGCM_config_Initialize"
398}
399
400#===================================
401function IGCM_config_DaysInPeriodLength
402{
403  IGCM_debug_PushStack "IGCM_config_DaysInPeriodLength"
404
405  typeset i
406
407  # Determine number of day(s) in PeriodLength :
408  case ${config_UserChoices_PeriodLength} in
409  *Y|*y)
410    PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[yY]//' )
411    echo
412    IGCM_debug_Print 2 "Number of years for PeriodLength : ${PeriodLengthInYears}"
413    PeriodLengthInDays=0
414    i=0
415    until [ $i -ge $PeriodLengthInYears ] ; do
416      (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) ))
417      (( i=i+1 ))
418    done
419    ;;
420  *M|*m)
421    PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[mM]//' )
422    echo
423    IGCM_debug_Print 2 "Number of months for PeriodLength : ${PeriodLengthInMonths}"
424    PeriodLengthInDays=0
425    i=0
426    until [ $i -ge $PeriodLengthInMonths ] ; do
427      if [ $(( 10#${month} + ${i} )) -lt 13 ] ; then
428        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( 10#${month} + ${i} )) ) ))
429      else
430        (( PeriodLengthInDays  = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( 10#${month} + ${i} - 12 )) ) ))
431      fi
432      (( i=i+1 ))
433    done
434    ;;
435  *D|*d)
436    PeriodLengthInMonths=0
437    PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | sed -e 's/[dD]//' )
438    echo
439    IGCM_debug_Print 2 "Number of days for PeriodLength : ${PeriodLengthInDays}";;
440  *)
441    IGCM_debug_Exit "IGCM_config_DaysInPeriodLength " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D."
442    IGCM_debug_Verif_Exit ;;
443  esac
444
445  IGCM_debug_PopStack "IGCM_config_DaysInPeriodLength"
446}
447
448#===================================
449function IGCM_config_DateCoherency
450{
451  IGCM_debug_PushStack "IGCM_config_DateCoherency"
452
453  echo
454  IGCM_debug_Print 1 "IGCM_config_DateCoherency"
455  echo
456
457  typeset Length VerifiedPeriodDateBegin VerifiedPeriodDateEnd
458
459  # check coherency between (PeriodDateBegin, PeriodDateEnd) and (DateBegin, CumulPeriod, PeriodLength)
460  # DateBegin + CumulPeriod*PeriodLength = PeriodDateBegin
461  echo
462
463  case ${config_UserChoices_PeriodLength} in
464  *Y|*y)
465    Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInYears} ))Y )
466    ;;
467  *M|*m)
468    Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInMonths} ))M )
469    ;;
470  *D|*d)
471    Length=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} $(( ${CumulPeriod} * ${PeriodLengthInDays} ))D )
472    ;;
473  esac
474  VerifiedPeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Length}-1 )
475
476  if [ ${VerifiedPeriodDateEnd} != ${PeriodDateEnd} ] ; then
477    IGCM_debug_Print 1 "From run.card PeriodDateEnd is not consistent with DateBegin and CumulPeriod."
478    IGCM_debug_Print 1 "We have DateBegin = ${DateBegin}"
479    IGCM_debug_Print 1 "We have CumulPeriod = ${CumulPeriod}"
480    IGCM_debug_Print 1 "We have PeriodDateEnd = ${PeriodDateEnd}"
481    IGCM_debug_Print 1 "We have VerifiedPeriodDateEnd = ${VerifiedPeriodDateEnd}"
482    IGCM_debug_Print 1 "You must have change run.card in an inconsistent way."
483
484    IGCM_debug_Exit "STOP here to avoid further issues."
485  fi
486
487  # PeriodDateBegin + PeriodLength = PeriodDateEnd
488  VerifiedPeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${VerifiedPeriodDateEnd} $(( ${PeriodLengthInDays} * -1 )) )
489
490  IGCM_debug_PopStack "IGCM_config_DateCoherency"
491}
492
493#===================================
494function IGCM_config_StateCheck
495{
496  IGCM_debug_PushStack "IGCM_config_StateCheck"
497
498    #Test state of run in run.card
499    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState
500
501    if [ ${run_Configuration_PeriodState} = "Fatal" ] ; then
502      echo
503      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!"
504      IGCM_debug_Print 1 "Check the overall status of your simulation by visiting this page:"
505      IGCM_debug_Print 1 "https://hermes.ipsl.upmc.fr/static/simulation.detail.html?uid=${simuid}"
506      IGCM_debug_Print 1 "Then try running ${libIGCM}/clean_PeriodLenght.job to clean latest failed period"
507      IGCM_debug_Print 1 "Or try running ${libIGCM}/clean_latestPackperiod.job to clean lastest pack period."
508      IGCM_debug_Print 1 "Or use ${libIGCM}/purge_simulation.job to delete the full simulation."
509      IGCM_debug_Exit
510    elif [ $( echo ${run_Configuration_PeriodState} | grep Fatal | wc -l ) -eq 1 ] ; then
511      echo
512      IGCM_debug_Print 1 "!! Error in run.card with PeriodState : " ${run_Configuration_PeriodState} "!!"
513      IGCM_debug_Print 1 "Compute jobs has been stop because at least the above mentionned post-processing jobs fails."
514      IGCM_debug_Print 1 "Check post-processing jobs carefully by visiting this page:"
515      IGCM_debug_Print 1 "https://hermes.ipsl.upmc.fr/static/simulation.detail.html?uid=${simuid}"
516      IGCM_debug_Print 1 "Please visit that page to see how to fix issues:"
517      IGCM_debug_Print 1 "https://forge.ipsl.jussieu.fr/igcmg_doc/wiki/DocGmonitor"
518      IGCM_debug_Print 1 "Then try running ${libIGCM}/clean_PeriodLenght.job to clean latest failed period"
519      IGCM_debug_Print 1 "Or try running ${libIGCM}/clean_latestPackperiod.job to clean latest pack period."
520      IGCM_debug_Print 1 "Or use ${libIGCM}/purge_simulation.job to delete the full simulation."
521      IGCM_debug_Exit
522    fi
523
524  IGCM_debug_PopStack "IGCM_config_StateCheck"
525}
526
527#===================================
528function IGCM_config_Check
529{
530  IGCM_debug_PushStack "IGCM_config_Check"
531
532  # If one of the following modulo is not zero :
533  # we will issue an error then explain and exit in
534  # AA_job IGCM_debug_Verif_Exit call before binary submission
535
536  echo
537  IGCM_debug_Print 1 "IGCM_config_Check"
538  echo
539
540  typeset i
541
542  # Check RebuildFrequency against key frequencies : PeriodLength ; PackFrequency ; TimeSeriesFrequency ; SeasonalFrequency
543  if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then
544    AsynchronousRebuild=true
545    IGCM_debug_Print 1 "Asynchronous rebuild has been activated."
546    echo
547    # modulo (RebuildFrequency and PeriodLength/TimeSeriesFrequency/SeasonalFrequency) must be zero
548    IGCM_debug_Print 1 "Check coherence between RebuildFrequency and PeriodLength"
549    IGCM_post_CheckModuloFrequency config_Post_RebuildFrequency config_UserChoices_PeriodLength
550    IGCM_debug_Print 1 "Check coherence between PackFrequency and RebuildFrequency"
551    IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_Post_RebuildFrequency
552    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and RebuildFrequency"
553    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_RebuildFrequency
554    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and RebuildFrequency"
555    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_RebuildFrequency
556  else
557    AsynchronousRebuild=false
558    IGCM_debug_Print 1 "Asynchronous rebuild has not been activated"
559    IGCM_debug_Print 1 "Proceed with standard post-treatment pathway"
560    echo
561    #modulo (PeriodLength and TimeSeriesFrequency/SeasonalFrequency) must be zero
562    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PeriodLength"
563    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_UserChoices_PeriodLength
564    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PeriodLength"
565    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency   config_UserChoices_PeriodLength
566  fi
567
568  # Check PackFrequency against other key frequencies
569  # Modulo (PackFrequency and TimeSeriesFrequency/SeasonalFrequency and PeriodLenght) must be zero
570  if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then
571    Pack=true
572    #
573    IGCM_debug_Print 1 "Check coherence between PackFrequency and PeriodLength"
574    IGCM_post_CheckModuloFrequency config_Post_PackFrequency config_UserChoices_PeriodLength
575    IGCM_debug_Print 1 "Check coherence between TimeSeriesFrequency and PackFrequency"
576    IGCM_post_CheckModuloFrequency config_Post_TimeSeriesFrequency config_Post_PackFrequency
577    IGCM_debug_Print 1 "Check coherence between SeasonalFrequency and PackFrequency"
578    IGCM_post_CheckModuloFrequency config_Post_SeasonalFrequency config_Post_PackFrequency
579  else
580    Pack=false
581  fi
582
583  # modulo (TimeSeriesFrequency and all Chunck2D) must be zero
584  NbJob=${#CHUNCK2D_SIZE[@]}
585  i=0
586  until [ $i -ge $NbJob ]; do
587    value=${CHUNCK2D_SIZE[${i}]}
588    IGCM_debug_Print 1 "Check coherence between ${CHUNCK2D_NAME[${i}]} Chunck2D frequency and TimeSeriesFrequency"
589    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency
590    case ${value} in
591    *Y|*y) ;;
592    *)
593      IGCM_debug_Print 1 "All ChunckJob2D frequency must be expressed in year *Y|*y in comp.card"
594      IGCM_debug_Exit "This will stop the job" ;;
595    esac
596    (( i=i+1 ))
597  done
598
599  # modulo (TimeSeriesFrequency and all Chunck3D) must be zero
600  NbJob=${#CHUNCK3D_SIZE[@]}
601  i=0
602  until [ $i -ge $NbJob ]; do
603    value=${CHUNCK3D_SIZE[${i}]}
604    IGCM_debug_Print 1 "Check coherence between ${CHUNCK3D_NAME[${i}]} Chunck3D frequency and TimeSeriesFrequency"
605    IGCM_post_CheckModuloFrequency value config_Post_TimeSeriesFrequency
606    case ${value} in
607    *Y|*y) ;;
608    *)
609      IGCM_debug_Print 1 "All ChunckJob3D frequency must be expressed in year *Y|*y in comp.card"
610      IGCM_debug_Exit "This will stop the job" ;;
611    esac
612    (( i=i+1 ))
613  done
614
615  # check to be sure there is enough space on temporary filesystems to run
616  echo
617  IGCM_debug_Print 1 "Check if there is enough space on temporary filesystem"
618  IGCM_sys_check_quota
619
620  # check to be sure that RUN_DIR_PATH, that will be removed is not pointing to an important directory
621  echo
622  IGCM_debug_Print 1 "Check where RUN_DIR_PATH variable is pointing to"
623  IGCM_sys_check_path
624
625
626  IGCM_debug_PopStack "IGCM_config_Check"
627}
628
629#===================================
630function IGCM_config_ConfigureExecution
631{
632  IGCM_debug_PushStack " IGCM_config_ConfigureExecution"
633
634  #echo
635  IGCM_debug_Print 1 " IGCM_config_ConfigureExecution"
636  #echo
637
638  typeset ExeNameIn ExeNameFirst CompNameFirst configCardPath comp i
639  typeset tempvar tempvarMPI tempvarNOD NbElts NbExec
640
641  # config.card path
642  configCardPath=$1
643
644  coreNumber=0
645  mpiTasks=0
646  openMPthreads=0
647  NbExec=0
648
649  OK_PARA_MPI=false
650  OK_PARA_OMP=false
651  OK_PARA_NOD=false
652  OK_PARA_MPMD=false
653
654  for comp in ${config_ListOfComponents[*]} ; do
655
656    # Manage component executable
657    IGCM_card_DefineArrayFromOption ${configCardPath} Executable ${comp}
658
659    eval ExeNameIn=\${config_Executable_${comp}[0]}
660
661    # NO order in config.card for parallelized values !
662    # just use suffix : MPI , OMP and NOD (for number of NODes.)
663
664    # NOD is the number of NODes allocated
665    eval ${comp}_PROC_NOD=0
666
667    # MPI is the number of MPI processus per nodes
668    eval ${comp}_PROC_MPI=0
669
670    # OMP is the number of OpenMP threads per MPI processus
671    eval ${comp}_PROC_OMP=0
672
673    # DEP is the factor to increase the number of cores per process
674    eval ${comp}_PROC_DEP=0
675
676    # DEDICATED is the flag to activate the use of dedicated node for XIOS server only
677    eval ${comp}_OK_DEDICATED=0
678
679    # Only if we really have an executable for the component :
680    if ( [ "X${ExeNameIn}" != X\"\" ] && [ "X${ExeNameIn}" != "Xinca.dat" ] ) ; then
681
682      IGCM_debug_Print 1 ${comp}
683
684      # Keep the first executable found and the first CompName
685      eval ExeNameFirst=${ExeNameIn}
686      CompNameFirst=${comp}
687
688      # Are we a second executable?
689      (( NbExec = NbExec + 1 ))
690
691      # set 1 MPI task, 1 OpenMP thread and 1 node as default
692      eval ${comp}_PROC_MPI=1
693      eval ${comp}_PROC_OMP=1
694      eval ${comp}_PROC_NOD=1
695      eval ${comp}_PROC_DEP=1
696
697      eval NbElts=\${#config_Executable_${comp}[@]}
698      if [ ${NbElts} -gt 2 ] ; then
699        #
700        # CURRENT METHOD TO SPECIFY MPI AND OMP RESSOURCES
701        #
702        i=2
703        while [ ${i} -lt ${NbElts} ] ; do
704          eval tempvar=\${config_Executable_${comp}[${i}]}
705          IGCM_debug_Print 2 ${tempvar}
706
707          if [ X${tempvar} = X ] ; then
708            IGCM_debug_Print 2 "Error reading MPI/OMP parameters !!!"
709            IGCM_debug_Exit "Check your config.card. Exit now"
710            IGCM_debug_Verif_Exit
711          fi
712
713          case ${tempvar} in
714          *[mM][pP][iI]*)
715            # Read MPI parameter for composante
716            eval ${comp}_PROC_MPI=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/MPI//" )
717            OK_PARA_MPI=true;;
718          *[oO][mM][pP]*)
719            # Read OMP parameter for composante
720            eval ${comp}_PROC_OMP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/OMP//" )
721            ;;
722          *[nN][oO][dD]*)
723            # Read NOD (NumBer of Nodes) parameter for composante
724            eval ${comp}_PROC_NOD=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/NOD//" )
725            OK_PARA_NOD=true
726            OK_PARA_MPI=true
727            ;;
728            *[dD][eE][pP]*)
729            # Read DEP parameter for composante
730            eval ${comp}_PROC_DEP=$( echo ${tempvar} | tr '[a-z]' '[A-Z]' | sed -e "s/DEP//" )
731            ;;
732            *[dD][eE][dD][iI][cC][aA][tT][eE][dD]*)
733            # Read DEDICATED parameter for composante
734            eval ${comp}_OK_DEDICATED=1
735          esac
736          (( i = i + 1 ))
737        done
738      else
739        #
740        # BACKWARD COMPATIBILITY NOT SUPPORTED ANYMORE
741        #
742        IGCM_debug_Exit "You are using a deprecated ressources specification mechanism in your config.card"
743        IGCM_debug_Exit "Please check : https://forge.ipsl.jussieu.fr/igcmg_doc/wiki/DocEsetup#ThesectionExecutable"
744        IGCM_debug_Exit "Please modify ${configCardPath}"
745        exit
746      fi
747      if [ ${comp}_PROC_NOD -gt 1 ] ; then
748            if ( [ ${comp}_PROC_MPI -gt 1 ] && [ ${comp}_PROC_OMP -gt 1 ] ) ; then
749              IGCM_debug_Print 2 "Error using MPI/OMP/NOD parameters !!!"
750              IGCM_debug_Exit "It is not allowed to use MPI and OMP and NOD parameters for the same component"
751              IGCM_debug_Exit "Check your config.card. Exit now"
752              IGCM_debug_Verif_Exit
753            fi
754            if [ "${comp}" != "IOS" ] ; then
755              IGCM_debug_Print 2 "Error using NOD parameter !!!"
756              IGCM_debug_Exit "NOD parameter is only available for IOS component "
757              IGCM_debug_Exit "Check your config.card. Exit now"
758              IGCM_debug_Verif_Exit
759            fi
760      fi
761      if ( [ ${comp}_OK_DEDICATED -eq 1 ] && [ "${comp}" != "IOS" ] ) ; then
762            IGCM_debug_Print 2 "Error using DEDICATED parameter !!!"
763            IGCM_debug_Exit "DEDICATED parameter is only available for IOS component "
764            IGCM_debug_Exit "Check your config.card. Exit now"
765            IGCM_debug_Verif_Exit
766      fi
767
768      eval tempvarMPI=\${${comp}_PROC_MPI}
769      eval tempvarNOD=\${${comp}_PROC_NOD}
770      eval tempvarOMP=\${${comp}_PROC_OMP}
771      eval tempvarDEP=\${${comp}_PROC_DEP}
772
773      # set OMP mode if more than 1 OMP thread.
774      [ ${tempvarOMP} -ge 2 ] && OK_PARA_OMP=true
775
776      # Number of OMP threads
777      [ ${openMPthreads} -lt ${tempvarOMP} ] && openMPthreads=${tempvarOMP}
778
779      # SUM UP NUMBER OF CORES
780      if [ ${comp}_PROC_NOD -gt 1 ] ; then 
781          (( coreNumber = coreNumber + tempvarNOD * NB_CORE_PER_NODE ))
782      else
783          (( coreNumber = coreNumber + tempvarMPI * tempvarNOD * tempvarOMP * tempvarDEP ))
784      fi
785      # SUM UP NUMBER OF MPI TASKS
786      (( mpiTasks = mpiTasks + tempvarMPI * tempvarNOD ))
787    fi
788  done
789
790  # MANDATORY FOR THE OPA9.DRIVER. USED TO EDIT OPA NAMELIST
791  # WE SHOULD PLANIFY NUM_PROC_??? DEPRECATION
792  NUM_PROC_CPL=${CPL_PROC_MPI}
793  NUM_PROC_OCE=${OCE_PROC_MPI}
794  NUM_PROC_ATM=${ATM_PROC_MPI}
795
796  # set MPMD mode if more than 2 executable names.
797  [ ${NbExec} -ge 2 ] && OK_PARA_MPMD=true 
798
799  # Define the execution type we are running in
800  if ( ${OK_PARA_MPMD} ) ; then
801    if ( ${OK_PARA_MPI} ) ; then
802      # MPMD always implies MPI
803      executionType=1
804    fi
805    if ( ${OK_PARA_OMP} ) ; then
806      # MPMD + MPI/OMP
807      executionType=2
808    fi
809  else
810    if ( ( ${OK_PARA_MPI} ) && ( ${OK_PARA_OMP} ) ) ; then
811      # SPMD + MPI/OMP
812      executionType=3
813    elif ( ( ${OK_PARA_MPI} ) && ( ! ${OK_PARA_OMP} ) ) ; then
814      # SPMD + MPI only
815      executionType=4
816    elif ( ( ! ${OK_PARA_MPI} ) && ( ${OK_PARA_OMP} ) ) ; then
817      # SPMD + OMP only
818      executionType=5
819    elif ( ( ! ${OK_PARA_MPI} ) && ( ! ${OK_PARA_OMP} ) ) ; then
820      # SEQUENTIAL THEN
821      executionType=6
822      coreNumber=1
823    fi
824  fi
825
826  IGCM_debug_Print 1 "MPI/OMP treatment coreNumber = ${coreNumber}"
827  IGCM_debug_Print 1 "MPI/OMP treatment mpiTasks = ${mpiTasks}"
828  IGCM_debug_Print 1 "MPI/OMP treatment openMPthreads = ${openMPthreads}"
829  IGCM_debug_Print 1 "MPI/OMP treatment executionType = ${executionType}"
830
831  IGCM_debug_PopStack "IGCM_config_ConfigureExecution"
832}
833
834#===================================
835function IGCM_config_PeriodStart
836{
837  IGCM_debug_PushStack "IGCM_config_PeriodStart"
838
839  echo
840  IGCM_debug_Print 1 "IGCM_config_PeriodStart"
841  echo
842
843  if ( ${FirstInitialize} ) ; then
844    #================================================#
845    #         Initialize date/period information     #
846    #================================================#
847
848    IGCM_date_GetYearMonthDay ${DateBegin} year month day
849    IGCM_config_DaysInPeriodLength
850
851    PeriodDateBegin=${DateBegin}
852    PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( ${PeriodLengthInDays} - 1 )) )
853    CumulPeriod=1
854
855    #=================================================#
856    #              Write updated run.card             #
857    #=================================================#
858
859    #Correct run.card Configuration for this period
860    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
861    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
862    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
863    if [ X$( grep "SubmitPath" ${SUBMIT_DIR}/run.card ) != X ] ; then
864      IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration SubmitPath ${SUBMIT_DIR}
865    fi
866
867    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
868
869  else
870    #================================================#
871    #         The file run.card allready exist       #
872    #================================================#
873
874    # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal"
875    IGCM_config_StateCheck
876    # And EXIT if not OK
877    IGCM_debug_Verif_Exit
878
879    #===================================#
880    #        Read updated run.card      #
881    #===================================#
882
883    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin
884    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd
885    IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod
886
887    PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} )
888    PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} )
889    CumulPeriod=${run_Configuration_CumulPeriod}
890
891    LastPeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate $( IGCM_date_ConvertFormatToGregorian ${PeriodDateBegin} ) -1 )
892
893    if [ ${Period} = 1 ]; then
894      # save last Job output and current run.card
895      typeset Potential
896      IGCM_sys_Cd ${SUBMIT_DIR}
897      #
898      IGCM_debug_Print 2 "Save previous ksh job output"
899      for Potential in $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.[0-9][0-9][0-9][0-9][0-9][0-9] ) ; do
900        if [ X${Pack} = Xtrue ] ; then
901          ( IGCM_sys_TestFileBuffer  ${R_BUF_KSH}/${Potential} ) || IGCM_sys_Cp ${Potential} ${R_BUF_KSH}/${Potential}.$$
902        else
903          ( IGCM_sys_TestFileArchive ${R_OUT_KSH}/${Potential} ) || IGCM_sys_Put_Out ${Potential} ${R_OUT_KSH}/${Potential}.$$ NOMOVE
904          IGCM_debug_Print 1 "Save of previous ksh job output is not done for Pack=false"
905        fi
906      done
907
908      #
909      IGCM_debug_Print 2 "Save current run.card"
910      IGCM_card_CheckConflict run.card
911
912      if [ X${Pack} = Xtrue ] ; then
913        IGCM_sys_Cp ${SUBMIT_DIR}/run.card ${R_BUF_KSH}/run.card
914      else
915        IGCM_sys_Put_Out ${SUBMIT_DIR}/run.card ${R_OUT_KSH}/run.card NOMOVE
916        IGCM_debug_Print 1 "Save of run.card is not done for Pack=false"
917      fi
918      #
919      IGCM_sys_Cd ${RUN_DIR}
920    else
921      unset FileToBeDeleted
922    fi
923
924    # Determine number of day(s) in PeriodLength
925    IGCM_date_GetYearMonthDay $PeriodDateBegin year month day
926    IGCM_config_DaysInPeriodLength
927
928    # Check coherency between (PeriodDateBegin, PeriodDateEnd) and (DateBegin, CumulPeriod, PeriodLength)
929    IGCM_config_DateCoherency
930    # And EXIT if not OK
931    IGCM_debug_Verif_Exit
932
933    # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal"
934    IGCM_config_StateCheck
935    # And EXIT if not OK
936    IGCM_debug_Verif_Exit
937
938    # We can say we are "Running" now.
939    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Running"
940  fi
941
942  # BEGIN: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh
943  # Compute year_m1 and year_p1 (year minus 1Y and year plus 1Y)
944  year_m1=$(( year - 1 ))
945  year_p1=$(( year + 1 ))
946  # Compute month_m1 (month minus 1M)
947  # Compute yyyymm_m1 (yyyymm minus 1M)
948  month_m1=$(( 10#${month} - 1 ))
949  if [ ${month_m1} = 0 ]; then
950    month_m1=12
951    yyyymm_m1=${year_m1}12
952  elif [ ${month_m1} -le 9 ]; then
953    month_m1=0${month_m1}
954    yyyymm_m1=${year}${month_m1}
955  else
956    yyyymm_m1=${year}${month_m1}
957  fi
958  # Compute month_p1 (month plus 1M)
959  # Compute yyyymm_p1 (yyyymm plus 1M)
960  month_p1=$(( 10#${month} + 1 ))
961  if [ ${month_p1} = 13 ]; then
962    month_p1=01
963    yyyymm_p1=${year_p1}01
964  elif [ ${month_p1} -le 9 ]; then
965    month_p1=0${month_p1}
966    yyyymm_p1=${year}${month_p1}
967  else
968    yyyymm_p1=${year}${month_p1}
969  fi
970
971
972  #===================================================================#
973  # Calculate CyclicYear to be used for looping over a given forcing  #
974  # period. Add CyclicBegin and CyclicEnd in config.card UserChoices. #
975  #===================================================================#
976
977  # To use the variable CyclicYear, one must add in config.card CyclicBegin and CyclicEnd.
978  # CyclicBegin is the first year in the cycle. CyclicEnd is the last year included in the cycle.
979  if ( [ ! X${config_UserChoices_CyclicBegin} = X ] && [ ! X${config_UserChoices_CyclicEnd} = X ] ) ; then
980    CycleNb=$(( ${config_UserChoices_CyclicEnd} - ${config_UserChoices_CyclicBegin} + 1 ))
981    #CyclicYear_p1=  #NOTDEFINED
982 
983    # For current year
984    yeartmp=$year
985    diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} ))
986    while [ $diffy -lt 0 ] ; do
987      yeartmp=$(( ${yeartmp} + ${CycleNb} ))
988      diffy=$(( $yeartmp - ${config_UserChoices_CyclicBegin} ))
989    done
990    CyclicYear=$(( ( ${diffy} % ${CycleNb} ) + ${config_UserChoices_CyclicBegin} ))
991
992    # For next coming year
993    CyclicYear_p1=$(( CyclicYear + 1 ))
994
995    # For previous year
996    CyclicYear_m1=$(( CyclicYear - 1 ))
997
998    IGCM_debug_Print 1 "CyclicYear   = ${CyclicYear}, current year=$year"
999    IGCM_debug_Print 1 "CyclicYear_p1 = ${CyclicYear_p1}, CyclicYear_m1 = ${CyclicYear_m1} "
1000  else
1001    CyclicYear="ERROR_CyclicYear_Variable_Not_Defined"
1002    CyclicYear_p1="ERROR_CyclicYear_p1_Variable_Not_Defined"
1003    IGCM_debug_Print 1 "CyclicYear wont be use without adding CyclicBegin and CyclicEnd in config.card"
1004  fi
1005
1006  # END: SHOULD GO IN A FUNCTION FROM libIGCM_date.ksh
1007
1008  #===================================================================#
1009  # Prepare variables available for ${COMP}.card and ${COMP}.driver   #
1010  #             But available to any son functions                    #
1011  #===================================================================#
1012
1013  # Period Length In Days between DateBegin and DateCurrent (at end of period == PeriodDateEnd !)
1014  (( SimulationLengthInDays = $( IGCM_date_DaysBetweenGregorianDate ${PeriodDateEnd} ${DateBegin} ) + 1 ))
1015
1016  # Debug Print :
1017  echo
1018  IGCM_debug_Print 1 "IGCM_config_PeriodStart : Before Execution"
1019  IGCM_debug_Print 1 "Year of simulation      : ${year}"
1020  IGCM_debug_Print 1 "Month of simulation     : ${month}"
1021  IGCM_debug_Print 1 "PeriodLengthInDays      : ${PeriodLengthInDays}"
1022  IGCM_debug_Print 1 "PeriodDateBegin         : ${PeriodDateBegin}"
1023  IGCM_debug_Print 1 "PeriodDateEnd           : ${PeriodDateEnd}"
1024  IGCM_debug_Print 1 "SimulationLengthInDays  : ${SimulationLengthInDays}"
1025  IGCM_debug_Print 1 "ExperienceLengthInDays  : ${ExperienceLengthInDays}"
1026
1027  #================================================================#
1028  #         Prepare variables available for comp_finalyze          #
1029  #================================================================#
1030
1031  # Period for save files
1032  DatesPeriod=${PeriodDateBegin}_${PeriodDateEnd}
1033
1034  # Prefix for save files of this period
1035  PREFIX=${config_UserChoices_JobName}_${DatesPeriod}
1036
1037  # List of files that will be deleted in RUN_DIR after run
1038  [ -f stack ] && FileToBeDeleted[0]="stack"
1039
1040  # Test if the same run as already been saved :
1041  if [ X${JobType} = XRUN ] ; then
1042    if [ ${DRYRUN} -le 0 ] ; then
1043      if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then
1044        IGCM_debug_Exit "IGCM_config_PeriodStart" "You are currently re-running an old job."
1045        IGCM_debug_Print 1 "Because of readonly permissions, you can't re-run a job when saved files"
1046        IGCM_debug_Print 1 " are still in the ARCHIVE directory. You must deleted those files, or "
1047        IGCM_debug_Print 1 " the whole ${R_SAVE} tree. See different clean_*.job in ${libIGCM} directory."
1048        IGCM_debug_Print 1 " This exit has been initiated because at least ${R_BUF_KSH}/${PREFIX}_${Exe_Output} exists."
1049        IGCM_debug_Verif_Exit
1050      fi
1051    fi
1052  else
1053    if ( IGCM_sys_TestFileBuffer ${R_BUF_KSH}/${PREFIX}_${Exe_Output} ) ; then
1054      IGCM_debug_Print 1 "IGCM_config_PeriodStart" "RErun an old job. Allowed in DEBUG or DEV mode."
1055    fi
1056  fi
1057
1058  #================================================================#
1059  #       Prepare variables available for binary execution         #
1060  #       Call function for creation of run script                 #
1061  #       Only done once per job                                   #
1062  #================================================================#
1063
1064  if [ ${Period} -eq 1 ]; then
1065    # Define the execution context (MPMD, SPMD, MPI/OMP ...)
1066    IGCM_config_ConfigureExecution ${SUBMIT_DIR}/config.card
1067    # Create the execution script for the current context
1068    IGCM_sys_build_execution_scripts
1069  fi
1070
1071  ExecutionFail=false
1072
1073  # Update the rabbitMQ queue
1074  IGCM_debug_BigBro_Update
1075
1076  IGCM_debug_PopStack "IGCM_config_PeriodStart"
1077}
1078
1079#===================================
1080function IGCM_config_SaveSourceModifications
1081{
1082  IGCM_debug_PushStack "IGCM_config_SaveSourceModifications"
1083
1084  typeset ExeOutDateMax listVarEnv
1085  ExeOutDateMax=$1
1086
1087  listVarEnv="ExeOutDateMax,R_OUT_EXE,PREFIX,SUBMIT_DIR"
1088  IGCM_sys_RshMaster "\
1089    . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh; \
1090    export ExeOutDateMax=${ExeOutDateMax};\
1091    export R_OUT_EXE=${R_OUT_EXE};\
1092    export PREFIX=${PREFIX};\
1093    export SUBMIT_DIR=${SUBMIT_DIR};\
1094    export listVarEnv=${listVarEnv};\
1095    Script_Output=out_SaveSourceModifications;\
1096    IGCM_sys_Qsub ${libIGCM}/SaveSourceModifications.job ${ExeOutDateMax} ${R_OUT_EXE} ${PREFIX} ${SUBMIT_DIR}"
1097
1098  IGCM_debug_PopStack "IGCM_config_SaveSourceModifications"
1099}
1100
1101#===================================
1102function IGCM_config_PeriodEnd
1103{
1104  IGCM_debug_PushStack "IGCM_config_PeriodEnd"
1105
1106  echo
1107  IGCM_debug_Print 1 "IGCM_config_PeriodEnd"
1108  echo
1109
1110  if [ ${DRYRUN} -le 1 ] ; then
1111
1112    IGCM_debug_Print 1 "Check components binary : size and creation date"
1113
1114    typeset LS_comp LS_bin ExeDate ExeCpuLog NextExeSize LastCompExeSize
1115    typeset comp i
1116    typeset ExeNameIn ExeNameOut UpdateExe ExeSecDateMax
1117
1118    #==================================#
1119    #        Get last Exe Size         #
1120    #==================================#
1121
1122    (( i=0 ))
1123    if ( ${FirstInitialize} ) ; then
1124      run_Log_LastExeSize=""
1125      for comp in ${config_ListOfComponents[*]} ; do
1126        run_Log_LastExeSize[$i]=0
1127        (( i=i+1 ))
1128      done
1129    else
1130      IGCM_card_DefineArrayFromOption ${SUBMIT_DIR}/run.card Log LastExeSize
1131    fi
1132    #==================================#
1133    #         And Build ExeDate        #
1134    #==================================#
1135
1136    # ExeDate = ATM_Jun_12_09:34-SRF_Jun_12_09:34-OCE_Jun_12_09:34-ICE_Jun_12_09:34-CPL_Jun_12_09:33
1137    # Would be nice to have next line but no way to format ls output (need to ls -l --time-style "+%Y-%m-%dT%H:%M")
1138    # ExeDate = ATM_2009-06-12T09:34+SRF_2009-06-12T09:34+OCE_2009-06-12T09:34+ICE_2009-06-12T09:34+CPL_2009-06-12T09:34
1139    ExeDate=""
1140    NextExeSize="( "
1141    (( i=0 ))
1142    UpdateExe=false
1143    (( ExeSecDateMax = 0 ))
1144    for comp in ${config_ListOfComponents[*]} ; do
1145
1146      IGCM_debug_Print 3 ${comp}
1147
1148      eval ExeNameIn=\${config_Executable_${comp}[0]}
1149      eval ExeNameOut=\${config_Executable_${comp}[1]}
1150      # Only if we really have an executable for the component :
1151      if [ X${ExeNameIn} = X\"\" ] ; then
1152        # If there is no exe file for this component
1153        (( ExeSize=0 ))
1154      else
1155        eval ExeNameIn=${ExeNameIn}
1156        LS_bin=${R_EXE}/${ExeNameIn}
1157        IGCM_sys_FileSize ${LS_bin} ExeSize
1158
1159        set +A LS_comp -- $( LC_TIME=en_US ls -l ${LS_bin} )
1160        if [ X${ExeDate} = X ] ; then
1161          # First component exe date
1162          ExeDate=${comp}_${LS_comp[5]}_${LS_comp[6]}
1163        else
1164          ExeDate=${ExeDate}-${comp}_${LS_comp[5]}_${LS_comp[6]}
1165        fi
1166        ExeDate=${ExeDate}_${LS_comp[7]}
1167      fi
1168
1169      if [ ${i} -eq 0 ] ; then
1170        # First component
1171        NextExeSize="( "${ExeSize}
1172      else
1173        NextExeSize=${NextExeSize}", "${ExeSize}
1174      fi
1175      LastCompExeSize=${run_Log_LastExeSize[$i]}
1176      (( i=i+1 ))
1177
1178      if [ ${ExeSize} -ne ${LastCompExeSize} ] ; then
1179        if ( ${FirstInitialize} ) ; then
1180          IGCM_debug_Print 1 "Save first ${ExeNameIn} in ${R_OUT_EXE} !"
1181        else
1182          IGCM_debug_Print 1 "${ExeNameIn} has changed in ${R_EXE} !"
1183          IGCM_debug_Print 1 "Save latest ${ExeNameIn} in ${R_OUT_EXE} !"
1184          FileToBeDeleted[${#FileToBeDeleted[@]}]=${ExeNameOut}
1185        fi
1186        IGCM_sys_Put_Out ${ExeNameOut} ${R_OUT_EXE}/${PREFIX}_${ExeNameIn} rw
1187        UpdateExe=true
1188
1189        # SD : switch off for now
1190        #IGCM_sys_GetDate_FichWork ${LS_bin} ExeSecDate
1191        #if [ $ExeSecDateMax -lt $ExeSecDate ] ; then
1192        #  ExeSecDateMax=$ExeSecDate
1193        #fi
1194      fi
1195    done
1196
1197    # SD : switch off for now
1198    #if ( ${UpdateExe} ) ; then
1199    #  echo "Launch SaveSourceModifications."
1200    #  IGCM_config_SaveSourceModifications ${ExeSecDateMax}
1201    #fi
1202
1203    NextExeSize=${NextExeSize}" )"
1204    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Log LastExeSize "${NextExeSize}"
1205
1206    if [ ${DRYRUN} -le 1 ] ; then
1207      tail -1500 ${Exe_Output} > ${Exe_Output}_tail.txt
1208      ExeCpuLog=$( gawk -f ${libIGCM}/libIGCM_sys/IGCM_add_out.awk ${Exe_Output}_tail.txt )
1209      RET=$?
1210      if [ $RET -eq 0 ] ; then
1211        # ExeCpuLog variable contents 5 fields
1212        echo "${CumulPeriod} ${PeriodDateBegin} ${PeriodDateEnd} ${ExeCpuLog} ${ExeDate}" |   \
1213          gawk '{printf("# %11d | %15s | %15s | %19s | %19s | %15.5f | %15.5f | %15.5f | %s\n", \
1214            $1,$2,$3,$4,$5,$6,$7,$8,$9)}' >> ${SUBMIT_DIR}/run.card
1215      fi
1216      FileToBeDeleted[${#FileToBeDeleted[@]}]=${Exe_Output}_tail.txt
1217    fi
1218
1219  fi
1220
1221  #==================================#
1222  #         Save Job output          #
1223  #==================================#
1224  if [ X${Pack} = Xtrue ] ; then
1225    IGCM_sys_PutBuffer_Out ${Exe_Output} ${R_BUF_KSH}/${PREFIX}_${Exe_Output}
1226  else
1227    IGCM_sys_Put_Out ${Exe_Output} ${R_OUT_KSH}/${PREFIX}_${Exe_Output}
1228  fi
1229  FileToBeDeleted[${#FileToBeDeleted[@]}]=${Exe_Output}
1230
1231  # All was right ? no ? then we stop.
1232  IGCM_debug_Verif_Exit
1233
1234  # If all was OK, we can delete all files not necessary for next Job
1235  echo
1236  IGCM_debug_Print 1 "Files that will be deleted before next period-run : "
1237
1238  if [ ${DRYRUN} -le 2 ] ; then
1239    for f in ${FileToBeDeleted[@]} ; do [ -f ${f} ] && ls -la $f ; [ -f ${f} ] && rm -f $f ; done
1240  else
1241    echo ${FileToBeDeleted[@]}
1242  fi
1243
1244  # Send some accounting element to the user if CumulPeriod=3
1245  if [ ${CumulPeriod} -eq 3 ] ; then
1246    echo
1247    IGCM_debug_Print 1 "Send email containing some accounting information : "
1248
1249    RealCpuTime=$( echo ${ExeCpuLog} | gawk '{print $3}' )
1250
1251    consumeHoursPerPeriod=$( echo "scale=6;${RealCpuTime}*${coreNumber}/3600" | bc )
1252
1253    consumeHoursPerWholeSimulation=$( echo "scale=6;${consumeHoursPerPeriod}/${PeriodLengthInDays}*${ExperienceLengthInDays}" | bc )
1254
1255    recommendedPeriodNb=$( echo "scale=6;${jobWarningDelay}/3600/${consumeHoursPerPeriod}*${coreNumber}" | bc )
1256
1257    IGCM_sys_SendMail Accounting
1258  fi
1259
1260  #=================================================#
1261  #         Modification of libIGCM behaviour       #
1262  #=================================================#
1263
1264  # To use this function, one must copy libIGCM.card from ${libIGCM} directory
1265  # and put it in ${SUBMIT_DIR} directory. After modifications of ${SUBMIT_DIR}/libIGCM.card,
1266  # variables define inside [UserChanges] will be modified for next Period of libIGCM main loop.
1267  if [ -f ${SUBMIT_DIR}/libIGCM.card ] ; then
1268    echo
1269    echo "########################################################################"
1270    echo "!!!                 Modification of libIGCM behaviour                !!!"
1271    echo
1272
1273    IGCM_debug_Print 1 "DefineArrayFromOption  : libIGCM_UserChanges in libIGCM.card"
1274    IGCM_card_DefineArrayFromSection ${SUBMIT_DIR}/libIGCM.card UserChanges
1275    IGCM_debug_Print 2 "libIGCM_UserChanges" ${libIGCM_UserChanges[*]}
1276
1277    # Special treatments for libIGCM internals
1278    for option in ${libIGCM_UserChanges[*]} ; do
1279      IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/libIGCM.card UserChanges ${option}
1280
1281      echo "We will change : ${option}."
1282      eval echo "Previous value : " \${${option}}
1283      eval echo "Change to : " \${libIGCM_UserChanges_${option}}
1284
1285      eval ${option}=\${libIGCM_UserChanges_${option}}
1286
1287      case ${option} in
1288      config_UserChoices_DateEnd)
1289        IGCM_debug_PrintVariables 1 config_UserChoices_DateEnd
1290        DateEnd=$( IGCM_date_ConvertFormatToGregorian ${config_UserChoices_DateEnd} )
1291
1292        # Period Length In Days between DateBegin and DateEnd
1293        (( ExperienceLengthInDays=$( IGCM_date_DaysBetweenGregorianDate ${DateEnd} ${DateBegin} )  + 1 ))
1294        if [ ${ExperienceLengthInDays} -lt 0 ] ; then
1295          IGCM_debug_Print 1 "Problem with dates in libIGCM.card : ${DateEnd} < ${DateBegin} ! You must check that."
1296          IGCM_debug_Exit "IGCM_PeriodEnd have wrong dates."
1297          IGCM_debug_Verif_Exit
1298        fi
1299        ;;
1300      config_UserChoices_PeriodLength)
1301        IGCM_debug_Print 1  "Change config_UserChoices_PeriodLength=${config_UserChoices_PeriodLength}"
1302        ;;
1303      PeriodNb)
1304        IGCM_debug_Print 1  "Loop in main Job with ${PeriodNb} period(s)"
1305        ;;
1306      config_Post_RebuildFrequency)
1307        IGCM_debug_Print 1  "Change config_Post_RebuildFrequency=${config_Post_RebuildFrequency} : IGCM_post_Configure"
1308        IGCM_post_Configure
1309        ;;
1310      config_Post_TimeSeriesFrequency)
1311        IGCM_debug_Print 1  "Change config_Post_TimeSeriesFrequency = ${config_Post_TimeSeriesFrequency} : IGCM_post_Configure"
1312        IGCM_post_Configure
1313        ;;
1314      config_Post_SeasonalFrequency)
1315        IGCM_debug_Print 1  "Change config_Post_SeasonalFrequency = ${config_Post_SeasonalFrequency} : IGCM_post_Configure"
1316        IGCM_post_Configure
1317        ;;
1318      esac
1319    done
1320
1321    echo
1322    echo "########################################################################"
1323    echo
1324  fi
1325
1326  #=================================================#
1327  #         Determine next computed period          #
1328  #=================================================#
1329
1330  PeriodDateBegin=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateEnd} 1 )
1331  IGCM_date_GetYearMonthDay $PeriodDateBegin year month day
1332  year_m1=$(( year - 1 ))
1333  year_p1=$(( year + 1 ))
1334  IGCM_config_DaysInPeriodLength
1335  PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $(( ${PeriodLengthInDays} - 1 )) )
1336
1337  # Debug Print :
1338  echo
1339  IGCM_debug_Print 1 "IGCM_config_PeriodEnd : Preparing Next Execution"
1340  IGCM_debug_Print 1 "PeriodDateBegin       : ${PeriodDateBegin}"
1341  IGCM_debug_Print 1 "PeriodDateEnd         : ${PeriodDateEnd}"
1342  IGCM_debug_Print 1 "PeriodLengthInDays    : ${PeriodLengthInDays}"
1343
1344  PeriodDateBegin=$( IGCM_date_ConvertFormatToHuman ${PeriodDateBegin} )
1345  PeriodDateEnd=$( IGCM_date_ConvertFormatToHuman ${PeriodDateEnd} )
1346
1347  (( CumulPeriod = CumulPeriod + 1 ))
1348
1349  # Debug Print :
1350  echo
1351  IGCM_debug_Print 3 "PeriodDateBegin Human : ${PeriodDateBegin}"
1352  IGCM_debug_Print 3 "PeriodDateEnd Human   : ${PeriodDateEnd}"
1353  IGCM_debug_Print 3 "CumulPeriod           : ${CumulPeriod}"
1354
1355  #=================================================#
1356  #             Write updated run.card              #
1357  #=================================================#
1358
1359  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin ${PeriodDateBegin}
1360  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd ${PeriodDateEnd}
1361  IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod ${CumulPeriod}
1362
1363  if ( ${FirstInitialize} ) ; then
1364    # It's no more the first time
1365    FirstInitialize=false
1366  fi
1367
1368  IGCM_debug_PopStack "IGCM_config_PeriodEnd"
1369}
1370
1371#===================================
1372function IGCM_config_Finalize
1373{
1374  IGCM_debug_PushStack "IGCM_config_Finalize"
1375
1376  echo
1377  IGCM_debug_Print 1 "IGCM_config_Finalize"
1378  echo
1379
1380  # Test state of run in run.card. Will schedule an exit if another process setted it to "Fatal"
1381  IGCM_config_StateCheck
1382
1383  # And EXIT if not OK
1384  IGCM_debug_Verif_Exit
1385
1386  if [ ${SimulationLengthInDays} -ge ${ExperienceLengthInDays} ] ; then
1387    #==========================#
1388    # End of entire simulation #
1389    #==========================#
1390    simulationIsOver=true
1391
1392    # Mail notification
1393    IGCM_sys_SendMail
1394    #
1395    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "Completed"
1396    #
1397    IGCM_debug_Print 1 "Normal End of computation."
1398
1399  else
1400    #=================#
1401    # Submit next job #
1402    #=================#
1403    simulationIsOver=false
1404
1405    IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue"
1406
1407    # Name of next Ksh Script output :
1408    Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${CumulPeriod} )
1409
1410    IGCM_debug_Print 1 "Submit next job"
1411    # SUBMIT NEXT JOB from SUBMIT_DIR and come back in RUN_DIR
1412    IGCM_sys_Cd ${SUBMIT_DIR}
1413    # Keep only the 5 latest ${Script_Output_Prefix}_${config_UserChoices_JobName}
1414    ScriptTot=$( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? 2>/dev/null | wc -l )
1415    [ ${ScriptTot} -gt 5 ] && rm -f $( ls ${Script_Output_Prefix}_${config_UserChoices_JobName}.?????? | head -$(( ${ScriptTot} - 5 )) )
1416    # Submit next job and come back
1417    IGCM_sys_Qsub ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}
1418    IGCM_sys_Cd -
1419  fi
1420
1421  # Clean ${RUN_DIR}=${RUN_DIR_PATH}/${config_UserChoices_JobName}.${$}
1422  # Only for production run (No clean up in DEV or DEB mode)
1423  # and command sent from .. directory.
1424  IGCM_sys_Cd ..
1425  [ X${JobType} = XRUN ] && IGCM_sys_RmRunDir -rf ${RUN_DIR_PATH}
1426
1427  # Inform the rabbitMQ queue
1428  IGCM_debug_BigBro_Finalize
1429
1430  IGCM_debug_PopStack "IGCM_config_Finalize"
1431}
1432
1433#===================================
1434function IGCM_config_ensembleXIOS
1435{
1436  IGCM_debug_PushStack "IGCM_config_ensembleXIOS"
1437
1438  echo
1439  IGCM_debug_Print 1 "IGCM_config_ensembleXIOS"
1440  echo
1441   whole_ensemble_size=$((config_Ensemble_PoolNumber * config_Ensemble_PoolSize))
1442   cp ${SUBMIT_DIR}/ENSEMBLES/create* .
1443   cp ${SUBMIT_DIR}/ENSEMBLES/script* .
1444
1445   j=0 #un compteur
1446   for i in $(cut -d: -f3 ${SUBMIT_DIR}/ensemble.txt); do
1447         noise_teta[$j]=$i
1448       j=$j+1
1449   done
1450
1451
1452   if [ ${config_Ensemble_EnsembleXIOS} = TRUE ] ; then
1453
1454       for (( pool_member_rank=0 ; pool_member_rank < $(($config_Ensemble_PoolSize+1)) ; pool_member_rank++ ))
1455       do
1456           whole_ensemble_rank=$(($config_Ensemble_PoolSize*$1+$pool_member_rank))
1457
1458           if (( pool_member_rank < $config_Ensemble_PoolSize ))
1459           then
1460               [ ! -d MEMBER_$whole_ensemble_rank ] && mkdir MEMBER_$whole_ensemble_rank
1461               cd MEMBER_$whole_ensemble_rank
1462               ../create_ensemble_def $whole_ensemble_size $config_Ensemble_PoolSize $1 $pool_member_rank ${noise_teta[$whole_ensemble_rank]}
1463                ../create_oasis_restart.sh $pool_member_rank
1464           else
1465               [ ! -d XIOS ] && mkdir XIOS
1466               cd XIOS
1467           fi
1468           ../create_oasis_namecoupl.sh $config_Ensemble_PoolSize $1
1469           ../create_iodef_xml.sh $config_Ensemble_PoolSize
1470           cd ..
1471        done
1472       ./create_runfile.sh $config_Ensemble_PoolSize $1
1473   fi
1474
1475  IGCM_debug_PopStack "IGCM_config_ensembleXIOS"
1476}
1477
Note: See TracBrowser for help on using the repository browser.