source: trunk/libIGCM/ins_job @ 1615

Last change on this file since 1615 was 1615, checked in by falletti, 6 months ago

Fixing bug for ins_job_Check_JobName and simplifying code.

  • Property svn:executable set to *
  • Property svn:keywords set to Revision Author Date
File size: 24.6 KB
Line 
1#!/bin/ksh
2
3#**************************************************************
4# Author: Jacques Belier
5# Contact:
6# $Revision::                                          $ Revision of last commit
7# $Author::                                            $ Author of last commit
8# $Date::                                              $ 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#- Installation of jobs according to environment
15#---------------------------------------------------------------------
16function ins_job_Usage
17{
18print - "
19ins_job installs the jobs in the directories which contain a file config.card
20
21ins_job also installs the jobs for post-processing in libIGCM folder.
22
23ins_job must be launched on the host on which the job will be submitted.
24
25Usage :
26  ${b_n} [-h] [-v] [-e]
27  or on irene/TGCC :
28  ${b_n} [-h] [-v] [-e] [-p project] [-q type_of_node] [-c number of cores]
29  or on jean-zay /IDRIS
30  ${b_n} [-h] [-v] [-e] [-p project] [-m MPI environment]
31Options :
32  -h                  : help
33  -v                  : verbose mode
34  -e                  : turn on ensemble mode (hindcast/forecast or date restart)
35  -f                  : ins_job force overwrite jobs if they already exist
36
37More options on irene only :
38  -p project          : add default project on irene
39  -q type_of_node     : add default type of nodes for postprocessing on irene skylake/xlarge
40  -c number of cores  : add default number of cores for postprocessing on irene 1-112
41
42More options on jean-zay only :
43  -p project          : add default project on irene
44  -m MPI environment  : add default MPI environment (Intel MPI or IBM MPI)
45  -t wall time        : change default wall time
46"
47}
48function ins_job_Warning
49{
50   [[ ${x_v} = 'verbose' ]] && print - "\n############### WARNING ###############";
51   [[ ${x_v} = 'verbose' ]] && print - "File ${n_f} already exists\nin directory ${j}";
52   [[ ${x_v} = 'verbose' ]] && print - "You must delete this file to update !";
53}
54
55function ins_job_Check_JobName
56{
57  verif=${JobName##[a-zA-Z]*(?([.\-])[a-zA-Z0-9])}
58
59  if [ ${#verif} -ne 0 ] ; then
60    print "\n################## ERROR for JobName in config.card ##################"
61    print "${JobName} is invalid:"
62    print "  - JobName can only contain alphanumeric characters, \".\" and \"-\""
63    print "  - JobName must start with a letter"
64    print "You must change JobName.\n"
65    ((NbErr=NbErr+1))
66    exit
67  fi
68}
69
70#-
71#     dirname     and      basename
72#-
73d_n=$(dirname ${0}); b_n=$(basename ${0});
74#-
75# Retrieving and validation of the options
76#-
77x_v='silencious';
78x_e=false;
79x_f=false;
80x_p=false;
81x_q=false;
82x_c=false;
83x_m=false;
84x_t=false;
85while getopts :hvefc:p:m:q:s:t: V ; do
86  case $V in
87  (h)  ins_job_Usage; exit 0;;
88  (v)  x_v='verbose';;
89  (e)  x_e=true;;
90  (f)  x_f=true;;
91  (p)  x_p=true
92       ProjectID=${OPTARG} ;;
93  (q)  x_q=true
94       ProjectNode=${OPTARG} ;;
95  (c)  x_c=true
96       ProjectCore=${OPTARG} ;;
97  (m)  x_m=true
98       MPIEnvironment=${OPTARG} ;;
99  (t)  x_t=true
100       WallTime=${OPTARG} ;;
101  (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
102       exit 2;;
103  (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
104       exit 2;;
105  esac
106done
107[ ${x_v} = 'silencious' ] && export DEBUG_sys=false
108shift $(($OPTIND-1));
109#-
110# Define working files
111#-
112F_MOD=$(cd ${d_n}'/..';/bin/pwd;)
113# [[ ${F_MOD##*/} != 'modipsl' ]] && \
114#  { print - "directory 'modipsl' unreachable"; exit 3; }
115W_W=${d_n}'/../libIGCM'
116[[ ! -d ${W_W} ]] && { print - "${W_W} unreachable"; exit 3; }
117libIGCM=$(cd ${W_W};/bin/pwd;)
118F_JOB=${libIGCM}'/AA_job';
119[[ ! -f ${F_JOB} ]] && { print - "${F_JOB} unreachable"; exit 3; }
120F_JOB_DEBUG=${libIGCM}'/AA_job_debug';
121[[ ! -f ${F_JOB_DEBUG} ]] && { print - "${F_JOB_DEBUG} unreachable"; exit 3; }
122F_RCI=${libIGCM}'/run.card.init';
123[[ ! -f ${F_RCI} ]] && { print - "${F_RCI} unreachable"; exit 3; }
124
125
126print "Start ins_job\n"
127print "Create job in current folder and post-treatment jobs in libIGCM folder.\n"
128
129if [ ${x_f} == 'false' ] ; then
130    print "The jobs will only be created if they don't already exist. No jobs will be overwritten.\n"
131else
132    print "All existing jobs will be overwritten.\n"
133fi
134
135
136#-
137# Accessing to functions (without stack)
138#-
139# No verbosity (0, 1, 2, 3)
140Verbosity=0
141# No de debug
142DEBUG_debug=false
143# Dont move libIGCM
144MirrorlibIGCM=false
145# Behave like computing job
146TaskType=computing
147# Source libIGCM
148print "Source modules and functions from libIGCM:"
149. ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh
150. ${libIGCM}/libIGCM_card/libIGCM_card.ksh
151. ${libIGCM}/libIGCM_date/libIGCM_date.ksh
152. ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh
153. ${libIGCM}/libIGCM_config/libIGCM_config.ksh
154if [ $x_e = 'true' ] ; then
155  . ${libIGCM}/libIGCM_ensemble/libIGCM_ensemble.ksh
156fi
157
158
159#-
160[[ ${x_v} = 'verbose' ]] && \
161 {
162  print - "";
163  print - '--- Host        : '${SYSTEM};
164  print - '--- modipsl     : '${F_MOD};
165  print - '--- libIGCM     : '${libIGCM};
166  print - '--- basic job   : '${F_JOB};
167  print - '--- basic card  : '${F_RCI};
168 }
169#-
170[[ ${x_v} = 'verbose' ]] && print - "\nInstallation of jobs for '${SYSTEM}'";
171#-
172
173NbErr=0
174
175#-
176# Define Project parameters to set up jobs header for Irene (TGCC)
177# on Irene define ProjectID and ProjectCore : option or answer
178# on Irene ProjectNode default projectnode set to xlarge since 17/10/2018
179#-
180
181if [ X"${SYSTEM}" == "Xirene" ] ; then
182
183  #- set ProjectID if required
184  if ( ! ${x_p} ) ; then
185    print - "Wait for the next question ..."
186    #- default ProjectID
187    ProjectID=$( ccc_myproject | grep -i irene |grep -i skylake | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u | grep -v gencmip6 | head -n 1 )
188    answer=""
189    print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | grep -i irene | grep -i skylake | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u ) ) or other xxxcmip6 : $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ; echo ) "
190    read answer
191
192    if [ "X${answer}" != "X" ] ; then
193      ProjectID=${answer}
194    fi
195
196  fi # if ( ! ${x_p} )
197
198  echo  ProjectID is ${ProjectID} at Irene
199
200
201  # set ProjectNode if required
202  if ( ! ${x_q} ) ; then 
203     #- default ProjectNode
204     ProjectNode="xlarge"
205     #- is xlarge possible for ${ProjectID} ?
206     echo $(ccc_myproject | grep -i irene | grep -i xlarge | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u) $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ) | grep ${ProjectID} >/dev/null 2>&1  || ProjectNode="xlarge"
207
208     if [ "X${ProjectNode}" == "Xxlarge" ] ; then
209       answerOK=false
210 
211       while ( ! ${answerOK} ) ; do
212         answer="" 
213         print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"skylake\" or \"xlarge\" : " 
214         read answer
215         [ "X${answer}" == "X" ] || [ "X${answer}" == "Xskylake" ] || [ "X${answer}" == "Xxlarge" ] && answerOK=true
216       done
217 
218       if [ "X${answer}" != "X" ] ; then
219         ProjectNode=${answer} 
220       fi
221
222     else
223       print - "PostProcessing will be done on ${ProjectNode}"
224     fi
225 
226  fi # if ( ! ${x_q} )
227  echo ProjectNode for post-processing is ${ProjectNode} at Irene
228
229  #- ProjectNode is known (option or answer) set ProjectCoreMax
230  [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" 
231  #- ProjectCoreMax is 48 for standard and 112 for xlarge
232
233  if ( ! ${x_c} ) ; then
234    #- ProjectNode is known (option or answer), set ProjectCore default
235    [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" 
236
237    # let check minimum/maximum value 1/${ProjectCoreMax}
238
239    answerOK=false
240
241    while ( ! ${answerOK} ) ; do
242      answer=""
243      print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : "
244      print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")"
245      read answer
246      [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true
247    done
248
249    if [ "X${answer}" != "X" ] ; then
250      ProjectCore=${answer}
251    fi
252
253  fi # if ( ! ${x_c} )
254
255  echo ProjectCore for post-processing is ${ProjectCore}
256  #- ProjectCore is set (option or answer)
257
258  #- set WallTime if required
259  if ( ! ${x_t} ) ; then
260    #- default WallTime 1800 s
261    WallTime=1800
262    answer=""
263    print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) "
264    read answer
265
266    if [ "X${answer}" != "X" ] ; then
267      WallTime=${answer}
268    fi
269
270  fi # if ( ! ${x_t} )
271   
272  echo Wall time limit is ${WallTime} seconds
273
274elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then
275
276  #- set ProjectID if required
277  if ( ! ${x_p} ) ; then
278    print - "Wait for the next question ..."
279    #- default ProjectID
280    ProjectID=$( ccc_myproject | grep -i irene |grep -i rome | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u | grep -v gencmip6 | head -n 1 )
281    answer=""
282    print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | grep -i irene | grep -i rome | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u ) ) or other xxxcmip6 : $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ; echo ) "
283    read answer
284
285    if [ "X${answer}" != "X" ] ; then
286      ProjectID=${answer}
287    fi
288
289  fi # if ( ! ${x_p} )
290
291  echo  ProjectID is ${ProjectID} at Irene-amd
292
293  # set ProjectNode if required
294  if ( ! ${x_q} ) ; then 
295     #- default ProjectNode
296     ProjectNode="rome"
297     #- is xlarge possible for ${ProjectID} ?
298     echo $(ccc_myproject | grep -i irene | grep -i xlarge | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | grep -v gencmip6 | sort -u) $(for i in $(groups) ; do echo $i|grep -v gencmip6|grep .cmip6 1>/dev/null 2>&1 && echo -n $i " " ; done ) | grep ${ProjectID} >/dev/null 2>&1  || ProjectNode="rome"
299
300     if [ "X${ProjectNode}" == "Xxlarge" ] ; then
301       answerOK=false
302 
303       while ( ! ${answerOK} ) ; do
304         answer="" 
305         print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"rome\"  : " 
306         read answer
307         [ "X${answer}" == "X" ] || [ "X${answer}" == "Xrome" ] && answerOK=true
308       done
309 
310       if [ "X${answer}" != "X" ] ; then
311         ProjectNode=${answer} 
312       fi
313
314     else
315       print - "PostProcessing will be done on ${ProjectNode}"
316     fi
317 
318  fi # if ( ! ${x_q} )
319  echo ProjectNode for post-processing is ${ProjectNode} at Irene-amd
320
321  #- ProjectNode is known (option or answer) set ProjectCoreMax
322  [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" 
323  #- ProjectCoreMax is 48 for standard and 112 for xlarge
324
325  if ( ! ${x_c} ) ; then
326    #- ProjectNode is known (option or answer), set ProjectCore default
327    [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" 
328
329    # let check minimum/maximum value 1/${ProjectCoreMax}
330
331    answerOK=false
332
333    while ( ! ${answerOK} ) ; do
334      answer=""
335      print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : "
336      print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")"
337      read answer
338      [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true
339    done
340
341    if [ "X${answer}" != "X" ] ; then
342      ProjectCore=${answer}
343    fi
344
345  fi # if ( ! ${x_c} )
346
347  echo ProjectCore for post-processing is ${ProjectCore}
348  #- ProjectCore is set (option or answer)
349
350  #- set WallTime if required
351  if ( ! ${x_t} ) ; then
352    #- default WallTime 1800 s
353    WallTime=1800
354    answer=""
355    print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) "
356    read answer
357
358    if [ "X${answer}" != "X" ] ; then
359      WallTime=${answer}
360    fi
361
362  fi # if ( ! ${x_t} )
363   
364  echo Wall time limit is ${WallTime} seconds
365
366elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then
367
368  #- set ProjectID if required
369  if ( ! ${x_p} ) ; then
370    print - "Wait for the next question ..."
371    #- default ProjectID
372    ProjectID=$( echo $IDRPROJ )
373    answer=""
374    print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are: $( groups ; echo ) "
375    read answer
376
377    if [ "X${answer}" != "X" ] ; then
378      ProjectID=${answer}
379    fi
380
381  fi # if ( ! ${x_p} )
382
383  echo  ProjectID is ${ProjectID} at Jean-Zay
384
385  #- set WallTime if required
386  if ( ! ${x_t} ) ; then
387    #- default WallTime 30 minutes
388    WallTime=30
389    answer=""
390    print - "Hit Enter or give required wall time in minutes for computing job (default is \"${WallTime}\" minutes, maximum is 1200 minutes) "
391    read answer
392
393    if [ "X${answer}" != "X" ] ; then
394      WallTime=${answer}
395    fi
396
397  fi # if ( ! ${x_t} )
398   
399  echo Wall time limit is ${WallTime} minutes
400
401elif [ X"${SYSTEM}" == "Xobelix" ] || [ X"${SYSTEM}" == "Xifort_CICLAD" ] ; then
402  # obelix, ciclad, climserv
403  echo ""
404  echo "You need to check and maybe adapt headers in the main job especially the line: "
405  echo "  #PBS -l nodes=x:ppn=y "
406  echo "where x is the number of nodes, y the number of cores per node and x*y is the total number of cores for the job. "
407  echo "y must not be bigger than the maximum numer of cores per node on the machine (often 8 or 16)."
408fi # if [ X"${SYSTEM}" == "Xirene" ]
409
410#-
411# Define the pattern string to substitute
412#-
413W_P='#-Q- '; W_W=${W_P}${SYSTEM}' ';
414#-
415# Extract list of 'config.card' files
416# and create jobs with AA_job
417#-
418F_CFG='config.card';
419F_CFG_ENS='ensemble.card';
420SUBMIT_DIR_ENS=$( pwd )
421for i in $( pwd )/config.card
422do
423  if [ ! -f $i ] ; then
424    echo ""
425    echo "################## WARNING ##################"
426    echo "No config.card available in current directory"
427    echo ""
428    conf_card=no
429    continue
430  fi
431  conf_card=yes
432
433
434  j=$(cd ${i%/*};/bin/pwd;)
435  n_f=${F_RCI##*/};
436
437  if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then
438    # Do not treat config.card if it is in sub-directory of EXPERIMENTS
439    # Continue to next config.card
440    continue
441  else
442    [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
443  fi
444
445  # Find out if new structure and set .resol filename
446  if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then
447    # New Structure
448    [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure"
449    new_struct=yes
450    resolfile=$j/.resol
451  else
452    # Old Structure
453    new_struct=no
454    resolfile=$j/../.resol
455  fi
456
457  # Get all variables declared in section UserChoices in config.card
458  IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices
459  # Set default values
460  config_UserChoices_ExpType=""
461  RESOL_ATM_3D=this_is_a_test_string
462  RESOL=this_is_another_test_string
463  ResolAtm=this_is_a_new_another_test
464  typeset option
465  for option in ${config_UserChoices[*]} ; do
466    IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option}
467  done
468
469  # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file
470  if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then
471    TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' )
472    echo TRUERESOL = $TRUERESOL
473    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" )
474    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
475  elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then
476    TRUERESOL=$( head -1 $resolfile  )
477    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" )
478    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
479  elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${ResolAtm} ) = X ] ; then
480    TRUERESOL=${config_UserChoices_ResolAtm}
481    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${ResolAtm}/${TRUERESOL}/" )
482    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
483  else
484    JobName=${config_UserChoices_JobName}
485  fi
486
487  # Check JobName validity : only alphanumerical characters, "-" and "." are authorized
488  # Exit if not valid.
489  ins_job_Check_JobName
490
491  [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}"
492
493  # Add specific treatment for new type of directory structure
494  if [ ${new_struct} == yes ] ; then
495
496    if [ "X${config_UserChoices_ExpType}" = X ] ; then
497      echo "\nERROR in ${j}/config.card"
498      echo "ins_job stops here"
499      echo "=> The variable ExpType must be added in config.card in section UserChoices"
500      echo "=> ExpType gives the directory for the .card configuration files for the wanted experiement. For exemple ExpType=IPSLCM5/historical"
501      exit 4
502    else
503      [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}"
504    fi
505
506    if [ -d ${j}/${JobName} ] ; then
507      echo "Directory ${j}/${JobName} exists already. It will not be overwritten."
508      echo "Remove the existing directory or change JobName before relaunching ins_job."
509      #continue
510      exit 
511    fi
512    echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}"
513    cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName}
514    cp -r ${j}/GENERAL/* ${j}/${JobName}/.
515    cp -f ${j}/${F_CFG}  ${j}/${JobName}/.
516    if [ -f ${F_CFG_ENS} ] ; then
517      cp -f ${j}/${F_CFG_ENS}  ${j}/${JobName}/.
518      SUBMIT_DIR_ENS=${j}/${JobName}
519    fi
520    rm -f ${j}/${F_CFG}
521    # rm -f ${j}/${F_CFG_ENS}
522    rm -f ${j}/${F_CFG}.bak
523    j=${j}/${JobName}
524    [[ ${x_v} = 'verbose' ]] && echo new j=$j
525  fi
526  # end specific treatment for new type directory structure
527
528  [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \
529   {
530    [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}";
531    \cp ${F_RCI} ${j};
532   }
533
534  #==================================
535  # Read ListOfComponents section:
536  #echo
537  #IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents"
538
539  IGCM_card_DefineArrayFromSection  ${j}'/'${F_CFG} ListOfComponents
540  for comp in ${config_ListOfComponents[*]} ; do
541    IGCM_card_DefineArrayFromOption  ${j}'/'${F_CFG} ListOfComponents ${comp}
542  done
543  #IGCM_debug_Print 3 ${config_ListOfComponents[*]}
544
545  #==================================
546  # Read Executable section:
547  IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} Executable
548
549  # Define the execution context (MPMD, SPMD, MPI/OMP ...)
550  IGCM_config_ConfigureExecution ${j}'/'${F_CFG}
551
552  # coreNumber    : TOTAL NUMBER OF CORES
553  # mpiTasks      : TOTAL NUMBER OF MPI TASKS
554  # openMPthreads : NUMBER OF OpenMP THREADS
555
556  # File name for Job_debug
557  n_f='Job_debug_'${JobName};
558  [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
559  sed -e "/^${W_W} */ s///" \
560      -e "/^${W_P}/d"       \
561      -e "s%::modipsl::%${F_MOD}%" \
562      -e "s/::Jobname::/${JobName}/" \
563      -e "s/::default_project::/${ProjectID}/" \
564      -e "s/::WallTime::/${WallTime}/" \
565      ${F_JOB_DEBUG} > ${libIGCM}'/'${n_f}
566  chmod u+x ${libIGCM}'/'${n_f}
567
568  # update Headers so that ressources description are accurate (MPMD/SPMD/...)
569  IGCM_sys_updateHeaders ${libIGCM}'/'${n_f}
570
571  # File name for Job
572  n_f='Job_'${JobName};
573  [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; }
574  [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
575  sed -e "/^${W_W} */ s///" \
576      -e "/^${W_P}/d"       \
577      -e "s%::modipsl::%${F_MOD}%" \
578      -e "s/::Jobname::/${JobName}/" \
579      -e "s/::default_project::/${ProjectID}/" \
580      -e "s/::WallTime::/${WallTime}/" \
581      ${F_JOB} > ${j}'/'${n_f}
582  chmod u+x ${j}'/'${n_f}
583
584  # update Headers so that ressources description are accurate (MPMD/SPMD/...)
585  IGCM_sys_updateHeaders ${j}'/'${n_f}
586 
587done
588
589#-
590# Extract list of AA_* files in libIGCM
591# and create jobs (for all except AA_job)
592#-
593for i in $(find ${libIGCM} -maxdepth 1 -name "AA_*" -print)
594do
595  i_f=${i##*/};
596  [[ ${i_f} = 'AA_job' ]] && { continue; }
597  [[ ${i_f} = 'AA_job_debug' ]]  && { continue; }
598  j=${i%/*}; n_f=${i_f#AA_}'.job';
599  [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; }
600  [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}"
601  sed -e "/^${W_W} */ s///" \
602      -e "s%::modipsl::%${F_MOD}%" \
603      -e "/^${W_P}/d"       \
604      -e "s/::default_node::/${ProjectNode}/" \
605      -e "s/::default_core::/${ProjectCore}/" \
606      -e "s/::default_project::/${ProjectID}/" \
607      -e "s/::default_post_project::/${ProjectID}/" \
608      ${i} > ${j}'/'${n_f}
609  chmod u+x ${j}'/'${n_f}
610done
611#-
612# set default_project in libIGCM_sys_irene and libIGCM_sys_jeanzay.
613#-
614if [ X"${SYSTEM}" == "Xirene" ] ; then
615  i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene.ksh
616  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
617elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then
618  i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene-amd.ksh
619  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
620elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then
621  i=${libIGCM}/libIGCM_sys/libIGCM_sys_jeanzay.ksh
622  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
623fi
624#-
625# Limited to hindcast/forecast and date restart Ensemble for the time being
626if [ ${x_e} = 'true' ] ; then
627    if [ ! -f ${F_CFG_ENS} ] ; then
628       echo ""
629       echo "################## WARNING ##################"
630       echo "No ensemble.card available in current directory"
631       echo ""
632       exit
633      #  continue
634   fi
635
636  #.. Read input data from ensemble.card ..
637  SUBMIT_DIR=${SUBMIT_DIR_ENS}
638  RUN_DIR="${CCCWORKDIR}/ENSEMBLE_TMP"
639  #
640  # Copy initial things around and define variables (hindcast/forecast case)
641  IGCM_sys_Cd ${SUBMIT_DIR}
642  IGCM_ensemble_Init
643
644  if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then
645    IGCM_sys_Cd ${SUBMIT_DIR}
646    IGCM_ensemble_DateInit
647    # As it says
648    IGCM_sys_Cd ${SUBMIT_DIR}
649    IGCM_ensemble_DateNonPeriodicStarts
650  fi
651
652  if [[ ${ensemble_Ens_PERTURB_active} = 'y' ]] ; then
653    IGCM_sys_Cd ${SUBMIT_DIR}
654    IGCM_ensemble_CastInit
655    # As it says
656    IGCM_sys_Cd ${SUBMIT_DIR}
657    IGCM_ensemble_CastPeriodicStarts
658    # As it says
659    #IGCM_sys_Cd ${SUBMIT_DIR}
660    #IGCM_ensemble_CastMemberList
661  fi
662  # Done
663  IGCM_sys_Cd ${SUBMIT_DIR}
664  # Clean
665  IGCM_sys_Rm -rf ${RUN_DIR}
666 
667fi
668
669#
670# Install a light copy of C-ESM-EP in SUBMIT_DIR/Cesmep and create a
671# C-ESM-EP launch script there.
672#
673# Only do this if we are in a folder containing a config.card (conf_card=yes)
674if [ ${conf_card} == yes ] ; then
675
676    [[ ${new_struct} == yes ]] && prefix="$JobName/" 
677
678    IGCM_card_DefineVariableFromOption ${prefix}config.card Post Cesmep
679   
680    if ( [ X${config_Post_Cesmep} = X${NULL_STR} ] || [ X${config_Post_Cesmep} = XNONE ] || \
681        [ X${config_Post_Cesmep} = X ] ) ; then
682        config_Post_Cesmep=FALSE
683    fi
684    if [ ${config_Post_Cesmep} != FALSE ]; then
685        IGCM_config_CommonConfiguration ${prefix}config.card
686        if [ x"${config_Post_CesmepMail}" == x"TRUE" ] || [ x"${config_Post_CesmepMail}" == x"True" ] ; then
687            # Compute mail adress - inspired by libIGCM_post.ksh - should be turned in a function
688            if [ ! -z ${config_UserChoices_MailName} ] ; then
689                MailAdress=${config_UserChoices_MailName}
690            elif [ -f ~/.forward ] ; then
691                MailAdress=$( cat ~/.forward )
692            else
693                MailAdress=${USER}
694            fi
695        else
696            MailAdress=None
697        fi
698        #
699        components=","
700        for comp in ${config_ListOfComponents[*]} ; do
701            components=${components}${comp}, ;
702        done
703        if ( [ X"${SYSTEM}" == X"irene" ]    || [ X"${SYSTEM}" == X"irene-amd" ] || \
704            [ X"${SYSTEM}" == X"mesoipsl" ] || [ X"${SYSTEM}" == X"jeanzay" ] ) ; then
705            IGCM_card_DefineVariableFromOption ${prefix}config.card UserChoices DateBegin
706            ${config_Post_CesmepCode}/libIGCM_install.sh $(pwd)/${prefix} \
707                ${config_Post_CesmepComparison} $JobName ${R_SAVE} "${ProjectID}" \
708                ${MailAdress} ${config_UserChoices_DateBegin//-/} \
709                ${config_Post_Cesmep} ${CesmepPeriod} ${config_Post_CesmepSlices} \
710                $components $CENTER ${CesmepSlicesDuration} \
711                ${config_Post_CesmepReferences} 
712            [ $? -ne 0 ] && echo -e "\nERROR : cannot configure C-ESM-EP run" && exit 5
713        else
714            echo -e "\nERROR Cannot (yet) handle CESMEP atlas on this computer system (${SYSTEM})"
715            echo "=> Variable Cesmep in config.card's section Post must be set to FALSE (rather than $config_Post_Cesmep)"
716            exit 6
717        fi
718    fi
719   
720fi
721
722#
723#-
724[[ ${x_v} = 'verbose' ]] && print - "";
725#-
726# That's all folks
727#-
728
729exit 0;
Note: See TracBrowser for help on using the repository browser.