Ignore:
Timestamp:
10/19/11 14:33:14 (13 years ago)
Author:
mmaipsl
Message:

Correct side effect when NEW_JobName and substring in Submit_dir PATH are very close. Protect some deletes. Add out_execution file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libIGCM_MPI_OpenMP/AA_move-and-rename

    r436 r509  
    6161{ 
    6262    IGCM_debug_PushStack "REPLACE_sed" 
     63    typeset RET 
    6364     
    6465    FILEIN=${1} 
     
    8586    IGCM_debug_PushStack "MOVE_and_RENAME_files" 
    8687 
    87     typeset VAR_files FILE_OUT 
     88    typeset VAR_files FILE_OUT file i RET 
    8889 
    8990    VAR_files=${1} 
    9091    eval VAR1=\${${VAR_files[0]}} 
    9192 
    92     set +A FILE_OUT -- $( eval echo \${${VAR_files}[*]} | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" ) 
     93    if [ X$( echo ${NEW_R_SAVE} | grep ${config_UserChoices_JobName} ) != X ]; then 
     94        set +A FILE_OUT -- $( eval echo \${${VAR_files}[*]} | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" ) 
     95        ((i=0)) 
     96        for file in ${FILE_OUT[@]} ; do 
     97            FILE_OUT[$i]=$( dirname $file )/$( echo $( basename $file ) | sed -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" ) 
     98            (( i = i + 1 )) 
     99        done 
     100    else 
     101        set +A FILE_OUT -- $( eval echo \${${VAR_files}[*]} | sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" ) 
     102    fi 
    93103    IGCM_debug_Print 3 "MOVE_and_RENAME_files all : ${VAR1}" 
    94104    IGCM_debug_Print 3 "    to     ${FILE_OUT}."  
     
    97107    for file_o in ${FILE_OUT[@]} ; do 
    98108        eval IGCM_sys_Mv \${${VAR_files}[${ifile}]} ${file_o} 
     109        RET=$? 
    99110        (( ifile = ifile + 1 )) 
    100111    done     
    101     RET=$? 
    102112 
    103113    IGCM_debug_PopStack "MOVE_and_RENAME_files" 
     
    242252# Change JobName and copy run.card 
    243253if [ -f ${OutinDir}/run.card ] ; then 
    244     REPLACE_sed ${OutinDir}/run.card ${OutNEWDir} 
     254    sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \ 
     255        ${OutinDir}/run.card > ${RUN_DIR_PATH}/run.card 
     256    RET=$? 
     257    if [ ${RET} = 0 ] ; then 
     258        IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${OutNEWDir} 
     259        IGCM_sys_Rm -f ${OutinDir}/run.card 
     260    fi 
    245261fi 
    246262 
     
    250266if [ ${#listfiles[*]} -gt 0 ] ; then 
    251267    IGCM_sys_Cp ${listfiles[*]} ${OutNEWDir} 
    252     IGCM_sys_Rm -f ${listfiles[*]} 
     268    RET=$? 
     269    if [ ${RET} = 0 ] ; then 
     270        IGCM_sys_Rm -f ${listfiles[*]} 
     271    fi 
    253272fi 
    254273 
     
    261280unset listfiles 
    262281set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_${config_Executable_Name}" ) 
     282MOVE_and_RENAME_files "listfiles" 
     283unset listfiles 
     284set +A listfiles -- $( find ${OutinDir} -type f -name "*_out_execution" ) 
    263285MOVE_and_RENAME_files "listfiles" 
    264286 
     
    415437    IGCM_sys_MkdirArchive ${NEW_R_SAVE}/${R_MONITORING} 
    416438    REPLACE_sed ${R_SAVE}/${R_MONITORING}/index.html ${NEW_R_SAVE}/${R_MONITORING} 
    417     REPLACE_sed ${R_SAVE}/${R_MONITORING}/run.card ${NEW_R_SAVE}/${R_MONITORING} 
     439    sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \ 
     440        ${R_SAVE}/${R_MONITORING}/run.card > ${RUN_DIR_PATH}/run.card 
     441    IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${NEW_R_SAVE}/${R_MONITORING} 
     442    RET=$? 
     443    if [ ${RET} = 0 ] ; then 
     444        IGCM_sys_Rm -f ${R_SAVE}/${R_MONITORING}/run.card 
     445    fi 
    418446    REPLACE_sed ${R_SAVE}/${R_MONITORING}/config.card ${NEW_R_SAVE}/${R_MONITORING} 
    419447    IGCM_sys_Cp -rp ${R_SAVE}/${R_MONITORING} ${NEW_R_SAVE} 
     
    487515if [ -f ${SUBMIT_DIR}/run.card ] ; then 
    488516    IGCM_debug_Print 1 "edit run.card" 
    489     sed -e "s&${R_SAVE}&${NEW_R_SAVE}&g" -e "s/${config_UserChoices_JobName}/${NEW_JobName}/g" \ 
     517    sed -e "s/OldPrefix=\ *${config_UserChoices_JobName}/OldPrefix= ${NEW_JobName}/g" \ 
    490518        ${SUBMIT_DIR}/run.card > ${RUN_DIR_PATH}/run.card 
    491519    IGCM_sys_Mv -f ${RUN_DIR_PATH}/run.card ${SUBMIT_DIR}/run.card 
Note: See TracChangeset for help on using the changeset viewer.