source: trunk/libIGCM/ins_job @ 1616

Last change on this file since 1616 was 1616, checked in by falletti, 4 months ago

Check OMP threds number (JeanZay? only) before the creation of simulation directory (previously: the check was done at the beginning of the simulation).

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