Changeset 679 for trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh
- Timestamp:
- 06/05/12 18:58:34 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_ensemble/libIGCM_ensemble.ksh
r678 r679 4 4 # Author: Sonia Labetoulle 5 5 # Contact: Sonia.Labetoulle__at__locean-ipsl.upmc.fr 6 # $Revision $ Revision of last commit7 # $Author $ Author of last commit8 # $Date $ Date of last commit6 # $Revision:: $ Revision of last commit 7 # $Author:: $ Author of last commit 8 # $Date:: $ Date of last commit 9 9 # IPSL (2012) 10 10 # This software is governed by the CeCILL licence see libIGCM/libIGCM_CeCILL.LIC … … 12 12 #************************************************************** 13 13 14 function IGCM_ensemble_ FilesUpdate14 function IGCM_ensemble_CastInit 15 15 { 16 IGCM_debug_PushStack "IGCM_ensemble_FilesUpdate" 16 IGCM_debug_PushStack "IGCM_ensemble_CastInit" 17 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 35 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB NAME 36 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DEBUT_INIT 37 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB FIN_INIT 38 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB PERIODICITE 39 IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB NONPERIODIC 40 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB DUREE 41 IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB DUREE_NONPERIODIC 42 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB MEMBER 43 IGCM_card_DefineArrayFromOption ${FileName} Ens_PERTURB PERTURB_BIN 44 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITFROM 45 IGCM_card_DefineVariableFromOption ${FileName} Ens_PERTURB INITPATH 46 IGCM_card_DefineVariableFromOption config.card UserChoices TagName 47 IGCM_card_DefineVariableFromOption config.card UserChoices CalendarType 48 IGCM_card_DefineArrayFromSection config.card ListOfComponents 49 50 IGCM_debug_Print 1 "NAME = ${ensemble_Ens_PERTURB_NAME}" 51 IGCM_debug_Print 1 "DEBUT_INIT = ${ensemble_Ens_PERTURB_DEBUT_INIT}" 52 IGCM_debug_Print 1 "FIN_INIT = ${ensemble_Ens_PERTURB_FIN_INIT}" 53 IGCM_debug_Print 1 "PERIODICITE = ${ensemble_Ens_PERTURB_PERIODICITE}" 54 IGCM_debug_Print 1 "NONPERIODIC = ${ensemble_Ens_PERTURB_NONPERIODIC[*]}" 55 IGCM_debug_Print 1 "DUREE = ${ensemble_Ens_PERTURB_DUREE}" 56 IGCM_debug_Print 1 "DUREE_NONPERIODIC = ${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[*]}" 57 IGCM_debug_Print 1 "MEMBER = ${ensemble_Ens_PERTURB_MEMBER}" 58 IGCM_debug_Print 1 "PERTURB_BIN = ${ensemble_Ens_PERTURB_PERTURB_BIN[*]}" 59 IGCM_debug_Print 1 "INITFROM = ${ensemble_Ens_PERTURB_INITFROM}" 60 IGCM_debug_Print 1 "INITFROM = ${ensemble_Ens_PERTURB_INITPATH}" 61 IGCM_debug_Print 1 "TagName = ${config_UserChoices_TagName}" 62 IGCM_debug_Print 1 "CalendarType = ${config_UserChoices_CalendarType}" 63 IGCM_debug_Print 1 "ListOfComponents = ${config_ListOfComponents[*]}" 64 65 PerturbExe=${ensemble_Ens_PERTURB_PERTURB_BIN[0]} 66 PerturbComp=${ensemble_Ens_PERTURB_PERTURB_BIN[1]} 67 PerturbFile=${ensemble_Ens_PERTURB_PERTURB_BIN[2]} 68 PerturbVar=${ensemble_Ens_PERTURB_PERTURB_BIN[3]} 69 PerturbAmp=${ensemble_Ens_PERTURB_PERTURB_BIN[4]} 70 71 IGCM_debug_Print 1 "PerturbExe = ${PerturbExe}" 72 IGCM_debug_Print 1 "PerturbFile = ${PerturbFile}" 73 IGCM_debug_Print 1 "PerturbComp = ${PerturbComp}" 74 IGCM_debug_Print 1 "PerturbVar = ${PerturbVar}" 75 IGCM_debug_Print 1 "PerturbAmp = ${PerturbAmp}" 76 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 ... 90 case ${ensemble_Ens_PERTURB_PERIODICITE} in 91 0) 92 IGCM_debug_Print 1 "No periodic start" 93 ;; 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]//' );; 98 *) 99 IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " \ 100 ${ensemble_Ens_PERTURB_PERIODICITE} \ 101 " invalid PERIODICITE : choose in *Y." 102 IGCM_debug_Verif_Exit ;; 103 esac 104 # ... Determine number of year(s) in DUREE ... 105 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]//' ) ;; 110 *) 111 IGCM_debug_Exit "IGCM_config_Analyse_PeriodLength " \ 112 ${ensemble_Ens_PERTURB_DUREE} \ 113 " invalid DUREE : choose in *Y." 114 IGCM_debug_Verif_Exit ;; 115 esac 116 117 # ... Loop over DateBegin ... 118 eval DateBegin=\${ensemble_Ens_PERTURB_DEBUT_INIT} 119 120 while [ ${DateBegin} -le ${ensemble_Ens_PERTURB_FIN_INIT} ] ; do 121 IGCM_date_GetYearMonth ${DateBegin} year month 122 123 # - 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 149 # - 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 )) 177 178 # - Determine DateEnd 179 (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) 180 181 # - Build directory name 182 IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${ensemble_Ens_PERTURB_PERIODICITE} $year $month $StartDir 183 184 # - Determine RestartDate 185 (( Offset = -1 )) 186 (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) 187 188 IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" 189 echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt 190 191 # - Create directory for current DateBegin 192 if [ ! -d ${StartDir} ] ; then 193 IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} 194 IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} 195 ln -s ../../.resol . 196 ln -s ../../.libmpi . 197 IGCM_sys_Cd ${RUN_DIR} 198 fi 199 200 # - Create directory in which to store new restart files 201 RestartDir=$ARCHIVE/IGCM_IN/${config_UserChoices_TagName}/${StartDir} 202 if [ ! -d ${RestartDir} ] ; then 203 IGCM_sys_MkdirArchive ${RestartDir} 204 fi 205 206 # - Loop over members 207 i=0 208 while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do 209 MemberDir="${StartDir}${Alpha[$i]}" 210 IGCM_debug_Print 3 "${MemberDir}" 211 212 JobName="Job_${MemberDir}" 213 214 pwd 215 ls 216 217 # * Create directory if it doesn't exist and copy/link files 218 if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then 219 IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} 220 # IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} 221 IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} 222 ln -s ../../COMP 223 ln -s ../../PARAM 224 ln -s ../../POST 225 IGCM_sys_Cd ${RUN_DIR} 226 IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} 227 IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/${JobName} 228 229 echo "cd ${StartDir}/${MemberDir}/ ; ccc_msub ${JobName} ;" >> Qsub.txt 230 231 echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt 232 echo "mv ${JobName}.tmp ${JobName} ; cd - ;" >> Qsub.txt 233 fi 234 235 # * Update files : config.card, Job_, COMP/comp.card 236 IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} 237 238 # * Apply noise on restart file 239 IGCM_ensemble_CastPerturbFile 240 241 (( i = i + 1 )) 242 done 243 244 # - Next DateBegin 245 echo "$DateBegin $PeriodLengthInDays" 246 case ${ensemble_Ens_PERTURB_PERIODICITE} in 247 *Y|*y|*M|*m) 248 (( DateBegin = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${PeriodLengthInDays} ) )) 249 ;; 250 esac 251 echo "New DateBegin = $DateBegin" 252 echo "========================================================================" 253 done 254 IGCM_debug_PopStack "IGCM_ensemble_CastPeriodicStarts" 255 } 256 257 258 259 260 261 262 263 264 265 266 267 268 269 function IGCM_ensemble_CastNonPeriodicStarts 270 { 271 IGCM_debug_PushStack "IGCM_ensemble_CastNonPeriodicStarts" 272 273 #.. Manage non periodic starts => Loop over DateBegin .. 274 # ========================== 275 276 echo "Manage non periodic starts" 277 278 DateNum=0 279 # ... Loop over ensemble_Ens_PERTURB_NONPERIODIC ... 280 echo ">${DateNum}<" 281 echo ">${#ensemble_Ens_PERTURB_NONPERIODIC[*]}<" 282 while [ $DateNum -lt ${#ensemble_Ens_PERTURB_NONPERIODIC[*]} ] ; do 283 DateBegin=${ensemble_Ens_PERTURB_NONPERIODIC[$DateNum]} 284 Duree=${ensemble_Ens_PERTURB_DUREE_NONPERIODIC[$DateNum]} 285 echo ">${DateBegin}<" 286 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 303 # - Determine number of day(s) in DUREE_NONPERIODIC 304 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 )) 323 324 # - Build directory name 325 echo "========================================================================" 326 echo "ensemble_Ens_PERTURB_NAME = ${ensemble_Ens_PERTURB_NAME}" 327 IGCM_ensemble_CastDirectoryName ${ensemble_Ens_PERTURB_NAME} ${Duree} $year $month $StartDir 328 329 # - Determine DateEnd 330 (( DateEnd = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${DureeLengthInDays} ) )) 331 echo ">${DateEnd}<" 332 333 echo "tout va bien 1" 334 335 # - Determine RestartDate 336 (( Offset = -1 )) 337 (( RestartDate = $( IGCM_date_AddDaysToGregorianDate ${DateBegin} ${Offset} ) )) 338 339 IGCM_debug_Print 2 "${DateBegin} => ${DateEnd} : ${StartDir}" 340 341 # - Does $StartDir already exist ? 342 #echo "tout va bien 2" ${StartDir} 343 if [ ! -d ${SUBMIT_DIR}/${StartDir} ] ; then 344 echo "create dir" 345 IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir} 346 IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir} 347 ln -s ../../.resol . 348 ln -s ../../.libmpi . 349 IGCM_sys_Cd ${RUN_DIR} 350 echo "${DateBegin} ${DateEnd} ${StartDir}" >> CreatedDir.txt 351 fi 352 PeriodDateEnd=$( grep -m1 ${StartDir} CreatedDir.txt | cut -f2 -d\ ) 353 354 # - Create directory in which to store new restart files if it does'nt already exist 355 RestartDir=$DMFDIR/IGCM_IN/${config_UserChoices_TagName}/${StartDir} 356 if [ ! -d ${RestartDir} ] ; then 357 IGCM_sys_MkdirArchive ${RestartDir} 358 fi 359 360 # - Loop over members 361 i=0 362 while [ $i -lt ${ensemble_Ens_PERTURB_MEMBER} ] ; do 363 MemberDir="${StartDir}${Alpha[$i]}" 364 IGCM_debug_Print 3 "${MemberDir}" 365 366 JobName="Job_${MemberDir}" 367 368 # * Create directory if it doesn't exist and copy files 369 if [ ! -d ${SUBMIT_DIR}/${StartDir}/${MemberDir} ] ; then 370 IGCM_sys_Mkdir ${SUBMIT_DIR}/${StartDir}/${MemberDir} 371 #IGCM_sys_Cp -r COMP/ PARAM/ ${StartDir}/${MemberDir} 372 IGCM_sys_Cd ${SUBMIT_DIR}/${StartDir}/${MemberDir} 373 ln -s ../../COMP 374 ln -s ../../PARAM 375 ln -s ../../POST 376 IGCM_sys_Cd ${RUN_DIR} 377 IGCM_sys_Cp config.card run.card.init ${SUBMIT_DIR}/${StartDir}/${MemberDir} 378 IGCM_sys_Cp Job_${ensemble_Ens_PERTURB_NAME} ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} 379 380 echo "cd ${StartDir}/${MemberDir}/ ; ccc_msub ${JobName} ;" >> Qsub.txt 381 382 echo "sed -e 's/PeriodNb=.*/PeriodNb=48/' ${JobName} > ${JobName}.tmp ; " >> Qsub.txt 383 echo "mv ${JobName}.tmp ${JobName} ; cd - ;" >> Qsub.txt 384 fi 385 386 # * Update files : config.card, Job_, COMP/comp.card 387 echo "${PeriodDateEnd} ? ${DateEnd}" 388 if [ ${PeriodDateEnd} -gt ${DateEnd} ] ; then 389 DateEnd=${PeriodDateEnd} 390 fi 391 IGCM_ensemble_CastFilesUpdate ${DateBegin} ${DateEnd} ${RestartDate} 392 393 # * Apply noise on restart file 394 IGCM_ensemble_CastPerturbFile 395 (( i = i + 1 )) 396 done 397 398 (( DateNum = DateNum + 1 )) 399 done 400 IGCM_debug_PopStack "IGCM_ensemble_CastNonPeriodicStarts" 401 } 402 403 function IGCM_ensemble_CastFilesUpdate 404 { 405 IGCM_debug_PushStack "IGCM_ensemble_CastFilesUpdate" 17 406 18 407 # set -vx … … 20 409 # Debug Print : 21 410 echo 22 IGCM_debug_Print 1 "IGCM_ensemble_ FilesUpdate :"411 IGCM_debug_Print 1 "IGCM_ensemble_CastFilesUpdate :" 23 412 echo 24 413 … … 50 439 IGCM_sys_Mv Job_${MemberDir}.tmp ${SUBMIT_DIR}/${StartDir}/${MemberDir}/Job_${MemberDir} 51 440 52 IGCM_debug_PopStack "IGCM_ensemble_ FilesUpdate"441 IGCM_debug_PopStack "IGCM_ensemble_CastFilesUpdate" 53 442 } 54 443 55 function IGCM_ensemble_ DirectoryName444 function IGCM_ensemble_CastDirectoryName 56 445 { 57 IGCM_debug_PushStack "IGCM_ensemble_ DirectoryName"446 IGCM_debug_PushStack "IGCM_ensemble_CastDirectoryName" 58 447 59 448 #.. Debug Print .. 60 449 echo 61 IGCM_debug_Print 1 "IGCM_ensemble_ DirectoryName :"450 IGCM_debug_Print 1 "IGCM_ensemble_CastDirectoryName :" 62 451 echo 63 452 … … 74 463 case ${Duree} in 75 464 *Y|*y) 76 siecle="$( echo $year | cut -c1-2 )" 465 siecle="$( echo $year | cut -c1-2 )" 77 466 siecle=$( (( $siecle - 18 )) ) 78 467 StartYear="${siecle}$( echo $year | cut -c3-4 )" … … 81 470 *M|*m) 82 471 echo $month 83 siecle="$( echo $year | cut -c1-2 )" 472 siecle="$( echo $year | cut -c1-2 )" 84 473 siecle=$( (( $siecle - 18 )) ) 85 474 StartYear="${siecle}$( echo $year | cut -c3-4 )" … … 89 478 esac 90 479 91 IGCM_debug_PopStack "IGCM_ensemble_ DirectoryName"480 IGCM_debug_PopStack "IGCM_ensemble_CastDirectoryName" 92 481 } 93 482 94 function IGCM_ensemble_ PerturbFile483 function IGCM_ensemble_CastPerturbFile 95 484 { 96 IGCM_debug_PushStack "IGCM_ensemble_ PerturbFile"485 IGCM_debug_PushStack "IGCM_ensemble_CastPerturbFile" 97 486 98 487 #.. Debug Print .. 99 488 echo 100 IGCM_debug_Print 1 "IGCM_ensemble_ PerturbFile :"489 IGCM_debug_Print 1 "IGCM_ensemble_CastPerturbFile :" 101 490 echo 102 491 … … 149 538 IGCM_card_WriteOption ${SUBMIT_DIR}/${StartDir}/${MemberDir}/config.card ${PerturbComp} RestartPath ${RestartDir}/ 150 539 151 IGCM_debug_PopStack "IGCM_ensemble_ PerturbFile"540 IGCM_debug_PopStack "IGCM_ensemble_CastPerturbFile" 152 541 }
Note: See TracChangeset
for help on using the changeset viewer.