[677] | 1 | #!/bin/ksh |
---|
| 2 | |
---|
| 3 | #************************************************************** |
---|
| 4 | # Author: Sonia Labetoulle |
---|
| 5 | # Contact: Sonia.Labetoulle__at__locean-ipsl.upmc.fr |
---|
[679] | 6 | # $Revision:: $ Revision of last commit |
---|
| 7 | # $Author:: $ Author of last commit |
---|
| 8 | # $Date:: $ Date of last commit |
---|
[677] | 9 | # IPSL (2012) |
---|
| 10 | # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC |
---|
| 11 | # |
---|
| 12 | #************************************************************** |
---|
| 13 | |
---|
[679] | 14 | function IGCM_ensemble_CastInit |
---|
[677] | 15 | { |
---|
[679] | 16 | IGCM_debug_PushStack "IGCM_ensemble_CastInit" |
---|
[677] | 17 | |
---|
[679] | 18 | set -A Alpha A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
---|
| 19 | set -A AlphaMonth a b c d e f g h i j k l |
---|
| 20 | |
---|
| 21 | IGCM_sys_Mkdir ${RUN_DIR} |
---|
| 22 | |
---|
| 23 | IGCM_sys_Cp ${SUBMIT_DIR}/config.card ${RUN_DIR} |
---|
| 24 | IGCM_sys_Cp ${SUBMIT_DIR}/ensemble.card ${RUN_DIR} |
---|
| 25 | IGCM_sys_Cp ${SUBMIT_DIR}/Job_* ${RUN_DIR} |
---|
| 26 | IGCM_sys_Cp ${SUBMIT_DIR}/run.card.init ${RUN_DIR} |
---|
| 27 | |
---|
[742] | 28 | # Useful? |
---|
| 29 | #if [ -f ${SUBMIT_DIR}/CreatedDir.txt ] ; then |
---|
| 30 | # IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR} |
---|
| 31 | #fi |
---|
| 32 | # Useful? |
---|
| 33 | #if [ -f ${SUBMIT_DIR}/Qsub.txt ] ; then |
---|
| 34 | # IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.txt ${RUN_DIR} |
---|
| 35 | #fi |
---|
[679] | 36 | |
---|
[735] | 37 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB actif |
---|
[679] | 38 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME |
---|
| 39 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DEBUT_INIT |
---|
| 40 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB FIN_INIT |
---|
| 41 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB PERIODICITE |
---|
| 42 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB NONPERIODIC |
---|
| 43 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DUREE |
---|
| 44 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB DUREE_NONPERIODIC |
---|
| 45 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB MEMBER |
---|
| 46 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB PERTURB_BIN |
---|
| 47 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITFROM |
---|
| 48 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITPATH |
---|
| 49 | IGCM_card_DefineVariableFromOption config.card UserChoices TagName |
---|
| 50 | IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType |
---|
| 51 | IGCM_card_DefineArrayFromSection config.card ListOfComponents |
---|
| 52 | |
---|
[737] | 53 | echo |
---|
| 54 | IGCM_debug_Print 1 "ACTIVE = ${ensemble_Ens_PERTURB_actif}" |
---|
[679] | 55 | IGCM_debug_Print 1 "NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
| 56 | IGCM_debug_Print 1 "DEBUT_INIT = ${ensemble_Ens_PERTURB_DEBUT_INIT}" |
---|
| 57 | IGCM_debug_Print 1 "FIN_INIT = ${ensemble_Ens_PERTURB_FIN_INIT}" |
---|
| 58 | IGCM_debug_Print 1 "PERIODICITE = ${ensemble_Ens_PERTURB_PERIODICITE}" |
---|
| 59 | IGCM_debug_Print 1 "NONPERIODIC = ${ensemble_Ens_PERTURB_NONPERIODIC[*]}" |
---|
| 60 | IGCM_debug_Print 1 "DUREE = ${ensemble_Ens_PERTURB_DUREE}" |
---|
| 61 | IGCM_debug_Print 1 "DUREE_NONPERIODIC = ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[*]}" |
---|
| 62 | IGCM_debug_Print 1 "MEMBER = ${ensemble_Ens_PERTURB_MEMBER}" |
---|
| 63 | IGCM_debug_Print 1 "PERTURB_BIN = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}" |
---|
| 64 | IGCM_debug_Print 1 "INITFROM = ${ensemble_Ens_PERTURB_INITFROM}" |
---|
[680] | 65 | IGCM_debug_Print 1 "INITPATH = ${ensemble_Ens_PERTURB_INITPATH}" |
---|
[679] | 66 | IGCM_debug_Print 1 "TagName = ${config_UserChoices_TagName}" |
---|
| 67 | IGCM_debug_Print 1 "CalendarType = ${config_UserChoices_CalendarType}" |
---|
| 68 | IGCM_debug_Print 1 "ListOfComponents = ${config_ListOfComponents[*]}" |
---|
| 69 | |
---|
| 70 | PerturbExe=${ensemble_Ens_PERTURB_PERTURB_BIN[0]} |
---|
| 71 | PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]} |
---|
| 72 | PerturbFile=${ensemble_Ens_PERTURB_PERTURB_BIN[2]} |
---|
| 73 | PerturbVar=${ensemble_Ens_PERTURB_PERTURB_BIN[3]} |
---|
| 74 | PerturbAmp=${ensemble_Ens_PERTURB_PERTURB_BIN[4]} |
---|
| 75 | |
---|
| 76 | IGCM_debug_Print 1 "PerturbExe = ${PerturbExe}" |
---|
| 77 | IGCM_debug_Print 1 "PerturbFile = ${PerturbFile}" |
---|
| 78 | IGCM_debug_Print 1 "PerturbComp = ${PerturbComp}" |
---|
| 79 | IGCM_debug_Print 1 "PerturbVar = ${PerturbVar}" |
---|
| 80 | IGCM_debug_Print 1 "PerturbAmp = ${PerturbAmp}" |
---|
| 81 | |
---|
[680] | 82 | # A few checks Period case: |
---|
[679] | 83 | |
---|
[680] | 84 | # ... Check PERIODICITE ... |
---|
[679] | 85 | case ${ensemble_Ens_PERTURB_PERIODICITE} in |
---|
[735] | 86 | _0_) |
---|
[737] | 87 | IGCM_debug_Print 1 "periodic start not active" |
---|
[736] | 88 | CastPeriodicStart=false |
---|
[679] | 89 | ;; |
---|
[680] | 90 | *[Yy]|*[Mm]) |
---|
[736] | 91 | CastPeriodicStart=true |
---|
[680] | 92 | IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITE}" ;; |
---|
[679] | 93 | *) |
---|
[680] | 94 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITE} : invalid PERIODICITE" |
---|
| 95 | IGCM_debug_Exit "Choose a value in *Y or *M" |
---|
[679] | 96 | IGCM_debug_Verif_Exit ;; |
---|
| 97 | esac |
---|
[680] | 98 | # ... Check DUREE ... |
---|
[679] | 99 | case ${ensemble_Ens_PERTURB_DUREE} in |
---|
[680] | 100 | *[Yy]|*[Mm]) |
---|
| 101 | IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_DUREE}" ;; |
---|
[679] | 102 | *) |
---|
[680] | 103 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE} invalid DUREE" |
---|
| 104 | IGCM_debug_Exit "Choose a value in choose in *Y or *M" |
---|
[679] | 105 | IGCM_debug_Verif_Exit ;; |
---|
| 106 | esac |
---|
| 107 | |
---|
[736] | 108 | # A few checks for the Non-Periodic case: |
---|
[680] | 109 | DateNum=0 |
---|
| 110 | while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
| 111 | |
---|
| 112 | # - Check DUREE_NONPERIODIC |
---|
| 113 | case ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} in |
---|
[735] | 114 | _0_) |
---|
[737] | 115 | IGCM_debug_Print 1 "non-periodic start not active" |
---|
[736] | 116 | CastNonPeriodicStart=false |
---|
[680] | 117 | ;; |
---|
| 118 | *[Yy]|*[Mm]) |
---|
| 119 | IGCM_debug_Print 1 "Non-periodic duration : ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]}" |
---|
[736] | 120 | CastNonPeriodicStart=true |
---|
[680] | 121 | ;; |
---|
| 122 | *) |
---|
| 123 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} : invalid DUREE" |
---|
| 124 | IGCM_debug_Exit "choose in *Y or *M" |
---|
| 125 | IGCM_debug_Verif_Exit ;; |
---|
| 126 | esac |
---|
| 127 | (( DateNum = DateNum + 1 )) |
---|
| 128 | done |
---|
| 129 | |
---|
[864] | 130 | # Need to know all the restart filename of the component we will apply the noise to |
---|
| 131 | IGCM_card_DefineArrayFromOption config.card ListOfComponents ${PerturbComp} |
---|
| 132 | eval compname=\${config_ListOfComponents_${PerturbComp}[0]} > /dev/null 2>&1 |
---|
| 133 | |
---|
| 134 | # Target the component's card we apply the noise to |
---|
| 135 | card=${SUBMIT_DIR}/COMP/${compname}.card |
---|
| 136 | |
---|
| 137 | # Read the restart file list. To be used later |
---|
| 138 | IGCM_card_DefineArrayFromOption ${card} RestartFiles List |
---|
| 139 | ListFilesName=${compname}_RestartFiles_List |
---|
| 140 | eval FileName0=\${${ListFilesName}[0]} > /dev/null 2>&1 |
---|
| 141 | eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 |
---|
| 142 | |
---|
| 143 | # Check |
---|
| 144 | IGCM_debug_Print 1 "Nb Restart Files = ${NbFiles}" |
---|
| 145 | |
---|
[680] | 146 | IGCM_debug_PopStack "IGCM_ensemble_CastInit" |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | function IGCM_ensemble_CastPeriodicStarts |
---|
| 150 | { |
---|
| 151 | IGCM_debug_PushStack "IGCM_ensemble_CastPeriodicStarts" |
---|
| 152 | |
---|
[736] | 153 | [ ${CastPeriodicStart} = false ] && return |
---|
| 154 | |
---|
[737] | 155 | echo |
---|
| 156 | IGCM_debug_Print 1 "Manage periodic starts" |
---|
| 157 | |
---|
[680] | 158 | #.. Manage periodic starts .. |
---|
| 159 | # ====================== |
---|
| 160 | |
---|
[679] | 161 | # ... Loop over DateBegin ... |
---|
| 162 | eval DateBegin=\${ensemble_Ens_PERTURB_DEBUT_INIT} |
---|
| 163 | |
---|
[680] | 164 | while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT} ] ; do |
---|
[679] | 165 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
| 166 | |
---|
| 167 | # - Determine number of day(s) in PERIODICITE |
---|
[680] | 168 | PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITE} ) |
---|
| 169 | |
---|
[679] | 170 | # - Determine number of day(s) in DUREE |
---|
[680] | 171 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_DUREE} ) - 1 )) |
---|
[679] | 172 | |
---|
| 173 | # - Determine DateEnd |
---|
| 174 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
| 175 | |
---|
| 176 | # - Build directory name |
---|
| 177 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITE} $year $month $StartDir |
---|
| 178 | |
---|
| 179 | # - Determine RestartDate |
---|
| 180 | (( Offset = -1 )) |
---|
| 181 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
| 182 | |
---|
| 183 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
| 184 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt |
---|
| 185 | |
---|
| 186 | # - Create directory for current DateBegin |
---|
| 187 | if [ ! -d ${StartDir} ] ; then |
---|
| 188 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
| 189 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
| 190 | ln -s ../../.resol . |
---|
| 191 | ln -s ../../.libmpi . |
---|
| 192 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 193 | fi |
---|
| 194 | |
---|
[870] | 195 | # - Create directory to store modified restart files |
---|
[737] | 196 | RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
[680] | 197 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
[679] | 198 | |
---|
| 199 | # - Loop over members |
---|
| 200 | i=0 |
---|
| 201 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
| 202 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
[737] | 203 | echo |
---|
[679] | 204 | IGCM_debug_Print 3 "${MemberDir}" |
---|
| 205 | |
---|
| 206 | JobName="Job_${MemberDir}" |
---|
| 207 | |
---|
| 208 | # * Create directory if it doesn't exist and copy/link files |
---|
| 209 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
| 210 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
[680] | 211 | #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} |
---|
[679] | 212 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 213 | ln -s ../../COMP |
---|
| 214 | ln -s ../../PARAM |
---|
| 215 | ln -s ../../POST |
---|
| 216 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 217 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 218 | IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName} |
---|
| 219 | |
---|
[742] | 220 | # Dump command to be lauched |
---|
| 221 | echo "cd ${StartDir}/${MemberDir}/ ;" >> Qsub.${StartDir}.txt |
---|
| 222 | echo "${SUBMIT} ${JobName} ; cd -" >> Qsub.${StartDir}.txt |
---|
[679] | 223 | fi |
---|
| 224 | |
---|
| 225 | # * Update files : config.card, Job_, COMP/comp.card |
---|
| 226 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
| 227 | |
---|
| 228 | # * Apply noise on restart file |
---|
| 229 | IGCM_ensemble_CastPerturbFile |
---|
| 230 | |
---|
| 231 | (( i = i + 1 )) |
---|
| 232 | done |
---|
| 233 | |
---|
[742] | 234 | # Done. Save ${StartDir} submission text file |
---|
| 235 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR} |
---|
| 236 | |
---|
[679] | 237 | # - Next DateBegin |
---|
| 238 | echo "$DateBegin $PeriodLengthInDays" |
---|
| 239 | case ${ensemble_Ens_PERTURB_PERIODICITE} in |
---|
[680] | 240 | *[Yy]|*[Mm]) |
---|
[679] | 241 | (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) )) |
---|
| 242 | ;; |
---|
| 243 | esac |
---|
| 244 | echo "New DateBegin = $DateBegin" |
---|
| 245 | echo "========================================================================" |
---|
| 246 | done |
---|
| 247 | IGCM_debug_PopStack "IGCM_ensemble_CastPeriodicStarts" |
---|
| 248 | } |
---|
| 249 | |
---|
| 250 | function IGCM_ensemble_CastNonPeriodicStarts |
---|
| 251 | { |
---|
| 252 | IGCM_debug_PushStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
| 253 | |
---|
| 254 | #.. Manage non periodic starts => Loop over DateBegin .. |
---|
| 255 | # ========================== |
---|
| 256 | |
---|
[736] | 257 | [ ${CastNonPeriodicStart} = false ] && return |
---|
| 258 | |
---|
[737] | 259 | echo |
---|
| 260 | IGCM_debug_Print 1 "Manage non periodic starts" |
---|
| 261 | |
---|
[679] | 262 | DateNum=0 |
---|
| 263 | # ... Loop over ensemble_Ens_PERTURB_NONPERIODIC ... |
---|
| 264 | echo ">${DateNum}<" |
---|
| 265 | echo ">${#ensemble_Ens_PERTURB_NONPERIODIC[*]}<" |
---|
| 266 | while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
| 267 | DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[$DateNum]} |
---|
| 268 | Duree=${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} |
---|
| 269 | echo ">${DateBegin}<" |
---|
| 270 | echo ">${Duree}<" |
---|
[680] | 271 | |
---|
[679] | 272 | # - Determine number of day(s) in DUREE_NONPERIODIC |
---|
| 273 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
[680] | 274 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 )) |
---|
[679] | 275 | |
---|
| 276 | # - Build directory name |
---|
| 277 | echo "========================================================================" |
---|
| 278 | echo "ensemble_Ens_PERTURB_NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
| 279 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${Duree} $year $month $StartDir |
---|
| 280 | |
---|
| 281 | # - Determine DateEnd |
---|
| 282 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
| 283 | echo ">${DateEnd}<" |
---|
| 284 | echo "tout va bien 1" |
---|
| 285 | |
---|
| 286 | # - Determine RestartDate |
---|
| 287 | (( Offset = -1 )) |
---|
| 288 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
| 289 | |
---|
| 290 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
| 291 | |
---|
| 292 | # - Does $StartDir already exist ? |
---|
| 293 | #echo "tout va bien 2" ${StartDir} |
---|
| 294 | if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then |
---|
| 295 | echo "create dir" |
---|
| 296 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
| 297 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
| 298 | ln -s ../../.resol . |
---|
| 299 | ln -s ../../.libmpi . |
---|
| 300 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 301 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt |
---|
| 302 | fi |
---|
| 303 | PeriodDateEnd=$( grep -m1 ${StartDir} CreatedDir.txt | cut -f2 -d\ ) |
---|
| 304 | |
---|
| 305 | # - Create directory in which to store new restart files if it does'nt already exist |
---|
[737] | 306 | RestartDir=${STORAGE}/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
[680] | 307 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
[679] | 308 | |
---|
| 309 | # - Loop over members |
---|
| 310 | i=0 |
---|
| 311 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
| 312 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
| 313 | IGCM_debug_Print 3 "${MemberDir}" |
---|
| 314 | |
---|
| 315 | JobName="Job_${MemberDir}" |
---|
| 316 | |
---|
| 317 | # * Create directory if it doesn't exist and copy files |
---|
| 318 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
| 319 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 320 | #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} |
---|
| 321 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 322 | ln -s ../../COMP |
---|
| 323 | ln -s ../../PARAM |
---|
| 324 | ln -s ../../POST |
---|
| 325 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 326 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 327 | IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
| 328 | |
---|
[742] | 329 | # Dump command to be lauched |
---|
| 330 | echo "cd ${StartDir}/${MemberDir}/ ;" >> Qsub.${StartDir}.txt |
---|
| 331 | echo "${SUBMIT} ${JobName} ; cd -" >> Qsub.${StartDir}.txt |
---|
[679] | 332 | fi |
---|
| 333 | |
---|
| 334 | # * Update files : config.card, Job_, COMP/comp.card |
---|
| 335 | echo "${PeriodDateEnd} ? ${DateEnd}" |
---|
| 336 | if [ ${PeriodDateEnd} -gt ${DateEnd} ] ; then |
---|
| 337 | DateEnd=${PeriodDateEnd} |
---|
| 338 | fi |
---|
| 339 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
| 340 | |
---|
| 341 | # * Apply noise on restart file |
---|
| 342 | IGCM_ensemble_CastPerturbFile |
---|
| 343 | (( i = i + 1 )) |
---|
| 344 | done |
---|
| 345 | |
---|
[742] | 346 | # Done. Save ${StartDir} submission text file |
---|
| 347 | IGCM_sys_Cp ${RUN_DIR}/Qsub.${StartDir}.txt ${SUBMIT_DIR} |
---|
| 348 | |
---|
[679] | 349 | (( DateNum = DateNum + 1 )) |
---|
| 350 | done |
---|
| 351 | IGCM_debug_PopStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | function IGCM_ensemble_CastFilesUpdate |
---|
| 355 | { |
---|
| 356 | IGCM_debug_PushStack "IGCM_ensemble_CastFilesUpdate" |
---|
| 357 | |
---|
[677] | 358 | # Debug Print : |
---|
| 359 | echo |
---|
[679] | 360 | IGCM_debug_Print 1 "IGCM_ensemble_CastFilesUpdate :" |
---|
[677] | 361 | |
---|
| 362 | HumanDateBegin=$( IGCM_date_ConvertFormatToHuman ${1} ) |
---|
| 363 | HumanDateEnd=$( IGCM_date_ConvertFormatToHuman ${2} ) |
---|
| 364 | HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} ) |
---|
| 365 | # ==> config.card |
---|
| 366 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y' |
---|
| 367 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_PERTURB_NAME} |
---|
| 368 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${StartDir} |
---|
| 369 | |
---|
| 370 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName ${MemberDir} |
---|
| 371 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin} |
---|
| 372 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd ${HumanDateEnd} |
---|
| 373 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n" |
---|
| 374 | |
---|
[742] | 375 | for comp in ${config_ListOfComponents[*]} ; do |
---|
| 376 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} Restart "y" |
---|
| 377 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartDate ${HumanRestartDate} |
---|
| 378 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartJobName ${ensemble_Ens_PERTURB_INITFROM} |
---|
| 379 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${comp} RestartPath ${ensemble_Ens_PERTURB_INITPATH} |
---|
[677] | 380 | done |
---|
[742] | 381 | |
---|
[677] | 382 | # ==> Job |
---|
[742] | 383 | sed -e "s/\(#.*\)${ensemble_Ens_PERTURB_NAME}\( *#.*\)/\1${MemberDir} \2/" \ |
---|
| 384 | -e "s/\(#.*Script_Output_\)${ensemble_Ens_PERTURB_NAME}\(\.*\)/\1${MemberDir}\2/" \ |
---|
[824] | 385 | -e "s/^PeriodNb=.*/PeriodNb=60/" \ |
---|
[742] | 386 | ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp |
---|
| 387 | IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
[738] | 388 | |
---|
[679] | 389 | IGCM_debug_PopStack "IGCM_ensemble_CastFilesUpdate" |
---|
[677] | 390 | } |
---|
| 391 | |
---|
[679] | 392 | function IGCM_ensemble_CastDirectoryName |
---|
[677] | 393 | { |
---|
[679] | 394 | IGCM_debug_PushStack "IGCM_ensemble_CastDirectoryName" |
---|
[677] | 395 | |
---|
| 396 | #.. Debug Print .. |
---|
| 397 | echo |
---|
[679] | 398 | IGCM_debug_Print 1 "IGCM_ensemble_CastDirectoryName :" |
---|
[677] | 399 | echo |
---|
| 400 | |
---|
| 401 | Name=$1 |
---|
| 402 | Duree=$2 |
---|
| 403 | year=$3 |
---|
| 404 | month=$4 |
---|
| 405 | |
---|
| 406 | # - Build directory name |
---|
| 407 | case ${Duree} in |
---|
| 408 | *Y|*y) |
---|
[679] | 409 | siecle="$( echo $year | cut -c1-2 )" |
---|
[677] | 410 | siecle=$( (( $siecle - 18 )) ) |
---|
| 411 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
| 412 | StartDir="${Name}${StartYear}" |
---|
| 413 | ;; |
---|
| 414 | *M|*m) |
---|
| 415 | echo $month |
---|
[679] | 416 | siecle="$( echo $year | cut -c1-2 )" |
---|
[677] | 417 | siecle=$( (( $siecle - 18 )) ) |
---|
| 418 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
[829] | 419 | StartMonth="${AlphaMonth[ (( 10#${month} - 1 )) ]}" |
---|
[677] | 420 | StartDir="${Name}${StartYear}${StartMonth}" |
---|
| 421 | ;; |
---|
| 422 | esac |
---|
| 423 | |
---|
[679] | 424 | IGCM_debug_PopStack "IGCM_ensemble_CastDirectoryName" |
---|
[677] | 425 | } |
---|
| 426 | |
---|
[679] | 427 | function IGCM_ensemble_CastPerturbFile |
---|
[677] | 428 | { |
---|
[679] | 429 | IGCM_debug_PushStack "IGCM_ensemble_CastPerturbFile" |
---|
[677] | 430 | |
---|
[864] | 431 | typeset i i_ j j4 file_out file_out_ |
---|
| 432 | |
---|
[677] | 433 | #.. Debug Print .. |
---|
| 434 | echo |
---|
[679] | 435 | IGCM_debug_Print 1 "IGCM_ensemble_CastPerturbFile :" |
---|
[677] | 436 | |
---|
| 437 | #.. FileIn ? => RestartDate .. |
---|
| 438 | DirIn="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/${PerturbComp}/Restart" |
---|
[738] | 439 | DirInTar="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART" |
---|
| 440 | FileIn="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}" |
---|
[677] | 441 | DirOut="${RestartDir}/${MemberDir}/${PerturbComp}/Restart" |
---|
| 442 | |
---|
| 443 | # * Create member restart directory |
---|
| 444 | IGCM_sys_TestDirArchive ${DirOut} |
---|
| 445 | RET=$? |
---|
| 446 | if [ $RET -gt 0 ] ; then |
---|
| 447 | IGCM_sys_MkdirArchive ${DirOut} |
---|
| 448 | fi |
---|
| 449 | |
---|
[738] | 450 | FileOut="${MemberDir}_${RestartDate}_${PerturbFile}" |
---|
[864] | 451 | IGCM_debug_Print 1 "FileIn = ${DirIn}/${FileIn}" |
---|
[738] | 452 | IGCM_debug_Print 1 "FileOut = ${DirOut}/${FileOut}.nc" |
---|
| 453 | |
---|
| 454 | IGCM_sys_TestFileArchive ${DirOut}/${FileOut}.nc |
---|
[677] | 455 | RET=$? |
---|
| 456 | if [ $RET -gt 0 ] ; then |
---|
[737] | 457 | |
---|
[738] | 458 | # * Look for the restart file we apply the noise to |
---|
[737] | 459 | |
---|
[864] | 460 | # restart file list pertaining to the component we apply the noise to |
---|
| 461 | # but not being the precise restart file we will apply the noise to |
---|
| 462 | unset OtherFileInList |
---|
| 463 | # generic restart filename list (like flxat, sstoc, restart, ...) |
---|
| 464 | unset OtherGenericList |
---|
| 465 | |
---|
| 466 | if ( [ X${FileName0} != X${NULL_STR} ] && [ X${FileName0} != XNONE ] ) ; then |
---|
| 467 | (( i=0 )) |
---|
| 468 | until [ $i -ge ${NbFiles} ]; do |
---|
| 469 | |
---|
| 470 | (( i_ = i+1 )) |
---|
| 471 | eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 |
---|
| 472 | eval file_out=${file_out_} |
---|
| 473 | |
---|
| 474 | generic_restart_file_name_out=$( basename ${file_out} .nc ) |
---|
| 475 | |
---|
| 476 | if [ ! ${generic_restart_file_name_out} = ${PerturbFile} ] ; then |
---|
| 477 | set +A OtherFileInList ${OtherFileInList[*]} ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic_restart_file_name_out}\*.nc |
---|
| 478 | set +A OtherGenericList ${OtherGenericList[*]} ${generic_restart_file_name_out} |
---|
| 479 | fi |
---|
| 480 | |
---|
| 481 | (( i=i+3 )) |
---|
| 482 | done |
---|
| 483 | fi |
---|
| 484 | # How many restart files other than the one we will apply the noise to |
---|
| 485 | NbOtherFiles=${#OtherGenericList[*]} |
---|
| 486 | |
---|
[738] | 487 | ########################## |
---|
| 488 | # TO BE A FUNCTION BEGIN # |
---|
| 489 | ########################## |
---|
[677] | 490 | |
---|
[738] | 491 | if [ $( IGCM_sys_TestFileBuffer ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then |
---|
| 492 | IGCM_debug_Print 3 "Buffered restart" |
---|
| 493 | Buffered=true |
---|
| 494 | Archived=false |
---|
| 495 | Tared=false |
---|
| 496 | nb_restart_file=$(IGCM_sys_CountFileBuffer ${DirIn}/${FileIn}_????.nc) |
---|
| 497 | elif [ $( IGCM_sys_TestFileArchive ${DirIn}/${FileIn}*.nc ; echo $? ) = 0 ] ; then |
---|
| 498 | IGCM_debug_Print 3 "Archived restart" |
---|
| 499 | Buffered=false |
---|
| 500 | Archived=true |
---|
| 501 | Tared=false |
---|
| 502 | nb_restart_file=$(IGCM_sys_CountFileArchive ${DirIn}/${FileIn}_????.nc) |
---|
| 503 | else |
---|
| 504 | IGCM_debug_Print 3 "Tared restart" |
---|
| 505 | Buffered=false |
---|
| 506 | Archived=false |
---|
| 507 | Tared=true |
---|
[864] | 508 | |
---|
[738] | 509 | # Look for the tar file we want if we did not found it already |
---|
[864] | 510 | for PotentialTarFile in $( find ${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/RESTART -name "${ensemble_Ens_PERTURB_INITFROM}_*_restart.tar" -print ) ; do |
---|
| 511 | IsMatching=$( echo ${PotentialTarFile##*/} | sed "s:^${ensemble_Ens_PERTURB_INITFROM}_::" | sed "s:\.restart\.tar$::" | gawk -F_ -v restartdate=${RestartDate} '{if (($1 < restartdate) && ($2 >= restartdate)) {print $1"_"$2}}' ) |
---|
| 512 | if [ ! X${IsMatching} = X ] ; then |
---|
| 513 | TarFileFound=${PotentialTarFile} |
---|
| 514 | break |
---|
| 515 | fi |
---|
| 516 | done |
---|
| 517 | |
---|
| 518 | # Extract relevant restart files |
---|
| 519 | IGCM_debug_Print 1 "tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${OtherFileInList[*]}" |
---|
| 520 | tar xvf ${TarFileFound} ${PerturbComp}_${FileIn}*.nc ${OtherFileInList[*]} |
---|
[738] | 521 | nb_restart_file=$( IGCM_sys_CountFileBuffer ${PerturbComp}_${FileIn}_????.nc ) |
---|
| 522 | fi |
---|
| 523 | |
---|
[864] | 524 | # Move around and perturb restart files so as to be able to start hindcast/forecast simulation members |
---|
[738] | 525 | if [ ${nb_restart_file} -gt 1 ] ; then |
---|
| 526 | j=0 |
---|
[864] | 527 | until [ $j -ge ${nb_restart_file} ]; do |
---|
[738] | 528 | j4=${j} |
---|
| 529 | if [ X${Buffered} = Xtrue ] ; then |
---|
| 530 | IGCM_sys_GetBuffer ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
[864] | 531 | |
---|
| 532 | cd ${DirOut} |
---|
| 533 | for generic in ${OtherGenericList[*]} ; do |
---|
| 534 | ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}_${j4}.nc |
---|
| 535 | done |
---|
| 536 | cd - |
---|
| 537 | |
---|
[738] | 538 | elif [ X${Archived} = Xtrue ] ; then |
---|
| 539 | IGCM_sys_Get ${DirIn}/${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
[864] | 540 | |
---|
| 541 | for generic in ${OtherGenericList[*]} ; do |
---|
| 542 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}_${j4}.nc" |
---|
| 543 | done |
---|
| 544 | |
---|
[738] | 545 | elif [ X${Tared} = Xtrue ] ; then |
---|
| 546 | IGCM_sys_Mv ${PerturbComp}_${FileIn}_${j4}.nc ${RUN_DIR}/${FileOut}_${j4}.nc |
---|
[864] | 547 | |
---|
| 548 | for generic in ${OtherGenericList[*]} ; do |
---|
| 549 | IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${DirOut}/${MemberDir}_${RestartDate}_${generic}_${j4}.nc |
---|
| 550 | done |
---|
| 551 | |
---|
[738] | 552 | fi |
---|
| 553 | (( j=j+1 )) |
---|
| 554 | done |
---|
| 555 | else |
---|
| 556 | if [ X${Buffered} = Xtrue ] ; then |
---|
| 557 | IGCM_sys_GetBuffer ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
[864] | 558 | |
---|
| 559 | cd ${DirOut} |
---|
| 560 | for generic in ${OtherGenericList[*]} ; do |
---|
| 561 | ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}.nc |
---|
| 562 | done |
---|
| 563 | cd - |
---|
| 564 | |
---|
[738] | 565 | elif [ X${Archived} = Xtrue ] ; then |
---|
| 566 | IGCM_sys_Get ${DirIn}/${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
[864] | 567 | |
---|
| 568 | for generic in ${OtherGenericList[*]} ; do |
---|
| 569 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${MemberDir}_${RestartDate}_${generic}.nc" |
---|
| 570 | done |
---|
| 571 | |
---|
[738] | 572 | elif [ X${Tared} = Xtrue ] ; then |
---|
| 573 | IGCM_sys_Mv ${PerturbComp}_${FileIn}.nc ${RUN_DIR}/${FileOut}.nc |
---|
[864] | 574 | |
---|
| 575 | for generic in ${OtherGenericList[*]} ; do |
---|
| 576 | IGCM_sys_Mv ${PerturbComp}_${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${generic}.nc ${DirOut}/${MemberDir}_${RestartDate}_${generic}.nc |
---|
| 577 | done |
---|
| 578 | |
---|
[738] | 579 | fi |
---|
| 580 | fi |
---|
| 581 | |
---|
| 582 | ######################## |
---|
| 583 | # TO BE A FUNCTION END # |
---|
| 584 | ######################## |
---|
| 585 | |
---|
| 586 | IGCM_sys_Chmod 644 ${RUN_DIR}/${FileOut}.nc |
---|
| 587 | IGCM_debug_Print 1 "${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp}" |
---|
[737] | 588 | echo |
---|
[738] | 589 | ${PerturbExe} ${RUN_DIR}/${FileOut}.nc ${PerturbVar} ${PerturbAmp} > /dev/null 2>&1 |
---|
[737] | 590 | |
---|
[677] | 591 | if [ $? -ne 0 ] ; then |
---|
| 592 | echo "Abend $( basename ${PerturbExe} )" |
---|
[680] | 593 | return |
---|
[677] | 594 | fi |
---|
[738] | 595 | IGCM_sys_Put_Out ${RUN_DIR}/${FileOut}.nc ${DirOut}/ 644 |
---|
[677] | 596 | fi |
---|
| 597 | |
---|
| 598 | #.. Update config.card.. |
---|
| 599 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} Restart "y" |
---|
| 600 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartDate ${HumanRestartDate} |
---|
| 601 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartJobName ${MemberDir} |
---|
| 602 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath ${RestartDir}/ |
---|
| 603 | |
---|
[679] | 604 | IGCM_debug_PopStack "IGCM_ensemble_CastPerturbFile" |
---|
[677] | 605 | } |
---|