subroutine input_nc_read_grid(mb)
integer, intent(in) :: mb
integer :: fui, i, ii, sb
real(dp) :: ilon, ilat, iweight
! open weights and coordinates file
fui = input_open_file(NC_GRID)
read(fui, *) ! header line
do i = 1, nc_nrows
! read line
read(fui, *) sb, ilon, ilat, iweight
! count cells
nc_ncells_sb(sb) = nc_ncells_sb(sb) + 1
ii = nc_ncells_sb(sb)
! check input and assign
call check_range((/ilon/), 'longitude', (/-180., 180./), sb)
nc_lon_sb(sb, ii) = ilon
call check_range((/ilat/), 'latitude', (/-90., 90./), sb)
nc_lat_sb(sb, ii) = ilat
call check_range((/iweight/), 'weight', (/0., 1.e6/), sb)
nc_weight_sb(sb, ii) = iweight
! weights sum
nc_wsum_sb(sb) = nc_wsum_sb(sb) + nc_weight_sb(sb, ii)
end do
! close info file again
close(fui)
! adjust/make sure weights add up to 1
do sb = 1, mb
do ii = 1, nc_ncells_sb(sb)
nc_weight_sb(sb, ii) = nc_weight_sb(sb, ii) / nc_wsum_sb(sb)
enddo
enddo
end subroutine input_nc_read_grid