502 class(TimeArraySeriesType),
intent(inout) :: this
503 integer(I4B),
intent(in) :: nvals
504 real(DP),
dimension(nvals),
intent(inout) :: values
505 real(DP),
intent(in) :: time0
506 real(DP),
intent(in) :: time1
509 real(DP) :: area, currTime, nextTime, ratio0, ratio1, t0, &
510 t01, t1, timediff,
value, value0, value1, valuediff
512 type(ListNodeType),
pointer :: precNode => null()
513 type(ListNodeType),
pointer :: currNode => null(), nextnode => null()
514 type(TimeArrayType),
pointer :: currRecord => null(), nextrecord => null()
515 class(*),
pointer :: currObj => null(), nextobj => null()
517 10
format(
'Error encountered while performing integration', &
518 ' for time-array series "', a,
'" for time interval: ', &
519 g12.5,
' to ', g12.5)
525 call this%get_latest_preceding_node(time0, precnode)
526 if (
associated(precnode))
then
528 do while (.not. ldone)
529 currobj => currnode%GetItem()
530 currrecord => castastimearraytype(currobj)
531 currtime = currrecord%taTime
532 if (currtime < time1)
then
533 if (.not.
associated(currnode%nextNode))
then
535 if (.not. this%read_next_array())
then
536 write (errmsg, 10) trim(this%Name), time0, time1
537 call store_error(errmsg)
538 call store_error_unit(this%inunit)
541 if (
associated(currnode%nextNode))
then
542 nextnode => currnode%nextNode
543 nextobj => nextnode%GetItem()
544 nextrecord => castastimearraytype(nextobj)
545 nexttime = nextrecord%taTime
548 if (currtime >= time0)
then
553 if (nexttime <= time1)
then
561 select case (this%iMethod)
565 value0 = currrecord%taArray(i)
568 values(i) = values(i) + area
573 timediff = nexttime - currtime
574 ratio0 = (t0 - currtime) / timediff
575 ratio1 = (t1 - currtime) / timediff
576 valuediff = nextrecord%taArray(i) - currrecord%taArray(i)
577 value0 = currrecord%taArray(i) + ratio0 * valuediff
578 value1 = currrecord%taArray(i) + ratio1 * valuediff
579 area = 0.5d0 * t01 * (value0 + value1)
581 values(i) = values(i) + area
585 write (errmsg, 10) trim(this%Name), time0, time1
586 call store_error(errmsg)
587 call store_error(
'(Probable programming error)', terminate=.true.)
595 if (t1 >= time1)
then
598 if (.not.
associated(currnode%nextNode))
then
600 if (.not. this%read_next_array())
then
601 write (errmsg, 10) trim(this%Name), time0, time1
602 call store_error(errmsg)
603 call this%parser%StoreErrorUnit()
606 if (
associated(currnode%nextNode))
then
607 currnode => currnode%nextNode
609 write (errmsg, 10) trim(this%Name), time0, time1
610 call store_error(errmsg)
611 call store_error(
'(Probable programming error)', terminate=.true.)
617 if (this%autoDeallocate)
then
618 if (
associated(precnode))
then
619 if (
associated(precnode%prevNode))
then
620 call this%DeallocateBackward(precnode%prevNode)