libsim Versione 8.0.0

◆ v7d_v7d_transform()

subroutine v7d_v7d_transform ( type(transform_def), intent(in) this,
type(vol7d), intent(inout) vol7d_in,
type(vol7d), intent(out) vol7d_out,
type(vol7d), intent(in), optional v7d,
real, dimension(:), intent(in), optional maskbounds,
type(vol7d_level), dimension(:), intent(in), optional, target lev_out,
type(vol7d), intent(in), optional vol7d_coord_in,
character(len=*), intent(in), optional categoryappend )
private

Performs the specified abstract transformation on the data provided.

The abstract transformation is specified by this parameter; the corresponding specifical transformation (grid_transform object) is created and destroyed internally. The output transformed object is created internally and it does not require preliminary initialisation. The success of the transformation can be checked with the c_e method: c_e(vol7d_out).

Parametri
[in]thisobject specifying the abstract transformation
[in,out]vol7d_inobject to be transformed, it is not modified, despite the INTENT(inout)
[out]vol7d_outtransformed object, it does not require initialisation
[in]v7dobject containing a list of points over which transformation has to be done (required by some transformation types)
[in]maskboundsarray of boundary values for defining a subset of valid points where the values of maskgrid are within the first and last value of maskbounds (for transformation type 'metamorphosis:maskfill')
[in]lev_outvol7d_level object defining target vertical grid, for vertical interpolations
[in]vol7d_coord_inobject providing time constant input vertical coordinate for some kind of vertical interpolations
[in]categoryappendappend this suffix to log4fortran namespace category

Definizione alla linea 2774 del file volgrid6d_class.F90.

2776
2777 CALL get_val(grid_trans, point_mask=point_mask, output_point_index=point_index)
2778
2779 IF (ALLOCATED(point_index)) THEN
2780 CALL vol7d_alloc(vol7d_out, nanavari=1)
2781 CALL init(vol7d_out%anavar%i(1), 'B01192')
2782 ENDIF
2783
2784 CALL vol7d_alloc_vol(vol7d_out)
2785
2786 IF (ALLOCATED(point_index)) THEN
2787 DO inetwork = 1, SIZE(vol7d_in%network)
2788 vol7d_out%volanai(:,1,inetwork) = point_index(:)
2789 ENDDO
2790 ENDIF
2791 CALL compute(grid_trans, vol7d_in, vol7d_out)
2792
2793 IF (ALLOCATED(point_mask)) THEN ! keep full ana
2794 IF (SIZE(point_mask) /= SIZE(vol7d_in%ana)) THEN
2795 CALL l4f_log(l4f_warn, &
2796 'v7d_v7d_transform: inconsistency in point size: '//t2c(SIZE(point_mask)) &
2797 //':'//t2c(SIZE(vol7d_in%ana)))
2798 ELSE
2799#ifdef DEBUG
2800 CALL l4f_log(l4f_debug, 'v7d_v7d_transform: merging ana from in to out')
2801#endif
2802 CALL vol7d_copy(vol7d_in, vol7d_tmpana, &
2803 lana=point_mask, lnetwork=(/.true./), &
2804 ltime=(/.false./), ltimerange=(/.false./), llevel=(/.false./))
2805 CALL vol7d_append(vol7d_out, vol7d_tmpana)
2806 ENDIF
2807 ENDIF
2808
2809 ELSE
2810 CALL l4f_log(l4f_error, 'v7d_v7d_transform: transformation not valid')
2811 CALL raise_error()
2812 ENDIF
2813
2814ENDIF
2815
2816CALL delete (grid_trans)
2817IF (.NOT. PRESENT(v7d)) CALL delete(v7d_locana)
2818
2819END SUBROUTINE v7d_v7d_transform
2820
2821
2822!> Unrotate the wind components.
2823!! It converts u and v components of vector quantities relative to the
2824!! defined grid in the direction of increasing x and y coordinates to
2825!! u and v components relative to easterly and notherly direction. The
2826!! original fields are overwritten.
2827!! \todo Check and correct wind component flag (to be moved in
2828!! griddim_def?)
2829subroutine vg6d_wind_unrot(this)
2830type(volgrid6d) :: this !< object containing wind to be unrotated
2831
2832integer :: component_flag
2833
2834call get_val(this%griddim,component_flag=component_flag)
2835
2836if (component_flag == 1) then
2837 call l4f_category_log(this%category,l4f_info, &
2838 "unrotating vector components")
2839 call vg6d_wind__un_rot(this,.false.)
2840 call set_val(this%griddim,component_flag=0)
2841else
2842 call l4f_category_log(this%category,l4f_info, &
2843 "no need to unrotate vector components")
2844end if
2845
2846end subroutine vg6d_wind_unrot
2847
2848
2849!> Rotate the wind components.
2850!! It converts u and v components of vector quantities
2851!! relative to easterly and notherly direction to
2852!! defined grid in the direction of increasing x and y coordinates.
2853!! The original fields are overwritten.
2854subroutine vg6d_wind_rot(this)
2855type(volgrid6d) :: this !< object containing wind to be rotated
2856
2857integer :: component_flag
2858
2859call get_val(this%griddim,component_flag=component_flag)
2860
2861if (component_flag == 0) then
2862 call l4f_category_log(this%category,l4f_info, &
2863 "rotating vector components")
2864 call vg6d_wind__un_rot(this,.true.)
2865 call set_val(this%griddim,component_flag=1)
2866else
2867 call l4f_category_log(this%category,l4f_info, &
2868 "no need to rotate vector components")
2869end if
2870
2871end subroutine vg6d_wind_rot
2872
2873
2874! Generic UnRotate the wind components.
2875SUBROUTINE vg6d_wind__un_rot(this,rot)
2876TYPE(volgrid6d) :: this ! object containing wind to be (un)rotated
2877LOGICAL :: rot ! if .true. rotate else unrotate
2878
2879INTEGER :: i, j, k, l, a11, a12, a21, a22, stallo
2880double precision,pointer :: rot_mat(:,:,:)
2881real,allocatable :: tmp_arr(:,:)
2882REAL,POINTER :: voldatiu(:,:), voldativ(:,:)
2883INTEGER,POINTER :: iu(:), iv(:)
2884
2885IF (.NOT.ASSOCIATED(this%var)) THEN
2886 CALL l4f_category_log(this%category, l4f_error, &
2887 "trying to unrotate an incomplete volgrid6d object")
2888 CALL raise_fatal_error()
2889! RETURN
2890ENDIF
2891
2892CALL volgrid6d_var_hor_comp_index(this%var, iu, iv)
2893IF (.NOT.ASSOCIATED(iu)) THEN
2894 CALL l4f_category_log(this%category,l4f_error, &
2895 "unrotation impossible")
2896 CALL raise_fatal_error()
2897! RETURN
2898ENDIF
2899
2900! Temporary workspace
2901ALLOCATE(tmp_arr(this%griddim%dim%nx, this%griddim%dim%ny),stat=stallo)
2902IF (stallo /= 0) THEN
2903 CALL l4f_category_log(this%category, l4f_fatal, "allocating memory")
2904 CALL raise_fatal_error()
2905ENDIF
2906! allocate once for speed
2907IF (.NOT.ASSOCIATED(this%voldati)) THEN
2908 ALLOCATE(voldatiu(this%griddim%dim%nx, this%griddim%dim%ny), &
2909 voldativ(this%griddim%dim%nx, this%griddim%dim%ny))
2910ENDIF
2911
2912CALL griddim_unproj(this%griddim)
2913CALL wind_unrot(this%griddim, rot_mat)
2914
2915a11=1
2916if (rot)then
2917 a12=2
2918 a21=3
2919else
2920 a12=3
2921 a21=2
2922end if
2923a22=4
2924
2925DO l = 1, SIZE(iu)
2926 DO k = 1, SIZE(this%timerange)
2927 DO j = 1, SIZE(this%time)
2928 DO i = 1, SIZE(this%level)
2929! get data
2930 CALL volgrid_get_vol_2d(this, i, j, k, iu(l), voldatiu)
2931 CALL volgrid_get_vol_2d(this, i, j, k, iv(l), voldativ)
2932! convert units forward
2933! CALL compute(conv_fwd(iu(l)), voldatiu)
2934! CALL compute(conv_fwd(iv(l)), voldativ)
2935
2936! multiply wind components by rotation matrix
2937 WHERE(voldatiu /= rmiss .AND. voldativ /= rmiss)
2938 tmp_arr(:,:) = real(voldatiu(:,:)*rot_mat(:,:,a11) + &
2939 voldativ(:,:)*rot_mat(:,:,a12))
2940 voldativ(:,:) = real(voldatiu(:,:)*rot_mat(:,:,a21) + &
2941 voldativ(:,:)*rot_mat(:,:,a22))
2942 voldatiu(:,:) = tmp_arr(:,:)
2943 END WHERE
2944! convert units backward
2945! CALL uncompute(conv_fwd(iu(l)), voldatiu)
2946! CALL uncompute(conv_fwd(iv(l)), voldativ)
2947! put data
2948 CALL volgrid_set_vol_2d(this, i, j, k, iu(l), voldatiu)
2949 CALL volgrid_set_vol_2d(this, i, j, k, iv(l), voldativ)
2950 ENDDO
2951 ENDDO
2952 ENDDO
2953ENDDO
2954
2955IF (.NOT.ASSOCIATED(this%voldati)) THEN
2956 DEALLOCATE(voldatiu, voldativ)
2957ENDIF
2958DEALLOCATE(rot_mat, tmp_arr, iu, iv)
2959
2960END SUBROUTINE vg6d_wind__un_rot
2961
2962
2963!!$ try to understand the problem:
2964!!$
2965!!$ case:
2966!!$
2967!!$ 1) we have only one volume: we have to provide the direction of shift
2968!!$ compute H and traslate on it
2969!!$ 2) we have two volumes:
2970!!$ 1) volume U and volume V: compute H and traslate on it
2971!!$ 2) volume U/V and volume H : translate U/V on H
2972!!$ 3) we have tree volumes: translate U and V on H
2973!!$
2974!!$ strange cases:
2975!!$ 1) do not have U in volume U
2976!!$ 2) do not have V in volume V
2977!!$ 3) we have others variables more than U and V in volumes U e V
2978!!$
2979!!$
2980!!$ so the steps are:
2981!!$ 1) find the volumes
2982!!$ 2) define or compute H grid
2983!!$ 3) trasform the volumes in H
2984
2985!!$ N.B.
2986!!$ case 1) for only one vg6d (U or V) is not managed, but
2987!!$ the not pubblic subroutines will work but you have to know what you want to do
2988
2989
2990!> Convert grids type C to type A.
2991!! Use this to interpolate data from grid type C to grid type A
2992!! Grids type are defined by Arakawa.
2993!!
2994!! We need to find these types of area in a vg6d array
2995!! T area of points with temterature etc.
2996!! U area of points with u components of winds
2997!! V area of points with v components of winds
2998!!
2999!! this method works if it finds
3000!! two volumes:
3001!! 1) volume U and volume V: compute H and traslate on it
3002!! 2) volume U/V and volume H : translate U/V on H
3003!! three volumes: translate U and V on H
3004!!
3005!! try to work well on more datasets at once
3006subroutine vg6d_c2a (this)

Generated with Doxygen.