output_initialise Subroutine

public subroutine output_initialise(hydrotope_id, hydrotope_area, hydrotope_subbasin, subbasin_id, subbasin_nhydrotopes, subbasin_catchment, catchment_id, hydrotope_input_fid, subbasin_input_fid)

Uses

  • proc~~output_initialise~~UsesGraph proc~output_initialise output_initialise module~utilities utilities proc~output_initialise->module~utilities

Arguments

Type IntentOptional AttributesName
integer, intent(in), dimension(:):: hydrotope_id
real, intent(in), dimension(:):: hydrotope_area
integer, intent(in), dimension(:):: hydrotope_subbasin
integer, intent(in), dimension(:):: subbasin_id
integer, intent(in), dimension(:):: subbasin_nhydrotopes
integer, intent(in), dimension(:):: subbasin_catchment
integer, intent(in), dimension(:):: catchment_id
integer, intent(in) :: hydrotope_input_fid
integer, intent(in) :: subbasin_input_fid

Calls

proc~~output_initialise~~CallsGraph proc~output_initialise output_initialise proc~output_initialise_storage output_initialise_storage proc~output_initialise->proc~output_initialise_storage proc~output_allocate output_allocate proc~output_initialise->proc~output_allocate proc~output_initialise_is_requested output_initialise_is_requested proc~output_initialise->proc~output_initialise_is_requested proc~output_initialise_time output_initialise_time proc~output_initialise->proc~output_initialise_time proc~output_initialise_unit_shares output_initialise_unit_shares proc~output_initialise->proc~output_initialise_unit_shares proc~output_check_requested_vars output_check_requested_vars proc~output_initialise_storage->proc~output_check_requested_vars proc~output_open_files output_open_files proc~output_initialise_storage->proc~output_open_files proc~output_initialise_labelled output_initialise_labelled proc~output_initialise_storage->proc~output_initialise_labelled proc~output_initialise_storage_index output_initialise_storage_index proc~output_initialise_storage->proc~output_initialise_storage_index proc~log_error log_error proc~output_initialise_time->proc~log_error proc~output_check_requested_vars->proc~log_error proc~string_index string_index proc~output_check_requested_vars->proc~string_index proc~log_message log_message proc~log_error->proc~log_message proc~output_write_csv_header output_write_csv_header proc~output_open_files->proc~output_write_csv_header proc~output_open_file output_open_file proc~output_open_files->proc~output_open_file proc~output_initialise_labelled->proc~log_error proc~read_string_column read_string_column proc~output_initialise_labelled->proc~read_string_column proc~has_column has_column proc~output_initialise_labelled->proc~has_column proc~indeces_in_array indeces_in_array proc~output_initialise_storage_index->proc~indeces_in_array proc~read_string_column->proc~log_error proc~move_lines move_lines proc~read_string_column->proc~move_lines proc~read_csv_item read_csv_item proc~read_string_column->proc~read_csv_item proc~header_column_index header_column_index proc~read_string_column->proc~header_column_index proc~input_error_column_not_found input_error_column_not_found proc~read_string_column->proc~input_error_column_not_found proc~indeces_in_array->proc~string_index proc~has_column->proc~header_column_index 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~open_file open_file proc~output_open_file->proc~open_file 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~header_column_index->proc~move_lines proc~header_column_index->proc~input_error_column_not_found proc~open_file->proc~log_error proc~input_error_column_not_found->proc~log_error proc~colourise->proc~string_index

Called by

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

Contents

Source Code


Source Code

  subroutine output_initialise(hydrotope_id, hydrotope_area, hydrotope_subbasin, &
    subbasin_id, subbasin_nhydrotopes, subbasin_catchment, catchment_id, &
    hydrotope_input_fid, subbasin_input_fid)
    ! Process user input before variables are registered
    use utilities, only: string_index
    integer, dimension(:), intent(in) :: &
      ! Hydrotope IDs and subbasin mapping (must be same length)
      hydrotope_id, hydrotope_subbasin, &
      ! Subbasin IDs and catchment mapping (must be same length)
      subbasin_id, subbasin_nhydrotopes, subbasin_catchment, &
      !Catchment IDs
      catchment_id
    ! Hydrotope area for weighted averages
    real, dimension(:), intent(in) :: hydrotope_area
    ! File ids to read output labels
    integer, intent(in) :: hydrotope_input_fid
    integer, intent(in) :: subbasin_input_fid
    integer s

    ! Hydrotope arrays
    output_nhydrotopes = size(hydrotope_id)
    allocate(output_hydrotope_id(output_nhydrotopes))
    allocate(output_hydrotope_subbasin_ix(output_nhydrotopes))
    allocate(output_hydrotope_subbasin_share(output_nhydrotopes))
    output_hydrotope_id = hydrotope_id

    ! Subbasin arrays
    output_nsubbasins = size(subbasin_id)
    allocate(output_subbasin_id(output_nsubbasins))
    allocate(output_subbasin_catchment_ix(output_nsubbasins))
    ! initialised with 2 because if catchment ids not read with subcatch = False
    ! 2 is the index of the default catchment ID, 1 being the total catchment
    output_subbasin_catchment_ix = 2
    allocate(output_subbasin_catchment_share(output_nsubbasins))
    output_subbasin_id = subbasin_id
    allocate(output_subbasin_nhydrotopes(output_nsubbasins))
    output_subbasin_nhydrotopes = subbasin_nhydrotopes
    allocate(output_subbasin_hydrotope_stix(output_nsubbasins))
    output_subbasin_hydrotope_stix = 0
    ! Make cumsum out of sparse hydrotope numbers for quick start index
    do s = 1, output_nsubbasins-1
      output_subbasin_hydrotope_stix(s+1) = &
        output_subbasin_hydrotope_stix(s) + subbasin_nhydrotopes(s)
    end do

    ! Catchment arrays
    output_ncatchments = size(catchment_id) + 1  ! one extra for catchment total
    allocate(output_catchment_id(output_ncatchments))
    allocate(output_catchment_basin_share(output_ncatchments))
    output_catchment_id(1) = 0
    output_catchment_id(2:output_ncatchments) = catchment_id

    allocate(output_storage_index(output_nfiles, output_nvars))
    output_storage_index = 0

    call output_initialise_unit_shares(hydrotope_subbasin, subbasin_catchment, hydrotope_area)
    call output_initialise_time
    ! Fill convenience matrix
    call output_initialise_is_requested
    call output_initialise_storage(hydrotope_input_fid, subbasin_input_fid)

    call output_allocate(output_nsubbasins, output_nsubbasins)

  end subroutine output_initialise