520 class(TimeArraySeriesType),
intent(inout) :: this
521 integer(I4B),
intent(in) :: nvals
522 real(DP),
dimension(nvals),
intent(inout) :: values
523 real(DP),
intent(in) :: time0
524 real(DP),
intent(in) :: time1
527 real(DP) :: area, currTime, nextTime, ratio0, ratio1, t0, &
528 t01, t1, timediff,
value, value0, value1, valuediff
530 type(ListNodeType),
pointer :: precNode => null()
531 type(ListNodeType),
pointer :: currNode => null(), nextnode => null()
532 type(TimeArrayType),
pointer :: currRecord => null(), nextrecord => null()
533 class(*),
pointer :: currObj => null(), nextobj => null()
535 10
format(
'Error encountered while performing integration', &
536 ' for time-array series "', a,
'" for time interval: ', &
537 g12.5,
' to ', g12.5)
543 call this%get_latest_preceding_node(time0, precnode)
544 if (
associated(precnode))
then
546 do while (.not. ldone)
547 currobj => currnode%GetItem()
548 currrecord => castastimearraytype(currobj)
549 currtime = currrecord%taTime
550 if (currtime < time1)
then
551 if (.not.
associated(currnode%nextNode))
then
553 if (.not. this%read_next_array())
then
554 write (errmsg, 10) trim(this%Name), time0, time1
555 call store_error(errmsg)
556 call store_error_unit(this%inunit)
559 if (
associated(currnode%nextNode))
then
560 nextnode => currnode%nextNode
561 nextobj => nextnode%GetItem()
562 nextrecord => castastimearraytype(nextobj)
563 nexttime = nextrecord%taTime
566 if (currtime >= time0)
then
571 if (nexttime <= time1)
then
579 select case (this%iMethod)
583 value0 = currrecord%taArray(i)
586 values(i) = values(i) + area
591 timediff = nexttime - currtime
592 ratio0 = (t0 - currtime) / timediff
593 ratio1 = (t1 - currtime) / timediff
594 valuediff = nextrecord%taArray(i) - currrecord%taArray(i)
595 value0 = currrecord%taArray(i) + ratio0 * valuediff
596 value1 = currrecord%taArray(i) + ratio1 * valuediff
597 area = 0.5d0 * t01 * (value0 + value1)
599 values(i) = values(i) + area
603 write (errmsg, 10) trim(this%Name), time0, time1
604 call store_error(errmsg)
605 call store_error(
'(Probable programming error)', terminate=.true.)
613 if (t1 >= time1)
then
616 if (.not.
associated(currnode%nextNode))
then
618 if (.not. this%read_next_array())
then
619 write (errmsg, 10) trim(this%Name), time0, time1
620 call store_error(errmsg)
621 call this%parser%StoreErrorUnit()
624 if (
associated(currnode%nextNode))
then
625 currnode => currnode%nextNode
627 write (errmsg, 10) trim(this%Name), time0, time1
628 call store_error(errmsg)
629 call store_error(
'(Probable programming error)', terminate=.true.)
635 if (this%autoDeallocate)
then
636 if (
associated(precnode))
then
637 if (
associated(precnode%prevNode))
then
638 call this%DeallocateBackward(precnode%prevNode)