[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 | |
---|
| 28 | if [ -f ${SUBMIT_DIR}/CreatedDir.txt ] ; then |
---|
| 29 | IGCM_sys_Cp ${SUBMIT_DIR}/CreatedDir.txt ${RUN_DIR} |
---|
| 30 | fi |
---|
| 31 | if [ -f ${SUBMIT_DIR}/Qsub.txt ] ; then |
---|
| 32 | IGCM_sys_Cp ${SUBMIT_DIR}/Qsub.txt ${RUN_DIR} |
---|
| 33 | fi |
---|
| 34 | |
---|
[680] | 35 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB ACTIVE |
---|
[679] | 36 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME |
---|
| 37 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DEBUT_INIT |
---|
| 38 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB FIN_INIT |
---|
| 39 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB PERIODICITE |
---|
| 40 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB NONPERIODIC |
---|
| 41 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DUREE |
---|
| 42 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB DUREE_NONPERIODIC |
---|
| 43 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB MEMBER |
---|
| 44 | IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB PERTURB_BIN |
---|
| 45 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITFROM |
---|
| 46 | IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITPATH |
---|
| 47 | IGCM_card_DefineVariableFromOption config.card UserChoices TagName |
---|
| 48 | IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType |
---|
| 49 | IGCM_card_DefineArrayFromSection config.card ListOfComponents |
---|
| 50 | |
---|
[680] | 51 | IGCM_debug_Print 1 "ACTIVE = ${ensemble_Ens_PERTURB_ACTIVE}" |
---|
[679] | 52 | IGCM_debug_Print 1 "NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
| 53 | IGCM_debug_Print 1 "DEBUT_INIT = ${ensemble_Ens_PERTURB_DEBUT_INIT}" |
---|
| 54 | IGCM_debug_Print 1 "FIN_INIT = ${ensemble_Ens_PERTURB_FIN_INIT}" |
---|
| 55 | IGCM_debug_Print 1 "PERIODICITE = ${ensemble_Ens_PERTURB_PERIODICITE}" |
---|
| 56 | IGCM_debug_Print 1 "NONPERIODIC = ${ensemble_Ens_PERTURB_NONPERIODIC[*]}" |
---|
| 57 | IGCM_debug_Print 1 "DUREE = ${ensemble_Ens_PERTURB_DUREE}" |
---|
| 58 | IGCM_debug_Print 1 "DUREE_NONPERIODIC = ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[*]}" |
---|
| 59 | IGCM_debug_Print 1 "MEMBER = ${ensemble_Ens_PERTURB_MEMBER}" |
---|
| 60 | IGCM_debug_Print 1 "PERTURB_BIN = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}" |
---|
| 61 | IGCM_debug_Print 1 "INITFROM = ${ensemble_Ens_PERTURB_INITFROM}" |
---|
[680] | 62 | IGCM_debug_Print 1 "INITPATH = ${ensemble_Ens_PERTURB_INITPATH}" |
---|
[679] | 63 | IGCM_debug_Print 1 "TagName = ${config_UserChoices_TagName}" |
---|
| 64 | IGCM_debug_Print 1 "CalendarType = ${config_UserChoices_CalendarType}" |
---|
| 65 | IGCM_debug_Print 1 "ListOfComponents = ${config_ListOfComponents[*]}" |
---|
| 66 | |
---|
| 67 | PerturbExe=${ensemble_Ens_PERTURB_PERTURB_BIN[0]} |
---|
| 68 | PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]} |
---|
| 69 | PerturbFile=${ensemble_Ens_PERTURB_PERTURB_BIN[2]} |
---|
| 70 | PerturbVar=${ensemble_Ens_PERTURB_PERTURB_BIN[3]} |
---|
| 71 | PerturbAmp=${ensemble_Ens_PERTURB_PERTURB_BIN[4]} |
---|
| 72 | |
---|
| 73 | IGCM_debug_Print 1 "PerturbExe = ${PerturbExe}" |
---|
| 74 | IGCM_debug_Print 1 "PerturbFile = ${PerturbFile}" |
---|
| 75 | IGCM_debug_Print 1 "PerturbComp = ${PerturbComp}" |
---|
| 76 | IGCM_debug_Print 1 "PerturbVar = ${PerturbVar}" |
---|
| 77 | IGCM_debug_Print 1 "PerturbAmp = ${PerturbAmp}" |
---|
| 78 | |
---|
[680] | 79 | # A few checks Period case: |
---|
[679] | 80 | |
---|
[680] | 81 | # ... Check PERIODICITE ... |
---|
[679] | 82 | case ${ensemble_Ens_PERTURB_PERIODICITE} in |
---|
| 83 | 0) |
---|
| 84 | IGCM_debug_Print 1 "No periodic start" |
---|
[680] | 85 | return |
---|
[679] | 86 | ;; |
---|
[680] | 87 | *[Yy]|*[Mm]) |
---|
| 88 | IGCM_debug_Print 1 "Periodic length : ${ensemble_Ens_PERTURB_PERIODICITE}" ;; |
---|
[679] | 89 | *) |
---|
[680] | 90 | IGCM_debug_Exit "IGCM_ensemble_CastInit ${ensemble_Ens_PERTURB_PERIODICITE} : invalid PERIODICITE" |
---|
| 91 | IGCM_debug_Exit "Choose a value in *Y or *M" |
---|
[679] | 92 | IGCM_debug_Verif_Exit ;; |
---|
| 93 | esac |
---|
[680] | 94 | # ... Check DUREE ... |
---|
[679] | 95 | case ${ensemble_Ens_PERTURB_DUREE} in |
---|
[680] | 96 | *[Yy]|*[Mm]) |
---|
| 97 | IGCM_debug_Print 1 "Periodic duration : ${ensemble_Ens_PERTURB_DUREE}" ;; |
---|
[679] | 98 | *) |
---|
[680] | 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" |
---|
[679] | 101 | IGCM_debug_Verif_Exit ;; |
---|
| 102 | esac |
---|
| 103 | |
---|
[680] | 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 | |
---|
| 128 | function IGCM_ensemble_CastPeriodicStarts |
---|
| 129 | { |
---|
| 130 | IGCM_debug_PushStack "IGCM_ensemble_CastPeriodicStarts" |
---|
| 131 | |
---|
| 132 | echo "Manage periodic starts" |
---|
| 133 | |
---|
| 134 | #.. Manage periodic starts .. |
---|
| 135 | # ====================== |
---|
| 136 | |
---|
[679] | 137 | # ... Loop over DateBegin ... |
---|
| 138 | eval DateBegin=\${ensemble_Ens_PERTURB_DEBUT_INIT} |
---|
| 139 | |
---|
[680] | 140 | while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT} ] ; do |
---|
[679] | 141 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
| 142 | |
---|
| 143 | # - Determine number of day(s) in PERIODICITE |
---|
[680] | 144 | PeriodLengthInDays=$( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_PERIODICITE} ) |
---|
| 145 | |
---|
[679] | 146 | # - Determine number of day(s) in DUREE |
---|
[680] | 147 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${ensemble_Ens_PERTURB_DUREE} ) - 1 )) |
---|
[679] | 148 | |
---|
| 149 | # - Determine DateEnd |
---|
| 150 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
| 151 | |
---|
| 152 | # - Build directory name |
---|
| 153 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITE} $year $month $StartDir |
---|
| 154 | |
---|
| 155 | # - Determine RestartDate |
---|
| 156 | (( Offset = -1 )) |
---|
| 157 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
| 158 | |
---|
| 159 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
| 160 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt |
---|
| 161 | |
---|
| 162 | # - Create directory for current DateBegin |
---|
| 163 | if [ ! -d ${StartDir} ] ; then |
---|
| 164 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
| 165 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
| 166 | ln -s ../../.resol . |
---|
| 167 | ln -s ../../.libmpi . |
---|
| 168 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 169 | fi |
---|
| 170 | |
---|
| 171 | # - Create directory in which to store new restart files |
---|
| 172 | RestartDir=$ARCHIVE/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
[680] | 173 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
[679] | 174 | |
---|
| 175 | # - Loop over members |
---|
| 176 | i=0 |
---|
| 177 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
| 178 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
| 179 | IGCM_debug_Print 3 "${MemberDir}" |
---|
| 180 | |
---|
| 181 | JobName="Job_${MemberDir}" |
---|
| 182 | |
---|
| 183 | pwd |
---|
| 184 | ls |
---|
| 185 | |
---|
| 186 | # * Create directory if it doesn't exist and copy/link files |
---|
| 187 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
| 188 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
[680] | 189 | #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} |
---|
[679] | 190 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 191 | ln -s ../../COMP |
---|
| 192 | ln -s ../../PARAM |
---|
| 193 | ln -s ../../POST |
---|
| 194 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 195 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 196 | IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName} |
---|
| 197 | |
---|
| 198 | echo "cd ${StartDir}/${MemberDir}/ ; ccc_msub ${JobName} ;" >> Qsub.txt |
---|
| 199 | |
---|
| 200 | echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt |
---|
| 201 | echo "mv ${JobName}.tmp ${JobName} ; cd - ;" >> Qsub.txt |
---|
| 202 | fi |
---|
| 203 | |
---|
| 204 | # * Update files : config.card, Job_, COMP/comp.card |
---|
| 205 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
| 206 | |
---|
| 207 | # * Apply noise on restart file |
---|
| 208 | IGCM_ensemble_CastPerturbFile |
---|
| 209 | |
---|
| 210 | (( i = i + 1 )) |
---|
| 211 | done |
---|
| 212 | |
---|
| 213 | # - Next DateBegin |
---|
| 214 | echo "$DateBegin $PeriodLengthInDays" |
---|
| 215 | case ${ensemble_Ens_PERTURB_PERIODICITE} in |
---|
[680] | 216 | *[Yy]|*[Mm]) |
---|
[679] | 217 | (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) )) |
---|
| 218 | ;; |
---|
| 219 | esac |
---|
| 220 | echo "New DateBegin = $DateBegin" |
---|
| 221 | echo "========================================================================" |
---|
| 222 | done |
---|
| 223 | IGCM_debug_PopStack "IGCM_ensemble_CastPeriodicStarts" |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | function IGCM_ensemble_CastNonPeriodicStarts |
---|
| 227 | { |
---|
| 228 | IGCM_debug_PushStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
| 229 | |
---|
| 230 | #.. Manage non periodic starts => Loop over DateBegin .. |
---|
| 231 | # ========================== |
---|
| 232 | |
---|
| 233 | echo "Manage non periodic starts" |
---|
| 234 | |
---|
| 235 | DateNum=0 |
---|
| 236 | # ... Loop over ensemble_Ens_PERTURB_NONPERIODIC ... |
---|
| 237 | echo ">${DateNum}<" |
---|
| 238 | echo ">${#ensemble_Ens_PERTURB_NONPERIODIC[*]}<" |
---|
| 239 | while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do |
---|
| 240 | DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[$DateNum]} |
---|
| 241 | Duree=${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} |
---|
| 242 | echo ">${DateBegin}<" |
---|
| 243 | echo ">${Duree}<" |
---|
[680] | 244 | |
---|
[679] | 245 | # - Determine number of day(s) in DUREE_NONPERIODIC |
---|
| 246 | IGCM_date_GetYearMonth ${DateBegin} year month |
---|
[680] | 247 | DureeLengthInDays=$(( $( IGCM_date_DaysInCurrentPeriod ${DateBegin} ${Duree} ) - 1 )) |
---|
[679] | 248 | |
---|
| 249 | # - Build directory name |
---|
| 250 | echo "========================================================================" |
---|
| 251 | echo "ensemble_Ens_PERTURB_NAME = ${ensemble_Ens_PERTURB_NAME}" |
---|
| 252 | IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${Duree} $year $month $StartDir |
---|
| 253 | |
---|
| 254 | # - Determine DateEnd |
---|
| 255 | (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) |
---|
| 256 | echo ">${DateEnd}<" |
---|
| 257 | echo "tout va bien 1" |
---|
| 258 | |
---|
| 259 | # - Determine RestartDate |
---|
| 260 | (( Offset = -1 )) |
---|
| 261 | (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) |
---|
| 262 | |
---|
| 263 | IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" |
---|
| 264 | |
---|
| 265 | # - Does $StartDir already exist ? |
---|
| 266 | #echo "tout va bien 2" ${StartDir} |
---|
| 267 | if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then |
---|
| 268 | echo "create dir" |
---|
| 269 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} |
---|
| 270 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} |
---|
| 271 | ln -s ../../.resol . |
---|
| 272 | ln -s ../../.libmpi . |
---|
| 273 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 274 | echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt |
---|
| 275 | fi |
---|
| 276 | PeriodDateEnd=$( grep -m1 ${StartDir} CreatedDir.txt | cut -f2 -d\ ) |
---|
| 277 | |
---|
| 278 | # - Create directory in which to store new restart files if it does'nt already exist |
---|
| 279 | RestartDir=$DMFDIR/IGCM_IN/${config_UserChoices_TagName}/${StartDir} |
---|
[680] | 280 | IGCM_sys_MkdirArchive ${RestartDir} |
---|
[679] | 281 | |
---|
| 282 | # - Loop over members |
---|
| 283 | i=0 |
---|
| 284 | while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do |
---|
| 285 | MemberDir="${StartDir}${Alpha[$i]}" |
---|
| 286 | IGCM_debug_Print 3 "${MemberDir}" |
---|
| 287 | |
---|
| 288 | JobName="Job_${MemberDir}" |
---|
| 289 | |
---|
| 290 | # * Create directory if it doesn't exist and copy files |
---|
| 291 | if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then |
---|
| 292 | IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 293 | #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} |
---|
| 294 | IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 295 | ln -s ../../COMP |
---|
| 296 | ln -s ../../PARAM |
---|
| 297 | ln -s ../../POST |
---|
| 298 | IGCM_sys_Cd ${RUN_DIR} |
---|
| 299 | IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} |
---|
| 300 | IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
| 301 | |
---|
| 302 | echo "cd ${StartDir}/${MemberDir}/ ; ccc_msub ${JobName} ;" >> Qsub.txt |
---|
| 303 | |
---|
| 304 | echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt |
---|
| 305 | echo "mv ${JobName}.tmp ${JobName} ; cd - ;" >> Qsub.txt |
---|
| 306 | fi |
---|
| 307 | |
---|
| 308 | # * Update files : config.card, Job_, COMP/comp.card |
---|
| 309 | echo "${PeriodDateEnd} ? ${DateEnd}" |
---|
| 310 | if [ ${PeriodDateEnd} -gt ${DateEnd} ] ; then |
---|
| 311 | DateEnd=${PeriodDateEnd} |
---|
| 312 | fi |
---|
| 313 | IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} |
---|
| 314 | |
---|
| 315 | # * Apply noise on restart file |
---|
| 316 | IGCM_ensemble_CastPerturbFile |
---|
| 317 | (( i = i + 1 )) |
---|
| 318 | done |
---|
| 319 | |
---|
| 320 | (( DateNum = DateNum + 1 )) |
---|
| 321 | done |
---|
| 322 | IGCM_debug_PopStack "IGCM_ensemble_CastNonPeriodicStarts" |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | function IGCM_ensemble_CastFilesUpdate |
---|
| 326 | { |
---|
| 327 | IGCM_debug_PushStack "IGCM_ensemble_CastFilesUpdate" |
---|
| 328 | |
---|
[677] | 329 | # set -vx |
---|
| 330 | |
---|
| 331 | # Debug Print : |
---|
| 332 | echo |
---|
[679] | 333 | IGCM_debug_Print 1 "IGCM_ensemble_CastFilesUpdate :" |
---|
[677] | 334 | echo |
---|
| 335 | |
---|
| 336 | HumanDateBegin=$( IGCM_date_ConvertFormatToHuman ${1} ) |
---|
| 337 | HumanDateEnd=$( IGCM_date_ConvertFormatToHuman ${2} ) |
---|
| 338 | HumanRestartDate=$( IGCM_date_ConvertFormatToHuman ${3} ) |
---|
| 339 | # ==> config.card |
---|
| 340 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleRun 'y' |
---|
| 341 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleName ${ensemble_Ens_PERTURB_NAME} |
---|
| 342 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Ensemble EnsembleDate ${StartDir} |
---|
| 343 | |
---|
| 344 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices JobName ${MemberDir} |
---|
| 345 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateBegin ${HumanDateBegin} |
---|
| 346 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card UserChoices DateEnd ${HumanDateEnd} |
---|
| 347 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card Restarts OverRule "n" |
---|
| 348 | |
---|
| 349 | for Comp in ${config_ListOfComponents[*]} ; do |
---|
| 350 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} Restart "y" |
---|
| 351 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartDate ${HumanRestartDate} |
---|
| 352 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartJobName ${ensemble_Ens_PERTURB_INITFROM} |
---|
| 353 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${Comp} RestartPath ${ensemble_Ens_PERTURB_INITPATH} |
---|
| 354 | done |
---|
| 355 | # ==> Job |
---|
| 356 | # SD : to be encapsulated in a sys function |
---|
| 357 | sed -e "s/\(#MSUB -r \)[A-Za-z0-9]*\( *#.*\)/\1 ${MemberDir} \2/" \ |
---|
| 358 | -e "s/\(#MSUB -o Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \ |
---|
| 359 | -e "s/\(#MSUB -e Script_Output_\)[A-Za-z0-9]*\(\.*\)/\1${MemberDir}\2/" \ |
---|
| 360 | ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} > Job_${MemberDir}.tmp |
---|
| 361 | IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} |
---|
| 362 | |
---|
[679] | 363 | IGCM_debug_PopStack "IGCM_ensemble_CastFilesUpdate" |
---|
[677] | 364 | } |
---|
| 365 | |
---|
[679] | 366 | function IGCM_ensemble_CastDirectoryName |
---|
[677] | 367 | { |
---|
[679] | 368 | IGCM_debug_PushStack "IGCM_ensemble_CastDirectoryName" |
---|
[677] | 369 | |
---|
| 370 | #.. Debug Print .. |
---|
| 371 | echo |
---|
[679] | 372 | IGCM_debug_Print 1 "IGCM_ensemble_CastDirectoryName :" |
---|
[677] | 373 | echo |
---|
| 374 | |
---|
| 375 | # set -vx |
---|
| 376 | |
---|
| 377 | Name=$1 |
---|
| 378 | Duree=$2 |
---|
| 379 | year=$3 |
---|
| 380 | month=$4 |
---|
| 381 | |
---|
| 382 | # - Build directory name |
---|
| 383 | case ${Duree} in |
---|
| 384 | *Y|*y) |
---|
[679] | 385 | siecle="$( echo $year | cut -c1-2 )" |
---|
[677] | 386 | siecle=$( (( $siecle - 18 )) ) |
---|
| 387 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
| 388 | StartDir="${Name}${StartYear}" |
---|
| 389 | ;; |
---|
| 390 | *M|*m) |
---|
| 391 | echo $month |
---|
[679] | 392 | siecle="$( echo $year | cut -c1-2 )" |
---|
[677] | 393 | siecle=$( (( $siecle - 18 )) ) |
---|
| 394 | StartYear="${siecle}$( echo $year | cut -c3-4 )" |
---|
| 395 | StartMonth="${AlphaMonth[ (( $month - 1 )) ]}" |
---|
| 396 | StartDir="${Name}${StartYear}${StartMonth}" |
---|
| 397 | ;; |
---|
| 398 | esac |
---|
| 399 | |
---|
[679] | 400 | IGCM_debug_PopStack "IGCM_ensemble_CastDirectoryName" |
---|
[677] | 401 | } |
---|
| 402 | |
---|
[679] | 403 | function IGCM_ensemble_CastPerturbFile |
---|
[677] | 404 | { |
---|
[679] | 405 | IGCM_debug_PushStack "IGCM_ensemble_CastPerturbFile" |
---|
[677] | 406 | |
---|
| 407 | #.. Debug Print .. |
---|
| 408 | echo |
---|
[679] | 409 | IGCM_debug_Print 1 "IGCM_ensemble_CastPerturbFile :" |
---|
[677] | 410 | echo |
---|
| 411 | |
---|
| 412 | #.. FileIn ? => RestartDate .. |
---|
| 413 | DirIn="${ensemble_Ens_PERTURB_INITPATH}/${ensemble_Ens_PERTURB_INITFROM}/${PerturbComp}/Restart" |
---|
| 414 | FileIn="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}.nc" |
---|
| 415 | DirOut="${RestartDir}/${MemberDir}/${PerturbComp}/Restart" |
---|
| 416 | # FileOut="${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_${PerturbFile}_${MemberDir}.nc" |
---|
| 417 | # FileOut=${FileIn} |
---|
| 418 | FileOut="${MemberDir}_${RestartDate}_${PerturbFile}.nc" |
---|
| 419 | IGCM_debug_Print 1 "FileIn = ${DirIn}/${FileIn}" |
---|
| 420 | IGCM_debug_Print 1 "FileOut = ${DirOut}/${FileOut}" |
---|
| 421 | |
---|
| 422 | # * Create member restart directory |
---|
| 423 | IGCM_sys_TestDirArchive ${DirOut} |
---|
| 424 | RET=$? |
---|
| 425 | if [ $RET -gt 0 ] ; then |
---|
| 426 | IGCM_sys_MkdirArchive ${DirOut} |
---|
| 427 | fi |
---|
| 428 | |
---|
| 429 | IGCM_sys_TestFileArchive ${DirOut}/${FileOut} |
---|
| 430 | RET=$? |
---|
| 431 | if [ $RET -gt 0 ] ; then |
---|
| 432 | # ${PerturbExe} ${DirIn}/${FileIn} ${DirOut}/${FileOut} \ |
---|
| 433 | # ${PerturbVar} ${PerturbAmp} |
---|
| 434 | # IGCM_sys_Cp ${DirIn}/${FileIn} ${DirOut}/${FileOut} |
---|
| 435 | # IGCM_sys_Chmod u+w ${DirOut}/${FileOut} |
---|
| 436 | # ${PerturbExe} ${DirOut}/${FileOut} ${PerturbVar} ${PerturbAmp} |
---|
| 437 | IGCM_sys_Get ${DirIn}/${FileIn} ${RUN_DIR}/${FileOut} |
---|
| 438 | IGCM_sys_Chmod 744 ${RUN_DIR}/${FileOut} |
---|
| 439 | |
---|
| 440 | ${PerturbExe} ${RUN_DIR}/${FileOut} ${PerturbVar} ${PerturbAmp} |
---|
| 441 | if [ $? -ne 0 ] ; then |
---|
| 442 | echo "Abend $( basename ${PerturbExe} )" |
---|
[680] | 443 | return |
---|
[677] | 444 | fi |
---|
| 445 | |
---|
| 446 | IGCM_sys_Put_Out ${RUN_DIR}/${FileOut} ${DirOut}/ 744 |
---|
| 447 | |
---|
| 448 | # IGCM_sys_Cd ${DirOut} |
---|
| 449 | # ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc ${MemberDir}_${RestartDate}_flxat.nc |
---|
| 450 | # IGCM_sys_Cd - |
---|
| 451 | IGCM_sys_RshArchive "cd ${DirOut} ; ln -s ${DirIn}/${ensemble_Ens_PERTURB_INITFROM}_${RestartDate}_flxat.nc ${MemberDir}_${RestartDate}_flxat.nc" |
---|
| 452 | fi |
---|
| 453 | |
---|
| 454 | #.. Update config.card.. |
---|
| 455 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} Restart "y" |
---|
| 456 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartDate ${HumanRestartDate} |
---|
| 457 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartJobName ${MemberDir} |
---|
| 458 | IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath ${RestartDir}/ |
---|
| 459 | |
---|
[679] | 460 | IGCM_debug_PopStack "IGCM_ensemble_CastPerturbFile" |
---|
[677] | 461 | } |
---|