module params_geometry_m !! Parameter for selection of equilibrium use screen_io_m, only : get_stdout use parallelisation_setup_m, only : is_rank_info_writer use equilibrium_factory_m, only : get_equilibrium_identifier use error_handling_grillix_m, only: handle_error, error_info_t use status_codes_grillix_m, only : GRILLIX_ERR_NAMELIST, GRILLIX_ERR_OTHER implicit none private type, public :: params_geometry_t !! Parameters for geometry integer, private :: geometry !! Type of geometry, i.e. CIRCULAR, SLAB contains procedure, public :: set => set_parameters_geometry procedure, public :: get_geometry procedure, public :: display => display_parameters_geometry end type contains subroutine set_parameters_geometry(self, filename, geometry_in) !! Sets parameters for geometry, either via namelist from file, or setting explicitly class(params_geometry_t), intent(inout) :: self !! Instance of the type character(*), intent(in), optional :: filename !! Filename where parameter are read from integer, intent(in), optional :: geometry_in !! Type of geometry integer :: io_error character(len=150) :: geometry character(len=256) :: io_errmsg namelist / params_geometry / & geometry if ( (.not.present(filename)) .and. & (present(geometry_in)) ) then ! input via explicit setting self%geometry = geometry_in elseif ( (present(filename)) .and. & (.not.present(geometry_in)) ) then ! Input via file ! Default setting geometry = 'CIRCULAR' open(unit = 20, 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(20, nml = params_geometry, iostat = io_error, iomsg = io_errmsg) if (io_error /= 0) then call handle_error(io_errmsg, GRILLIX_ERR_NAMELIST, __LINE__, __FILE__) endif close(20) self%geometry = get_equilibrium_identifier(geometry) else call handle_error('Input to subroutine not consistent', & GRILLIX_ERR_OTHER, __LINE__, __FILE__) endif end subroutine pure integer function get_geometry(self) !! Gets type of geometry class(params_geometry_t), intent(in) :: self !! Instance of the type get_geometry = self%geometry end function subroutine display_parameters_geometry(self) !! Displays information about parameters class(params_geometry_t), intent(in) :: self !! Instance of the type if (is_rank_info_writer) then write(get_stdout(),201)self%geometry 201 FORMAT(/ & 'Parameters geometry -----------------------' /, & X,'equi_identifier = ',I3 /, & '-------------------------------------------') endif end subroutine end module