source: trunk/libIGCM/ins_job @ 1584

Last change on this file since 1584 was 1584, checked in by jgipsl, 15 months ago

Added question if the user wants to overwrite existing jobs.

  • Property svn:executable set to *
  • Property svn:keywords set to Revision Author Date
File size: 23.5 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
195
196if [ X"${SYSTEM}" == "Xirene" ] ; then
197
198  #- set ProjectID if required
199  if ( ! ${x_p} ) ; then
200    print - "Wait for the next question ..."
201    #- default ProjectID
202    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 )
203    answer=""
204    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 ) "
205    read answer
206
207    if [ "X${answer}" != "X" ] ; then
208      ProjectID=${answer}
209    fi
210
211  fi # if ( ! ${x_p} )
212
213  echo  ProjectID is ${ProjectID} at Irene
214
215
216  # set ProjectNode if required
217  if ( ! ${x_q} ) ; then 
218     #- default ProjectNode
219     ProjectNode="xlarge"
220     #- is xlarge possible for ${ProjectID} ?
221     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"
222
223     if [ "X${ProjectNode}" == "Xxlarge" ] ; then
224       answerOK=false
225 
226       while ( ! ${answerOK} ) ; do
227         answer="" 
228         print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"skylake\" or \"xlarge\" : " 
229         read answer
230         [ "X${answer}" == "X" ] || [ "X${answer}" == "Xskylake" ] || [ "X${answer}" == "Xxlarge" ] && answerOK=true
231       done
232 
233       if [ "X${answer}" != "X" ] ; then
234         ProjectNode=${answer} 
235       fi
236
237     else
238       print - "PostProcessing will be done on ${ProjectNode}"
239     fi
240 
241  fi # if ( ! ${x_q} )
242  echo ProjectNode for post-processing is ${ProjectNode} at Irene
243
244  #- ProjectNode is known (option or answer) set ProjectCoreMax
245  [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" 
246  #- ProjectCoreMax is 48 for standard and 112 for xlarge
247
248  if ( ! ${x_c} ) ; then
249    #- ProjectNode is known (option or answer), set ProjectCore default
250    [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" 
251
252    # let check minimum/maximum value 1/${ProjectCoreMax}
253
254    answerOK=false
255
256    while ( ! ${answerOK} ) ; do
257      answer=""
258      print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : "
259      print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")"
260      read answer
261      [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true
262    done
263
264    if [ "X${answer}" != "X" ] ; then
265      ProjectCore=${answer}
266    fi
267
268  fi # if ( ! ${x_c} )
269
270  echo ProjectCore for post-processing is ${ProjectCore}
271  #- ProjectCore is set (option or answer)
272
273  #- set WallTime if required
274  if ( ! ${x_t} ) ; then
275    #- default WallTime 1800 s
276    WallTime=1800
277    answer=""
278    print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) "
279    read answer
280
281    if [ "X${answer}" != "X" ] ; then
282      WallTime=${answer}
283    fi
284
285  fi # if ( ! ${x_t} )
286   
287  echo Wall time limit is ${WallTime} seconds
288
289elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then
290
291  #- set ProjectID if required
292  if ( ! ${x_p} ) ; then
293    print - "Wait for the next question ..."
294    #- default ProjectID
295    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 )
296    answer=""
297    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 ) "
298    read answer
299
300    if [ "X${answer}" != "X" ] ; then
301      ProjectID=${answer}
302    fi
303
304  fi # if ( ! ${x_p} )
305
306  echo  ProjectID is ${ProjectID} at Irene-amd
307
308  # set ProjectNode if required
309  if ( ! ${x_q} ) ; then 
310     #- default ProjectNode
311     ProjectNode="rome"
312     #- is xlarge possible for ${ProjectID} ?
313     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"
314
315     if [ "X${ProjectNode}" == "Xxlarge" ] ; then
316       answerOK=false
317 
318       while ( ! ${answerOK} ) ; do
319         answer="" 
320         print - "Hit Enter or give TYPE OF NODE required for post-processing (default is \"${ProjectNode}\"), possible types of nodes are \"rome\"  : " 
321         read answer
322         [ "X${answer}" == "X" ] || [ "X${answer}" == "Xrome" ] && answerOK=true
323       done
324 
325       if [ "X${answer}" != "X" ] ; then
326         ProjectNode=${answer} 
327       fi
328
329     else
330       print - "PostProcessing will be done on ${ProjectNode}"
331     fi
332 
333  fi # if ( ! ${x_q} )
334  echo ProjectNode for post-processing is ${ProjectNode} at Irene-amd
335
336  #- ProjectNode is known (option or answer) set ProjectCoreMax
337  [ "${ProjectNode}" = "xlarge" ] && ProjectCoreMax="112" || ProjectCoreMax="48" 
338  #- ProjectCoreMax is 48 for standard and 112 for xlarge
339
340  if ( ! ${x_c} ) ; then
341    #- ProjectNode is known (option or answer), set ProjectCore default
342    [ "${ProjectNode}" = "xlarge" ] && ProjectCore="8" || ProjectCore="4" 
343
344    # let check minimum/maximum value 1/${ProjectCoreMax}
345
346    answerOK=false
347
348    while ( ! ${answerOK} ) ; do
349      answer=""
350      print - "possible numbers of cores are \"1\" to \"${ProjectCoreMax}\" for ${ProjectNode} : "
351      print - "Hit Enter or give NUMBER OF CORES required for post-processing (default is \"${ProjectCore}\")"
352      read answer
353      [ "X${answer}" == "X" ] || [ ${answer} -ge 1 -a ${answer} -le ${ProjectCoreMax} ] && answerOK=true
354    done
355
356    if [ "X${answer}" != "X" ] ; then
357      ProjectCore=${answer}
358    fi
359
360  fi # if ( ! ${x_c} )
361
362  echo ProjectCore for post-processing is ${ProjectCore}
363  #- ProjectCore is set (option or answer)
364
365  #- set WallTime if required
366  if ( ! ${x_t} ) ; then
367    #- default WallTime 1800 s
368    WallTime=1800
369    answer=""
370    print - "Hit Enter or give required wall time in seconds for computing job (default is \"${WallTime}\" seconds, maximum is 86400 seconds) "
371    read answer
372
373    if [ "X${answer}" != "X" ] ; then
374      WallTime=${answer}
375    fi
376
377  fi # if ( ! ${x_t} )
378   
379  echo Wall time limit is ${WallTime} seconds
380
381elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then
382
383  #- set ProjectID if required
384  if ( ! ${x_p} ) ; then
385    print - "Wait for the next question ..."
386    #- default ProjectID
387    ProjectID=$( echo $IDRPROJ )
388    answer=""
389    print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are: $( groups ; echo ) "
390    read answer
391
392    if [ "X${answer}" != "X" ] ; then
393      ProjectID=${answer}
394    fi
395
396  fi # if ( ! ${x_p} )
397
398  echo  ProjectID is ${ProjectID} at Jean-Zay
399
400  #- set WallTime if required
401  if ( ! ${x_t} ) ; then
402    #- default WallTime 30 minutes
403    WallTime=30
404    answer=""
405    print - "Hit Enter or give required wall time in minutes for computing job (default is \"${WallTime}\" minutes, maximum is 1200 minutes) "
406    read answer
407
408    if [ "X${answer}" != "X" ] ; then
409      WallTime=${answer}
410    fi
411
412  fi # if ( ! ${x_t} )
413   
414  echo Wall time limit is ${WallTime} minutes
415
416elif [ X"${SYSTEM}" == "Xada" ] ; then
417  if ( ! ${x_m} ) ; then
418    MPIEnvironment=IBM
419    # Intel MPI Environment.
420    answerOK=false     
421    while ( ! ${answerOK} ) ; do
422      answer=""
423      print - "Hit Enter or give MPI Environement (default is ${MPIEnvironment}), possible MPI environments are IBM (MPI IBM) and Intel (MPI Intel) :"
424      read answer
425      [ "X${answer}" == "X" ] || [ "X${answer}" == "XIBM" ] || [ "X${answer}" == "XIntel" ] && answerOK=true
426    done
427
428    if [ "X${answer}" != "X" ] ; then
429      MPIEnvironment=${answer}
430    fi
431  fi # if ( ! ${x_pm} )
432  echo MPIEnvironment is ${MPIEnvironment}
433
434elif [ X"${SYSTEM}" == "Xobelix" ] || [ X"${SYSTEM}" == "Xifort_CICLAD" ] ; then
435  # obelix, ciclad, climserv
436  echo ""
437  echo "You need to check and maybe adapt headers in the main job especially the line: "
438  echo "  #PBS -l nodes=x:ppn=y "
439  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. "
440  echo "y must not be bigger than the maximum numer of cores per node on the machine (often 8 or 16)."
441fi # if [ X"${SYSTEM}" == "Xirene" ]
442
443#-
444# Define the pattern string to substitute
445#-
446W_P='#-Q- '; W_W=${W_P}${SYSTEM}' ';
447#-
448# Extract list of 'config.card' files
449# and create jobs with AA_job
450#-
451F_CFG='config.card';
452F_CFG_ENS='ensemble.card';
453SUBMIT_DIR_ENS=$( pwd )
454for i in $( pwd )/config.card
455do
456  if [ ! -f $i ] ; then
457    echo ""
458    echo "################## WARNING ##################"
459    echo "No config.card available in current directory"
460    echo ""
461    continue
462  fi
463
464
465  j=$(cd ${i%/*};/bin/pwd;)
466  n_f=${F_RCI##*/};
467
468  if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then
469    # Do not treat config.card if it is in sub-directory of EXPERIMENTS
470    # Continue to next config.card
471    continue
472  else
473    [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
474  fi
475
476  # Find out if new structure and set .resol filename
477  if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then
478    # New Structure
479    [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure"
480    new_struct=yes
481    resolfile=$j/.resol
482  else
483    # Old Structure
484    new_struct=no
485    resolfile=$j/../.resol
486  fi
487
488  # Get all variables declared in section UserChoices in config.card
489  IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices
490  # Set default values
491  config_UserChoices_ExpType=""
492  RESOL_ATM_3D=this_is_a_test_string
493  RESOL=this_is_another_test_string
494  ResolAtm=this_is_a_new_another_test
495  typeset option
496  for option in ${config_UserChoices[*]} ; do
497    IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option}
498  done
499
500  # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file
501  if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then
502    TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' )
503    echo TRUERESOL = $TRUERESOL
504    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" )
505    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
506  elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then
507    TRUERESOL=$( head -1 $resolfile  )
508    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" )
509    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
510  elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${ResolAtm} ) = X ] ; then
511    TRUERESOL=${config_UserChoices_ResolAtm}
512    JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${ResolAtm}/${TRUERESOL}/" )
513    IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName}
514  else
515    JobName=${config_UserChoices_JobName}
516  fi
517
518  # Check JobName validity : only alphanumerical characters, "-" and "." are authorized
519  ins_job_Check_JobName
520  RetCode=$?
521  [[ $RetCode -gt 0 ]] && continue
522
523  [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}"
524
525  # Add specific treatment for new type of directory structure
526  if [ ${new_struct} == yes ] ; then
527
528    if [ "X${config_UserChoices_ExpType}" = X ] ; then
529      echo "\nERROR in ${j}/config.card"
530      echo "ins_job stops here"
531      echo "=> The variable ExpType must be added in config.card in section UserChoices"
532      echo "=> ExpType gives the directory for the .card configuration files for the wanted experiement. For exemple ExpType=IPSLCM5/historical"
533      exit 4
534    else
535      [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}"
536    fi
537
538    if [ -d ${j}/${JobName} ] ; then
539      echo "Directory ${j}/${JobName} exists already. It will not be overwritten."
540      echo "Remove the existing directory or change JobName before relaunching ins_job."
541      #continue
542      exit 
543    fi
544    echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}"
545    cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName}
546    cp -r ${j}/GENERAL/* ${j}/${JobName}/.
547    cp -f ${j}/${F_CFG}  ${j}/${JobName}/.
548    if [ -f ${F_CFG_ENS} ] ; then
549      cp -f ${j}/${F_CFG_ENS}  ${j}/${JobName}/.
550      SUBMIT_DIR_ENS=${j}/${JobName}
551    fi
552    rm -f ${j}/${F_CFG}
553    # rm -f ${j}/${F_CFG_ENS}
554    rm -f ${j}/${F_CFG}.bak
555    j=${j}/${JobName}
556    [[ ${x_v} = 'verbose' ]] && echo new j=$j
557  fi
558  # end specific treatment for new type directory structure
559
560  [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \
561   {
562    [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}";
563    \cp ${F_RCI} ${j};
564   }
565
566  #==================================
567  # Read ListOfComponents section:
568  #echo
569  #IGCM_debug_Print 1 "DefineArrayFromSection : ListOfComponents"
570
571  IGCM_card_DefineArrayFromSection  ${j}'/'${F_CFG} ListOfComponents
572  for comp in ${config_ListOfComponents[*]} ; do
573    IGCM_card_DefineArrayFromOption  ${j}'/'${F_CFG} ListOfComponents ${comp}
574  done
575  #IGCM_debug_Print 3 ${config_ListOfComponents[*]}
576
577  #==================================
578  # Read Executable section:
579  IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} Executable
580
581  # Define the execution context (MPMD, SPMD, MPI/OMP ...)
582  IGCM_config_ConfigureExecution ${j}'/'${F_CFG}
583
584  # coreNumber    : TOTAL NUMBER OF CORES
585  # mpiTasks      : TOTAL NUMBER OF MPI TASKS
586  # openMPthreads : NUMBER OF OpenMP THREADS
587
588  # File name for Job_debug
589  n_f='Job_debug_'${JobName};
590  [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
591  sed -e "/^${W_W} */ s///" \
592      -e "/^${W_P}/d"       \
593      -e "s%::modipsl::%${F_MOD}%" \
594      -e "s/::Jobname::/${JobName}/" \
595      -e "s/::default_project::/${ProjectID}/" \
596      -e "s/::WallTime::/${WallTime}/" \
597      ${F_JOB_DEBUG} > ${libIGCM}'/'${n_f}
598  chmod u+x ${libIGCM}'/'${n_f}
599
600  # update Headers so that ressources description are accurate (MPMD/SPMD/...)
601  IGCM_sys_updateHeaders ${libIGCM}'/'${n_f}
602
603  # File name for Job
604  n_f='Job_'${JobName};
605  [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; }
606  [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}";
607  sed -e "/^${W_W} */ s///" \
608      -e "/^${W_P}/d"       \
609      -e "s%::modipsl::%${F_MOD}%" \
610      -e "s/::Jobname::/${JobName}/" \
611      -e "s/::default_project::/${ProjectID}/" \
612      -e "s/::WallTime::/${WallTime}/" \
613      ${F_JOB} > ${j}'/'${n_f}
614  chmod u+x ${j}'/'${n_f}
615
616  # update Headers so that ressources description are accurate (MPMD/SPMD/...)
617  IGCM_sys_updateHeaders ${j}'/'${n_f}
618 
619done
620
621#-
622# Extract list of AA_* files in libIGCM
623# and create jobs (for all except AA_job)
624#-
625for i in $(find ${libIGCM} -maxdepth 1 -name "AA_*" -print)
626do
627  i_f=${i##*/};
628  [[ ${i_f} = 'AA_job' ]] && { continue; }
629  [[ ${i_f} = 'AA_job_debug' ]]  && { continue; }
630  j=${i%/*}; n_f=${i_f#AA_}'.job';
631  [[ ${x_f} = 'false' ]] && [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; }
632  [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}"
633  sed -e "/^${W_W} */ s///" \
634      -e "s%::modipsl::%${F_MOD}%" \
635      -e "/^${W_P}/d"       \
636      -e "s/::default_node::/${ProjectNode}/" \
637      -e "s/::default_core::/${ProjectCore}/" \
638      -e "s/::default_project::/${ProjectID}/" \
639      -e "s/::default_post_project::/${ProjectID}/" \
640      ${i} > ${j}'/'${n_f}
641  chmod u+x ${j}'/'${n_f}
642done
643#-
644# set default_project in libIGCM_sys_irene and libIGCM_sys_jeanzay.
645#-
646if [ X"${SYSTEM}" == "Xirene" ] ; then
647  i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene.ksh
648  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
649elif [ X"${SYSTEM}" == "Xirene-amd" ] ; then
650  i=${libIGCM}/libIGCM_sys/libIGCM_sys_irene-amd.ksh
651  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
652elif [ X"${SYSTEM}" == "Xjeanzay" ] ; then
653  i=${libIGCM}/libIGCM_sys/libIGCM_sys_jeanzay.ksh
654  sed -i -e "s/::default_project::/${ProjectID}/" ${i}
655fi
656#-
657# Limited to hindcast/forecast and date restart Ensemble for the time being
658if [ ${x_e} = 'true' ] ; then
659    if [ ! -f ${F_CFG_ENS} ] ; then
660       echo ""
661       echo "################## WARNING ##################"
662       echo "No ensemble.card available in current directory"
663       echo ""
664       exit
665      #  continue
666   fi
667
668  #.. Read input data from ensemble.card ..
669  SUBMIT_DIR=${SUBMIT_DIR_ENS}
670  RUN_DIR="${CCCWORKDIR}/ENSEMBLE_TMP"
671  #
672  # Copy initial things around and define variables (hindcast/forecast case)
673  IGCM_sys_Cd ${SUBMIT_DIR}
674  IGCM_ensemble_Init
675
676  if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then
677    IGCM_sys_Cd ${SUBMIT_DIR}
678    IGCM_ensemble_DateInit
679    # As it says
680    IGCM_sys_Cd ${SUBMIT_DIR}
681    IGCM_ensemble_DateNonPeriodicStarts
682  fi
683
684  if [[ ${ensemble_Ens_PERTURB_active} = 'y' ]] ; then
685    IGCM_sys_Cd ${SUBMIT_DIR}
686    IGCM_ensemble_CastInit
687    # As it says
688    IGCM_sys_Cd ${SUBMIT_DIR}
689    IGCM_ensemble_CastPeriodicStarts
690    # As it says
691    #IGCM_sys_Cd ${SUBMIT_DIR}
692    #IGCM_ensemble_CastMemberList
693  fi
694  # Done
695  IGCM_sys_Cd ${SUBMIT_DIR}
696  # Clean
697  IGCM_sys_Rm -rf ${RUN_DIR}
698 
699fi
700#-
701[[ ${x_v} = 'verbose' ]] && print - "";
702#-
703# That's all folks
704#-
705
706if [ ${NbErr} -ne 0 ] ; then
707  echo "################ ERROR ################"
708  echo "${NbErr} invalid JobName(s) found, check the log"
709fi
710
711
712exit 0;
Note: See TracBrowser for help on using the repository browser.