Ignore:
Timestamp:
04/25/23 14:26:44 (15 months ago)
Author:
ssenesi
Message:

merge branch libIGCM_CESMEP with trunk that handles RedHat8 on Irene

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libIGCM_CESMEP/AA_clean_PeriodLength

    r1567 r1585  
    1010# 
    1111#************************************************************** 
    12 # ID of your genci project. Curie only : post-processing jobs need it to run properly 
    13 #-Q- curie export BRIDGE_MSUB_PROJECT=::default_project:: 
    14 #-Q- irene export BRIDGE_MSUB_PROJECT=::default_project:: 
    15 #-Q- irene-amd export BRIDGE_MSUB_PROJECT=::default_project:: 
    1612 
    17 #set -eu 
    18 #set -vx 
    19  
    20 libIGCM=::modipsl::/libIGCM 
    21  
    22 #D- Task type DO NOT CHANGE (computing, post-processing or checking) 
    23 TaskType=post-processing 
    24  
    25 #D--------------------------------------------------------------------== 
    26 #D-                   -1. User modification place 
    27 #D--------------------------------------------------------------------== 
    28  
    29 #D- Increased verbosity (1, 2, 3) 
    30 Verbosity=3 
    31  
    32 #D- Low level debug : to bypass lib test checks and stack construction 
    33 #D- Default=true 
    34 DEBUG_debug=false 
    35  
    36 #D--------------------------------------------------------------------== 
    37  
    38 echo "clean PeriodLenght script :" 
    39 echo "Script used to clean a PeriodLength from the IGCM_OUT directory !" 
    40 echo "This script will erase files !!! Be careful and read all informations !" 
    41 echo "----" 
    42 echo "It must be called in Experience directory (so-called SUBMIT_DIR)." 
    43 echo "----" 
    44  
    45 #D--------------------------------------------------------------------== 
    46  
    47 . ${libIGCM}/libIGCM_debug/libIGCM_debug.ksh 
    48 . ${libIGCM}/libIGCM_card/libIGCM_card.ksh 
    49 . ${libIGCM}/libIGCM_date/libIGCM_date.ksh 
    50 #------- 
    51 SUBMIT_DIR=$( pwd ) 
    52 . ${libIGCM}/libIGCM_sys/libIGCM_sys.ksh 
    53 . ${libIGCM}/libIGCM_config/libIGCM_config.ksh 
    54 #------- 
    55 ( ${DEBUG_debug} ) && IGCM_debug_Check 
    56 ( ${DEBUG_debug} ) && IGCM_card_Check 
    57 ( ${DEBUG_debug} ) && IGCM_date_Check 
    58  
    59 clean_CESMEP() 
    60 { 
    61     IGCM_card_DefineVariableFromOption ${prefix}config.card Post Cesmep 
    62     if [ ${config_Post_Cesmep} != FALSE ]; then 
    63         echo -e "\033[1;32mDo you want to erase the CESMEP atlas and dedicated CliMAF cache) ?" 
    64         echo -n -e " Your answer (y/n) : \033[m" 
    65         read reponse 
    66         case ${reponse} in 
    67             oui|OUI|o|y|yes|YES) 
    68                 $SUBMIT_DIR/cesmep_lite/libIGCM_clean.sh 
    69                 ;; 
    70         esac   
    71     fi 
    72 } 
    73  
    74 #================================== 
    75 # First of all 
    76 # 
    77 # Read libIGCM compatibility version in config.card 
    78 # Read UserChoices section 
    79 # Read Ensemble section 
    80 # Read Post section 
    81 # Define all netcdf output directories 
    82 #================================== 
    83 IGCM_config_CommonConfiguration ${SUBMIT_DIR}/config.card 
    84  
    85 #================================== 
    86 # Define default value to keep compatibility with previous card: means before changes due to TGCC 
    87 if [ X${PackDefault} = Xtrue ] ; then 
    88   [ X${config_Post_PackFrequency} = X ] && config_Post_PackFrequency=${config_Post_RebuildFrequency} 
    89 else 
    90   config_Post_PackFrequency=NONE 
    91 fi 
    92  
    93 #================================== 
    94 # Is the pack active 
    95 if ( [ ! X${config_Post_PackFrequency} = X${NULL_STR} ] && [ ! X${config_Post_PackFrequency} = XNONE ] ) ; then 
    96   Pack=true 
    97 fi 
    98  
    99 IGCM_sys_TestDirArchive ${R_SAVE} 
    100 [ $? != 0 ] && IGCM_debug_Exit "IGCM_sys_TestDirArchive" 
    101  
    102 if [ ! -f ${SUBMIT_DIR}/run.card ]; then 
    103   echo "You seem NOT to have a run.card in this directory !!" 
    104   echo "This script will fail because it doesn't know what to do without run.card available." 
    105   exit 1 
    106 else 
    107   #===================================# 
    108   #        Read updated run.card      # 
    109   #===================================# 
    110   IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
    111   IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateBegin 
    112   IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodDateEnd 
    113   IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration CumulPeriod 
    114  
    115   #  
    116   if [ X${run_Configuration_CumulPeriod} = X ] ; then 
    117     echo -e "\033[1;32mCumulPeriod is empty so we want to erase run.card to start properly. Do you want that?" 
    118     echo -n -e " Your answer (y/n) : \033[m" 
    119     read reponse 
    120     case ${reponse} in 
    121  
    122     oui|OUI|o|y|yes|YES) 
    123       echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
    124       IGCM_sys_Rm ${SUBMIT_DIR}/run.card 
    125       ;; 
    126     non|NON|n|no|NO) 
    127       echo "Nothing to do !" 
    128       ;; 
    129     esac 
    130     clean_CESMEP 
    131     exit 0 
    132   fi 
    133  
    134   PeriodDateEnd=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateEnd} ) 
    135   echo "Search files with ${PeriodDateEnd} in ${R_SAVE}" 
    136   set +A ListFiles -- $( IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" " ) 
    137   CountListFiles=${#ListFiles[@]} 
    138  
    139   if [ X${Pack} = Xtrue ] ; then 
    140     echo "Search files with ${PeriodDateEnd} in ${R_BUFR}" 
    141     set +A ListFilesBuf -- $( IGCM_sys_RshMaster "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" " ) 
    142     CountListFilesBuf=${#ListFilesBuf[@]} 
    143   else 
    144     CountListFilesBuf=0 
    145   fi 
    146  
    147   # If exist, erase REBUILD DIR 
    148   PeriodDateBegin=$( IGCM_date_ConvertFormatToGregorian ${run_Configuration_PeriodDateBegin} ) 
    149   CountRebuildDir=0 
    150   if [ X${config_Post_RebuildFrequency} != X ] ; then 
    151     set +A RebuildDir -- $( find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" ) 
    152     CountRebuildDir=${#RebuildDir[@]} 
    153   fi 
    154  
    155   IGCM_debug_Print 1 "Number of files to be erased : ${CountListFiles}." 
    156   if ( [ ${CountListFiles} -gt 0 ] || [ ${CountListFilesBuf} -gt 0 ] ) ; then 
    157     for file in ${ListFiles[@]} ; do 
    158       IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" 
    159     done 
    160     if [ X${Pack} = Xtrue ] ; then 
    161       for file in ${ListFilesBuf[@]} ; do 
    162         IGCM_debug_Print 2 -e "\033[1;31m ${file}\033[m" 
    163       done 
    164     fi 
    165     echo -e "\033[1;32mDo you REALLY want to erase all those files ?" 
    166     echo -n -e " Your answer (y/n) : \033[m" 
    167     read reponse 
    168     case ${reponse} in 
    169  
    170       oui|OUI|o|y|yes|YES) 
    171         echo "OK. It will be erased." 
    172         IGCM_sys_RshArchive "find ${R_SAVE} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" 
    173         if [ X${Pack} = Xtrue ] ; then 
    174           IGCM_sys_RshMaster  "find ${R_BUFR} -name \"*${PeriodDateEnd}*\" -exec rm -f '{}' \;" 
    175         fi 
    176         echo "done." 
    177         ;; 
    178       non|NON|n|no|NO) 
    179         echo "Nothing to do !" 
    180         ;; 
    181     esac 
    182   fi 
    183  
    184   if [ ${CountRebuildDir} -gt 0 ] ; then 
    185     IGCM_debug_Print 1 "Number of REBUILD Dirs to be erased : ${CountRebuildDir}." 
    186     for Dir in ${RebuildDir[@]} ; do 
    187       IGCM_debug_Print 2 -e "\033[1;31m ${Dir}\033[m" 
    188     done 
    189  
    190     echo -e "\033[1;32mDo you REALLY want to erase all those Directories ?" 
    191     echo -n -e " Your answer (y/n) : \033[m" 
    192     read reponse 
    193     case ${reponse} in 
    194  
    195       oui|OUI|o|y|yes|YES) 
    196         echo "OK. It will be erased." 
    197         find ${REBUILD_DIR} -type d -name "*${PeriodDateBegin}*" -exec rm -Rf '{}' \; 
    198         echo "done." 
    199         ;; 
    200       non|NON|n|no|NO) 
    201         echo "Nothing to do !" 
    202         ;; 
    203     esac 
    204   fi 
    205  
    206   IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/run.card Configuration PeriodState 
    207   if ( [ ${run_Configuration_PeriodState} != "Running" ] && [ ${run_Configuration_PeriodState} != "OnQueue" ] && [ ${run_Configuration_PeriodState} != "Continue" ] ) ; then 
    208  
    209     echo -e "\033[1;32mNOW do you want to continue the simulation (Set PeriodState=OnQueue into run.card) ?" 
    210     echo -n -e " Your answer (y/n) : \033[m" 
    211     read reponse 
    212     case ${reponse} in 
    213  
    214       oui|OUI|o|y|yes|YES) 
    215         echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
    216         IGCM_card_WriteOption ${SUBMIT_DIR}/run.card Configuration PeriodState "OnQueue" 
    217         ;; 
    218       non|NON|n|no|NO) 
    219         echo "Nothing to do !" 
    220         ;; 
    221     esac 
    222   else 
    223     echo "You can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
    224   fi 
    225  
    226   if [ X${run_Configuration_CumulPeriod} = X1 ] ; then 
    227     echo -e "\033[1;32mCumulPeriod=1 so we want to erase run.card to start properly. Do you want that too?" 
    228     echo -n -e " Your answer (y/n) : \033[m" 
    229     read reponse 
    230     case ${reponse} in 
    231  
    232       oui|OUI|o|y|yes|YES) 
    233         echo "OK. Now you can submit the Job : ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}." 
    234         IGCM_sys_Rm ${SUBMIT_DIR}/run.card 
    235         ;; 
    236       non|NON|n|no|NO) 
    237         echo "Nothing to do !" 
    238         ;; 
    239     esac 
    240   else 
    241     # if not first period 
    242     Script_Output_Prefix=${config_UserChoices_Script_Output_Prefix:='Script_Output'} 
    243     Script_Output_Job=${Script_Output_Prefix}_${config_UserChoices_JobName} 
    244     Script_Output=${Script_Output_Prefix}_${config_UserChoices_JobName}.$( printf "%06d" ${run_Configuration_CumulPeriod} ) 
    245  
    246     echo -e "\033[1;32mDo you want to change the number in Script_Output? (${Script_Output} into Job) ?" 
    247     echo -n -e " Your answer (y/n) : \033[m" 
    248     read reponse 
    249     case ${reponse} in 
    250  
    251       oui|OUI|o|y|yes|YES) 
    252         cp ${SUBMIT_DIR}/Job_${config_UserChoices_JobName} ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$ 
    253         sed -e"s/${Script_Output_Job}.[0-9][0-9][0-9][0-9][0-9][0-9]/${Script_Output}/"  ${SUBMIT_DIR}/Job_${config_UserChoices_JobName}_SAVED_$$  >${SUBMIT_DIR}/Job_${config_UserChoices_JobName} 
    254         echo "Job : Job_${config_UserChoices_JobName} modified." 
    255         echo "Old job saved here : Job_${config_UserChoices_JobName}_SAVED_$$" 
    256         ;; 
    257       non|NON|n|no|NO) 
    258         echo "Nothing done in Job_${config_UserChoices_JobName} !" 
    259         ;; 
    260     esac 
    261  
    262   fi 
    263  
    264   clean_CESMEP 
    265    
    266 fi 
    267 exit 0 
     13echo "" 
     14echo "clean_PeriodLength.job has been replaced by clean_or_continue.job." 
     15echo "The new script keeps the same funtionnalities as the old one. " 
     16echo "Launch using " 
     17echo "../../../libIGCM/clean_or_continue.job -h   : for help" 
     18echo "../../../libIGCM/clean_or_continut.job      : for normal execution" 
     19echo "Exit now" 
     20echo "" 
     21exit 
Note: See TracChangeset for help on using the changeset viewer.