source: trunk/libIGCM/ins_job @ 1614

Last change on this file since 1614 was 1614, checked in by falletti, 4 months ago

Remove questions part for Ada (old IDRIS machine)

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