source: trunk/libIGCM/ins_job @ 1605

Last change on this file since 1605 was 1605, checked in by ssenesi, 6 months ago

Let ins_job pass CesmepSLicesDuration to Cesmep install script

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