module params_neut_data_paths_m !! Parameters for the filepaths of neutrals data use error_handling_grillix_m, only: handle_error use status_codes_grillix_m, only : GRILLIX_ERR_NAMELIST use screen_io_m, only : get_stdout use technical_constants_m, only : PATHLEN_MAX implicit none character(len=PATHLEN_MAX), protected :: path_k_iz = 'S_H.dat' !! Filepath to ionization rate data character(len=PATHLEN_MAX), protected :: path_k_rec = 'R_H.dat' !! Filepath to reconmbination rate data character(len=PATHLEN_MAX), protected :: path_w_iz = 'Wiz_H.dat' !! Filepath to ionization cooling rate data character(len=PATHLEN_MAX), protected :: path_p_rec = 'Pradrec_H.dat' !! Filepath to recombination cooling rate data public :: read_params_neut_data_paths public :: write_params_neut_data_paths namelist / neut_data_paths / & path_k_iz, & path_k_rec, & path_w_iz, & path_p_rec private neut_data_paths contains subroutine read_params_neut_data_paths(filename) !! Reads parameters related with neut_data_paths_m character(len=*), intent(in) :: filename !! Filename, to read from integer :: io_unit, io_error character(len=256) :: io_errmsg open(newunit=io_unit, file=filename, 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=neut_data_paths, 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 subroutine write_params_neut_data_paths(filename) !! Reads parameters related with neut_data_paths_m character(len=*), intent(in), optional :: filename !! If present, filename where params are written to, !! if not present, writes to screen integer :: io_unit, io_error character(len=256) :: io_errmsg if (present(filename)) then open(newunit=io_unit, file=filename, status='unknown', & access='append', action='write', & iostat=io_error, iomsg=io_errmsg ) if (io_error /= 0) then call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, & __LINE__, __FILE__) endif else io_unit = get_stdout() endif write(io_unit, nml=neut_data_paths, iostat=io_error, iomsg=io_errmsg) if (io_error /= 0) then call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, & __LINE__, __FILE__) endif if (present(filename)) then close(io_unit) endif end subroutine end module