module params_hsolver_m !! Parameters for elliptic (2D) solvers use precision_grillix_m, only : GP 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 helmholtz_solver_factory_m, only : & parameters_helmholtz_solver_factory implicit none character(len=16), protected :: select_hsolver = 'MGMRES' !! Type of solver for perpendicular helmholtz_solver type(parameters_helmholtz_solver_factory), protected :: params_hsolver !! Parameters for perpendicular elliptic solver public :: read_params_hsolver public :: write_params_hsolver ! These variables are defined additionally for I/O via namelist character(len=16), private, save :: & solver, & dirsolver_type, & smoother_type real(GP), private, save :: & rtol, & restol_zero integer, private, save :: & gmres_maxiter, & gmres_nrestart, & mgrid_npresmooth, & mgrid_npostsmooth, & dbgout character(len=1), private, save :: & mgrid_cycletype namelist / hsolver / solver, dirsolver_type, smoother_type, & rtol, restol_zero, gmres_maxiter, gmres_nrestart, & mgrid_cycletype, mgrid_npresmooth, mgrid_npostsmooth, & dbgout private hsolver contains subroutine read_params_hsolver(filename) !! Reads parameters related with hsolver character(len=*), intent(in) :: filename !! Filename, to read from integer :: io_unit, io_error character(len=256) :: io_errmsg ! Load default values from defaults of parameters_helmholtz_solver_factor solver = select_hsolver dirsolver_type = params_hsolver%dirsolver_type smoother_type = params_hsolver%smoother_type rtol = params_hsolver%rtol restol_zero = params_hsolver%restol_zero gmres_maxiter = params_hsolver%gmres_maxiter gmres_nrestart = params_hsolver%gmres_nrestart mgrid_cycletype = params_hsolver%mgrid_cycletype mgrid_npresmooth = params_hsolver%mgrid_npresmooth mgrid_npostsmooth = params_hsolver%mgrid_npostsmooth dbgout = params_hsolver%dbgout 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=hsolver, iostat=io_error, iomsg=io_errmsg) if (io_error /= 0) then call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, & __LINE__, __FILE__) endif select_hsolver = solver params_hsolver%dirsolver_type = dirsolver_type params_hsolver%smoother_type = smoother_type params_hsolver%rtol = rtol params_hsolver%restol_zero = restol_zero params_hsolver%gmres_maxiter = gmres_maxiter params_hsolver%gmres_nrestart = gmres_nrestart params_hsolver%mgrid_cycletype = mgrid_cycletype params_hsolver%mgrid_npresmooth = mgrid_npresmooth params_hsolver%mgrid_npostsmooth = mgrid_npostsmooth params_hsolver%dbgout = dbgout close(io_unit) end subroutine subroutine write_params_hsolver(filename) !! Writes parameters related with hsolver 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=hsolver, 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