output_initialise_user_input Subroutine

public subroutine output_initialise_user_input()

Uses

  • proc~~output_initialise_user_input~~UsesGraph proc~output_initialise_user_input output_initialise_user_input module~input input proc~output_initialise_user_input->module~input module~utilities utilities proc~output_initialise_user_input->module~utilities module~input->module~utilities

Arguments

None

Calls

proc~~output_initialise_user_input~~CallsGraph proc~output_initialise_user_input output_initialise_user_input proc~extend_unique_string extend_unique_string proc~output_initialise_user_input->proc~extend_unique_string proc~log_error log_error proc~output_initialise_user_input->proc~log_error proc~string_index string_index proc~output_initialise_user_input->proc~string_index proc~open_file open_file proc~output_initialise_user_input->proc~open_file proc~log_create log_create proc~output_initialise_user_input->proc~log_create proc~get_config_fid get_config_fid proc~output_initialise_user_input->proc~get_config_fid proc~extend_unique_string->proc~log_error proc~log_message log_message proc~log_error->proc~log_message proc~open_file->proc~log_error proc~log_create->proc~open_file proc~log_str2level log_str2level proc~log_create->proc~log_str2level proc~get_config_fid->proc~open_file 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~colourise->proc~string_index

Called by

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

Contents


Source Code

  subroutine output_initialise_user_input
    ! Read and interpret output namelist parameters
    use utilities, only: &
      extend_unique_string, &
      string_index, &
      open_file, &
      log_create, &
      master_log
    use input, only: get_config_fid
    integer ios, i, v
    character(len=identifier_max_length) :: &
      name, format, variables(output_max_variables), space, time
    namelist / file / &
      name, format, variables, space, time

    ! General options from central config nml
    read(get_config_fid(), nml=OUTPUT_PARAMETERS)

    ! Create master log file
    master_log = log_create(trim(output_dir)//"/"//trim(master_logfile), &
      log_stderr_level, log_stdout_level, log_file_level)

    ! count requested output files
    output_specs_fid = open_file(output_specs_path)
    output_nfiles = -1
    ios = 0
    do while (ios /= -1)
      output_nfiles = output_nfiles + 1
      read(output_specs_fid, nml=file, iostat=ios)
    end do
    rewind(output_specs_fid)
    if (output_nfiles == 0) &
      call log_error("output_initialise_user_input", &
        "No output file definition found in "//output_specs_path)
    ! Allocate arrays of nfiles length
    allocate(output_files(output_nfiles))
    do i = 1, output_nfiles
      name = ''
      format = output_default_format
      variables = ''
      space = ''
      time = ''
      read(output_specs_fid, nml=file)
      ! Check input and store
      if (trim(name) == '') &
        call log_error("output_initialise_user_input", "No name given for output file.")
      output_files(i)%name = name
      output_files(i)%nvars = string_index('', variables) - 1
      if (output_files(i)%nvars == 0) &
        call log_error("output_initialise_user_input", &
          "No variables define for output file "//trim(name))
      output_files(i)%variables = variables
      output_files(i)%space = string_index(space, output_space_dim)
      if (output_files(i)%space == 0) call log_error("output_initialise_user_input", &
        trim(space)//" is not a valid output space domain in file "//trim(name))
      output_files(i)%time = string_index(time, output_time_dim)
      if (output_files(i)%time == 0) call log_error("output_initialise_user_input", &
        trim(time)//" is not a valid output time domain in file "//trim(name))
      output_files(i)%format = string_index(format, output_format_dim)
      if (output_files(i)%format == 0) call log_error("output_initialise_user_input", &
        trim(format)//" is not a valid output format in file "//trim(name))
      ! Store unique variables
      call extend_unique_string(variables, output_requested_vars)
    end do
    ! Get variable indeces for each file%variables in output_requested_vars
    do i = 1, output_nfiles
      do v = 1, output_files(i)%nvars
        output_files(i)%variable_ix(v) = string_index(output_files(i)%variables(v), &
          output_requested_vars)
      end do
    end do
    ! Count all requested variables
    output_nvars = string_index("", output_requested_vars) - 1
    allocate(output_var_state(output_nvars))
    output_var_state = .True.
  end subroutine output_initialise_user_input