subroutine input_nc_read_climate(flu, humi, mb, ra, subp, tmn, tmx, tx)
real(dp), dimension(:), intent(in) :: flu
real(dp), dimension(:), intent(out) :: humi
integer, intent(in) :: mb
real(dp), dimension(:), intent(out) :: ra
real(dp), dimension(:), intent(out) :: subp
real(dp), dimension(:), intent(out) :: tmn
real(dp), dimension(:), intent(out) :: tmx
real(dp), dimension(:), intent(out) :: tx
! counters need for day length
integer j
! reals need for day length
real(dp) :: mm(6) = 0
call input_nc_weighted_mean(1, tx, mb)
call input_nc_weighted_mean(2, tmn, mb)
call input_nc_weighted_mean(3, tmx, mb)
call input_nc_weighted_mean(4, subp, mb)
call input_nc_weighted_mean(5, ra, mb)
call input_nc_weighted_mean(6, humi, mb)
if (NC_DEBUG) then
mm = 0
do j = 1, mb
mm(1) = mm(1) + tx(j) * flu(j)
mm(2) = mm(2) + tmn(j) * flu(j)
mm(3) = mm(3) + tmx(j) * flu(j)
mm(4) = mm(4) + subp(j) * flu(j)
mm(5) = mm(5) + ra(j) * flu(j)
mm(6) = mm(6) + humi(j) * flu(j)
enddo
call log_debug("input_nc_read_climate", &
'ncdf climate (tmean, tmin, tmax, prec, rad, hum) avarage on day:', &
int=nc_nday, reals=mm)
endif
! update current record number
nc_nday = nc_nday + 1
! If relative humidity is not provided
if (isNaN(humi(1)) ) humi = - 999.9
if (isNaN(ra(1)) ) ra = 1.
end subroutine input_nc_read_climate