Changeset 1583 for trunk


Ignore:
Timestamp:
04/19/23 11:21:58 (12 months ago)
Author:
jgipsl
Message:

Added option -f which will delete files without asking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/AA_clean_or_continue

    r1575 r1583  
    3737echo "" 
    3838echo "clean_or_continue.job " 
    39 if  [ $# -gt 0 ] ; then 
     39 
     40# Read arguments 
     41print_help=no 
     42force_rm=no 
     43while (($# > 0)) ; do 
     44  case $1 in 
     45    "-h") 
     46        print_help=yes ; shift ;; 
     47 
     48    "-f") 
     49        force_rm=yes ; shift ;; 
     50    *) 
     51        echo "Unknown option "$1" . Use -h for help." 
     52        exit 
     53   esac 
     54done 
     55 
     56 
     57if [ $print_help == yes ] ; then 
    4058    # Print help and exit 
    4159    echo "" 
    4260    echo "The script is called from in the your experiment directory, the so-called SUBMIT_DIR, in the following way" 
    43     echo "../../../libIGCM/clean_or_continue.job -h      : to print following information" 
    44     echo "../../../libIGCM/clean_or_continue.job         : normal execution" 
     61    echo "../../../libIGCM/clean_or_continue.job         : normal execution, you'll be asked before files are deleted" 
     62    echo "../../../libIGCM/clean_or_continue.job -f      : force normal execution to delete files without asking" 
     63    echo "../../../libIGCM/clean_or_continue.job -h      : print following information" 
    4564    echo "" 
    4665    echo "This script can be used for 3 cases:" 
     
    6281    exit 
    6382fi 
    64 echo "" 
    65 echo "This script needs to delete files to work correctly. Therefore you should answer yes to the questions." 
    66 echo "Use ../../../libIGCM/clean_or_contine.job -h  for more information" 
    67 echo "" 
     83 
     84if [ $force_rm == yes ] ; then 
     85  echo "" 
     86  echo "Option -f to delete files without asking is set" 
     87else 
     88  echo "" 
     89  echo "This script needs to delete files to work correctly. Therefore you should answer yes to the questions." 
     90  echo "Use ../../../libIGCM/clean_or_contine.job -h  for more information" 
     91  echo "" 
     92fi 
    6893 
    6994#D--------------------------------------------------------------------== 
     
    124149  #  
    125150  if [ X${run_Configuration_CumulPeriod} = X ] ; then 
    126     echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?" 
    127     echo -n -e " Your answer (y/n) : \033[m" 
    128     read reponse 
     151    if [ $force_rm == yes ] ; then 
     152        echo -e "\033[1;32mCumulPeriod is empty so run.card will be deleted to start properly. " 
     153        reponse=yes 
     154    else 
     155        echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?" 
     156        echo -n -e " Your answer (y/n) : \033[m" 
     157        read reponse 
     158    fi 
    129159    case ${reponse} in 
    130160 
    131161    oui|OUI|o|y|yes|YES) 
    132       echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
     162      echo "Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}" 
    133163      IGCM_sys_Rm ${SUBMIT_DIR}/run.card 
    134164      ;; 
     
    171201      done 
    172202    fi 
    173     echo -e "\033[1;32mDo you REALLY want to erase all those files ?" 
    174     echo -n -e " Your answer (y/n) : \033[m" 
    175     read reponse 
    176     case ${reponse} in 
    177  
    178       oui|OUI|o|y|yes|YES) 
    179         echo "OK. It will be erased." 
     203    if [ $force_rm == yes ] ; then 
     204        reponse=y 
     205    else 
     206        echo -e "\033[1;32mDo you REALLY want to erase all those files ?" 
     207        echo -n -e " Your answer (y/n) : \033[m" 
     208        read reponse 
     209    fi 
     210    case ${reponse} in 
     211 
     212      oui|OUI|o|y|yes|YES) 
     213        echo "The files will be erased." 
    180214        IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" 
    181215        if [ X${Pack} = Xtrue ] ; then 
     
    196230    done 
    197231 
    198     echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?" 
    199     echo -n -e " Your answer (y/n) : \033[m" 
    200     read reponse 
    201     case ${reponse} in 
    202  
    203       oui|OUI|o|y|yes|YES) 
    204         echo "OK. It will be erased." 
     232    if [ $force_rm == yes ] ; then 
     233        reponse=y 
     234    else 
     235        echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?" 
     236        echo -n -e " Your answer (y/n) : \033[m" 
     237        read reponse 
     238    fi 
     239    case ${reponse} in 
     240 
     241      oui|OUI|o|y|yes|YES) 
     242        echo "The files will be erased." 
    205243        find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \; 
    206244        echo "done." 
     
    215253  if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
    216254 
    217     echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" 
    218     echo -n -e " Your answer (y/n) : \033[m" 
    219     read reponse 
    220     case ${reponse} in 
    221  
    222       oui|OUI|o|y|yes|YES) 
    223         echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
     255    if [ $force_rm == yes ] ; then 
     256        echo -e "\033[1;32mPeriodState=OnQueue is set in run.card)" 
     257        reponse=y 
     258    else 
     259        echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" 
     260        echo -n -e " Your answer (y/n) : \033[m" 
     261        read reponse 
     262    fi 
     263    case ${reponse} in 
     264 
     265      oui|OUI|o|y|yes|YES) 
     266        echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}" 
    224267        IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" 
    225268        ;; 
     
    229272    esac 
    230273  else 
    231     echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
     274    echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}" 
    232275  fi 
    233276 
    234277  if [ X${run_Configuration_CumulPeriod} = X1 ] ; then 
    235     echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?" 
    236     echo -n -e " Your answer (y/n) : \033[m" 
    237     read reponse 
    238     case ${reponse} in 
    239  
    240       oui|OUI|o|y|yes|YES) 
    241         echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
     278    if [ $force_rm == yes ] ; then 
     279        echo -e "\033[1;32mCumulPeriod=1 and therfor run.card is deleted to start properly." 
     280        reponse=y 
     281    else 
     282        echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?" 
     283        echo -n -e " Your answer (y/n) : \033[m" 
     284        read reponse 
     285    fi 
     286    case ${reponse} in 
     287 
     288      oui|OUI|o|y|yes|YES) 
     289        echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}" 
    242290        IGCM_sys_Rm ${SUBMIT_DIR}/run.card 
    243291        ;; 
     
    252300    Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${run_Configuration_CumulPeriod} ) 
    253301 
    254     echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?" 
    255     echo -n -e " Your answer (y/n) : \033[m" 
    256     read reponse 
     302    if [ $force_rm == yes ] ; then 
     303        echo -e "\033[1;32mThe number in the jobname in Script_Output is changed." 
     304        reponse=y 
     305    else 
     306        echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?" 
     307        echo -n -e " Your answer (y/n) : \033[m" 
     308        read reponse 
     309    fi 
    257310    case ${reponse} in 
    258311 
Note: See TracChangeset for help on using the changeset viewer.