Ignore:
Timestamp:
07/19/07 13:44:11 (17 years ago)
Author:
bellier
Message:

JB: no overwrite already existing files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modipsl/trunk/util/ins_job

    r92 r93  
    66function ins_job_Usage 
    77{ 
    8 echo " 
     8print - " 
    99ins_job installs the jobs in the directories 
    1010which contain a file config.card 
     
    2020  -v   : verbose mode 
    2121" 
     22} 
     23function ins_job_Warning 
     24{ 
     25   print - "\n############### WARNING ###############"; 
     26   print - "File ${n_f} already exists\nin directory ${j}"; 
     27   print - "You must delete this file to update !"; 
    2228} 
    2329#- 
     
    9096. ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    9197#- 
     98# Define the pattern string to substitute 
     99#- 
     100W_P='#-Q- '; W_W=${W_P}${x_t}; 
     101#- 
    92102# Extract list of 'config.card' files 
    93103# and create jobs with AA_job 
     
    97107for i in ${l_cfg} 
    98108do 
    99   j=$(cd ${i%/*};pwd) 
    100   \cp ${F_RCI} ${j} 
    101   IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices JobName 
    102   print - "\nWorking with file ${F_CFG}"; 
    103   print - "in directory ${j}"; 
    104   print - "for Job_${config_UserChoices_JobName}" 
    105   W_P='#-Q- '; W_W=${W_P}${x_t}; 
    106   sed -e "/^${W_W} */ s///" \ 
    107       -e "/^${W_P}/d"       \ 
    108       -e "s%::modipsl::%${F_MOD}%" \ 
    109       -e "s/::Jobname::/${config_UserChoices_JobName}/" \ 
    110       ${F_JOB} > ${j}'/Job_'${config_UserChoices_JobName} 
     109 j=$(cd ${i%/*};pwd) 
     110 n_f=${F_RCI##*/}; 
     111 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; } 
     112 [[ ! -f ${j}'/'${n_f} ]] && \ 
     113  { 
     114   print - "\nCopying file ${F_RCI}\nin directory ${j}"; 
     115   \cp ${F_RCI} ${j}; 
     116  } 
     117 IGCM_card_DefineVariableFromOption ${j}'/'${F_CFG} UserChoices JobName 
     118 n_f='Job_'${config_UserChoices_JobName}; 
     119 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 
     120 print - "\nWorking with file ${F_CFG}\nin directory ${j}\nfor ${n_f}"; 
     121 sed -e "/^${W_W} */ s///" \ 
     122     -e "/^${W_P}/d"       \ 
     123     -e "s%::modipsl::%${F_MOD}%" \ 
     124     -e "s/::Jobname::/${config_UserChoices_JobName}/" \ 
     125     ${F_JOB} > ${j}'/'${n_f} 
    111126done 
    112127#- 
     
    117132for i in ${l_cfg} 
    118133do 
    119   i_f=${i##*/}; 
    120   [[ ${i_f} = 'AA_job' ]] && continue 
    121   i_d=${i%/*}; n_f=${i_f#AA_}'.job'; 
    122   print - "\nIn directory ${i_d}\n${i_f} -> ${n_f}" 
    123   sed -e "/^${W_W} */ s///" \ 
    124       -e "/^${W_P}/d"       \ 
    125       ${i} > ${i_d}'/'${n_f} 
     134 i_f=${i##*/}; 
     135 [[ ${i_f} = 'AA_job' ]] && { continue; } 
     136 j=${i%/*}; n_f=${i_f#AA_}'.job'; 
     137 [[ -f ${j}'/'${n_f} ]] && { ins_job_Warning; continue; } 
     138 print - "\nIn directory ${j}\n${i_f} -> ${n_f}" 
     139 sed -e "/^${W_W} */ s///" \ 
     140     -e "/^${W_P}/d"       \ 
     141     ${i} > ${j}'/'${n_f} 
    126142done 
     143#- 
     144print - ""; 
    127145#- 
    128146# That's all folks 
Note: See TracChangeset for help on using the changeset viewer.