catchment_initialise_parameters Subroutine

public subroutine catchment_initialise_parameters(mb, nbyr, sbar)

Author : stefan.liersch@pik-potsdam.de Date : 2010-02-24 modified: 2010-02-25

PURPOSE : Reading file subcatch.def count number of subcatchments (user defined aggregation of subbasins)

CALLED : from subroutine main program

ToDo : - Writing output like pcp etc. at subcatchment level to specific output files


Arguments

Type IntentOptional AttributesName
integer, intent(in) :: mb
integer, intent(in) :: nbyr
real(kind=dp), intent(in), dimension(:):: sbar

Calls

proc~~catchment_initialise_parameters~~CallsGraph proc~catchment_initialise_parameters catchment_initialise_parameters proc~catchment_assign_subcatch catchment_assign_subcatch proc~catchment_initialise_parameters->proc~catchment_assign_subcatch proc~log_warn log_warn proc~catchment_initialise_parameters->proc~log_warn proc~catchment_read_subcatch_params catchment_read_subcatch_params proc~catchment_initialise_parameters->proc~catchment_read_subcatch_params proc~catchment_initialise_subcatchm catchment_initialise_subcatchm proc~catchment_initialise_parameters->proc~catchment_initialise_subcatchm proc~log_message log_message proc~log_warn->proc~log_message proc~log_debug log_debug proc~catchment_read_subcatch_params->proc~log_debug proc~read_real_column read_real_column proc~catchment_read_subcatch_params->proc~read_real_column proc~read_integer_column read_integer_column proc~catchment_read_subcatch_params->proc~read_integer_column proc~river_allocate_subcatch river_allocate_subcatch proc~catchment_initialise_subcatchm->proc~river_allocate_subcatch proc~groundwater_allocate_subcatch groundwater_allocate_subcatch proc~catchment_initialise_subcatchm->proc~groundwater_allocate_subcatch proc~evapotranspiration_allocate_sc evapotranspiration_allocate_sc proc~catchment_initialise_subcatchm->proc~evapotranspiration_allocate_sc proc~soil_allocate_subcatch soil_allocate_subcatch proc~catchment_initialise_subcatchm->proc~soil_allocate_subcatch proc~snow_allocate_subcatch snow_allocate_subcatch proc~catchment_initialise_subcatchm->proc~snow_allocate_subcatch proc~log_debug->proc~log_message 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~input_type_conversion_error input_type_conversion_error proc~read_real_column->proc~input_type_conversion_error proc~move_lines move_lines proc~read_real_column->proc~move_lines proc~log_error log_error proc~read_real_column->proc~log_error proc~check_range check_range proc~read_real_column->proc~check_range proc~read_csv_item read_csv_item proc~read_real_column->proc~read_csv_item proc~header_column_index header_column_index proc~read_real_column->proc~header_column_index proc~input_error_column_not_found input_error_column_not_found proc~read_real_column->proc~input_error_column_not_found proc~read_integer_column->proc~input_type_conversion_error proc~read_integer_column->proc~move_lines proc~check_int_range check_int_range proc~read_integer_column->proc~check_int_range proc~read_integer_column->proc~log_error proc~read_integer_column->proc~read_csv_item proc~read_integer_column->proc~header_column_index proc~read_integer_column->proc~input_error_column_not_found proc~to_string to_string proc~log_write->proc~to_string proc~input_type_conversion_error->proc~log_error proc~check_int_range->proc~log_warn proc~check_int_range->proc~log_error proc~out_of_range_error out_of_range_error proc~check_int_range->proc~out_of_range_error proc~log_error->proc~log_message 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~check_range->proc~log_warn proc~check_range->proc~log_error proc~check_range->proc~out_of_range_error proc~header_column_index->proc~move_lines proc~header_column_index->proc~input_error_column_not_found proc~input_error_column_not_found->proc~log_error proc~out_of_range_error->proc~log_error proc~out_of_range_error->proc~to_string proc~string_index string_index proc~colourise->proc~string_index

Called by

proc~~catchment_initialise_parameters~~CalledByGraph proc~catchment_initialise_parameters catchment_initialise_parameters proc~initialise initialise proc~initialise->proc~catchment_initialise_parameters program~swim swim program~swim->proc~initialise

Contents


Source Code

  subroutine catchment_initialise_parameters(mb, nbyr, sbar)
    !-------------------------------------------------------------------------------
    ! Author : stefan.liersch@pik-potsdam.de
    ! Date : 2010-02-24
    ! modified: 2010-02-25
    !
    ! PURPOSE : Reading file subcatch.def
    !           count number of subcatchments (user defined aggregation of subbasins)
    !
    ! CALLED : from subroutine main program
    !
    ! ToDo : - Writing output like pcp etc. at subcatchment level to specific output files
    !
    !-------------------------------------------------------------------------------
    integer, intent(in) :: mb
    integer, intent(in) :: nbyr
    real(dp), dimension(:), intent(in) :: sbar

    ! read file subcatch.def
    ! enable assignment of individual subbasin parameters

    integer :: i, n, nosub
    character(len=20) :: temp_name

    ! skip this routine if no subcatch parameters
    if (.not. bSubcatch) then
      allocate(catchment_ids(1))
      catchment_ids = 1
      return
    end if

    nosub = 0
    do n = 1, mb
      if (subcatch_id(n) < 0) nosub = nosub + 1
    end do
    if (nosub > 0) then
      call log_warn("catchment_initialise_parameters", &
        "You are simulating with a subset of n subbasins:", int=mb - nosub)
    end if

    ! allocate arrays
    n_subcatch = MAXVAL(subcatch_id)
    call catchment_initialise_subcatchm(n_subcatch, nbyr)
    do i = 1, mb
      if (subcatch_id(i) /= 0) then
        write(temp_name, '(I5)') subcatch_id(i)
        subcatch_name(subcatch_id(i)) = trim(adjustl(temp_name))
        subcatch_area(subcatch_id(i)) = subcatch_area(subcatch_id(i)) + sbar(i) !subarea(i)
      end if
    end do

    ! read individual subcatchment bsn parameters
    call catchment_read_subcatch_params

    ! assign parameters at the subcatchment level
    call catchment_assign_subcatch(mb)

  end subroutine catchment_initialise_parameters