- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
/tags/libIGCM_v1_1/libIGCM_sys/libIGCM_sys_platine.ksh
r20 r30 1258 1258 echo "IGCM_sys_rebuild :" $@ 1259 1259 fi 1260 /home/cont003/p86ipsl/bin/platine/rebuild -f -o $@ 1260 1261 /home/cont003/p86ipsl/IA64/bin/rebuild -f -o $@ 1261 1262 if [ $? -gt 0 ] ; then 1262 1263 echo "IGCM_sys_rebuild : erreur ${@}." -
/trunk/libIGCM/AA_create_se
r20 r30 441 441 # 442 442 elif [ ${config_UserChoices_TagName} = "LMDZ4OR" ] || \ 443 [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] || \ 444 [ ${config_UserChoices_TagName} = "LMDz4OR_v2" ] ; then 443 [ ${config_UserChoices_TagName} = "LMDZ4OR_v2" ] ; then 445 444 # 446 445 IGCM_sys_QsubPost atlas_LMDZ ; -
/trunk/libIGCM/AA_create_ts
r20 r30 241 241 FlagDir=$( echo ${FILE} | awk -F "_" '{print $1}' ) 242 242 case ${FlagDir} in 243 1Y) TS_Dir=TS_YE ;;244 1M) TS_Dir=TS_MO ;;245 5D|1D) TS_Dir=TS_DA ;;246 HF) 247 INS) 243 *Y) TS_Dir=TS_YE ;; 244 *M) TS_Dir=TS_MO ;; 245 *D) TS_Dir=TS_DA ;; 246 HF) TS_Dir=TS_HF ;; 247 INS) TS_Dir=TS_INS ;; 248 248 esac 249 249 … … 297 297 IGCM_debug_PushStack "create_ts_next_date" $@ 298 298 typeset year month Length 299 case ${1} in 300 1Y|1y) 301 IGCM_date_GetYearMonth ${2} year month 302 Length=$( IGCM_date_DaysInYear $(( year + 1 )) ) ;; 303 1M|1m) 304 IGCM_date_GetYearMonth ${2} year month 305 if [ $month -lt 12 ] ; then 306 Length=$( IGCM_date_DaysInMonth $year $(( month + 1 )) ) 299 case ${config_UserChoices_PeriodLength} in 300 *Y|*y) 301 PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 302 IGCM_date_GetYearMonth ${1} year month 303 (( Length=0 )) 304 (( i=0 )) 305 until [ $i -ge $PeriodLengthInYears ] ; do 306 (( Length = Length + $( IGCM_date_DaysInYear $(( year + i + 1 )) ) )) 307 (( i=i+1 )) 308 done 309 ;; 310 *M|*m) 311 PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 312 IGCM_date_GetYearMonth ${1} year month 313 (( year0=year )) 314 if [ $(( month + 1 )) -lt 13 ] ; then 315 month0=$(( month + 1 )) 307 316 else 308 Length=$( IGCM_date_DaysInMonth $(( year + 1 )) 1 ) 309 fi ;; 317 month0=$(( month + 1 - 12 )) 318 (( year = year0 + 1 )) 319 fi 320 (( Length=0 )) 321 (( i=0 )) 322 until [ $i -ge $PeriodLengthInMonths ] ; do 323 if [ $(( month0 + i )) -lt 13 ] ; then 324 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i )) ) )) 325 else 326 (( year = year0 + 1 )) 327 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month0 + i - 12 )) ) )) 328 fi 329 (( i=i+1 )) 330 done 331 ;; 310 332 *D|*d) 311 Length=$( echo ${ 1} | sed -e "s/[dD]//" ) ;;333 Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 312 334 *) 313 IGCM_debug_Exit "create_ts " ${ 1} " invalid PeriodLength : choose in 1Y, 1M, 5D, 1D."335 IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in 1Y, *M, *D." 314 336 IGCM_debug_Verif_Exit_Post ;; 315 337 esac … … 323 345 IGCM_debug_PushStack "create_ts_begin_date" $@ 324 346 typeset year month Length 325 case ${1} in 326 1Y|1y) 327 IGCM_date_GetYearMonth ${2} year month 328 Length=$( IGCM_date_DaysInYear $year ) ;; 329 1M|1m) 330 IGCM_date_GetYearMonth ${2} year month 331 Length=$( IGCM_date_DaysInMonth $year $month ) ;; 347 case ${config_UserChoices_PeriodLength} in 348 *Y|*y) 349 PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 350 IGCM_date_GetYearMonth ${1} year month 351 if [ X${2} = Xend ] ; then 352 (( year = year - PeriodLengthInYears + 1)) 353 fi 354 (( Length=0 )) 355 (( i=0 )) 356 until [ $i -ge $PeriodLengthInYears ] ; do 357 (( Length = Length + $( IGCM_date_DaysInYear $(( year + i )) ) )) 358 (( i=i+1 )) 359 done 360 ;; 361 *M|*m) 362 PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 363 IGCM_date_GetYearMonth ${1} year month 364 if [ X${2} = Xend ] ; then 365 (( month = $month - $PeriodLengthInMonths + 1 )) 366 fi 367 (( year0=$year )) 368 if [ $month -le 0 ] ; then 369 (( month = $month + 12 )) 370 year=$( printf "%04i\n" $(( year - 1 )) ) 371 fi 372 month=$( printf "%02i\n" ${month} ) 373 (( Length=0 )) 374 (( i=0 )) 375 until [ $i -ge $PeriodLengthInMonths ] ; do 376 if [ $(( month + i )) -lt 13 ] ; then 377 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 378 else 379 (( year = year0 + 1 )) 380 (( Length = Length + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 381 fi 382 (( i=i+1 )) 383 done 384 ;; 332 385 *D|*d) 333 Length=$( echo ${ 1} | sed -e "s/[dD]//" ) ;;386 Length=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) ;; 334 387 *) 335 IGCM_debug_Exit "create_ts " ${ 1} " invalid PeriodLength : choose in 1Y, 1M, 5D, 1D."388 IGCM_debug_Exit "create_ts " ${config_UserChoices_PeriodLength} " invalid PeriodLength : choose in 1Y, *M, *D." 336 389 IGCM_debug_Verif_Exit_Post ;; 337 390 esac … … 375 428 # First Time Series Submission 376 429 FIRST_PASS=TRUE 377 Length=$( create_ts_begin_date ${ config_UserChoices_PeriodLength} ${DateBegin})430 Length=$( create_ts_begin_date ${DateBegin} begin) 378 431 DATE_FIN_JOB_B=$( IGCM_date_AddDaysToGregorianDate ${DateBegin} $(( Length - 1 )) ) 379 432 else … … 402 455 FlagDir=$( echo ${file} | awk -F "_" '{print $1}' ) 403 456 case ${FlagDir} in 404 1Y)TS_Dir=TS_YE ;;405 1M)TS_Dir=TS_MO ;;406 5D|1D)TS_Dir=TS_DA ;;407 HF) 408 INS) 457 *Y) TS_Dir=TS_YE ;; 458 *M) TS_Dir=TS_MO ;; 459 *D) TS_Dir=TS_DA ;; 460 HF) TS_Dir=TS_HF ;; 461 INS) TS_Dir=TS_INS ;; 409 462 esac 410 463 for var in $( eval echo \${LISTE_VARS_${file}[*]} ) ; do … … 438 491 while [ ${DATE_COUNT} -lt ${PeriodDateEnd} ] ; do 439 492 (( NBRE_FILE_TOT = NBRE_FILE_TOT + 1 )) 440 Length=$( create_ts_next_date ${ config_UserChoices_PeriodLength} ${DATE_COUNT} )493 Length=$( create_ts_next_date ${DATE_COUNT} ) 441 494 DATE_COUNT=$( IGCM_date_AddDaysToGregorianDate ${DATE_COUNT} ${Length} ) 442 495 done … … 469 522 DATE_COURANTE=${DATE_FIN_JOB_B_LOOP} 470 523 else 471 Length=$( create_ts_next_date ${ config_UserChoices_PeriodLength} ${DATE_FIN_JOB_B_LOOP} )524 Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 472 525 DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 473 526 fi … … 486 539 487 540 if [ ! ${FIRST_PASS} = TRUE ] && [ ${CURRENT_LOOP} -eq 1 ] ; then 488 Length=$( create_ts_next_date ${ config_UserChoices_PeriodLength} ${DATE_FIN_JOB_B_LOOP} )541 Length=$( create_ts_next_date ${DATE_FIN_JOB_B_LOOP} ) 489 542 DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN_JOB_B_LOOP} ${Length} ) 490 543 elif [ -z "${DATE_COURANTE}" ] ; then 491 544 DATE_COURANTE=${DATE_FIN_JOB_B} 492 545 else 493 Length=$( create_ts_next_date ${ config_UserChoices_PeriodLength} ${DATE_FIN} )546 Length=$( create_ts_next_date ${DATE_FIN} ) 494 547 DATE_COURANTE=$( IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 495 548 fi … … 501 554 while [ ${COMPTEUR} -lt ${NBRE_FILE_LOOP} ] ; do 502 555 # 503 Length=$( create_ts_next_date ${ config_UserChoices_PeriodLength} ${DATE_LOOP} )556 Length=$( create_ts_next_date ${DATE_LOOP} ) 504 557 DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length} ) 505 558 (( TotLength = TotLength + Length )) … … 518 571 [ ${NBRE_FILE_LOOP} -eq 0 ] && NBRE_FILE_LOOP=${UNIX_MAX_LIMIT} 519 572 520 Length=$( create_ts_next_date ${ config_UserChoices_PeriodLength} ${DATE_FIN} )573 Length=$( create_ts_next_date ${DATE_FIN} ) 521 574 DATE_COURANTE=$(IGCM_date_AddDaysToGregorianDate ${DATE_FIN} ${Length} ) 522 575 DATE_FIN=${PeriodDateEnd} … … 546 599 FlagDir=$( echo ${file} | awk -F "_" '{print $1}' ) 547 600 case ${FlagDir} in 548 1Y) TS_Dir=TS_YE ; FreqDir=AN;;549 1M) TS_Dir=TS_MO ; FreqDir=MO ;;601 *Y) TS_Dir=TS_YE ; FreqDir=YE ;; 602 *M) TS_Dir=TS_MO ; FreqDir=MO ;; 550 603 *D) TS_Dir=TS_DA ; FreqDir=DA ;; 551 604 HF) TS_Dir=TS_HF ; FreqDir=HF ;; … … 567 620 while [ ${COMPTEUR} -le ${NBRE_FILE_LOOP} ] ; do 568 621 # 569 Length1=$( create_ts_begin_date ${ config_UserChoices_PeriodLength} ${DATE_LOOP})622 Length1=$( create_ts_begin_date ${DATE_LOOP} end) 570 623 DATE_TAB=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} $(( 1 - Length1 )) )_${DATE_LOOP} 571 624 572 Length2=$( create_ts_next_date ${ config_UserChoices_PeriodLength} ${DATE_LOOP})625 Length2=$( create_ts_next_date ${DATE_LOOP} end) 573 626 DATE_LOOP=$( IGCM_date_AddDaysToGregorianDate ${DATE_LOOP} ${Length2} ) 574 627 … … 596 649 # WE CAN CONCATENATE FILES AT THIS POINT 597 650 [ "${FLAG_B}" = "TRUE" ] && DATE_BUILD_B=${DateBegin}_${DATE_FIN_JOB_B_LOOP_PREC} 598 Length=$( create_ts_begin_date ${ config_UserChoices_PeriodLength} ${DATE_COURANTE})651 Length=$( create_ts_begin_date ${DATE_COURANTE} end) 599 652 DATE_BUILD1=$( IGCM_date_AddDaysToGregorianDate ${DATE_COURANTE} -$(( Length - 1 )) ) 600 653 DATE_BUILD=${DATE_BUILD1}_${DATE_FIN} -
/trunk/libIGCM/AA_job
r20 r30 361 361 #D- 362 362 # ------------------------------------------------------------------ 363 #D- Launch post-treatment process if necessary364 # ------------------------------------------------------------------ 365 IGCM_post_ Initialize363 #D- Launch remote rebuild or/and post-treatment process if necessary 364 # ------------------------------------------------------------------ 365 IGCM_post_Configure 366 366 367 367 #D- -
/trunk/libIGCM/libIGCM_card/IGCM_card_Test.ksh
r20 r30 82 82 83 83 diff ${libIGCM}/libIGCM_card/TestFile.card NewTestFile.card 84 rm -f NewTestFile.card 84 rm -f NewTestFile.card NewTestFile.card.bak 85 85 -
/trunk/libIGCM/libIGCM_card/IGCM_card_WriteOption.awk
r20 r30 102 102 END { 103 103 104 if (! exit_value ) {104 if (! exit_value ) { 105 105 106 myprint("###############################") 107 myprint("section ====> " section) 108 myprint("option ====> " option) 109 myprint("value ====> " value) 106 myprint("###############################") 107 myprint("section ====> " section) 108 myprint("option ====> " option) 109 myprint("value ====> " value) 110 111 if (section_found == 0) { 112 print "Error: Section not found", section, option 113 } else if (option_found == 0) { 114 print "Error: Option not found", section, option 115 } 116 117 } else { 110 118 111 if (section_found == 0) { 112 print "Error: Section not found" 113 } else if (option_found == 0) { 114 print "Error: Option not found" 115 } 119 print "Error in with IGCM_WriteOption : ", section, option 116 120 117 }121 } 118 122 119 123 } -
/trunk/libIGCM/libIGCM_card/libIGCM_card.ksh
r20 r30 167 167 #D-#================================================================== 168 168 #D-function IGCM_card_WriteOption 169 #D-* Purpose: Write an option froma given file.card and section169 #D-* Purpose: Write an option in a given file.card and section 170 170 #D-* Usage: IGCM_card_WriteOption file.card section newvalue 171 171 #D-* Examples: IGCM_card_WriteOption file.card Recipes Red 150 … … 181 181 typeset tmpfile=tmpfile_$$ 182 182 ( awk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile} 183 cp $1 $1.bak 183 184 mv ${tmpfile} $1 184 185 else … … 188 189 fi 189 190 IGCM_debug_PopStack "IGCM_card_WriteOption" 191 } 192 193 #D-#================================================================== 194 #D-function IGCM_card_WriteArrayOption 195 #D-* Purpose: Write an array option a given file.card and section 196 #D-* Usage: IGCM_card_WriteArrayOption file.card section option newarray 197 #D-* Examples: set -A MyArray -- 1 2 3 198 #D- IGCM_card_WriteArrayOption file.card Recipes List MyArray 199 #D- 200 function IGCM_card_WriteArrayOption 201 { 202 IGCM_debug_PushStack "IGCM_card_WriteArrayOption" $@ 203 204 if [ -r "$1" ] && [ -w "$1" ] ; then 205 typeset tmpfile=tmpfile_$$ 206 if [ X"${4}" != X"" ]; then 207 tab=$4 208 IGCM_card_WriteOption $1 $2 $3 '('$( eval echo \${${tab}[@]} | sed -e 's/ /,/g' )')' 209 else 210 IGCM_card_WriteOption $1 $2 $3 '()' 211 fi 212 else 213 echo "--Error--> IGCM_card_WriteArrayOption $@" 214 echo " $1 is not readable or not writable" 215 IGCM_debug_Exit "IGCM_card_WriteArrayOption" 216 fi 217 IGCM_debug_PopStack "IGCM_card_WriteArrayOption" 190 218 } 191 219 -
/trunk/libIGCM/libIGCM_comp/libIGCM_comp.ksh
r20 r30 528 528 529 529 typeset ListTextName TextName0 530 typeset comp compname comptagname card ListFilesName FileName0 NbFiles 530 typeset comp compname comptagname card ListFilesName FileName0 NbFiles SaveOnArchive 531 531 typeset i i_ file_in file_in_ file_out file_out_ generic_file_name nb_rebuild_file 532 532 for comp in ${config_ListOfComponents[*]} ; do … … 585 585 (( i=0 )) 586 586 until [ $i -ge $NbFiles ]; do 587 SaveOnArchive=true 587 588 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 588 589 eval file_in=${file_in_} … … 590 591 eval file_out_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 591 592 eval file_out=${file_out_} 592 593 # 593 594 generic_file_name=$( basename ${file_in} .nc ) 594 595 nb_rebuild_file=$( ls | grep "${generic_file_name}[_0-9]*.nc" | wc -l ) 595 if [ ${nb_rebuild_file} -gt 1 ] ; then 596 IGCM_debug_Print 2 "Rebuilding ${file_in}" 597 IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc 598 # DEBUG Rebuild : 599 #eval IGCM_sys_Cp ${generic_file_name}_*.nc \${R_OUT_${comp}_O_M}/ 600 elif [ -f ${generic_file_name}_0000.nc ] ; then 596 # 597 if ( [ ${nb_rebuild_file} -eq 1 ] && [ -f ${generic_file_name}_0000.nc ] ) ; then 598 IGCM_debug_Print 2 "Parallelism with 1 process. Rebuilding ${file_in} not needed" 601 599 IGCM_sys_Mv ${generic_file_name}_0000.nc ${file_in} 600 elif [ ${nb_rebuild_file} -gt 1 ] ; then 601 IGCM_debug_Print 2 "Parallelism detected rebuilding ${file_in} is needed" 602 if ( [ X${config_Post_RebuildFrequency} = X${NULL_STR} ] || [ X${config_Post_RebuildFrequency} = XNONE ] ) ; then 603 IGCM_debug_Print 2 "Rebuilding ${file_in} online" 604 IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc 605 else 606 IGCM_debug_Print 2 "Preparing offline rebuild for ${file_in}" 607 IGCM_sys_Mkdir ${RUN_DIR}/REBUILD_${PeriodDateBegin} 608 IGCM_sys_Mv ${generic_file_name}_????.nc ${RUN_DIR}/REBUILD_${PeriodDateBegin} 609 # Prepare headers for the shell dedicated to offline rebuild 610 if [ ! -f ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh ] ; then 611 echo \#!/bin/ksh > ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 612 echo function IGCM_FlushRebuild >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 613 echo { >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 614 echo IGCM_debug_PushStack "IGCM_FlushRebuild" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 615 echo echo >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 616 echo IGCM_debug_Print 1 "IGCM_FlushRebuild :" >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 617 echo echo >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 618 fi 619 # Prepare the shell dedicated to offline rebuild 620 echo IGCM_sys_rebuild ${file_in} ${generic_file_name}_*.nc >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 621 echo IGCM_sys_Put_Out ${file_in} ${file_out} >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 622 echo IGCM_sys_Rm ${generic_file_name}_*.nc >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 623 SaveOnArchive=false 624 fi 602 625 fi 603 604 IGCM_sys_Put_Out ${file_in} ${file_out}605 if [ $? -eq 0 ] ; then606 eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1626 # 627 if [ ${SaveOnArchive} = true ] ; then 628 IGCM_sys_Put_Out ${file_in} ${file_out} 629 [ $? -eq 0 ] && eval FileToBeDeleted[${#FileToBeDeleted[@]}]="${file_in}" > /dev/null 2>&1 607 630 if [ ${nb_rebuild_file} -gt 1 ] ; then 608 eval FileToBeDeleted[${#FileToBeDeleted[@]}]=$( ls | grep "${generic_file_name}_[0-9]*.nc" ) > /dev/null 2>&1 631 for DelFile in $( ls | grep "${generic_file_name}[_0-9]*.nc" ) ; do 632 eval FileToBeDeleted[${#FileToBeDeleted[@]}]=${DelFile} > /dev/null 2>&1 633 done 609 634 fi 610 635 fi -
/trunk/libIGCM/libIGCM_config/libIGCM_config.ksh
r20 r30 118 118 done 119 119 120 echo 121 IGCM_debug_Print 1 "DefineVariableFromOption : config_Post" 122 # 123 IGCM_card_DefineVariableFromOption ${SUBMIT_DIR}/config.card Post RebuildFrequency 124 # 125 120 126 #================================================================# 121 127 # Test and Prepare directories # … … 195 201 196 202 case ${config_UserChoices_PeriodLength} in 197 1Y|1y) 198 (( PeriodLengthInDays = $( IGCM_date_DaysInYear $year ) )) ;; 199 1M|1m) 200 (( PeriodLengthInDays = $( IGCM_date_DaysInMonth $year $month ) )) ;; 201 5D|5d) 202 (( PeriodLengthInDays = 5 )) ;; 203 1D|1d) 204 (( PeriodLengthInDays = 1 )) ;; 203 *Y|*y) 204 PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 205 IGCM_debug_Print 1 "Number of years for PeriodLength : ${PeriodLengthInYears}" 206 PeriodLengthInDays=0 207 i=0 208 until [ $i -ge $PeriodLengthInYears ] ; do 209 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) 210 (( i=i+1 )) 211 done 212 ;; 213 *M|*m) 214 PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 215 IGCM_debug_Print 1 "Number of months for PeriodLength : ${PeriodLengthInMonths}" 216 typeset year1 217 PeriodLengthInDays=0 218 year1=year 219 i=0 220 until [ $i -ge $PeriodLengthInMonths ] ; do 221 if [ $(( month + i )) -lt 13 ] ; then 222 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 223 else 224 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 225 fi 226 (( i=i+1 )) 227 done 228 ;; 229 *D|*d) 230 PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | awk -F '[dD]' '{print $1}' ) ;; 205 231 *) 206 IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length : choose in 1Y, 1M, 5D, 1D."232 IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." 207 233 IGCM_debug_Verif_Exit ;; 208 234 esac … … 271 297 # Determine number of day(s) in PeriodLength : 272 298 case ${config_UserChoices_PeriodLength} in 273 1Y|1y) 274 (( PeriodLengthInDays = $( IGCM_date_DaysInYear $year ) )) ;; 275 1M|1m) 276 (( PeriodLengthInDays = $( IGCM_date_DaysInMonth $year $month ) )) ;; 277 5D|5d) 278 (( PeriodLengthInDays=5 )) ;; 279 1D|1d) 280 (( PeriodLengthInDays=1 )) ;; 299 *Y|*y) 300 PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 301 IGCM_debug_Print 1 "Number of years for PeriodLength : ${PeriodLengthInYears}" 302 PeriodLengthInDays=0 303 i=0 304 until [ $i -ge $PeriodLengthInYears ] ; do 305 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) 306 (( i=i+1 )) 307 done 308 ;; 309 *M|*m) 310 PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 311 IGCM_debug_Print 1 "Number of months for PeriodLength : ${PeriodLengthInMonths}" 312 typeset year1 313 PeriodLengthInDays=0 314 year1=year 315 i=0 316 until [ $i -ge $PeriodLengthInMonths ] ; do 317 if [ $(( month + i )) -lt 13 ] ; then 318 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 319 else 320 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 321 fi 322 (( i=i+1 )) 323 done 324 ;; 325 *D|*d) 326 PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | awk -F '[dD]' '{print $1}' ) ;; 281 327 *) 282 IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length : choose in 1Y, 1M, 5D, 1D."328 IGCM_debug_Exit "IGCM_config_PeriodStart " ${config_UserChoices_PeriodLength} " invalid period length : choose in *Y, *M, *D." 283 329 IGCM_debug_Verif_Exit ;; 284 330 esac … … 457 503 # Determine number of day(s) in PeriodLength : 458 504 case ${config_UserChoices_PeriodLength} in 459 1Y|1y) PeriodLengthInDays=$( expr $( IGCM_date_DaysInYear $year ) ) ;; 460 1M|1m) PeriodLengthInDays=$( expr $( IGCM_date_DaysInMonth $year $month ) ) ;; 461 5D|5d) PeriodLengthInDays=$( expr 5 ) ;; 462 1D|1d) PeriodLengthInDays=$( expr 1 ) ;; 505 *Y|*y) 506 PeriodLengthInYears=$( echo ${config_UserChoices_PeriodLength} | awk -F '[yY]' '{print $1}' ) 507 IGCM_debug_Print 1 "Number of years for PeriodLength : ${PeriodLengthInYears}" 508 PeriodLengthInDays=0 509 i=0 510 until [ $i -ge $PeriodLengthInYears ] ; do 511 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInYear $(( year + i )) ) )) 512 (( i=i+1 )) 513 done 514 ;; 515 M|*m) 516 PeriodLengthInMonths=$( echo ${config_UserChoices_PeriodLength} | awk -F '[mM]' '{print $1}' ) 517 IGCM_debug_Print 1 "Number of months for PeriodLength : ${PeriodLengthInMonths}" 518 typeset year1 519 PeriodLengthInDays=0 520 year1=year 521 i=0 522 until [ $i -ge $PeriodLengthInMonths ] ; do 523 if [ $(( month + i )) -lt 13 ] ; then 524 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i )) ) )) 525 else 526 (( PeriodLengthInDays = PeriodLengthInDays + $( IGCM_date_DaysInMonth $year $(( month + i - 12 )) ) )) 527 fi 528 (( i=i+1 )) 529 done 530 ;; 531 *D|*d) 532 PeriodLengthInDays=$( echo ${config_UserChoices_PeriodLength} | awk -F '[dD]' '{print $1}' ) ;; 463 533 esac 464 534 PeriodDateEnd=$( IGCM_date_AddDaysToGregorianDate ${PeriodDateBegin} $( expr ${PeriodLengthInDays} - 1 ) ) -
/trunk/libIGCM/libIGCM_date/libIGCM_date.ksh
r20 r30 153 153 function IGCM_date_DaysInYear 154 154 { 155 IGCM_debug_PushStack "IGCM_date_DaysInYear" $@155 # IGCM_debug_PushStack "IGCM_date_DaysInYear" $@ 156 156 # return the number of days in a year 157 157 # usage IGCM_date_DaysInYear yyyy … … 159 159 # What is the calendar : 160 160 if [ "${config_UserChoices_CalendarType}" = "360d" ] ; then 161 echo 360 162 IGCM_debug_PopStack "IGCM_date_DaysInYear" 161 if [ X$2 = X ] ; then 162 echo 360 163 else 164 eval $2=360 > /dev/null 2>&1 165 fi 166 # IGCM_debug_PopStack "IGCM_date_DaysInYear" 163 167 return 164 168 else 165 169 if [ "${config_UserChoices_CalendarType}" = "noleap" ] ; then 166 echo 365 167 IGCM_debug_PopStack "IGCM_date_DaysInYear" 170 if [ X$2 = X ] ; then 171 echo 365 172 else 173 eval $2=365 > /dev/null 2>&1 174 fi 175 176 # IGCM_debug_PopStack "IGCM_date_DaysInYear" 168 177 return 169 178 fi 170 179 fi 180 181 typeset y a 171 182 172 183 # if there is no argument on the command line, … … 184 195 185 196 # if it is evenly divisible by 400 it must be a leap year 186 a=$( expr $y \% 400)197 a=$(( $y % 400 )) 187 198 if [ $a = 0 ] 188 199 then 189 echo 366 190 IGCM_debug_PopStack "IGCM_date_DaysInYear" 200 if [ X$2 = X ] ; then 201 echo 366 202 else 203 eval $2=366 > /dev/null 2>&1 204 fi 205 206 # IGCM_debug_PopStack "IGCM_date_DaysInYear" 191 207 return 192 208 fi 193 209 194 210 #if it is evenly divisible by 100 it must not be a leap year 195 a=$( expr $y \% 100)211 a=$(( $y % 100 )) 196 212 if [ $a = 0 ] 197 213 then 198 echo 365 199 IGCM_debug_PopStack "IGCM_date_DaysInYear" 214 if [ X$2 = X ] ; then 215 echo 365 216 else 217 eval $2=365 > /dev/null 2>&1 218 fi 219 220 # IGCM_debug_PopStack "IGCM_date_DaysInYear" 200 221 return 201 222 fi 202 223 203 224 # if it is evenly divisible by 4 it must be a leap year 204 a=$( expr $y \% 4)225 a=$(( $y % 4 )) 205 226 if [ $a = 0 ] 206 227 then 207 echo 366 208 IGCM_debug_PopStack "IGCM_date_DaysInYear" 228 if [ X$2 = X ] ; then 229 echo 366 230 else 231 eval $2=366 > /dev/null 2>&1 232 fi 233 234 # IGCM_debug_PopStack "IGCM_date_DaysInYear" 209 235 return 210 236 fi 211 237 212 238 # otherwise it is not a leap year 213 echo 365 214 215 IGCM_debug_PopStack "IGCM_date_DaysInYear" 239 if [ X$2 = X ] ; then 240 echo 365 241 else 242 eval $2=365 > /dev/null 2>&1 243 fi 244 245 # IGCM_debug_PopStack "IGCM_date_DaysInYear" 216 246 } 217 247 … … 227 257 function IGCM_date_DaysInMonth 228 258 { 229 IGCM_debug_PushStack "IGCM_date_DaysInMonth" $@259 # IGCM_debug_PushStack "IGCM_date_DaysInMonth" $@ 230 260 231 261 # calculates the number of days in a month 232 262 # usage IGCM_date_DaysInMonth yyyy mm 233 263 # or IGCM_date_DaysInMonth yyyymmdd 234 264 235 265 # What is the calendar : 236 266 if [ "${config_UserChoices_CalendarType}" = "360d" ] ; then 237 echo 30 238 IGCM_debug_PopStack "IGCM_date_DaysInMonth" 267 if [ X$3 = X ] ; then 268 echo 30 269 else 270 eval $3=30 > /dev/null 2>&1 271 fi 272 273 # IGCM_debug_PopStack "IGCM_date_DaysInMonth" 239 274 return 240 275 fi 276 277 typeset ymd y m diy 241 278 242 279 # if there are no command line arguments then assume that a yyyymmdd is being … … 251 288 ymd=$1 252 289 else 253 ymd=$( expr \( \( $1 \* 10000 \) \+ \( $2 \* 100 \) \+ 1 \))290 ymd=$(( ( $1 * 10000 ) + ( $2 * 100 ) + 1 )) 254 291 fi 255 292 256 293 # extract the year and the month 257 y=$( expr $ymd / 10000) ;258 m=$( expr \( $ymd \% 10000 \) / 100) ;294 y=$(( $ymd / 10000 )) ; 295 m=$(( ( $ymd % 10000 ) / 100 )) ; 259 296 260 297 # 30 days hath september etc. 261 298 case $m in 262 299 1|3|5|7|8|10|12) 263 echo 31 264 IGCM_debug_PopStack "IGCM_date_DaysInMonth" 300 if [ X$3 = X ] ; then 301 echo 31 302 else 303 eval $3=31 > /dev/null 2>&1 304 fi 305 306 # IGCM_debug_PopStack "IGCM_date_DaysInMonth" 265 307 return ;; 266 308 4|6|9|11) 267 echo 30 268 IGCM_debug_PopStack "IGCM_date_DaysInMonth" 309 if [ X$3 = X ] ; then 310 echo 30 311 else 312 eval $3=30 > /dev/null 2>&1 313 fi 314 315 # IGCM_debug_PopStack "IGCM_date_DaysInMonth" 269 316 return ;; 270 317 *) ;; … … 274 321 # Use IGCM_date_DaysInYear to get the number of days in the year and return a value 275 322 # accordingly. 276 diy=$( IGCM_date_DaysInYear $y )323 IGCM_date_DaysInYear $y diy 277 324 case $diy in 278 325 365) 279 echo 28 280 IGCM_debug_PopStack "IGCM_date_DaysInMonth" 326 if [ X$3 = X ] ; then 327 echo 28 328 else 329 eval $3=28 > /dev/null 2>&1 330 fi 331 332 # IGCM_debug_PopStack "IGCM_date_DaysInMonth" 281 333 return ;; 282 334 366) 283 echo 29 284 IGCM_debug_PopStack "IGCM_date_DaysInMonth" 335 if [ X$3 = X ] ; then 336 echo 29 337 else 338 eval $3=29 > /dev/null 2>&1 339 fi 340 341 # IGCM_debug_PopStack "IGCM_date_DaysInMonth" 285 342 return ;; 286 343 esac 287 344 288 IGCM_debug_PopStack "IGCM_date_DaysInMonth"345 # IGCM_debug_PopStack "IGCM_date_DaysInMonth" 289 346 } 290 347 … … 303 360 # usage IGCM_date_ConvertGregorianDateToJulian 19980429 304 361 362 typeset dt y m d x jul 363 305 364 # if there is no command line argument, then assume that the date 306 365 # is coming in on a pipe and use read to collect it … … 313 372 314 373 # break the yyyymmdd into separate parts for year, month and day 315 y=$( expr $dt / 10000)316 m=$( expr \( $dt \% 10000 \) / 100)317 d=$( expr \( $dt \% 100 \))374 y=$(( $dt / 10000 )) 375 m=$(( ( $dt % 10000 ) / 100 )) 376 d=$(( ( $dt % 100 ) )) 318 377 319 378 # add the days in each month up to (but not including the month itself) … … 323 382 # and add them to 14. 324 383 x=1 325 while [ $ ( expr $x \< $m ) = 1]384 while [ $x -lt $m ] 326 385 do 327 md=$( IGCM_date_DaysInMonth $y $x )328 d=$( expr \( $d \+ $md \))329 x=$( expr \( $x \+ 1 \))386 IGCM_date_DaysInMonth $y $x md 387 d=$(( $d + $md )) 388 x=$(( $x + 1 )) 330 389 done 331 390 332 391 # combine the year and day back together again and you have the julian date. 333 jul=$( expr \( $y \* 1000 \) + $d)392 jul=$(( ( $y * 1000 ) + $d )) 334 393 echo $jul 335 394 … … 351 410 # usage IGCM_date_ConvertJulianDateToGregorian 1998213 352 411 412 typeset dt y m d md grg 413 353 414 # if there is no command line argument, assume one is being 354 415 # piped in and read it … … 361 422 362 423 # break apart the year and the days 363 y=$( expr $dt / 1000)364 d=$( expr $dt \% 1000)424 y=$(( $dt / 1000 )) 425 d=$(( $dt % 1000 )) 365 426 366 427 # subtract the number of days in each month starting from 1 … … 369 430 # month to get the correct day of the month 370 431 m=1 371 while [ $ ( expr $d \> 0 ) = 1]432 while [ $d -gt 0 ] 372 433 do 373 md=$( IGCM_date_DaysInMonth $y $m )374 d=$( expr $d \- $md)375 m=$( expr $m \+ 1)434 IGCM_date_DaysInMonth $y $m md 435 d=$(( $d - $md )) 436 m=$(( $m + 1 )) 376 437 done 377 438 378 d=$( expr $d \+ $md)439 d=$(( $d + $md )) 379 440 380 441 # the loop steps one past the correct month, so back up the month 381 m=$( expr $m \- 1)442 m=$(( $m - 1 )) 382 443 383 444 # assemble the results into a gregorian date 384 grg=$( expr \( $y \* 10000 \) \+ \( $m \* 100 \) \+ $d)445 grg=$(( ( $y * 10000 ) + ( $m * 100 ) + $d )) 385 446 echo $( IGCM_date_GregorianDigit $grg ) 386 447 … … 402 463 # usage IGCM_date_AddDaysToJulianDate 1998312 { ,-}14 403 464 465 typeset dif yd d y diy 466 404 467 # Read the difference from the command lines 405 468 # and the date from the command line, or standard input … … 414 477 415 478 # Break it into pieces 416 d=$( expr $yd \% 1000)417 y=$( expr $yd / 1000)479 d=$(( $yd % 1000 )) 480 y=$(( $yd / 1000 )) 418 481 419 482 # Add the number of days (if days is negative this results is 420 483 # a subtraction) 421 d=$( expr $d \+ $dif)484 d=$(( $d + $dif )) 422 485 423 486 # Extract the days in the year 424 diy=$( IGCM_date_DaysInYear $y )487 IGCM_date_DaysInYear $y diy 425 488 426 489 # If the calculated day exceeds the days in the year, … … 429 492 # test until you end up with a day number that falls within the 430 493 # days of the year 431 while [ $ ( expr $d \> $diy ) = 1]494 while [ $d -gt $diy ] 432 495 do 433 d=$( expr $d - $diy)434 y=$( expr $y \+ 1)435 diy=$( IGCM_date_DaysInYear $y )496 d=$(( $d - $diy )) 497 y=$(( $y + 1 )) 498 IGCM_date_DaysInYear $y diy 436 499 done 437 500 … … 441 504 # loop on this test until you end up with a number that 442 505 # falls within the days of the year 443 while [ $ ( expr $d \< 1 ) =1 ]506 while [ $d -lt 1 ] 444 507 do 445 y=$( expr $y - 1)446 diy=$( IGCM_date_DaysInYear $y )447 d=$( expr $d \+ $diy)508 y=$(( $y - 1 )) 509 IGCM_date_DaysInYear $y diy 510 d=$(( $d + $diy )) 448 511 done 449 512 450 513 # put the year and day back together and echo the result 451 yd=$( expr \( $y \* 1000 \) + $d)514 yd=$(( ( $y * 1000 ) + $d )) 452 515 453 516 echo $yd … … 539 602 540 603 # Break the dates in to year and day portions 541 yyyy1=$( expr $jul1 / 1000)542 yyyy2=$( expr $jul2 / 1000)543 ddd1=$( expr $jul1 \% 1000)544 ddd2=$( expr $jul2 \% 1000)604 yyyy1=$(( $jul1 / 1000 )) 605 yyyy2=$(( $jul2 / 1000 )) 606 ddd1=$(( $jul1 % 1000 )) 607 ddd2=$(( $jul2 % 1000 )) 545 608 546 609 # Subtract days 547 res=$( expr $ddd1 - $ddd2)610 res=$(( $ddd1 - $ddd2 )) 548 611 549 612 # Then add days in year until year2 matches year1 550 613 551 614 if [ "${config_UserChoices_CalendarType}" = "360d" ] ; then 552 res=$( expr \( \( $yyyy1 \- $yyyy2 \) \* 360 \) \+ $res)615 res=$(( ( ( $yyyy1 - $yyyy2 ) * 360 ) + $res )) 553 616 elif [ "${config_UserChoices_CalendarType}" = "noleap" ] ; then 554 res=$( expr \( \( $yyyy1 \- $yyyy2 \) \* 365 \) \+ $res)617 res=$(( ( ( $yyyy1 - $yyyy2 ) * 365 ) + $res )) 555 618 elif ( [ "${config_UserChoices_CalendarType}" = "leap" ] || [ "${config_UserChoices_CalendarType}" = "gregorian" ] ) ; then 556 619 while [ $yyyy2 -lt $yyyy1 ] 557 620 do 558 diy=$( IGCM_date_DaysInYear $yyyy2 )559 res=$( expr $res + $diy)560 yyyy2=$( expr $yyyy2 + 1)621 IGCM_date_DaysInYear $yyyy2 diy 622 res=$(( $res + $diy )) 623 yyyy2=$(( $yyyy2 + 1 )) 561 624 done 562 625 fi … … 567 630 if [ $1 -lt $2 ] 568 631 then 569 res=$( expr $res \* -1)632 res=$(( $res * -1 )) 570 633 fi 571 634 … … 690 753 num=19000101 691 754 fi 692 echo $( expr \( $( IGCM_date_DaysBetweenGregorianDate $1 ${num} ) \+ $aux \))755 echo $(( $( IGCM_date_DaysBetweenGregorianDate $1 ${num} ) + $aux )) 693 756 694 757 IGCM_debug_PopStack "IGCM_date_DaysSinceJC" -
/trunk/libIGCM/libIGCM_post/libIGCM_post.ksh
r20 r30 15 15 16 16 #======================================================================= 17 18 function IGCM_post_Configure 19 { 20 IGCM_debug_PushStack "IGCM_post_Configure" 21 22 # Debug Print : 23 echo 24 IGCM_debug_Print 1 "IGCM_post_Configure :" 25 echo 26 27 typeset NbDays PeriodEndJul PostEndJul PeriodPost 28 RebuildFrequency=false 29 30 if ( [ ! X${config_Post_RebuildFrequency} = X${NULL_STR} ] && [ ! X${config_Post_RebuildFrequency} = XNONE ] ) ; then 31 32 IGCM_debug_Print 1 "Asynchronous rebuild has been activated." 33 echo 34 35 case ${config_Post_RebuildFrequency} in 36 *y|*Y) 37 PeriodYear=$( echo ${config_Post_RebuildFrequency} | sed -e "s/[yY]//" ) 38 case ${config_UserChoices_PeriodLength} in 39 *Y|*y) 40 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[yY]//" ) 41 if [ ${PeriodPost} -le ${PeriodYear} ] ; then 42 if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % ${PeriodYear} ) -eq 0 ] ; then 43 RebuildFrequency=true 44 NbRebuildDir=$( expr ${PeriodYear} / ${PeriodPost} ) 45 fi 46 else 47 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 48 IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}" 49 fi ;; 50 *M|*m) 51 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" ) 52 if [ ${PeriodPost} -le $(( ${PeriodYear} * 12 )) ] ; then 53 if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % $(( ${PeriodYear} * 12 )) ) -eq 0 ] ; then 54 RebuildFrequency=true 55 NbRebuildDir=$( expr $(( 12 * ${PeriodYear} )) / ${PeriodPost} ) 56 fi 57 else 58 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 59 IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}" 60 fi ;; 61 *D|*d) 62 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) 63 NbDays=$( IGCM_date_DaysInYear ${year} ) 64 if [ ${config_UserChoices_CalendarType} = 360d ] || [ ${config_UserChoices_CalendarType} = noleap ] ; then 65 if [ ${PeriodPost} -le $(( ${PeriodYear} * ${NbDays} )) ] ; then 66 if [ $( expr ${CumulPeriod} % $( expr \( ${NbDays} \* ${PeriodYear} \/ ${PeriodPost} \) ) ) -eq 0 ] ; then 67 RebuildFrequency=true 68 NbRebuildDir=$( expr $(( ${NbDays} * ${PeriodYear} )) / ${PeriodPost} ) 69 fi 70 else 71 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 72 IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}" 73 fi 74 else 75 # if [ ${PeriodYear} -eq 1 ] ; then 76 # PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) 77 # PostEndJul=${year}${NbDays} 78 # #echo "PeriodYear=${PeriodYear} NbDays=${NbDays}" 79 # #echo "PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}" 80 # if [ ${PostEndJul} -eq ${PeriodEndJul} ] ; then 81 # RebuildFrequency=true 82 # NbRebuildDir=$( expr ${NbDays} / ${PeriodPost} ) 83 # fi 84 # else 85 IGCM_debug_Print 3 "For RebuildFrequency with leap calendar:" 86 IGCM_debug_Print 3 "We have a daily PeriodLength frequency and RebuildFrequency=${PeriodYear}Y." 87 IGCM_debug_Print 3 "No post-treatment. Case not properly handle at this moment." 88 # fi 89 fi;; 90 esac ;; 91 *M|*m) 92 PeriodMonth=$( echo ${config_Post_RebuildFrequency} | sed -e "s/[mM]//" ) 93 case ${config_UserChoices_PeriodLength} in 94 *Y|*y) 95 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 96 IGCM_debug_Print 3 "RebuildFrequency frequency ${config_Post_RebuildFrequency}" ;; 97 *M|*m) 98 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" ) 99 if [ ${PeriodPost} -le ${PeriodMonth} ] ; then 100 if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % ${PeriodMonth} ) -eq 0 ] ; then 101 RebuildFrequency=true 102 NbRebuildDir=$( expr ${PeriodMonth} / ${PeriodPost} ) 103 fi 104 else 105 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 106 IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}" 107 fi ;; 108 *D|*d) 109 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 110 IGCM_debug_Print 3 "RebuildFrequency frequency : ${config_Post_RebuildFrequency}" ;; 111 esac 112 ;; 113 NONE|none) 114 ;; 115 *) 116 IGCM_debug_Print 3 "KeyWord not allowed for RebuildFrequency in config.card" 117 ;; 118 esac 119 else 120 # 121 IGCM_debug_Print 1 "Asynchronous rebuild has not been activated" 122 IGCM_debug_Print 1 "Proceed with standard post-treatment pathway" 123 echo 124 # 125 fi 126 127 IGCM_debug_Print 1 "RebuildFrequency flag value : ${RebuildFrequency}" 128 IGCM_post_Initialize 129 130 IGCM_debug_PopStack "IGCM_post_Configure" 131 } 132 17 133 function IGCM_post_Initialize 18 134 { … … 29 145 # READ TIME SERIES OR SEASONAL FREQUENCY 30 146 # AND TURN ON THE FLAG WHEN MODULO IS ZERO 31 for post_freq in RebuildFrequencyTimeSeriesFrequency SeasonalFrequency ; do147 for post_freq in TimeSeriesFrequency SeasonalFrequency ; do 32 148 # 33 149 # Initialize … … 45 161 # 46 162 if ( [ X${config_Post_post_freq} = X${NULL_STR} ] || [ X${config_Post_post_freq} = XNONE ] ) ; then 47 #48 continue49 #163 # 164 continue 165 # 50 166 fi 51 167 # … … 60 176 # 61 177 if [ X${FileName0} != X${NULL_STR} ] ; then 62 #63 #IGCM_debug_Print 1 "Component : ${compname}"64 #65 # INITIALISATION66 #67 eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&168 typeset i=069 #70 until [ $i -eq $NbFiles ]; do71 178 # 72 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 73 eval file_in=${file_in_} 74 let $(( i_ = i+2 )) 75 eval flag_post_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 76 eval flag_post=${flag_post_} 179 #IGCM_debug_Print 1 "Component : ${compname}" 77 180 # 78 if [ X${flag_post} != XNONE ] ; then 79 # 80 # Initialize ${flag_post}_${compname}_${post_freq} 81 # 82 eval ${flag_post}_${compname}_${post_freq}=false 83 # 84 case ${config_Post_post_freq} in 85 *y|*Y) 86 PeriodYear=$( echo ${config_Post_post_freq} | sed -e "s/[yY]//" ) 87 case ${config_UserChoices_PeriodLength} in 88 1Y|1y) 89 if [ $( expr ${CumulPeriod} % ${PeriodYear} ) -eq 0 ] ; then 90 eval ${flag_post}_${compname}_${post_freq}=true 91 eval ${post_freq}=true 92 POST=true 93 fi ;; 94 1M|1m) 95 if [ $( expr ${CumulPeriod} % $( expr ${PeriodYear} \* 12 ) ) -eq 0 ] ; then 96 eval ${flag_post}_${compname}_${post_freq}=true 97 eval ${post_freq}=true 98 POST=true 99 fi ;; 100 *D|*d) 101 LengthDays=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) 102 NbDays=$( IGCM_date_DaysInYear ${year} ) 103 if [ ${config_UserChoices_CalendarType} = 360d ] | [ ${config_UserChoices_CalendarType} = noleap ] ; then 104 if [ $( expr ${CumulPeriod} % $( expr \( ${NbDays} \* ${PeriodYear} \/ ${LengthDays} \) ) ) -eq 0 ] ; then 105 eval ${flag_post}_${compname}_${post_freq}=true 106 eval ${post_freq}=true 107 POST=true 108 fi 109 else 110 if [ ${PeriodYear} -eq 1 ] ; then 111 PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) 112 PostEndJul=${year}${NbDays} 113 #echo "PeriodYear=${PeriodYear} Year ; NbDays${NbDays} PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}" 114 if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then 115 eval ${flag_post}_${compname}_${post_freq}=true 116 eval ${post_freq}=true 117 POST=true 118 fi 119 else 120 echo "For ${post_freq}, for ${comp} and ${file_in} :" 121 echo "We have a daily WriteFrequency and ${post_freq}=${PeriodYear}Y." 122 echo "No post-treatment." 123 fi 124 fi;; 125 esac ;; 126 1M|1m) 127 case ${config_UserChoices_PeriodLength} in 128 1Y|1y) 129 IGCM_debug_Print 3 "Frequency not allowed for TimeSeriesFrequency in ${flag_post}" ;; 130 1M|1m) 131 eval ${flag_post}_${compname}_${post_freq}=true 132 eval ${post_freq}=true 133 POST=true;; 134 *D|*d) 135 NbDays=$( IGCM_date_DaysInMonth ${year} ${month} ) 136 PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) 137 PostEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${year}${month}${NbDays} ) 138 #echo "year_month=${year}_${month} Month ; NbDays${NbDays} PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}" 139 if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then 140 eval ${flag_post}_${compname}_${post_freq}=true 141 eval ${post_freq}=true 142 POST=true 143 fi 144 ;; 145 esac 146 ;; 147 NONE|none) 148 ;; 149 *) 150 IGCM_debug_Print 3 "KeyWord not allowed for ${post_freq} in config.card" 151 ;; 152 esac 153 fi 154 let $(( i=i+3 )) 155 done 181 # INITIALISATION 182 # 183 eval NbFiles=\${#${ListFilesName}[@]} > /dev/null 2>&1 184 typeset i=0 185 # 186 until [ $i -eq $NbFiles ]; do 187 # 188 eval file_in_=\${${ListFilesName}[$i]} > /dev/null 2>&1 189 eval file_in=${file_in_} 190 let $(( i_ = i+2 )) 191 eval flag_post_=\${${ListFilesName}[$i_]} > /dev/null 2>&1 192 eval flag_post=${flag_post_} 193 # 194 if [ X${flag_post} != XNONE ] ; then 195 # 196 case ${config_Post_post_freq} in 197 *y|*Y) 198 PeriodYear=$( echo ${config_Post_post_freq} | sed -e "s/[yY]//" ) 199 case ${config_UserChoices_PeriodLength} in 200 *Y|*y) 201 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[yY]//" ) 202 if [ ${PeriodPost} -le ${PeriodYear} ] ; then 203 if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % ${PeriodYear} ) -eq 0 ] ; then 204 eval ${post_freq}=true 205 POST=true 206 fi 207 else 208 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 209 IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " 210 fi ;; 211 *M|*m) 212 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" ) 213 if [ ${PeriodPost} -le $(( ${PeriodYear} * 12 )) ] ; then 214 if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % $(( ${PeriodYear} * 12 )) ) -eq 0 ] ; then 215 eval ${post_freq}=true 216 POST=true 217 fi 218 else 219 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 220 IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " 221 fi ;; 222 *D|*d) 223 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[dD]//" ) 224 NbDays=$( IGCM_date_DaysInYear ${year} ) 225 if [ ${config_UserChoices_CalendarType} = 360d ] | [ ${config_UserChoices_CalendarType} = noleap ] ; then 226 if [ ${PeriodPost} -le $(( ${PeriodYear} * ${NbDays} )) ] ; then 227 if [ $( expr ${CumulPeriod} % $( expr \( ${NbDays} \* ${PeriodYear} \/ ${PeriodPost} \) ) ) -eq 0 ] ; then 228 eval ${post_freq}=true 229 POST=true 230 fi 231 else 232 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 233 IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " 234 fi 235 else 236 # if [ ${PeriodYear} -eq 1 ] ; then 237 # PeriodEndJul=$( IGCM_date_ConvertGregorianDateToJulian ${PeriodDateEnd} ) 238 # PostEndJul=${year}${NbDays} 239 # #echo "PeriodYear=${PeriodYear} NbDays=${NbDays}" 240 # #echo PeriodEndJul=${PeriodEndJul} PostEndJul=${PostEndJul}" 241 # if [ ${PostEndJul} -le ${PeriodEndJul} ] ; then 242 # eval ${post_freq}=true 243 # POST=true 244 # fi 245 # else 246 IGCM_debug_Print 3 "For ${post_freq} with leap calendar, for ${comp} and ${file_in} :" 247 IGCM_debug_Print 3 "We have a daily PeriodLength frequency and RebuildFrequency=${PeriodYear}Y." 248 IGCM_debug_Print 3 "No post-treatment. Case not properly handle at this moment." 249 # fi 250 fi;; 251 esac ;; 252 *M|*m) 253 PeriodMonth=$( echo ${config_Post_RebuildFrequency} | sed -e "s/[mM]//" ) 254 case ${config_UserChoices_PeriodLength} in 255 *Y|*y) 256 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 257 IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;; 258 *M|*m) 259 PeriodPost=$( echo ${config_UserChoices_PeriodLength} | sed -e "s/[mM]//" ) 260 if [ ${PeriodPost} -le ${PeriodMonth} ] ; then 261 if [ $( expr $(( ${CumulPeriod} * ${PeriodPost} )) % ${PeriodMonth} ) -eq 0 ] ; then 262 eval ${post_freq}=true 263 POST=true 264 fi 265 else 266 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 267 IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " 268 fi;; 269 *D|*d) 270 IGCM_debug_Print 3 "PeriodLength frequency ${config_UserChoices_PeriodLength} not compatbile with" 271 IGCM_debug_Print 3 "${flag_post} frequency : ${config_Post_post_freq} " ;; 272 esac ;; 273 NONE|none) 274 ;; 275 *) 276 IGCM_debug_Print 3 "KeyWord not allowed for ${post_freq} in config.card" 277 ;; 278 esac 279 fi 280 let $(( i=i+3 )) 281 done 156 282 fi 157 283 done 158 284 done 159 285 IGCM_debug_Print 1 "POST-TREATEMENT flag value : ${POST}" 160 [ ${POST} = true ] && IGCM_post_Submit286 [ ${POST} = true ] || [ ${RebuildFrequency} = true ] && IGCM_post_Submit 161 287 162 288 IGCM_debug_PopStack "IGCM_post_Initialize" … … 172 298 echo 173 299 174 typeset comp175 176 300 POST_DIR=${R_OUT_POST}/${config_UserChoices_TagName}/${config_UserChoices_JobName} 177 echo "POST_DIR = ${POST_DIR}" 301 IGCM_debug_Print 1 "POST_DIR = ${POST_DIR}" 302 303 #============ TIME SERIES POST-TREATMENT ===========# 304 if [ ${TimeSeriesFrequency} = true ] ; then 305 306 IGCM_debug_Print 2 "TIME SERIES POST-TREATMENT :" 307 echo 308 # 309 typeset listVarEnv 310 listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF" 311 312 if [ ${RebuildFrequency} = true ] ; then 313 # 314 echo IGCM_sys_QsubPost create_ts >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 315 # 316 else 317 # 318 IGCM_sys_RshPost <<-EOF 319 export MODIPSL=${MODIPSL} 320 export libIGCM_SX=${libIGCM} 321 export libIGCM=${libIGCM_POST} 322 export SUBMIT_DIR=${SUBMIT_DIR} 323 export POST_DIR=${POST_DIR} 324 export DateBegin=${DateBegin} 325 export PeriodDateEnd=${PeriodDateEnd} 326 export StandAlone=false 327 export RESOL_ATM=${RESOL_ATM} 328 export RESOL_OCE=${RESOL_OCE} 329 export RESOL_ICE=${RESOL_ICE} 330 export RESOL_SRF=${RESOL_SRF} 331 export listVarEnv=${listVarEnv} 332 . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh 333 . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh 334 IGCM_sys_MkdirWork ${POST_DIR} 335 IGCM_debug_Verif_Exit 336 IGCM_sys_QsubPost create_ts 337 EOF 338 # 339 fi 340 fi 341 342 #============= SEASONAL POST-TREATMENT ============# 343 if [ ${SeasonalFrequency} = true ] ; then 344 # 345 IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :" 346 echo 347 # 348 typeset listVarEnv 349 listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF" 350 351 if [ ${RebuildFrequency} = true ] ; then 352 # 353 echo IGCM_sys_QsubPost create_se >> ${RUN_DIR}/REBUILD_${PeriodDateBegin}/rebuild.ksh 354 # 355 else 356 # 357 IGCM_sys_RshPost <<-EOF 358 export MODIPSL=${MODIPSL} 359 export libIGCM_SX=${libIGCM} 360 export libIGCM=${libIGCM_POST} 361 export SUBMIT_DIR=${SUBMIT_DIR} 362 export POST_DIR=${POST_DIR} 363 export DateBegin=${DateBegin} 364 export PeriodDateEnd=${PeriodDateEnd} 365 export StandAlone=false 366 export RESOL_ATM=${RESOL_ATM} 367 export RESOL_OCE=${RESOL_OCE} 368 export RESOL_ICE=${RESOL_ICE} 369 export RESOL_SRF=${RESOL_SRF} 370 export listVarEnv=${listVarEnv} 371 . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh 372 . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh 373 IGCM_sys_MkdirWork ${POST_DIR} 374 IGCM_debug_Verif_Exit 375 IGCM_sys_QsubPost create_se 376 EOF 377 # 378 fi 379 fi 178 380 179 381 #============== REBUILD POST-TREATMENT =============# … … 183 385 echo 184 386 # 185 # BUILD A PACKED LIST FOR POST-TREATMENT JOB186 # BECAUSE IT'S NOT POSSIBLE TO DEFINE DYNAMICAL187 # VARIABLE NAME THROUGHT RSH !!188 #189 LISTE_PACK=" "190 #191 fi192 193 #============ TIME SERIES POST-TREATMENT ===========#194 if [ ${TimeSeriesFrequency} = true ] ; then195 196 IGCM_debug_Print 2 "TIME SERIES POST-TREATMENT :"197 echo198 #199 387 typeset listVarEnv 200 listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR, POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"388 listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,RUN_DIR,POST_DIR,DateBegin,PeriodDateBegin,PeriodDateEnd,NbRebuildDir,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF" 201 389 IGCM_sys_RshPost <<-EOF 202 390 export MODIPSL=${MODIPSL} … … 204 392 export libIGCM=${libIGCM_POST} 205 393 export SUBMIT_DIR=${SUBMIT_DIR} 394 export RUN_DIR=${RUN_DIR} 206 395 export POST_DIR=${POST_DIR} 207 396 export DateBegin=${DateBegin} 397 export PeriodDateBegin=${PeriodDateBegin} 208 398 export PeriodDateEnd=${PeriodDateEnd} 399 export NbRebuildDir=${NbRebuildDir} 209 400 export StandAlone=false 210 401 export RESOL_ATM=${RESOL_ATM} … … 217 408 IGCM_sys_MkdirWork ${POST_DIR} 218 409 IGCM_debug_Verif_Exit 219 IGCM_sys_QsubPost create_ts410 IGCM_sys_QsubPost rebuild 220 411 EOF 221 412 fi 222 413 223 #============= SEASONAL POST-TREATMENT ============#224 if [ ${SeasonalFrequency} = true ] ; then225 #226 IGCM_debug_Print 2 "SEASONNAL POST-TREATMENT :"227 echo228 #229 typeset listVarEnv230 listVarEnv="MODIPSL,libIGCM,libIGCM_SX,SUBMIT_DIR,POST_DIR,DateBegin,PeriodDateEnd,StandAlone,RESOL_ATM,RESOL_OCE,RESOL_ICE,RESOL_SRF"231 IGCM_sys_RshPost <<-EOF232 export MODIPSL=${MODIPSL}233 export SUBMIT_DIR=${SUBMIT_DIR}234 export libIGCM_SX=${libIGCM}235 export libIGCM=${libIGCM_POST}236 export SUBMIT_DIR=${SUBMIT_DIR}237 export POST_DIR=${POST_DIR}238 export DateBegin=${DateBegin}239 export PeriodDateEnd=${PeriodDateEnd}240 export StandAlone=false241 export RESOL_ATM=${RESOL_ATM}242 export RESOL_OCE=${RESOL_OCE}243 export RESOL_ICE=${RESOL_ICE}244 export RESOL_SRF=${RESOL_SRF}245 export listVarEnv=${listVarEnv}246 . ${libIGCM_POST}/libIGCM_debug/libIGCM_debug.ksh247 . ${libIGCM_POST}/libIGCM_sys/libIGCM_sys.ksh248 IGCM_sys_MkdirWork ${POST_DIR}249 IGCM_debug_Verif_Exit250 IGCM_sys_QsubPost create_se251 EOF252 fi253 254 414 IGCM_debug_PopStack "IGCM_post_Submit" 255 415 } 256 257 -
/trunk/libIGCM/libIGCM_sys/libIGCM_sys_platine.ksh
r20 r30 135 135 if [ $LSB_QUEUE == post ] ; then 136 136 typeset -r RUN_DIR_PATH=${SCRATCHDIR}/tmp$$ 137 if [ ! -d ${RUN_DIR_PATH} ]; then 138 \mkdir -p ${RUN_DIR_PATH} 139 if [ $? -gt 0 ] ; then 140 echo "Error in creation of "${RUN_DIR_PATH} 141 fi 142 fi 137 143 fi 138 144 139 145 #==================================================== 140 146 #- HOST_MPIRUN_COMMAND 141 typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:=" srun"}147 typeset -r HOST_MPIRUN_COMMAND=${HOST_MPIRUN_COMMAND:="time srun"} 142 148 143 149 #D-#================================================== … … 1252 1258 echo "IGCM_sys_rebuild :" $@ 1253 1259 fi 1254 /home/cont003/p86ipsl/ bin/platine/rebuild -f -o $@1260 /home/cont003/p86ipsl/IA64/bin/rebuild -f -o $@ 1255 1261 if [ $? -gt 0 ] ; then 1256 1262 echo "IGCM_sys_rebuild : erreur ${@}." -
/trunk/libIGCM/run.card.init
r20 r30 20 20 [PostProcessing] 21 21 # postraitements state == .date 22 PostState = Start23 22 24 MonitoringRunning=n 25 MonitoringCompleted= 23 #RebuildRunning=y/n 24 #RebuildToComplete=number of dir to rebuild 25 #RebuildDateID=PeriodDateEnd correspondant au dernier flag de RebuildFrequency=true 26 26 27 27 TimeSeriesRunning=n … … 29 29 30 30 SeasonalRunning=n 31 SeasonalCompleted=32 31 33 32 # machine time == .log
Note: See TracChangeset
for help on using the changeset viewer.