io_params_template_paths_s.f90 Source File


Contents


Source Code

submodule (params_template_m) io_params_template_paths_s
    !! Handles I/O of paths parameters of template models
    use parallelisation_setup_m, only : is_rank_info_writer
    use screen_io_m, only : get_stdout
    use error_handling_grillix_m, only: handle_error
    use status_codes_grillix_m, only : GRILLIX_ERR_NAMELIST
    implicit none

    namelist / paths_template / path_features, path_tstep, path_params, path_parbnd, path_mms, path_init_select, &
        path_snapsdir, diagfile_path, path_mmsjobout

contains

    module subroutine read_params_template_paths(optional_filepath)
        !! Initializes parameters related with paths configuration
        character(len=*), intent(in), optional :: optional_filepath
        !! Filename, where to read path parameters from

        character(len=:), allocatable :: fpath
        integer :: io_unit, io_error
        character(len=256) :: io_errmsg

        if (present(optional_filepath)) then
            fpath = optional_filepath
        else
            fpath = paths_filename
        endif

        open(newunit=io_unit, file=fpath, status='old', action='read', iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__)
        endif
        read(io_unit, nml=paths_template, iostat=io_error, iomsg=io_errmsg)
        if (io_error /= 0) then
            call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__)
        endif
        close(io_unit)

    end subroutine

    module subroutine display_params_template_paths()

        if (is_rank_info_writer) then
            write(get_stdout(), nml=paths_template)
        endif

    end subroutine

end submodule