libsim  Versione8.0.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 3205 del file volgrid6d_class.F90.

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 
3219 end if
3220 
3221 
3222 call griddim_unproj(this%griddim)
3223 
3224 
3225 end subroutine vg6d_c2a_grid
3226 
3227 ! Convert C grid to A grid
3228 subroutine vg6d_c2a_mat(this,cgrid)
3229 
3230 type(volgrid6d),intent(inout) :: this ! object containing fields to be translated
3231 integer,intent(in) :: cgrid ! in C grid (Arakawa) we have 0=T,1=U,2=V points
3232 
3233 INTEGER :: i, j, k, iv, stallo
3234 REAL,ALLOCATABLE :: tmp_arr(:,:)
3235 REAL,POINTER :: voldatiuv(:,:)
3236 
3237 
3238 IF (cgrid == 0) RETURN ! nothing to do
3239 IF (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
3244 ENDIF
3245 
3246 ! Temporary workspace
3247 ALLOCATE(tmp_arr(this%griddim%dim%nx, this%griddim%dim%ny),stat=stallo)
3248 if (stallo /=0)then
3249  call l4f_log(l4f_fatal,"allocating memory")
3250  call raise_fatal_error()
3251 end if
3252 
3253 ! allocate once for speed
3254 IF (.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
3260 ENDIF
3261 
3262 IF (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 
3290 ELSE 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
3317 ENDIF ! tertium non datur
3318 
3319 IF (.NOT.ASSOCIATED(this%voldati)) THEN
3320  DEALLOCATE(voldatiuv)
3321 ENDIF
3322 DEALLOCATE (tmp_arr)
3323 
3324 end subroutine vg6d_c2a_mat
3325 
3326 

Generated with Doxygen.