source: trunk/libIGCM/ins_job @ 1659

Last change on this file since 1659 was 1659, checked in by aclsce, 3 months ago

Merged with branches/libIGCM_PREPOST to split main Job into 3 Jobs (prerun, compute and postrun) on JeanZay? supercomputer at IDRIS.
Prerun and postrun run on prepost partition to have access to STORE space.

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