solver3d_factory_m.f90 Source File


Source Code

module solver3d_factory_m
    !! Factory routine for solver3d
    use error_handling_m, only : handle_error, error_info_t
    use status_codes_m, only : PARALLAX_ERR_SOLVER3D
    use solver3d_m, only : solver3d_t, solver3d_PIM_t
#ifdef ENABLE_CERFACS
    use solver3d_m, only : solver3d_CERFACS_t
#endif
    
    implicit none

    public :: solver3d_factory

contains

    subroutine solver3d_factory(solver_type, solver3d)
        !! Factory routine for solver3d
        character(len=*), intent(in) :: solver_type
        !! Desired type of solver3d 
        !!  - PIM: Based on PIM library
        class(solver3d_t), allocatable, intent(out) :: solver3d
        !! Created solver3d

        select case(solver_type)
            case('PIM')
                allocate(solver3d_PIM_t :: solver3d)
#ifdef ENABLE_CERFACS
            case('CERFACS')
                allocate(solver3d_CERFACS_t :: solver3d)
#endif
            case default
                call handle_error('solver_type not valid', &
                              PARALLAX_ERR_SOLVER3D, __LINE__, __FILE__, &
                              error_info_t(solver_type))

        end select

    end subroutine

end module