module params_brag_sources_external_select_m !! Parameters for external sources in Braginskii model 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=64), protected :: nesrc_select = 'NONE' !! Type of particle source character(len=PATHLEN_MAX), protected :: nesrc_path = '' !! Name of file where parameters !! for particle source are read character(len=64), protected :: tesrc_select = 'NONE' !! Type of electron temperature source character(len=PATHLEN_MAX), protected :: tesrc_path = '' !! Name of file where parameters !! for electron temperature source are read logical, protected :: is_powersource = .false. !! Switch that treats sources as power sources character(len=64), protected :: tisrc_select = 'NONE' !! Type of ion temperature source character(len=PATHLEN_MAX), protected :: tisrc_path = '' !! Name of file where parameters for ion temperature source are read public :: read_params_brag_sources_external_select public :: write_params_brag_sources_external_select namelist / brag_sources_external_select / & nesrc_select, & nesrc_path, & tesrc_select, & tesrc_path, & tisrc_select, & tisrc_path, & is_powersource private brag_sources_external_select contains subroutine read_params_brag_sources_external_select(filename) !! Reads parameters related with brag_sources_external_select 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=brag_sources_external_select, 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_brag_sources_external_select(filename) !! Reads parameters related with brag_sources_external_select 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=brag_sources_external_select, 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