Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | mb |
subroutine input_nc_check_grid(mb)
integer, intent(in) :: mb
integer :: fui, sb
integer :: lastsb = 0
integer :: imxc = 0
! check ncinfo file for length and maxcells
fui = input_open_file(NC_GRID)
read(fui, *) ! header line
do
read(fui, *, END=10) sb
nc_nrows = nc_nrows + 1
! count cells per subbasin and update max counter
if (sb /= lastsb) imxc = 0
lastsb = sb
imxc = imxc + 1
nc_mxc = max(nc_mxc, imxc)
! check subbasin count
if (sb > mb) then
call log_warn("input_nc_check_grid", "SubbasinID in (line) larger than number of subbasins:", &
i1=sb, int=nc_nrows)
endif
enddo
10 close(fui)
! make sure lastsb==mb
if (lastsb /= mb) then
call log_warn("input_nc_check_grid", 'Last subbasinID in '//trim(NC_GRID)// &
' does not match the last subbasinID', i1=lastsb, int=mb)
endif
! report file length and maxcells per subbasin
if (NC_DEBUG) call log_debug("input_nc_check_grid", 'Lines in ncgrid file:', int=nc_nrows)
if (NC_DEBUG) call log_debug("input_nc_check_grid", 'Maximum cells per subbasin:', int=nc_mxc)
end subroutine input_nc_check_grid