H.1.7 Output_Monomial Procedure

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

  subroutine Output_Monomial (Monomial, First, Last, Unit, Indent, status)

    ! Input variables.

    ! Variable to be output.
    type(Monomial_type), intent(inout) :: Monomial 
    type(integer), intent(in), optional :: First    ! Extents of value data
    type(integer), intent(in), optional :: Last     !   to be output.
    type(integer), intent(in), optional :: Unit     ! Output unit.
    type(integer), optional :: Indent               ! Indentation.

    ! Output variable.

    type(Status_type), intent(out), optional :: status  ! Exit status.

    ! Internal variables.

    type(integer) :: A_First                        ! Actual first value.
    type(integer) :: A_Last                         ! Actual last value.
    type(integer) :: A_Unit                         ! Actual output unit.
    type(integer) :: A_Indent                       ! Actual indentation.
    type(character,80) :: Blanks                    ! A line of blanks.
    type(Mathematic_Vector_type) :: Coefficient_MV  ! Temp MV for Coefficient.
    type(Mathematic_Vector_type) :: Phi_MV          ! Temp MV for Phi_k, Phi_n.
    type(Status_type), dimension(2) :: allocate_status ! Allocation Status.
    type(Status_type) :: consolidated_status           ! Consolidated Status.

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

    ! Verify requirements.

    VERIFY(Valid_State(Monomial),5)                  ! Monomial is valid.

    ! Set unit number.
    
    if (PRESENT(Unit)) then
      A_Unit = Unit
    else
      A_Unit = 6
    end if

    ! Set indentation.
    
    if (PRESENT(Indent)) then
      A_Indent = Indent
    else
      A_Indent = 0
    end if
    Blanks = ' '
     
    ! Set up local limits in terms of global limits.

    if (PRESENT(First)) then
      A_First = First
    else
      A_First = 1
    end if
    if (PRESENT(Last)) then
      A_Last = Last
    else
      A_Last = Length_Total(Monomial%Structure)
    end if

    ! Allocations and initializations.

    call Initialize (allocate_status)
    call Initialize (consolidated_status)

    ! Output Identification Info.

    if (this_is_IO_PE) then
      write (A_Unit,100) Blanks(1:A_Indent), 'Monomial Information:'
      write (A_Unit,101) Blanks(1:A_Indent+2), 'Name                 = ', &
                         TRIM(Monomial%Name)
      write (A_Unit,102) Blanks(1:A_Indent+2), 'Initialized          =', &
                         Initialized(Monomial)
      write (A_Unit,103) Blanks(1:A_Indent+2), 'Exponent             =', &
                         Monomial%Exponent
      write (A_Unit,101) Blanks(1:A_Indent+2), 'Locus                = ', &
                         TRIM(Monomial%Locus)
      write (A_Unit,102) Blanks(1:A_Indent+2), 'Derivative           =', &
                         Monomial%Derivative
      write (A_Unit,103) Blanks(1:A_Indent+2), 'Delta t              =', &
                         Monomial%Delta_t
      write (A_Unit,104) Blanks(1:A_Indent+2), 'Variable             =', &
                         Monomial%Variable
      write (A_Unit,104) Blanks(1:A_Indent+2), 'Equation             =', &
                         Monomial%Equation
      write (A_Unit,104) Blanks(1:A_Indent+2), 'NEquations           =', &
                         Monomial%NEquations
    end if

    ! Output internal structure info.

    call Output (Monomial%Structure, A_Unit, 'Monomial Locus', A_Indent+2)

    call Initialize (Coefficient_MV, Monomial%Structure, &
                     'Coefficient as an MV', allocate_status(1))
    Coefficient_MV = Monomial%Coefficient
    call Output (Coefficient_MV, A_First, A_Last, A_Unit, A_Indent+2)
    call Finalize (Coefficient_MV)

    call Initialize (Phi_MV, Monomial%Structure, &
                     'Phi_k as an MV', allocate_status(2))
    Phi_MV = Monomial%Phi_k
    call Output (Phi_MV, A_First, A_Last, A_Unit, A_Indent+2)
    call Finalize (Phi_MV)

    if (Monomial%Derivative) then
      call Initialize (Phi_MV, Monomial%Structure, &
                       'Phi_n as an MV', allocate_status(2))
      Phi_MV = Monomial%Phi_n
      call Output (Phi_MV, A_First, A_Last, A_Unit, A_Indent+2)
      call Finalize (Phi_MV)
    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)

    ! Format statements.

    100 format (/, 2a, /)
    101 format (3a)
    102 format (2a, l2)
    103 format (2a, 1p, e13.5e3)
    104 format (2a, 1p, i4)

    ! Verify guarantees - none.

    return
  end subroutine Output_Monomial



Michael L. Hall