input_nc_check_grid Subroutine

public subroutine input_nc_check_grid(mb)

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: mb

Calls

proc~~input_nc_check_grid~~CallsGraph proc~input_nc_check_grid input_nc_check_grid proc~log_warn log_warn proc~input_nc_check_grid->proc~log_warn proc~input_open_file input_open_file proc~input_nc_check_grid->proc~input_open_file proc~log_debug log_debug proc~input_nc_check_grid->proc~log_debug proc~log_message log_message proc~log_warn->proc~log_message proc~open_file open_file proc~input_open_file->proc~open_file proc~log_debug->proc~log_message proc~log_error log_error proc~open_file->proc~log_error proc~log_write log_write proc~log_message->proc~log_write proc~log_format_message log_format_message proc~log_message->proc~log_format_message proc~to_string to_string proc~log_write->proc~to_string proc~date_time_str date_time_str proc~log_format_message->proc~date_time_str proc~colourise colourise proc~log_format_message->proc~colourise proc~log_error->proc~log_message proc~string_index string_index proc~colourise->proc~string_index

Called by

proc~~input_nc_check_grid~~CalledByGraph proc~input_nc_check_grid input_nc_check_grid proc~input_nc_initialise input_nc_initialise proc~input_nc_initialise->proc~input_nc_check_grid proc~initialise initialise proc~initialise->proc~input_nc_initialise program~swim swim program~swim->proc~initialise

Contents

Source Code


Source Code

  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