libsim  Versione 7.2.6

◆ 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 3194 del file volgrid6d_class.F90.

3195  step_lat=(ymax-ymin)/dble(this%griddim%dim%ny-1)
3196  ymin=ymin-step_lat/2.d0
3197  ymax=ymax-step_lat/2.d0
3198  call set_val(this%griddim, ymin=ymin, ymax=ymax)
3199 ! improve grid definition precision
3200  CALL griddim_setsteps(this%griddim)
3201 
3202  case default
3203 
3204  call l4f_category_log(this%category,l4f_fatal,"C grid type not known")
3205  call raise_fatal_error ()
3206 
3207  end select
3208 
3209 end if
3210 
3211 
3212 call griddim_unproj(this%griddim)
3213 
3214 
3215 end subroutine vg6d_c2a_grid
3216 
3217 ! Convert C grid to A grid
3218 subroutine vg6d_c2a_mat(this,cgrid)
3219 
3220 type(volgrid6d),intent(inout) :: this ! object containing fields to be translated
3221 integer,intent(in) :: cgrid ! in C grid (Arakawa) we have 0=T,1=U,2=V points
3222 
3223 INTEGER :: i, j, k, iv, stallo
3224 REAL,ALLOCATABLE :: tmp_arr(:,:)
3225 REAL,POINTER :: voldatiuv(:,:)
3226 
3227 
3228 IF (cgrid == 0) RETURN ! nothing to do
3229 IF (cgrid /= 1 .AND. cgrid /= 2) THEN ! wrong cgrid
3230  CALL l4f_category_log(this%category,l4f_fatal,"C grid type "// &
3231  trim(to_char(cgrid))//" not known")
3232  CALL raise_error()
3233  RETURN
3234 ENDIF
3235 
3236 ! Temporary workspace
3237 ALLOCATE(tmp_arr(this%griddim%dim%nx, this%griddim%dim%ny),stat=stallo)
3238 if (stallo /=0)then
3239  call l4f_log(l4f_fatal,"allocating memory")
3240  call raise_fatal_error()
3241 end if
3242 
3243 ! allocate once for speed
3244 IF (.NOT.ASSOCIATED(this%voldati)) THEN
3245  ALLOCATE(voldatiuv(this%griddim%dim%nx, this%griddim%dim%ny), stat=stallo)
3246  IF (stallo /= 0) THEN
3247  CALL l4f_log(l4f_fatal,"allocating memory")
3248  CALL raise_fatal_error()
3249  ENDIF
3250 ENDIF
3251 
3252 IF (cgrid == 1) THEN ! U points to H points
3253  DO iv = 1, SIZE(this%var)
3254  DO k = 1, SIZE(this%timerange)
3255  DO j = 1, SIZE(this%time)
3256  DO i = 1, SIZE(this%level)
3257  tmp_arr(:,:) = rmiss
3258  CALL volgrid_get_vol_2d(this, i, j, k, iv, voldatiuv)
3259 
3260 ! West boundary extrapolation
3261  WHERE(voldatiuv(1,:) /= rmiss .AND. voldatiuv(2,:) /= rmiss)
3262  tmp_arr(1,:) = voldatiuv(1,:) - (voldatiuv(2,:) - voldatiuv(1,:)) / 2.
3263  END WHERE
3264 
3265 ! Rest of the field
3266  WHERE(voldatiuv(1:this%griddim%dim%nx-1,:) /= rmiss .AND. &
3267  voldatiuv(2:this%griddim%dim%nx,:) /= rmiss)
3268  tmp_arr(2:this%griddim%dim%nx,:) = &
3269  (voldatiuv(1:this%griddim%dim%nx-1,:) + &
3270  voldatiuv(2:this%griddim%dim%nx,:)) / 2.
3271  END WHERE
3272 
3273  voldatiuv(:,:) = tmp_arr
3274  CALL volgrid_set_vol_2d(this, i, j, k, iv, voldatiuv)
3275  ENDDO
3276  ENDDO
3277  ENDDO
3278  ENDDO
3279 
3280 ELSE IF (cgrid == 2) THEN ! V points to H points
3281  DO iv = 1, SIZE(this%var)
3282  DO k = 1, SIZE(this%timerange)
3283  DO j = 1, SIZE(this%time)
3284  DO i = 1, SIZE(this%level)
3285  tmp_arr(:,:) = rmiss
3286  CALL volgrid_get_vol_2d(this, i, j, k, iv, voldatiuv)
3287 
3288 ! South boundary extrapolation
3289  WHERE(voldatiuv(:,1) /= rmiss .AND. voldatiuv(:,2) /= rmiss)
3290  tmp_arr(:,1) = voldatiuv(:,1) - (voldatiuv(:,2) - voldatiuv(:,1)) / 2.
3291  END WHERE
3292 
3293 ! Rest of the field
3294  WHERE(voldatiuv(:,1:this%griddim%dim%ny-1) /= rmiss .AND. &
3295  voldatiuv(:,2:this%griddim%dim%ny) /= rmiss)
3296  tmp_arr(:,2:this%griddim%dim%ny) = &
3297  (voldatiuv(:,1:this%griddim%dim%ny-1) + &
3298  voldatiuv(:,2:this%griddim%dim%ny)) / 2.
3299  END WHERE
3300 
3301  voldatiuv(:,:) = tmp_arr
3302  CALL volgrid_set_vol_2d(this, i, j, k, iv, voldatiuv)
3303  ENDDO
3304  ENDDO
3305  ENDDO
3306  ENDDO
3307 ENDIF ! tertium non datur
3308 
3309 IF (.NOT.ASSOCIATED(this%voldati)) THEN
3310  DEALLOCATE(voldatiuv)
3311 ENDIF
3312 DEALLOCATE (tmp_arr)
3313 
3314 end subroutine vg6d_c2a_mat
3315 
3316 

Generated with Doxygen.