Ignore:
Timestamp:
06/06/12 13:03:49 (12 years ago)
Author:
sdipsl
Message:
  • refactoring and cosmetics
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh

    r679 r680  
    3333  fi 
    3434 
     35  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB ACTIVE 
    3536  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME 
    3637  IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DEBUT_INIT 
     
    4849  IGCM_card_DefineArrayFromSection   config.card ListOfComponents 
    4950 
     51  IGCM_debug_Print 1 "ACTIVE            = ${ensemble_Ens_PERTURB_ACTIVE}" 
    5052  IGCM_debug_Print 1 "NAME              = ${ensemble_Ens_PERTURB_NAME}" 
    5153  IGCM_debug_Print 1 "DEBUT_INIT        = ${ensemble_Ens_PERTURB_DEBUT_INIT}" 
     
    5860  IGCM_debug_Print 1 "PERTURB_BIN       = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}" 
    5961  IGCM_debug_Print 1 "INITFROM          = ${ensemble_Ens_PERTURB_INITFROM}" 
    60   IGCM_debug_Print 1 "INITFROM          = ${ensemble_Ens_PERTURB_INITPATH}" 
     62  IGCM_debug_Print 1 "INITPATH          = ${ensemble_Ens_PERTURB_INITPATH}" 
    6163  IGCM_debug_Print 1 "TagName           = ${config_UserChoices_TagName}" 
    6264  IGCM_debug_Print 1 "CalendarType      = ${config_UserChoices_CalendarType}" 
     
    7577  IGCM_debug_Print 1 "PerturbAmp  = ${PerturbAmp}" 
    7678 
    77   IGCM_debug_PopStack "IGCM_ensemble_CastInit" 
    78 } 
    79  
    80 function IGCM_ensemble_CastPeriodicStarts 
    81 { 
    82   IGCM_debug_PushStack "IGCM_ensemble_CastPeriodicStarts" 
    83  
    84   echo "Manage periodic starts" 
    85  
    86 #.. Manage periodic starts .. 
    87 #   ====================== 
    88  
    89 # ... Determine number of year(s) in PERIODICITE ... 
     79  # A few checks Period case: 
     80 
     81  # ... Check PERIODICITE ... 
    9082  case ${ensemble_Ens_PERTURB_PERIODICITE} in 
    9183  0) 
    9284    IGCM_debug_Print 1 "No periodic start" 
     85    return 
    9386    ;; 
    94   *Y|*y) 
    95     PeriodLengthInYears=$( echo ${ensemble_Ens_PERTURB_PERIODICITE} | sed -e 's/[yY]//' );; 
    96   *M|*m) 
    97     PeriodLengthInMonths=$( echo ${ensemble_Ens_PERTURB_PERIODICITE} | sed -e 's/[mM]//' );; 
     87  *[Yy]|*[Mm]) 
     88    IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITE}" ;; 
    9889  *) 
    99     IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " \ 
    100       ${ensemble_Ens_PERTURB_PERIODICITE} \ 
    101       " invalid PERIODICITE : choose in *Y." 
     90    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITE} : invalid PERIODICITE" 
     91    IGCM_debug_Exit "Choose a value in *Y or *M" 
    10292    IGCM_debug_Verif_Exit ;; 
    10393  esac 
    104 # ... Determine number of year(s) in DUREE ... 
     94# ... Check DUREE ... 
    10595  case ${ensemble_Ens_PERTURB_DUREE} in 
    106   *Y|*y) 
    107     DureeLengthInYears=$( echo ${ensemble_Ens_PERTURB_DUREE} | sed -e 's/[yY]//' ) ;; 
    108   *M|*m) 
    109     DureeLengthInMonths=$( echo ${ensemble_Ens_PERTURB_DUREE} | sed -e 's/[mM]//' ) ;; 
     96  *[Yy]|*[Mm]) 
     97    IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_DUREE}" ;; 
    11098  *) 
    111     IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " \ 
    112       ${ensemble_Ens_PERTURB_DUREE} \ 
    113       " invalid DUREE : choose in *Y." 
     99    IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE} invalid DUREE" 
     100    IGCM_debug_Exit "Choose a value in choose in *Y or *M" 
    114101    IGCM_debug_Verif_Exit ;; 
    115102  esac 
    116103 
     104  # A few checks Non-Period case: 
     105  DateNum=0 
     106  while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do 
     107 
     108    # - Check DUREE_NONPERIODIC 
     109    case ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} in 
     110    0) 
     111      IGCM_debug_Print 1 "No non-periodic start" 
     112      return 
     113      ;; 
     114    *[Yy]|*[Mm]) 
     115      IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]}" 
     116      ;; 
     117    *) 
     118      IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} : invalid DUREE" 
     119      IGCM_debug_Exit "choose in *Y or *M" 
     120      IGCM_debug_Verif_Exit ;; 
     121    esac 
     122    (( DateNum = DateNum + 1 )) 
     123  done 
     124 
     125  IGCM_debug_PopStack "IGCM_ensemble_CastInit" 
     126} 
     127 
     128function IGCM_ensemble_CastPeriodicStarts 
     129{ 
     130  IGCM_debug_PushStack "IGCM_ensemble_CastPeriodicStarts" 
     131 
     132  echo "Manage periodic starts" 
     133 
     134#.. Manage periodic starts .. 
     135#   ====================== 
     136 
    117137# ... Loop over DateBegin ... 
    118138  eval DateBegin=\${ensemble_Ens_PERTURB_DEBUT_INIT} 
    119139 
    120   while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT}  ] ; do 
     140  while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT} ] ; do 
    121141    IGCM_date_GetYearMonth ${DateBegin} year month 
    122142 
    123143  # - Determine number of day(s) in PERIODICITE 
    124     PeriodLengthInDays=0 
    125     case ${ensemble_Ens_PERTURB_PERIODICITE} in 
    126     *Y|*y) 
    127       i=0 
    128       until [ $i -ge ${PeriodLengthInYears} ] ; do 
    129         (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) 
    130         (( i = i + 1 )) 
    131       done 
    132       ;; 
    133     *M|*m) 
    134       i=0 
    135       year_wrk=$year 
    136       month_wrk=$month 
    137       until [ $i -ge ${PeriodLengthInMonths} ] ; do 
    138         (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year_wrk $month_wrk ) )) 
    139         if [ $month_wrk -lt 12 ] ; then 
    140           (( month_wrk = month_wrk + 1 )) 
    141         else 
    142           (( year_wrk  = year_wrk + 1 )) 
    143           (( month_wrk = 1 )) 
    144         fi 
    145         (( i = i + 1 )) 
    146       done 
    147       ;; 
    148     esac 
     144    PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITE} ) 
     145 
    149146  # - Determine number of day(s) in DUREE 
    150     DureeLengthInDays=0 
    151     case ${ensemble_Ens_PERTURB_DUREE} in 
    152     *Y|*y) 
    153       i=0 
    154       until [ $i -ge ${DureeLengthInYears} ] ; do 
    155         (( DureeLengthInDays = DureeLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) 
    156         (( i = i + 1 )) 
    157       done 
    158       ;; 
    159     *M|*m) 
    160       i=0 
    161       year_wrk=$year 
    162       month_wrk=$month 
    163       until [ $i -ge ${DureeLengthInMonths} ] ; do 
    164         (( DureeLengthInDays = DureeLengthInDays + $( IGCM_date_DaysInMonth $year_wrk $month_wrk ) )) 
    165         if [ $month_wrk -lt 12 ] ; then 
    166           (( month_wrk = month_wrk + 1 )) 
    167         else 
    168           (( year_wrk  = year_wrk + 1 )) 
    169           (( month_wrk = 1 )) 
    170         fi 
    171         (( i = i + 1 )) 
    172       done 
    173       ;; 
    174     esac 
    175  
    176     (( DureeLengthInDays = DureeLengthInDays - 1 )) 
     147    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_DUREE} ) - 1 )) 
    177148 
    178149  # - Determine DateEnd 
     
    200171  # - Create directory in which to store new restart files 
    201172    RestartDir=$ARCHIVE/IGCM_IN/${config_UserChoices_TagName}/${StartDir} 
    202     if [ ! -d  ${RestartDir} ] ; then 
    203       IGCM_sys_MkdirArchive ${RestartDir} 
    204     fi 
     173    IGCM_sys_MkdirArchive ${RestartDir} 
    205174 
    206175  # - Loop over members 
     
    218187      if [ ! -d  ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then 
    219188        IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} 
    220 #      IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} 
     189        #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} 
    221190        IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} 
    222191        ln -s ../../COMP 
     
    245214    echo "$DateBegin  $PeriodLengthInDays" 
    246215    case ${ensemble_Ens_PERTURB_PERIODICITE} in 
    247     *Y|*y|*M|*m) 
     216    *[Yy]|*[Mm]) 
    248217      (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) )) 
    249218      ;; 
     
    254223  IGCM_debug_PopStack "IGCM_ensemble_CastPeriodicStarts" 
    255224} 
    256  
    257  
    258  
    259  
    260  
    261  
    262  
    263  
    264  
    265  
    266  
    267  
    268225 
    269226function IGCM_ensemble_CastNonPeriodicStarts 
     
    285242    echo ">${DateBegin}<" 
    286243    echo ">${Duree}<" 
    287   # - Determine number of year(s) in DUREE_NONPERIODIC 
    288     case ${Duree} in 
    289     0) 
    290       IGCM_debug_Print 1 "No non-periodic start" 
    291       exit 
    292       ;; 
    293     *Y|*y) 
    294       DureeLengthInYears=$( echo ${Duree} | sed -e 's/[yY]//' ) 
    295       ;; 
    296     *M|*m) 
    297       DureeLengthInMonths=$( echo ${Duree} | sed -e 's/[mM]//' ) 
    298       ;; 
    299     *) 
    300       IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " ${Duree} " invalid DUREE : choose in *Y." 
    301       IGCM_debug_Verif_Exit ;; 
    302     esac 
     244 
    303245  # - Determine number of day(s) in DUREE_NONPERIODIC 
    304246    IGCM_date_GetYearMonth ${DateBegin} year month 
    305     DureeLengthInDays=0 
    306     case ${Duree} in 
    307     *Y|*y) 
    308       i=0 
    309       until [ $i -ge ${DureeLengthInYears} ] ; do 
    310         (( DureeLengthInDays = DureeLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) 
    311         (( i = i + 1 )) 
    312       done 
    313       ;; 
    314     *M|*m) 
    315       i=0 
    316       until [ $i -ge ${DureeLengthInMonths} ] ; do 
    317         (( DureeLengthInDays = DureeLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 
    318         (( i = i + 1 )) 
    319       done 
    320       ;; 
    321     esac 
    322     (( DureeLengthInDays = DureeLengthInDays - 1 )) 
     247    DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 )) 
    323248 
    324249  # - Build directory name 
     
    330255    (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) 
    331256    echo ">${DateEnd}<" 
    332  
    333257    echo "tout va bien 1" 
    334258 
     
    354278  # - Create directory in which to store new restart files if it does'nt already exist 
    355279    RestartDir=$DMFDIR/IGCM_IN/${config_UserChoices_TagName}/${StartDir} 
    356     if [ ! -d  ${RestartDir} ] ; then 
    357       IGCM_sys_MkdirArchive ${RestartDir} 
    358     fi 
     280    IGCM_sys_MkdirArchive ${RestartDir} 
    359281 
    360282  # - Loop over members 
     
    457379  year=$3 
    458380  month=$4 
    459  
    460   set -A AlphaMonth a b c d e f g h i j k l 
    461381 
    462382  # - Build directory name 
     
    521441    if [ $? -ne 0 ] ; then 
    522442      echo "Abend $( basename ${PerturbExe} )" 
    523       exit 
     443      return 
    524444    fi 
    525445 
Note: See TracChangeset for help on using the changeset viewer.