Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | ivar | |||
real(kind=dp), | intent(out) | :: | v_sb(:) | |||
integer, | intent(in) | :: | mb |
subroutine input_nc_weighted_mean(ivar, v_sb, mb)
use netcdf, only : nf90_get_var
integer, intent(in) :: mb
! variable index
integer, intent (in) :: ivar
real(dp), intent (out) :: v_sb(:) ! the subbasin variable to be filled
integer :: start(3), count(3) ! to supply to nc_get_var
! looping ints
integer sb, i
! Read 1 record of NLONS*NLATS*NLVLS values, starting at the beginning
! of the record (the (1, 1, rec) element in the netCDF file).
count = (/ nc_nx, nc_ny, 1 /)
start = (/ nc_xmin, nc_ymin, nc_nday /)
! read one day/record
call input_nc_check_error( nf90_get_var(nc_ids(ivar), nc_var_ids(ivar), nc_var_in, start, count) )
! apply offset and scale_factor
nc_var_in = nc_var_in * nc_attr_vals(ivar, 1) + nc_attr_vals(ivar, 2)
! interpolate and fill v_sb
v_sb = 0
do sb = 1, mb
do i = 1, nc_ncells_sb(sb)
v_sb(sb) = v_sb(sb) + nc_var_in(nc_x_sb(sb, i), nc_y_sb(sb, i)) * nc_weight_sb(sb, i)
end do
enddo
end subroutine input_nc_weighted_mean