G.3.1 Initialize_Solver Procedure

The main documentation of the Initialize_Solver Procedure contains additional explanation of this code listing.

  subroutine Initialize_Solver (Solver, Package, status)

    ! Use associations.

    use Caesar_Flags_Module, only: initialized_flag

    ! Input variables.

    type(character,*), intent(in) :: Package          ! Solver package to call.

    ! Output variables.

    type(Solver_type), intent(out) :: Solver        ! Solver to be initialized.
    type(Status_type), intent(out), optional :: status  ! Exit status.

    ! Internal variables.

    type(Status_type), dimension(1) :: allocate_status  ! Allocation Status.
    type(Status_type) :: consolidated_status            ! Consolidated Status.

    !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ! Verify requirements.

    VERIFY(.not.Valid_State(Solver),5)    ! Solver is not valid.

    ! Allocations and initializations.

    call Initialize (allocate_status)
    call Initialize (consolidated_status)

    ! Set up internals.

    if (Package(1:4) == 'LAMG') then
      Solver%Package = 'LAMG'
    else
      ! No Package match found.
      VERIFY(.false., 0)
    end if

    ! Default Solver settings.

    Solver%Epsilon = 1.d-10
    Solver%Stopping_Test = '||r||/||b|| < Eps'
    Solver%Maximum_Iterations = 1000

    ! Default LAMG settings.

    if (Solver%Package == 'LAMG') then

      Solver%LAMG_levout = 2     ! Package output: 0=silent, 4=verbose.

    end if

    ! Process status variables.

    consolidated_status = allocate_status
    if (PRESENT(status)) then
      WARN_IF(Error(consolidated_status), 5)
      status = consolidated_status
    else
      VERIFY(Normal(consolidated_status), 5)
    end if
    call Finalize (consolidated_status)
    call Finalize (allocate_status)

    ! Set initialization flag.

    Solver%Initialized = initialized_flag

    ! Verify guarantees.

    VERIFY(Valid_State(Solver),5)  ! Solver is now valid.

    return
  end subroutine Initialize_Solver



Michael L. Hall