- Timestamp:
- 11/03/08 19:02:57 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/AA_create_ts
r18 r29 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}
Note: See TracChangeset
for help on using the changeset viewer.