      subroutine Header(String)
! This short subroutine print a header in a nice way

!----------------------------------------------------------------------
!  Copyright 2003-2014 Ecole Normale Supérieure de Lyon, 
!  Centre National de la Recherche Scientifique,
!  Université Claude Bernard Lyon 1. All rights reserved.
!
!  This work is registered with the Agency for the Protection of Programs 
!  as IDDN.FR.001.100009.000.S.P.2014.000.30625
!
!  Authors: P. Fleurat-Lessard, P. Dayal
!  Contact: optnpath@gmail.com
!
! This file is part of "Opt'n Path".
!
!  "Opt'n Path" is free software: you can redistribute it and/or modify
!  it under the terms of the GNU Affero General Public License as
!  published by the Free Software Foundation, either version 3 of the License,
!  or (at your option) any later version.
!
!  "Opt'n Path" is distributed in the hope that it will be useful,
!  but WITHOUT ANY WARRANTY; without even the implied warranty of
!
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  GNU Affero General Public License for more details.
!
!  You should have received a copy of the GNU Affero General Public License
!  along with "Opt'n Path". If not, see <http://www.gnu.org/licenses/>.
!
! Contact The Office of Technology Licensing, valorisation@ens-lyon.fr,
! for commercial licensing opportunities.
!----------------------------------------------------------------------

         IMPLICIT NONE


         CHARACTER(*) :: String

         INTERFACE
            function valid(string) result (isValid)
              CHARACTER(*), intent(in) :: string
              logical                  :: isValid
            END function VALID
         END INTERFACE


         CHARACTER(70) :: Head1,Sep
         CHARACTER(70) :: String2
         INTEGER :: LenS,Len1,Pos1
         INTEGER :: Idx,PosE
         LOGICAL :: Debug


         Debug=Valid("Header")

         Head1="====================================================================="
           Sep="                                                                     "

           If (debug) THEN
              WRITe(*,'(A)') Head1
              WRITE(*,'(A)') "=     Entering Header.... "
              WRITe(*,'(A)') Head1
           END IF

         WRITe(*,'(A)') Head1

         LenS=len_Trim(String)
         DO WHILE (LenS>65)
            Idx=Index(String(1:65)," ",BACK=.TRUE.)
            If (Idx>0) THEN
               PosE=Idx-1
            ELSE 
               PosE=65
            END IF
            
            String2=AdjustL(Trim(String(1:PosE)))
            LenS=Len_Trim(String2)
 !        WRITE(*,*) "DBG Head:",LenS, String
            Pos1=33-Int(LenS/2)
            Len1=67-LenS-Pos1

            WRITE(*,'(A)') "=" // Sep(1:Pos1) // TRIM(String2) // Sep(1:Len1) // "="
            String2=String(PosE+1:)
            String=AdjustL(String2)
            LenS=Len_Trim(String)
      END DO

         Pos1=34-Int(LenS/2)
         Len1=67-LenS-Pos1
         
         WRITE(*,'(A)') "=" // Sep(1:Pos1) // TRIM(String) // Sep(1:Len1) // "="

         WRITe(*,'(A)') Head1

           If (debug) THEN
              WRITe(*,'(A)') Head1
              WRITE(*,'(A)') "=     Exiting Header.... "
              WRITe(*,'(A)') Head1
           END IF


       END subroutine Header
