source: trunk/libIGCM/ins_job @ 1597

Last change on this file since 1597 was 1597, checked in by jgipsl, 8 months ago

Added option -n for not overwriting existing job (in opposite to the -f which overwrites). No overwriting has always been the default.

  • Property svn:executable set to *
  • Property svn:keywords set to Revision Author Date
File size: 23.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    continue
466  fi
467
468
469  j=$(cd ${i%/*};/bin/pwd;)
470  n_f=${F_RCI##*/};
471
472  if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then
473    # Do not treat config.card if it is in sub-directory of EXPERIMENTS
474    # Continue to next config.card
475    continue
476  else
477    [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
478  fi
479
480  # Find out if new structure and set .resol filename
481  if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then
482    # New Structure
483    [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure"
484    new_struct=yes
485    resolfile=$j/.resol
486  else
487    # Old Structure
488    new_struct=no
489    resolfile=$j/../.resol
490  fi
491
492  # Get all variables declared in section UserChoices in config.card
493  IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices
494  # Set default values
495  config_UserChoices_ExpType=""
496  RESOL_ATM_3D=this_is_a_test_string
497  RESOL=this_is_another_test_string
498  ResolAtm=this_is_a_new_another_test
499  typeset option
500  for option in ${config_UserChoices[*]} ; do
501    IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option}
502  done
503
504  # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file
505  if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then
506    TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' )
507    echo TRUERESOL = $TRUERESOL
508    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" )
509    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
510  elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then
511    TRUERESOL=$( head -1 $resolfile  )
512    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" )
513    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
514  elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${ResolAtm} ) = X ] ; then
515    TRUERESOL=${config_UserChoices_ResolAtm}
516    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${ResolAtm}/${TRUERESOL}/" )
517    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
518  else
519    JobName=${config_UserChoices_JobName}
520  fi
521
522  # Check JobName validity : only alphanumerical characters, "-" and "." are authorized
523  ins_job_Check_JobName
524  RetCode=$?
525  [[ $RetCode -gt 0 ]] && continue
526
527  [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}"
528
529  # Add specific treatment for new type of directory structure
530  if [ ${new_struct} == yes ] ; then
531
532    if [ "X${config_UserChoices_ExpType}" = X ] ; then
533      echo "\nERROR in ${j}/config.card"
534      echo "ins_job stops here"
535      echo "=> The variable ExpType must be added in config.card in section UserChoices"
536      echo "=> ExpType gives the directory for the .card configuration files for the wanted experiement. For exemple ExpType=IPSLCM5/historical"
537      exit 4
538    else
539      [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}"
540    fi
541
542    if [ -d ${j}/${JobName} ] ; then
543      echo "Directory ${j}/${JobName} exists already. It will not be overwritten."
544      echo "Remove the existing directory or change JobName before relaunching ins_job."
545      #continue
546      exit 
547    fi
548    echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}"
549    cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName}
550    cp -r ${j}/GENERAL/* ${j}/${JobName}/.
551    cp -f ${j}/${F_CFG}  ${j}/${JobName}/.
552    if [ -f ${F_CFG_ENS} ] ; then
553      cp -f ${j}/${F_CFG_ENS}  ${j}/${JobName}/.
554      SUBMIT_DIR_ENS=${j}/${JobName}
555    fi
556    rm -f ${j}/${F_CFG}
557    # rm -f ${j}/${F_CFG_ENS}
558    rm -f ${j}/${F_CFG}.bak
559    j=${j}/${JobName}
560    [[ ${x_v} = 'verbose' ]] && echo new j=$j
561  fi
562  # end specific treatment for new type directory structure
563
564  [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \
565   {
566    [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}";
567    \cp ${F_RCI} ${j};
568   }
569
570  #==================================
571  # Read ListOfComponents section:
572  #echo
573  #IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents"
574
575  IGCM_card_DefineArrayFromSection  ${j}'/'${F_CFG} ListOfComponents
576  for comp in ${config_ListOfComponents[*]} ; do
577    IGCM_card_DefineArrayFromOption  ${j}'/'${F_CFG} ListOfComponents ${comp}
578  done
579  #IGCM_debug_Print 3 ${config_ListOfComponents[*]}
580
581  #==================================
582  # Read Executable section:
583  IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} Executable
584
585  # Define the execution context (MPMD, SPMD, MPI/OMP ...)
586  IGCM_config_ConfigureExecution ${j}'/'${F_CFG}
587
588  # coreNumber    : TOTAL NUMBER OF CORES
589  # mpiTasks      : TOTAL NUMBER OF MPI TASKS
590  # openMPthreads : NUMBER OF OpenMP THREADS
591
592  # File name for Job_debug
593  n_f='Job_debug_'${JobName};
594  [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
595  sed -e "/^${W_W} */ s///" \
596      -e "/^${W_P}/d"       \
597      -e "s%::modipsl::%${F_MOD}%" \
598      -e "s/::Jobname::/${JobName}/" \
599      -e "s/::default_project::/${ProjectID}/" \
600      -e "s/::WallTime::/${WallTime}/" \
601      ${F_JOB_DEBUG} > ${libIGCM}'/'${n_f}
602  chmod u+x ${libIGCM}'/'${n_f}
603
604  # update Headers so that ressources description are accurate (MPMD/SPMD/...)
605  IGCM_sys_updateHeaders ${libIGCM}'/'${n_f}
606
607  # File name for Job
608  n_f='Job_'${JobName};
609  [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; }
610  [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
611  sed -e "/^${W_W} */ s///" \
612      -e "/^${W_P}/d"       \
613      -e "s%::modipsl::%${F_MOD}%" \
614      -e "s/::Jobname::/${JobName}/" \
615      -e "s/::default_project::/${ProjectID}/" \
616      -e "s/::WallTime::/${WallTime}/" \
617      ${F_JOB} > ${j}'/'${n_f}
618  chmod u+x ${j}'/'${n_f}
619
620  # update Headers so that ressources description are accurate (MPMD/SPMD/...)
621  IGCM_sys_updateHeaders ${j}'/'${n_f}
622 
623done
624
625#-
626# Extract list of AA_* files in libIGCM
627# and create jobs (for all except AA_job)
628#-
629for i in $(find ${libIGCM} -maxdepth 1 -name "AA_*" -print)
630do
631  i_f=${i##*/};
632  [[ ${i_f} = 'AA_job' ]] && { continue; }
633  [[ ${i_f} = 'AA_job_debug' ]]  && { continue; }
634  j=${i%/*}; n_f=${i_f#AA_}'.job';
635  [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; }
636  [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}"
637  sed -e "/^${W_W} */ s///" \
638      -e "s%::modipsl::%${F_MOD}%" \
639      -e "/^${W_P}/d"       \
640      -e "s/::default_node::/${ProjectNode}/" \
641      -e "s/::default_core::/${ProjectCore}/" \
642      -e "s/::default_project::/${ProjectID}/" \
643      -e "s/::default_post_project::/${ProjectID}/" \
644      ${i} > ${j}'/'${n_f}
645  chmod u+x ${j}'/'${n_f}
646done
647#-
648# set default_project in libIGCM_sys_irene and libIGCM_sys_jeanzay.
649#-
650if [ X"${SYSTEM}" == "Xirene" ] ; then
651  i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene.ksh
652  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
653elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then
654  i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene-amd.ksh
655  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
656elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then
657  i=${libIGCM}/libIGCM_sys/libIGCM_sys_jeanzay.ksh
658  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
659fi
660#-
661# Limited to hindcast/forecast and date restart Ensemble for the time being
662if [ ${x_e} = 'true' ] ; then
663    if [ ! -f ${F_CFG_ENS} ] ; then
664       echo ""
665       echo "################## WARNING ##################"
666       echo "No ensemble.card available in current directory"
667       echo ""
668       exit
669      #  continue
670   fi
671
672  #.. Read input data from ensemble.card ..
673  SUBMIT_DIR=${SUBMIT_DIR_ENS}
674  RUN_DIR="${CCCWORKDIR}/ENSEMBLE_TMP"
675  #
676  # Copy initial things around and define variables (hindcast/forecast case)
677  IGCM_sys_Cd ${SUBMIT_DIR}
678  IGCM_ensemble_Init
679
680  if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then
681    IGCM_sys_Cd ${SUBMIT_DIR}
682    IGCM_ensemble_DateInit
683    # As it says
684    IGCM_sys_Cd ${SUBMIT_DIR}
685    IGCM_ensemble_DateNonPeriodicStarts
686  fi
687
688  if [[ ${ensemble_Ens_PERTURB_active} = 'y' ]] ; then
689    IGCM_sys_Cd ${SUBMIT_DIR}
690    IGCM_ensemble_CastInit
691    # As it says
692    IGCM_sys_Cd ${SUBMIT_DIR}
693    IGCM_ensemble_CastPeriodicStarts
694    # As it says
695    #IGCM_sys_Cd ${SUBMIT_DIR}
696    #IGCM_ensemble_CastMemberList
697  fi
698  # Done
699  IGCM_sys_Cd ${SUBMIT_DIR}
700  # Clean
701  IGCM_sys_Rm -rf ${RUN_DIR}
702 
703fi
704#-
705[[ ${x_v} = 'verbose' ]] && print - "";
706#-
707# That's all folks
708#-
709
710if [ ${NbErr} -ne 0 ] ; then
711  echo "################ ERROR ################"
712  echo "${NbErr} invalid JobName(s) found, check the log"
713fi
714
715
716exit 0;
Note: See TracBrowser for help on using the repository browser.