libsim Versione 8.0.0

◆ volgrid6d_recompute_stat_proc_diff()

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

Specialized method for statistically processing a set of data already processed with the same statistical processing, on a different time interval.

This method performs statistical processing by difference of different intervals. Data with both analysis/observation or forecast timerange are processed.

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
  • 1 accumulation
  • 4 difference

Input volume may have any value of thistime_definition, and that value will be conserved in the output volume.

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]full_stepsif provided and .TRUE., process only data having processing interval (p2) equal to a multiple of step
[in]startif provided, together with full_steps, processes data on intervals starting at start +- an integer amount of step intervals
[in]cloneif provided and .TRUE. , clone the gaid's from this to that

Definizione alla linea 768 del file volgrid6d_class_compute.F90.

769INTEGER,POINTER :: map_tr(:)
770REAL,POINTER :: voldatiin(:,:), voldatiout(:,:)
771REAL,ALLOCATABLE :: int_ratio(:)
772LOGICAL :: lclone
773
774NULLIFY(voldatiin, voldatiout)
775
776! be safe
777CALL volgrid6d_alloc_vol(this)
778! when volume is not decoded it is better to clone anyway to avoid
779! overwriting fields
780lclone = optio_log(clone) .OR. .NOT.ASSOCIATED(this%voldati)
781
782IF (.NOT.((stat_proc_input == 0 .AND. stat_proc == 1) .OR. &
783 (stat_proc_input == 1 .AND. stat_proc == 0))) THEN
784
785 CALL l4f_category_log(this%category, l4f_warn, &
786 'compute_stat_proc_metamorph, can only be applied to average->accumulated timerange and viceversa')
787! return an empty volume, without signaling error
788 CALL init(that)
789 CALL volgrid6d_alloc_vol(that)
790 RETURN
791ENDIF
792
793! initialise the output volume
794CALL init(that, griddim=this%griddim, time_definition=this%time_definition)
795CALL volgrid6d_alloc(that, dim=this%griddim%dim, ntime=SIZE(this%time), &
796 nlevel=SIZE(this%level), nvar=SIZE(this%var), ini=.false.)
797that%time = this%time
798that%level = this%level
799that%var = this%var
800
801CALL compute_stat_proc_metamorph_common(stat_proc_input, this%timerange, stat_proc, &
802 that%timerange, map_tr)
803
804! complete the definition of the output volume
805CALL volgrid6d_alloc_vol(that, decode=ASSOCIATED(this%voldati))
806
807IF (stat_proc == 0) THEN ! average -> integral
808 int_ratio = 1./real(that%timerange(:)%p2)
809ELSE ! cumulation
810 int_ratio = real(that%timerange(:)%p2)
811ENDIF
812
813DO i6 = 1, SIZE(this%var)
814 DO j = 1, SIZE(map_tr)
815 DO i4 = 1, SIZE(that%time)
816 DO i3 = 1, SIZE(this%level)
817
818 IF (lclone) THEN
819 CALL copy(this%gaid(i3,i4,map_tr(j),i6), that%gaid(i3,i4,j,i6))
820 ELSE
821 that%gaid(i3,i4,map_tr(j),i6) = this%gaid(i3,i4,j,i6)
822 ENDIF
823 CALL volgrid_get_vol_2d(this, i3, i4, map_tr(j), i6, voldatiin)
824 CALL volgrid_get_vol_2d(that, i3, i4, j, i6, voldatiout)
825 WHERE (c_e(voldatiin))
826 voldatiout = voldatiin*int_ratio(j)
827 ELSEWHERE
828 voldatiout = rmiss
829 END WHERE
830 CALL volgrid_set_vol_2d(that, i3, i4, j, i6, voldatiout)
831 ENDDO
832 ENDDO
833 ENDDO
834ENDDO
835
836
837END SUBROUTINE volgrid6d_compute_stat_proc_metamorph
838
839!> Method for building a volume containing the vertical coordinate as
840!! a variable.
841!! This method produces a volgrid6d volume, derived from \a this,
842!! containing a single variable, horizontally constant, on the same
843!! input levels, which describes the vertical coordinate in the form
844!! of a physical variable. The grid, time and timerange metadata are
845!! the same as for the original volume. Only a single vertical level
846!! type, the one matching the \a level argument, is converted to a
847!! variable. The \a level argument can also indicate the layer between
848!! two surfaces of the same type, in that case the variable
849!! representing the vertical coordinate will be set to the value of
850!! the midpoint between the two layers. If something goes wrong,
851!! e.g. no level matches \a level argument or the level canot be
852!! converted to a physical value, an empty volume is returned.
853SUBROUTINE volgrid6d_compute_vert_coord_var(this, level, volgrid_lev)
854TYPE(volgrid6d),INTENT(in) :: this !< volume with the vertical levels
855TYPE(vol7d_level),INTENT(in) :: level !< vertical level to be converted to variable, only the type(s) of level are used not the value(s)
856TYPE(volgrid6d),INTENT(out) :: volgrid_lev !< output volume with the variable describing the vertical coordinate
857
858INTEGER :: nlev, i, ii, iii, iiii
859TYPE(grid_id) :: out_gaid
860LOGICAL,ALLOCATABLE :: levmask(:)
861TYPE(volgrid6d_var) :: lev_var
862
863CALL init(volgrid_lev) ! initialise to null
864IF (.NOT.ASSOCIATED(this%gaid)) THEN
865 CALL l4f_log(l4f_error, 'volgrid6d_compute_vert_coord_var: input volume not allocated')
866 RETURN
867ENDIF
868! if layer, both surfaces must be of the same type
869IF (c_e(level%level2) .AND. level%level1 /= level%level2) THEN
870 CALL l4f_log(l4f_error, 'volgrid6d_compute_vert_coord_var: requested (mixed) layer type not valid')
871 RETURN
872ENDIF
873
874! look for valid levels to be converted to vars
875ALLOCATE(levmask(SIZE(this%level)))
876levmask = this%level%level1 == level%level1 .AND. &
877 this%level%level2 == level%level2 .AND. c_e(this%level%l1)
878IF (c_e(level%level2)) levmask = levmask .AND. c_e(this%level%l2)
879nlev = count(levmask)
880IF (nlev == 0) THEN
881 CALL l4f_log(l4f_error, 'volgrid6d_compute_vert_coord_var: requested level type not available')
882 RETURN
883ENDIF
884
885out_gaid = grid_id_new()
886gaidloop: DO i=1 ,SIZE(this%gaid,1)
887 DO ii=1 ,SIZE(this%gaid,2)
888 DO iii=1 ,SIZE(this%gaid,3)
889 DO iiii=1 ,SIZE(this%gaid,4)
890 IF (c_e(this%gaid(i,ii,iii,iiii))) THEN ! conserve first valid gaid
891 CALL copy(this%gaid(i,ii,iii,iiii), out_gaid)
892 EXIT gaidloop
893 ENDIF
894 ENDDO
895 ENDDO
896 ENDDO
897ENDDO gaidloop
898
899! look for variable corresponding to level
900lev_var = convert(vol7d_var_new(btable=vol7d_level_to_var(level)), &
901 grid_id_template=out_gaid)
902IF (.NOT.c_e(lev_var)) THEN
903 CALL l4f_log(l4f_error, 'volgrid6d_compute_vert_coord_var: no variable corresponds to requested level type')
904 RETURN
905ENDIF
906
907! prepare output volume
908CALL init(volgrid_lev, griddim=this%griddim, &
909 time_definition=this%time_definition) !, categoryappend=categoryappend)
910CALL volgrid6d_alloc(volgrid_lev, ntime=SIZE(this%time), nlevel=nlev, &
911 ntimerange=SIZE(this%timerange), nvar=1)
912! fill metadata
913volgrid_lev%time = this%time
914volgrid_lev%level = pack(this%level, mask=levmask)
915volgrid_lev%timerange = this%timerange
916volgrid_lev%var(1) = lev_var
917
918CALL volgrid6d_alloc_vol(volgrid_lev, decode=.true.)

Generated with Doxygen.