source: trunk/libIGCM/ins_job @ 1611

Last change on this file since 1611 was 1611, checked in by jgipsl, 5 months ago

In addition to [1610], now remove the question.

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