io_params_template_tstep_s.f90 Source File


Contents


Source Code

submodule (params_template_m) io_params_template_tstep_s
    !! Handles I/O of timestep 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 / tstep_template / dtau, tau_fin, tau_snaps, tau_diag, tau_perf, &
        tstep_method, tstep_order

contains

    module subroutine read_params_template_tstep(optional_filepath)
        !! Initializes parameters related with timestep configuration
        character(len=*), intent(in), optional :: optional_filepath
        !! Filename, where to read timestep 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 = path_tstep
        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=tstep_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_tstep()

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

    end subroutine

end submodule