libsim Versione 8.0.0

◆ vg6d_c2a()

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

Generated with Doxygen.