Changeset 2688


Ignore:
Timestamp:
12/01/15 17:55:05 (6 years ago)
Author:
jgipsl
Message:

Empty ins_job. Only kept an explication.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modipsl/trunk/util/ins_job

    r2394 r2688  
    44#- Installation of jobs according to an environment 
    55#--------------------------------------------------------------------- 
    6 function ins_job_Usage 
    7 { 
    8 print - " 
    9 ins_job installs the jobs in the directories 
    10 which contain a file config.card 
    116 
    12 ins_job must be launched on the host 
    13 on which the job will be submitted 
     7echo "" 
     8echo "This script has been moved to libIGCM. Now please use ins_job in libIGCM directory." 
     9echo "Use for example ../../libIGCM/ins_job or ../../../libIGCM/ins_job from the directory where the config.card is." 
     10echo "See documentation https://forge.ipsl.jussieu.fr/igcmg_doc/wiki/DocEsetup" 
     11echo "" 
    1412 
    15 Usage : 
    16   ${b_n} [-h] [-v] [-e] [-p project] 
    17  
    18 Options : 
    19   -h          : help 
    20   -v          : verbose mode 
    21   -e          : turn on ensemble mode (hindcast/forecast or date restart) 
    22   -p project  : add default project on curie 
    23 " 
    24 } 
    25 function ins_job_Warning 
    26 { 
    27    [[ ${x_v} = 'verbose' ]] && print - "\n############### WARNING ###############"; 
    28    [[ ${x_v} = 'verbose' ]] && print - "File ${n_f} already exists\nin directory ${j}"; 
    29    [[ ${x_v} = 'verbose' ]] && print - "You must delete this file to update !"; 
    30 } 
    31  
    32 function ins_job_Check_JobName 
    33 { 
    34   verif=${JobName##[a-zA-Z]*(?([.\-])[a-zA-Z0-9])} 
    35  
    36   if [ ${#verif} -ne 0 ] ; then 
    37     echo "################ ERROR ################" 
    38     echo "${JobName} is invalid." 
    39     echo "- JobName can only contain alphanumeric characters, \".\" and \"-\"" 
    40     echo "- JobName must start with a letter" 
    41  
    42     ((NbErr=NbErr+1)) 
    43  
    44     Status=1 
    45   else 
    46     Status=0 
    47   fi 
    48  
    49   return ${Status} 
    50 } 
    51  
    52 #- 
    53 #     dirname     and      basename 
    54 #- 
    55 d_n=$(dirname ${0}); b_n=$(basename ${0}); 
    56 #- 
    57 # Retrieving and validation of the options 
    58 #- 
    59 x_v='silencious'; 
    60 x_e=false; 
    61 x_p=false; 
    62 while getopts :hvep: V ; do 
    63   case $V in 
    64   (h)  ins_job_Usage; exit 0;; 
    65   (v)  x_v='verbose';; 
    66   (e)  x_e=true;; 
    67   (p)  x_p=true 
    68        ProjectID=${OPTARG} ;; 
    69   (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2; 
    70        exit 2;; 
    71   (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2; 
    72        exit 2;; 
    73   esac 
    74 done 
    75 [ ${x_v} = 'silencious' ] && export DEBUG_sys=false 
    76 shift $(($OPTIND-1)); 
    77 #- 
    78 # Define working files 
    79 #- 
    80 F_MOD=$(cd ${d_n}'/..';/bin/pwd;) 
    81 # [[ ${F_MOD##*/} != 'modipsl' ]] && \ 
    82 #  { print - "directory 'modipsl' unreachable"; exit 3; } 
    83 W_W=${d_n}'/../libIGCM' 
    84 [[ ! -d ${W_W} ]] && { print - "${W_W} unreachable"; exit 3; } 
    85 libIGCM=$(cd ${W_W};/bin/pwd;) 
    86 F_JOB=${libIGCM}'/AA_job'; 
    87 [[ ! -f ${F_JOB} ]] && { print - "${F_JOB} unreachable"; exit 3; } 
    88 F_RCI=${libIGCM}'/run.card.init'; 
    89 [[ ! -f ${F_RCI} ]] && { print - "${F_RCI} unreachable"; exit 3; } 
    90 #- 
    91 # Host Name 
    92 #- 
    93 x_t=$(${d_n}/w_i_h) 2>/dev/null; 
    94 { [[ ${?} != 0 ]] && \ 
    95    { print - "\nw_i_h or uname unreachable\n" 1>&2; exit 1; }; } || \ 
    96   [[ ${x_t} = "Unknown" ]] && \ 
    97    { print - "\nLocal_Host not supported\n" 1>&2; exit 1; }; 
    98 #- 
    99 W_W=$(sed -n -e "s/^#-Q-  *\([^ ]*\).*$/\1/p" ${F_JOB} | \ 
    100        sort -u | sed -e "/${x_t}/!d"); 
    101 [[ '\?'"${W_W}" != '\?'${x_t} ]] && \ 
    102   { 
    103    print - "\nHost  "${x_t}"  not supported" 1>&2; 
    104    print - "'default' will be used" 1>&2; 
    105    x_t='default' 
    106   } 
    107 #- 
    108 [[ ${x_v} = 'verbose' ]] && \ 
    109  { 
    110   print - ""; 
    111   print - '--- Host        : '${x_t}; 
    112   print - '--- modipsl     : '${F_MOD}; 
    113   print - '--- libIGCM     : '${libIGCM}; 
    114   print - '--- basic job   : '${F_JOB}; 
    115   print - '--- basic card  : '${F_RCI}; 
    116  } 
    117 #- 
    118 [[ ${x_v} = 'verbose' ]] && print - "\nInstallation of jobs for '${x_t}'"; 
    119 #- 
    120 # Accessing to functions (without stack) 
    121 #- 
    122 DEBUG_debug=false 
    123 MirrorlibIGCM=false 
    124 TaskType=computing 
    125 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    126 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    127 . ${libIGCM}/libIGCM_date/libIGCM_date.ksh 
    128 . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh 
    129 if [ $x_e = 'true' ] ; then 
    130   . ${libIGCM}/libIGCM_ensemble/libIGCM_ensemble.ksh 
    131 fi 
    132  
    133 NbErr=0 
    134  
    135 #- 
    136 # Define Project ID to set up jobs header for Curie (TGCC) 
    137 #- 
    138 if ( ! ${x_p} ) ; then 
    139   if [ X"${x_t}" == "Xcurie" ] ; then 
    140     ProjectID=$( ccc_myproject | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | head -n 1 ) 
    141     ProjectID=${ProjectID:="gen2211"} 
    142     answer="" 
    143     print - "Hit Enter or give project ID (default is ${ProjectID}), possible projects are $( echo $( ccc_myproject | gawk '{ if ( $3 ~ /^project$/ && $4 !~ /^tgcc/ ) { print $4 } }' | sort -u ) ) :" 
    144     read answer 
    145  
    146     if [ "X${answer}" != "X" ] ; then 
    147       ProjectID=${answer} 
    148     fi 
    149     [ "${ProjectID}" = "gencmip6" ] && ProjectNode="standard" || ProjectNode="xlarge" 
    150   fi 
    151 else 
    152   if [ X"${x_t}" != "Xcurie" ] ; then 
    153     print - "\nOption -p invalid with this host (${x_t}): it will be ignored" 1>&2; 
    154   fi 
    155 fi 
    156  
    157 #- 
    158 # Define the pattern string to substitute 
    159 #- 
    160 W_P='#-Q- '; W_W=${W_P}${x_t}; 
    161 #- 
    162 # Extract list of 'config.card' files 
    163 # and create jobs with AA_job 
    164 #- 
    165 F_CFG='config.card'; 
    166 F_CFG_ENS='ensemble.card'; 
    167 SUBMIT_DIR_ENS=$( pwd ) 
    168 for i in $(find ${d_n}/.. -name ${F_CFG} -print) 
    169 do 
    170   j=$(cd ${i%/*};/bin/pwd;) 
    171   n_f=${F_RCI##*/}; 
    172  
    173   if [ ! X$( echo ${j} | grep EXPERIMENTS ) = X ] ; then 
    174     # Do not treat config.card if it is in sub-directory of EXPERIMENTS 
    175     # Continue to next config.card 
    176     continue 
    177   else 
    178     [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; 
    179   fi 
    180  
    181   # Find out if new structure and set .resol filename 
    182   if [ -d ${j}/EXPERIMENTS ] && [ -d ${j}/GENERAL ] ; then 
    183     # New Structure 
    184     [[ ${x_v} = 'verbose' ]] && echo "This is new configuration structure" 
    185     new_struct=yes 
    186     resolfile=$j/.resol 
    187   else 
    188     # Old Structure 
    189     new_struct=no 
    190     resolfile=$j/../.resol 
    191   fi 
    192  
    193   # Get all variables declared in section UserChoices in config.card 
    194   IGCM_card_DefineArrayFromSection ${j}'/'${F_CFG} UserChoices 
    195   # Set default values 
    196   config_UserChoices_JobClass=mono 
    197   config_UserChoices_JobNumProcTot=1 
    198   config_UserChoices_ExpType="" 
    199   RESOL_ATM_3D=this_is_a_test_string 
    200   RESOL=this_is_another_test_string 
    201   typeset option 
    202   for option in ${config_UserChoices[*]} ; do 
    203     IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices ${option} 
    204   done 
    205  
    206   # Find the JobName : JobName might contain the variable RESOL_ATM_3D that will be replaced by what is in .resol file 
    207   if [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL_ATM_3D} ) = X ] ; then 
    208     TRUERESOL=$( tail -1 $resolfile | awk "-F=" '{print $2}' ) 
    209     echo TRUERESOL = $TRUERESOL 
    210     JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL_ATM_3D}/${TRUERESOL}/" ) 
    211     IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} 
    212   elif [ ! X$( echo ${config_UserChoices_JobName} | grep ${RESOL} ) = X ] ; then 
    213     TRUERESOL=$( head -1 $resolfile  ) 
    214     JobName=$( echo ${config_UserChoices_JobName} | sed -e "s/${RESOL}/${TRUERESOL}/" ) 
    215     IGCM_card_WriteOption ${j}'/'${F_CFG} UserChoices JobName ${JobName} 
    216   else 
    217     JobName=${config_UserChoices_JobName} 
    218   fi 
    219  
    220   # Check JobName validity : only alphanumerical characters, "-" and "." are authorized 
    221   ins_job_Check_JobName 
    222   RetCode=$? 
    223   [[ $RetCode -gt 0 ]] && continue 
    224  
    225   [[ ${x_v} = 'verbose' ]] && echo "JobName=${JobName}" 
    226  
    227   # Add specific treatment for new type of directory structure 
    228   if [ ${new_struct} == yes ] ; then 
    229  
    230     if [ "X${config_UserChoices_ExpType}" = X ] ; then 
    231       echo "\nERROR in ${j}/config.card" 
    232       echo "ins_job stops here" 
    233       echo "=> The variable ExpType must be added in config.card in section UserChoices" 
    234       echo "=> ExpType gives the directory for the .card configurtaion files for the wanted experiement. For exemple ExpType=IPSLCM5/historical" 
    235       exit 4 
    236     else 
    237       [[ ${x_v} = 'verbose' ]] && echo "ExpType= ${config_UserChoices_ExpType}" 
    238     fi 
    239  
    240     if [ -d ${j}/${JobName} ] ; then 
    241       echo "Directory ${j}/${JobName} exist already, continue next config.card" 
    242       continue 
    243     fi 
    244     echo "=> Submit directory ${JobName} will be created with cards from EXPERIMENTS/${config_UserChoices_ExpType}" 
    245     cp -r ${j}/EXPERIMENTS/${config_UserChoices_ExpType} ${j}/${JobName} 
    246     cp -r ${j}/GENERAL/* ${j}/${JobName}/. 
    247     cp -f ${j}/${F_CFG}  ${j}/${JobName}/. 
    248     if [ -f ${F_CFG_ENS} ] ; then 
    249       cp -f ${j}/${F_CFG_ENS}  ${j}/${JobName}/. 
    250       SUBMIT_DIR_ENS=${j}/${JobName} 
    251     fi 
    252     rm -f ${j}/${F_CFG} 
    253     rm -f ${j}/${F_CFG_ENS} 
    254     rm -f ${j}/${F_CFG}.bak 
    255     j=${j}/${JobName} 
    256     [[ ${x_v} = 'verbose' ]] && echo new j=$j 
    257   fi 
    258   # end specific treatment for new type directory structure 
    259  
    260   [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } || \ 
    261    { 
    262     [[ ${x_v} = 'verbose' ]] && print - "\nCopying file ${F_RCI}\nin directory ${j}"; 
    263     \cp ${F_RCI} ${j}; 
    264    } 
    265  
    266   # File name for Job 
    267   n_f='Job_'${JobName}; 
    268   [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 
    269   [[ ${x_v} = 'verbose' ]] && print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; 
    270   sed -e "/^${W_W} */ s///" \ 
    271       -e "/^${W_P}/d"       \ 
    272       -e "s%::modipsl::%${F_MOD}%" \ 
    273       -e "s/::Jobname::/${JobName}/" \ 
    274       -e "s/::JobClass::/${config_UserChoices_JobClass}/" \ 
    275       -e "s/::JobNumProcTot::/${config_UserChoices_JobNumProcTot}/" \ 
    276       -e "s/::default_project::/${ProjectID}/" \ 
    277       ${F_JOB} > ${j}'/'${n_f} 
    278   chmod u+x ${j}'/'${n_f} 
    279 done 
    280 #- 
    281 # Extract list of AA_* files in libIGCM 
    282 # and create jobs (for all except AA_job) 
    283 #- 
    284 for i in $(find ${libIGCM} -maxdepth 1 -name "AA_*" -print) 
    285 do 
    286   i_f=${i##*/}; 
    287   [[ ${i_f} = 'AA_job' ]] && { continue; } 
    288   j=${i%/*}; n_f=${i_f#AA_}'.job'; 
    289   [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 
    290   [[ ${x_v} = 'verbose' ]] && print - "\nIn directory ${j}\n${i_f} -> ${n_f}" 
    291   sed -e "/^${W_W} */ s///" \ 
    292       -e "s%::modipsl::%${F_MOD}%" \ 
    293       -e "/^${W_P}/d"       \ 
    294       -e "s/::default_node::/${ProjectNode}/" \ 
    295       -e "s/::default_project::/${ProjectID}/" \ 
    296       ${i} > ${j}'/'${n_f} 
    297   chmod u+x ${j}'/'${n_f} 
    298 done 
    299 #- 
    300 # set default_project in libIGCM_sys_curie.ksh too. 
    301 #- 
    302 if [ X"${x_t}" == "Xcurie" ] ; then 
    303   i=${libIGCM}/libIGCM_sys/libIGCM_sys_curie.ksh 
    304   sed -i -e "s/::default_project::/${ProjectID}/" ${i} 
    305 fi 
    306 #- 
    307 # Limited to hindcast/forecast and date restart Ensemble for the time being 
    308 if [ ${x_e} = 'true' ] ; then 
    309   #.. Read input data from ensemble.card .. 
    310   SUBMIT_DIR=${SUBMIT_DIR_ENS} 
    311   RUN_DIR="${WORKDIR}/ENSEMBLE" 
    312   # 
    313   # Copy initial things around and define variables (hindcast/forecast case) 
    314   IGCM_sys_Cd ${SUBMIT_DIR} 
    315   IGCM_ensemble_Init 
    316  
    317   if [[ ${ensemble_Ens_PARAMETRIC_active} = 'y' ]] ; then 
    318     echo "WARNING: Parametric Ensemble is not implemented yet..." 
    319   fi 
    320  
    321   if [[ ${ensemble_Ens_DATE_active} = 'y' ]] ; then 
    322     IGCM_sys_Cd ${SUBMIT_DIR} 
    323     IGCM_ensemble_DateInit 
    324     # As it says 
    325     IGCM_sys_Cd ${SUBMIT_DIR} 
    326     IGCM_ensemble_DatePeriodicStarts 
    327     # As it says 
    328     IGCM_sys_Cd ${SUBMIT_DIR} 
    329     IGCM_ensemble_DateNonPeriodicStarts 
    330     # Clean 
    331     IGCM_sys_Rm -rf ${RUN_DIR} 
    332   fi 
    333  
    334   if [[ ${ensemble_Ens_PERTURB_active} = 'y' ]] ; then 
    335     IGCM_sys_Cd ${SUBMIT_DIR} 
    336     IGCM_ensemble_CastInit 
    337     # As it says 
    338     IGCM_sys_Cd ${SUBMIT_DIR} 
    339     IGCM_ensemble_CastPeriodicStarts 
    340     # As it says 
    341     IGCM_sys_Cd ${SUBMIT_DIR} 
    342     IGCM_ensemble_CastNonPeriodicStarts 
    343     # As it says 
    344     IGCM_sys_Cd ${SUBMIT_DIR} 
    345     IGCM_ensemble_CastMemberList 
    346     # Done 
    347     IGCM_sys_Cp ${RUN_DIR}/CreatedDir.txt ${SUBMIT_DIR} 
    348     IGCM_sys_Cd ${SUBMIT_DIR} 
    349     # Clean 
    350     IGCM_sys_Rm -rf ${RUN_DIR} 
    351   fi 
    352 fi 
    353 #- 
    354 [[ ${x_v} = 'verbose' ]] && print - ""; 
    355 #- 
    356 # That's all folks 
    357 #- 
    358  
    359 if [ ${NbErr} -ne 0 ] ; then 
    360   echo "################ ERROR ################" 
    361   echo "${NbErr} invalid JobName(s) found, check the log" 
    362 fi 
    363  
    364  
    365 exit 0; 
Note: See TracChangeset for help on using the changeset viewer.