libsim  Versione7.2.1

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

3147  step_lat=(ymax-ymin)/dble(this%griddim%dim%ny-1)
3148  ymin=ymin-step_lat/2.d0
3149  ymax=ymax-step_lat/2.d0
3150  call set_val(this%griddim, ymin=ymin, ymax=ymax)
3151 ! improve grid definition precision
3152  CALL griddim_setsteps(this%griddim)
3153 
3154  case default
3155 
3156  call l4f_category_log(this%category,l4f_fatal,"C grid type not known")
3157  call raise_fatal_error ()
3158 
3159  end select
3160 
3161 end if
3162 
3163 
3164 call griddim_unproj(this%griddim)
3165 
3166 
3167 end subroutine vg6d_c2a_grid
3168 
3169 ! Convert C grid to A grid
3170 subroutine vg6d_c2a_mat(this,cgrid)
3171 
3172 type(volgrid6d),intent(inout) :: this ! object containing fields to be translated
3173 integer,intent(in) :: cgrid ! in C grid (Arakawa) we have 0=T,1=U,2=V points
3174 
3175 INTEGER :: i, j, k, iv, stallo
3176 REAL,ALLOCATABLE :: tmp_arr(:,:)
3177 REAL,POINTER :: voldatiuv(:,:)
3178 
3179 
3180 IF (cgrid == 0) RETURN ! nothing to do
3181 IF (cgrid /= 1 .AND. cgrid /= 2) THEN ! wrong cgrid
3182  CALL l4f_category_log(this%category,l4f_fatal,"C grid type "// &
3183  trim(to_char(cgrid))//" not known")
3184  CALL raise_error()
3185  RETURN
3186 ENDIF
3187 
3188 ! Temporary workspace
3189 ALLOCATE(tmp_arr(this%griddim%dim%nx, this%griddim%dim%ny),stat=stallo)
3190 if (stallo /=0)then
3191  call l4f_log(l4f_fatal,"allocating memory")
3192  call raise_fatal_error()
3193 end if
3194 
3195 ! allocate once for speed
3196 IF (.NOT.ASSOCIATED(this%voldati)) THEN
3197  ALLOCATE(voldatiuv(this%griddim%dim%nx, this%griddim%dim%ny), stat=stallo)
3198  IF (stallo /= 0) THEN
3199  CALL l4f_log(l4f_fatal,"allocating memory")
3200  CALL raise_fatal_error()
3201  ENDIF
3202 ENDIF
3203 
3204 IF (cgrid == 1) THEN ! U points to H points
3205  DO iv = 1, SIZE(this%var)
3206  DO k = 1, SIZE(this%timerange)
3207  DO j = 1, SIZE(this%time)
3208  DO i = 1, SIZE(this%level)
3209  tmp_arr(:,:) = rmiss
3210  CALL volgrid_get_vol_2d(this, i, j, k, iv, voldatiuv)
3211 
3212 ! West boundary extrapolation
3213  WHERE(voldatiuv(1,:) /= rmiss .AND. voldatiuv(2,:) /= rmiss)
3214  tmp_arr(1,:) = voldatiuv(1,:) - (voldatiuv(2,:) - voldatiuv(1,:)) / 2.
3215  END WHERE
3216 
3217 ! Rest of the field
3218  WHERE(voldatiuv(1:this%griddim%dim%nx-1,:) /= rmiss .AND. &
3219  voldatiuv(2:this%griddim%dim%nx,:) /= rmiss)
3220  tmp_arr(2:this%griddim%dim%nx,:) = &
3221  (voldatiuv(1:this%griddim%dim%nx-1,:) + &
3222  voldatiuv(2:this%griddim%dim%nx,:)) / 2.
3223  END WHERE
3224 
3225  voldatiuv(:,:) = tmp_arr
3226  CALL volgrid_set_vol_2d(this, i, j, k, iv, voldatiuv)
3227  ENDDO
3228  ENDDO
3229  ENDDO
3230  ENDDO
3231 
3232 ELSE IF (cgrid == 2) THEN ! V points to H points
3233  DO iv = 1, SIZE(this%var)
3234  DO k = 1, SIZE(this%timerange)
3235  DO j = 1, SIZE(this%time)
3236  DO i = 1, SIZE(this%level)
3237  tmp_arr(:,:) = rmiss
3238  CALL volgrid_get_vol_2d(this, i, j, k, iv, voldatiuv)
3239 
3240 ! South boundary extrapolation
3241  WHERE(voldatiuv(:,1) /= rmiss .AND. voldatiuv(:,2) /= rmiss)
3242  tmp_arr(:,1) = voldatiuv(:,1) - (voldatiuv(:,2) - voldatiuv(:,1)) / 2.
3243  END WHERE
3244 
3245 ! Rest of the field
3246  WHERE(voldatiuv(:,1:this%griddim%dim%ny-1) /= rmiss .AND. &
3247  voldatiuv(:,2:this%griddim%dim%ny) /= rmiss)
3248  tmp_arr(:,2:this%griddim%dim%ny) = &
3249  (voldatiuv(:,1:this%griddim%dim%ny-1) + &
3250  voldatiuv(:,2:this%griddim%dim%ny)) / 2.
3251  END WHERE
3252 
3253  voldatiuv(:,:) = tmp_arr
3254  CALL volgrid_set_vol_2d(this, i, j, k, iv, voldatiuv)
3255  ENDDO
3256  ENDDO
3257  ENDDO
3258  ENDDO
3259 ENDIF ! tertium non datur
3260 
3261 IF (.NOT.ASSOCIATED(this%voldati)) THEN
3262  DEALLOCATE(voldatiuv)
3263 ENDIF
3264 DEALLOCATE (tmp_arr)
3265 
3266 end subroutine vg6d_c2a_mat
3267 
3268 

Generated with Doxygen.