libsim  Versione6.3.0

◆ vg6d_c2a()

subroutine, public volgrid6d_class::vg6d_c2a ( type(volgrid6d), dimension(:), intent(inout)  this)

Convert grids type C to type A.

Use this to interpolate data from grid type C to grid type A Grids type are defined by Arakawa.

We need to find these types of area in a vg6d array T area of points with temterature etc. U area of points with u components of winds V area of points with v components of winds

this method works if it finds two volumes: 1) volume U and volume V: compute H and traslate on it 2) volume U/V and volume H : translate U/V on H three volumes: translate U and V on H

try to work well on more datasets at once

Parametri
[in,out]thisvettor of volumes volgrid6d to elaborate

Definizione alla linea 3156 del file volgrid6d_class.F90.

3156 
3157 
3158 call griddim_unproj(this%griddim)
3159 
3160 
3161 end subroutine vg6d_c2a_grid
3162 
3163 ! Convert C grid to A grid
3164 subroutine vg6d_c2a_mat(this,cgrid)
3165 
3166 type(volgrid6d),intent(inout) :: this ! object containing fields to be translated
3167 integer,intent(in) :: cgrid ! in C grid (Arakawa) we have 0=T,1=U,2=V points
3168 
3169 INTEGER :: i, j, k, iv, stallo
3170 REAL,ALLOCATABLE :: tmp_arr(:,:)
3171 REAL,POINTER :: voldatiuv(:,:)
3172 
3173 
3174 IF (cgrid == 0) RETURN ! nothing to do
3175 IF (cgrid /= 1 .AND. cgrid /= 2) THEN ! wrong cgrid
3176  CALL l4f_category_log(this%category,l4f_fatal,"C grid type "// &
3177  trim(to_char(cgrid))//" not known")
3178  CALL raise_error()
3179  RETURN
3180 ENDIF
3181 
3182 ! Temporary workspace
3183 ALLOCATE(tmp_arr(this%griddim%dim%nx, this%griddim%dim%ny),stat=stallo)
3184 if (stallo /=0)then
3185  call l4f_log(l4f_fatal,"allocating memory")
3186  call raise_fatal_error()
3187 end if
3188 
3189 ! allocate once for speed
3190 IF (.NOT.ASSOCIATED(this%voldati)) THEN
3191  ALLOCATE(voldatiuv(this%griddim%dim%nx, this%griddim%dim%ny), stat=stallo)
3192  IF (stallo /= 0) THEN
3193  CALL l4f_log(l4f_fatal,"allocating memory")
3194  CALL raise_fatal_error()
3195  ENDIF
3196 ENDIF
3197 
3198 IF (cgrid == 1) THEN ! U points to H points
3199  DO iv = 1, SIZE(this%var)
3200  DO k = 1, SIZE(this%timerange)
3201  DO j = 1, SIZE(this%time)
3202  DO i = 1, SIZE(this%level)
3203  tmp_arr(:,:) = rmiss
3204  CALL volgrid_get_vol_2d(this, i, j, k, iv, voldatiuv)
3205 
3206 ! West boundary extrapolation
3207  WHERE(voldatiuv(1,:) /= rmiss .AND. voldatiuv(2,:) /= rmiss)
3208  tmp_arr(1,:) = voldatiuv(1,:) - (voldatiuv(2,:) - voldatiuv(1,:)) / 2.
3209  END WHERE
3210 
3211 ! Rest of the field
3212  WHERE(voldatiuv(1:this%griddim%dim%nx-1,:) /= rmiss .AND. &
3213  voldatiuv(2:this%griddim%dim%nx,:) /= rmiss)
3214  tmp_arr(2:this%griddim%dim%nx,:) = &
3215  (voldatiuv(1:this%griddim%dim%nx-1,:) + &
3216  voldatiuv(2:this%griddim%dim%nx,:)) / 2.
3217  END WHERE
3218 
3219  voldatiuv(:,:) = tmp_arr
3220  CALL volgrid_set_vol_2d(this, i, j, k, iv, voldatiuv)
3221  ENDDO
3222  ENDDO
3223  ENDDO
3224  ENDDO
3225 
3226 ELSE IF (cgrid == 2) THEN ! V points to H points
3227  DO iv = 1, SIZE(this%var)
3228  DO k = 1, SIZE(this%timerange)
3229  DO j = 1, SIZE(this%time)
3230  DO i = 1, SIZE(this%level)
3231  tmp_arr(:,:) = rmiss
3232  CALL volgrid_get_vol_2d(this, i, j, k, iv, voldatiuv)
3233 
3234 ! South boundary extrapolation
3235  WHERE(voldatiuv(:,1) /= rmiss .AND. voldatiuv(:,2) /= rmiss)
3236  tmp_arr(:,1) = voldatiuv(:,1) - (voldatiuv(:,2) - voldatiuv(:,1)) / 2.
3237  END WHERE
3238 
3239 ! Rest of the field
3240  WHERE(voldatiuv(:,1:this%griddim%dim%ny-1) /= rmiss .AND. &
3241  voldatiuv(:,2:this%griddim%dim%ny) /= rmiss)
3242  tmp_arr(:,2:this%griddim%dim%ny) = &
3243  (voldatiuv(:,1:this%griddim%dim%ny-1) + &
3244  voldatiuv(:,2:this%griddim%dim%ny)) / 2.
3245  END WHERE
3246 
3247  voldatiuv(:,:) = tmp_arr
3248  CALL volgrid_set_vol_2d(this, i, j, k, iv, voldatiuv)
3249  ENDDO
3250  ENDDO
3251  ENDDO
3252  ENDDO
3253 ENDIF ! tertium non datur
3254 
3255 IF (.NOT.ASSOCIATED(this%voldati)) THEN
3256  DEALLOCATE(voldatiuv)
3257 ENDIF
3258 DEALLOCATE (tmp_arr)
3259 
3260 end subroutine vg6d_c2a_mat
3261 
3262 
3266 subroutine display_volgrid6d (this)
3267 
3268 TYPE(volgrid6d),intent(in) :: this
3269 integer :: i
3270 
3271 #ifdef DEBUG
3272 call l4f_category_log(this%category,L4F_DEBUG,"ora mostro gridinfo " )
3273 #endif
3274 
3275 print*,"----------------------- volgrid6d display ---------------------"
3276 call display(this%griddim)
3277 
3278 IF (ASSOCIATED(this%time))then
3279  print*,"---- time vector ----"
Restituiscono il valore dell'oggetto in forma di stringa stampabile.

Generated with Doxygen.