source: trunk/libIGCM/ins_job @ 1610

Last change on this file since 1610 was 1610, checked in by jgipsl, 6 months ago

Revert changset [1597] which didn't have concensus. The question if you whant to overwrite jobs is not aksed anymore. No overwriting is always the default. Use argument -f to overwrite jobs.

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