source: trunk/libIGCM/ins_job @ 1606

Last change on this file since 1606 was 1606, checked in by ssenesi, 5 months ago

For C-ESM-EP : handle a reference simulation and ensure that CesmepSlicesDuration? <=

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