libsim Versione 7.1.11

◆ volgrid6d_compute_stat_proc_agg()

subroutine volgrid6d_compute_stat_proc_agg ( type(volgrid6d), intent(inout)  this,
type(volgrid6d), intent(out)  that,
integer, intent(in)  stat_proc,
type(timedelta), intent(in)  step,
type(datetime), intent(in), optional  start,
logical, intent(in), optional  full_steps,
type(timedelta), intent(in), optional  max_step,
logical, intent(in), optional  clone 
)

Method for statistically processing a set of instantaneous data.

This method performs statistical processing by aggregation of instantaneous data.

The output that volgrid6d object contains elements from the original volume this satisfying the conditions

Output data will have timerange of type stat_proc, and p2 = step. The supported statistical processing methods (parameter stat_proc) are:

  • 0 average
  • 2 maximum
  • 3 minimum
  • 4 difference

A maximum distance in time for input valid data can be assigned with the optional argument max_step, in order to filter datasets with too long "holes".

Parametri
[in,out]thisvolume providing data to be recomputed, it is not modified by the method, apart from performing a volgrid6d_alloc_vol on it
[out]thatoutput volume which will contain the recomputed data
[in]stat_proctype of statistical processing to be recomputed (from grib2 table), only data having timerange of this type will be recomputed and will appear in the output volume
[in]steplength of the step over which the statistical processing is performed
[in]startstart of statistical processing interval
[in]full_stepsif .TRUE. and start is not provided, apply processing only on intervals starting at a forecast time or a reference time modulo step
[in]max_stepmaximum allowed distance in time between two contiguougs valid data within an interval, for the interval to be eligible for statistical processing
[in]cloneif provided and .TRUE. , clone the gaid's from this to that

Definizione alla linea 588 del file volgrid6d_class_compute.F90.

590lclone = optio_log(clone) .OR. .NOT.ASSOCIATED(this%voldati)
591! initialise the output volume
592CALL init(that, griddim=this%griddim, time_definition=this%time_definition)
593CALL volgrid6d_alloc(that, dim=this%griddim%dim, &
594 nlevel=SIZE(this%level), nvar=SIZE(this%var), ini=.false.)
595that%level = this%level
596that%var = this%var
597
598! compute length of cumulation step in seconds
599CALL getval(step, asec=steps)
600
601! compute the statistical processing relations, output time and
602! timerange are defined here
603CALL recompute_stat_proc_diff_common(this%time, this%timerange, stat_proc, step, &
604 that%time, that%timerange, map_tr, f, keep_tr, &
605 this%time_definition, full_steps, start)
606nitr = SIZE(f)
607
608! complete the definition of the output volume
609CALL volgrid6d_alloc_vol(that, decode=ASSOCIATED(this%voldati))
610! allocate workspace once
611IF (.NOT.ASSOCIATED(that%voldati)) THEN
612 ALLOCATE(voldatiin1(this%griddim%dim%nx, this%griddim%dim%ny), &
613 voldatiin2(this%griddim%dim%nx, this%griddim%dim%ny), &
614 voldatiout(this%griddim%dim%nx, this%griddim%dim%ny))
615ENDIF
616
617! copy the timeranges already satisfying the requested step, if any
618DO i4 = 1, SIZE(this%time)
619 DO i = 1, nitr
620 IF (c_e(keep_tr(i, i4, 2))) THEN
621 l = keep_tr(i, i4, 1)
622 k = keep_tr(i, i4, 2)
623#ifdef DEBUG
624 CALL l4f_category_log(this%category, l4f_debug, &
625 'volgrid6d_recompute_stat_proc_diff, good timerange: '//t2c(f(i))// &
626 '->'//t2c(k))
627#endif
628 DO i6 = 1, SIZE(this%var)
629 DO i3 = 1, SIZE(this%level)
630 IF (c_e(this%gaid(i3,i4,f(i),i6))) THEN
631 IF (lclone) THEN
632 CALL copy(this%gaid(i3,i4,f(i),i6), that%gaid(i3,l,k,i6))
633 ELSE
634 that%gaid(i3,l,k,i6) = this%gaid(i3,i4,f(i),i6)
635 ENDIF
636 IF (ASSOCIATED(that%voldati)) THEN
637 that%voldati(:,:,i3,l,k,i6) = this%voldati(:,:,i3,i4,f(i),i6)
638 ELSE
639 CALL volgrid_get_vol_2d(this, i3, i4, f(i), i6, voldatiout)
640 CALL volgrid_set_vol_2d(that, i3, l, k, i6, voldatiout)
641 ENDIF
642 ENDIF
643 ENDDO
644 ENDDO
645 ENDIF
646 ENDDO
647ENDDO
648
649! varbufr required for setting posdef, optimize with an array
650ALLOCATE(varbufr(SIZE(this%var)))
651DO i6 = 1, SIZE(this%var)
652 varbufr(i6) = convert(this%var(i6))
653ENDDO
654! compute statistical processing
655DO l = 1, SIZE(this%time)
656 DO k = 1, nitr
657 DO j = 1, SIZE(this%time)
658 DO i = 1, nitr
659 IF (c_e(map_tr(i,j,k,l,1))) THEN
660 DO i6 = 1, SIZE(this%var)
661 DO i3 = 1, SIZE(this%level)
662
663 IF (c_e(this%gaid(i3,j,f(i),i6)) .AND. &
664 c_e(this%gaid(i3,l,f(k),i6))) THEN
665! take the gaid from the second time/timerange contributing to the
666! result (l,f(k))
667 IF (lclone) THEN
668 CALL copy(this%gaid(i3,l,f(k),i6), &
669 that%gaid(i3,map_tr(i,j,k,l,1),map_tr(i,j,k,l,2),i6))
670 ELSE
671 that%gaid(i3,map_tr(i,j,k,l,1),map_tr(i,j,k,l,2),i6) = &
672 this%gaid(i3,l,f(k),i6)
673 ENDIF
674
675! get/set 2d sections API is used
676 CALL volgrid_get_vol_2d(this, i3, l, f(k), i6, voldatiin1)
677 CALL volgrid_get_vol_2d(this, i3, j, f(i), i6, voldatiin2)
678 IF (ASSOCIATED(that%voldati)) &
679 CALL volgrid_get_vol_2d(that, i3, &
680 map_tr(i,j,k,l,1), map_tr(i,j,k,l,2), i6, voldatiout)
681
682 IF (stat_proc == 0) THEN ! average
683 WHERE(c_e(voldatiin1(:,:)) .AND. c_e(voldatiin2(:,:)))
684 voldatiout(:,:) = &
685 (voldatiin1(:,:)*this%timerange(f(k))%p2 - &
686 voldatiin2(:,:)*this%timerange(f(i))%p2)/ &
687 steps
688 ELSEWHERE
689 voldatiout(:,:) = rmiss
690 END WHERE
691 ELSE IF (stat_proc == 1 .OR. stat_proc == 4) THEN ! acc, diff
692 WHERE(c_e(voldatiin1(:,:)) .AND. c_e(voldatiin2(:,:)))
693 voldatiout(:,:) = voldatiin1(:,:) - voldatiin2(:,:)
694 ELSEWHERE
695 voldatiout(:,:) = rmiss
696 END WHERE
697 IF (stat_proc == 1) THEN
698 CALL vol7d_var_features_posdef_apply(varbufr(i6), voldatiout)
699 ENDIF
700 ENDIF
701
702 CALL volgrid_set_vol_2d(that, i3, &
703 map_tr(i,j,k,l,1), map_tr(i,j,k,l,2), i6, voldatiout)
704
705 ENDIF
706 ENDDO
707 ENDDO
708 ENDIF
709 ENDDO
710 ENDDO
711 ENDDO
712ENDDO
713
714IF (.NOT.ASSOCIATED(that%voldati)) THEN
715 DEALLOCATE(voldatiin1, voldatiin2, voldatiout)
716ENDIF
717
718END SUBROUTINE volgrid6d_recompute_stat_proc_diff
719
720

Generated with Doxygen.