source: branches/libIGCM_CESMEP/ins_job

Last change on this file was 1585, checked in by ssenesi, 11 months ago

merge branch libIGCM_CESMEP with trunk that handles RedHat8 on Irene

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