C                            MAINPROGRAMME
C
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C +                                                                    +
C + WRITTEN BY E. PERENTHALER AND U. ZUCKER MPI-FKF (1979)             +
C +                                                                    +
C + (LAST UPDATE DEZEMBER 1980)                                        +
C +                                                                    +
C + IN ADDITION THE FOLLOWING SUBROUTINES ARE CALLED                   +
C + TITEL, TIME, ANFANG (ENTRY 'ENDE')                                 +
C +                                                                    +
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C
C---- DIMENSION DECLARATION FOR PROGRAMMES OF THE NEW GENERATION
C
C   - In the field LINE one has to write the name of that person,
C     who is responsible for correct running of PROMETHEUS
C   - MAXLIN  is the number of lines per page for the printer used.
C   - IN is logical number of standard input unit
C   - OUT same for output-unit
C   - MARK = 0 means print out the program title page
C
	CHARACTER*4 LABEL
C
	DIMENSION LINE(11)
	DATA LINE/4H   W,4H.F. ,4HKUHS,4H    ,4HUNI ,4HKARL,
	1  4HRUHE,4H    ,4H  TE,4HL. 3,4H317 /
	DATA IN,IOUT/09,17/
	MAXLIN = 59
	MARK = 0
C
C---- OTHERS
C
      ITITEL = 1
C
C--- OPEN CONTROL AND LISTING FILES
C
	OPEN(UNIT=IN,STATUS='OLD',IOSTAT=IOERROR)
	IF(IOERROR.NE.0) 
	1   STOP 'ERROR: Unable to open control parameter file'
	OPEN(UNIT=IOUT,STATUS='NEW')
C
C Skip the LABEL card if present
C
	READ(IN,1000) LABEL
1000	FORMAT(A4)
	IF(LABEL .NE. 'REFI') REWIND(UNIT=IN)
C
	CALL CALREF(IN,IOUT,LINE,MAXLIN,MARK)
C
C---- FINISHING UP
C
	CALL ENDE(0,IOUT)
	END


                        SUBROUTINE ANFANG (L,IOUT)
C
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C +                                                                    +
C + SUBROUTINE ANFANG WITH THE ENTRY ENDE CALLS THE ACTUAL TIME        +
C + AND PRINTS IT AS STARTING TIME OR TIME OF TERMINATION OF A         +
C + PROGRAMME, DEPENDING ON THE CALLED ENTRY  ANFANG  OR  ENDE.        +
C + WRITTEN BY E. PERENTHALER (JULY 1979)                              +
C +                                                                    +
C + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C---- TYPE STATEMENTS
C     ---------------
C
	CHARACTER DAT*9,TIM*8
C
	CALL DATE(DAT)
	CALL TIME(TIM)
	IF (L .NE. 1) WRITE (IOUT,10) DAT,TIM
10	FORMAT(17H PROGRAM START   ,A9,2X,A8)
	IF (L .EQ. 1) WRITE (IOUT,11) DAT,TIM
11	FORMAT(37X,16HPROGRAM START   ,A9,2X,A8)
	RETURN
C
	ENTRY ENDE (L,IOUT)
	CALL DATE(DAT)
	CALL TIME(TIM)
	IF (L .NE. 1) WRITE (IOUT,20) DAT,TIM
20	FORMAT(//,21H0PROGRAM FINISHED    ,A9,2X,A8)
	IF (L .EQ. 1) WRITE (IOUT,21) DAT,TIM
21	FORMAT(//,1H0,35X,20HPROGRAM FINISHED    ,A9,2X,A8)
	RETURN
C
	END


                         SUBROUTINE TITEL(IOUT)
C
C       THIS ROUTINE GENERATES THE COVER OF THE SYSTEM PROMETHEUS
C
C             PROGRAMMERS   E. PERENTHALER AND U. ZUCKER
C
C                             NOVEMBER 1980
C
C----            IOUT IS LOGICAL NUMBER OF OUTPUT UNIT
C
C---- PRINT COVER. (THERE ARE MORE THAN ONE FORMAT STATEMENT, BECAUSE
C      OF A POSSIBLE MAXIMUM NUMBER OF CONTINUATION CARDS ALLOWED)
C
      WRITE(IOUT,1)
      WRITE(IOUT,2)
      WRITE(IOUT,3)
      WRITE(IOUT,4)
      WRITE(IOUT,5)
C
C---- WRITE COVER.   FIRST IN GREAT LETTERS    PROMETHEUS
C
C---- FIRST LINE
    1 FORMAT(1H1,4(/),10X,8(1HX),3X,8(1HX),5X,6(1HX),3X,3(1HX),4X,3(1HX
     & ),1X,10(1HX),1X,11(1HX),1X,3(1HX),4X,3(1HX),1X,10(1HX),1X,3(1HX
     & ),4X,3(1HX),3X,8(1HX)/
     & 10X,9(1HX),2X,9(1HX),3X,8(1HX),2X,3(1HX),4X,3(1HX),1X,10(1HX),1
     & X,11(1HX),1X,3(1HX),4X,3(1HX),1X,10(1HX),1X,3(1HX),4X,3(1HX),1X
     & ,10(1HX)/
     & 10X,3(1HX),4X,3(1HX),1X,3(1HX),4X,3(1HX),1X,3(1HX),4X,3(1HX),1X
     & ,3(1HX),4X,3(1HX),1X,3(1HX),12X,3(1HX),5X,3(1HX),4X,3(1HX),1X,3
     & (1HX),8X,3(1HX),4X,3(1HX),1X,3(1HX)/
     & 10X,3(1HX),4X,3(1HX),2(1X,3(1HX),4X,3(1HX)),1X,4(1HX),2X,4(1HX)
     & ,1X,3(1HX),12X,3(1HX),5X,3(1HX),4X,3(1HX),1X,3(1HX),8X,3(1HX),4
     & X,3(1HX),1X,3(1HX)/
     & 10X,9(1HX),2X,9(1HX),2X,3(1HX),4X,3(1HX),1X,10(1HX),1X,8(1HX),
     & 7X,3(1HX),5X,10(1HX),1X,8(1HX),3X,3(1HX),4X,3(1HX),2X,5(1HX))
C
C---- SIXTH LINE
   2  FORMAT(
     & 10X,8(1HX),3X,6(1HX),5X,3(1HX),4X,3(1HX),1X,10(1HX),1X,8(1HX),
     & 7X,3(1HX),5X,10(1HX),1X,8(1HX),3X,3(1HX),4X,3(1HX),4X,6(1HX)/
     & 10X,3(1HX),8X,3(1HX),1X,3(1HX),4X,3(1HX),4X,3(1HX),1X,3(1HX),1
     & X,2(1HX),2(1X,3(1HX)),12X,3(1HX),5X,3(1HX),4X,3(1HX),1X,3(1HX)
     & ,8X,3(1HX),4X,3(1HX),8X,3(1HX)/
     & 10X,3(1HX),8X,3(1HX),2X,3(1HX),3X,3(1HX),4X,3(1HX),1X,3(1HX),4X
     & ,3(1HX),1X,3(1HX),12X,3(1HX),5X,3(1HX),4X,3(1HX),1X,3(1HX),8X,3
     & (1HX),4X,3(1HX),8X,3(1HX)/
     & 10X,3(1HX),8X,3(1HX),3X,3(1HX),3X,8(1HX),2X,3(1HX),4X,3(1HX),1
     & X,10(1HX),5X,3(1HX),5X,3(1HX),4X,3(1HX),1X,10(1HX),2X,8(1HX),2
     & X,9(1HX)/
     & 10X,3(1HX),8X,3(1HX),4X,3(1HX),3X,6(1HX),3X,3(1HX),4X,3(1HX),1
     & X,10(1HX),5X,3(1HX),5X,3(1HX),4X,3(1HX),1X,10(1HX),3X,6(1HX),3
     & X,8(1HX),5(/))
C
C---- PRINT NOW     THE FIRE BEARING
C
C---- FIRST LINE
    3 FORMAT(21X,1HX,4X,1HX,18X,2(1HX),2X,1HX,18X,1HX,27X,1HX/
     & 21X,1HX,4X,1HX,17X,1HX,23X,1HX/
     & 19X,5(1HX),2X,4(1HX),4X,3(1HX),5X,5(1HX),2X,1HX,2X,1HX,1X,
     & 3(1HX),2X,3(1HX),6X,4(1HX),4X,3(1HX),4X,3(1HX),3X,1HX,1X,
     & 3(1HX),2X,1HX,2X,1HX,1X,2(1HX),4X,3(1HX)/
     & 21X,1HX,4X,1HX,3X,1HX,2X,1HX,3X,1HX,6X,1HX,4X,1HX,2X,2HXX,4X,
     & 1HX,3X,1HX,5X,1HX,3X,1HX,2X,1HX,3X,1HX,2X,1HX,2X,1HX,3X,2HXX,
     & 5X,1HX,2X,2(1HX),2X,1HX,2X,1HX,3X,1HX/
     & 21X,1HX,4X,1HX,3X,1HX,2X,5(1HX),6X,1HX,4X,1HX,2X,1HX,5X,5(1HX)
     & ,5X,1HX,3X,1HX,2X,5(1HX),2X,1HX,2X,1HX,3X,1HX,6X,1HX,2X,1HX,3X
     & ,1HX,2X,1HX,3X,1HX/
     & 21X,1HX,4X,1HX,3X,1HX,2X,1HX,10X,1HX,4X,1HX,2X,1HX,5X,1HX,9X,
     & 1HX,3X,1HX,2X,1HX,6X,1HX,2X,1HX,3X,1HX,6X,1HX,2X,1HX,3X,1HX,2X
     & ,1HX,3X,1HX/
     & 21X,1HX,4X,1HX,3X,1HX,3X,4(1HX),6X,1HX,4X,1HX,2X,1HX,6X,4(1HX)
     & ,5X,4(1HX),4X,4(1HX),3X,4(1HX),2X,1HX,6X,1HX,2X,1HX,3X,1HX,3X,
     & 4(1HX)/
     & 110X,1HX/106X,4(1HX),5(/))
C
C---- PRINT NOW    TITAN GOD
C
C---- FIRST LINE
    4 FORMAT(39X,5(1HX),2X,1HX,4X,1HX,21X,3(1HX),14X,1HX/
     & 41X,1HX,9X,1HX,20X,1HX,17X,1HX/
     & 41X,1HX,4X,1HX,2X,5(1HX),3X,3(1HX),3X,1HX,1X,3(1HX),4X,1HX,1X,
     & 3(1HX),3X,3(1HX),4X,4(1HX)/
     & 41X,1HX,4X,1HX,4X,1HX,4X,1HX,2X,1HX,3X,2(1HX),2X,1HX,4X,1HX,3X
     & ,1HX,2X,1HX,3X,1HX,2X,1HX,3X,1HX/
     & 41X,1HX,4X,1HX,4X,1HX,4X,1HX,2X,1HX,3X,1HX,3X,1HX,4X,1HX,3X,
     & 1HX,2X,1HX,3X,1HX,2X,1HX,3X,1HX/
     & 41X,1HX,4X,1HX,4X,1HX,4X,1HX,2X,1HX,3X,1HX,3X,1HX,4X,1HX,3X,
     & 1HX,2X,1HX,3X,1HX,2X,1HX,3X,1HX/
     & 41X,1HX,4X,1HX,4X,1HX,5X,4(1HX),2X,1HX,3X,1HX,5X,3(1HX),4X,
     & 3(1HX),4X,4(1HX),5(/))
C
C---- PRINT REST OF COVER
C
    5 FORMAT(38X,45HPROGRAMME SYSTEM FOR SOPHISTICATED STRUCTURE ,
     & 10HREFINEMENT,7(/),
     & 52X,21HVERSION OF APRIL 1981,7(/),
     & 44X,39HU.H. ZUCKER, E. PERENTHALER & W.F. KUHS)
C
      RETURN
      END
                          SUBROUTINE SPACE
     &                  (N,IOV,IB,IO,MAXLIN)
C
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C +                                                                    +
C + SUBROUTINE SPACE PRINTS THE FIRST AND THE LAST LINE OF THE COVER   +
C + FOR EACH PROGRAMME AND POSITIONES THE TEXT BLOCK OF THE COVER      +
C + DEPENDING ON THE MAXIMUM NUMBER OF LINES PER PAGE (MAXLIN).        +
C + WRITTEN BY E. PERENTHALER  MPI-FKF (DEZEMBER 1980)                 +
C +                                                                    +
C + THIS PROGRAMME IS CALLED BY EACH PROGRAMM OF THE SYSTEM            +
C + PROMETHEUS.                                                        +
C +                                                                    +
C + THIS PROGRAMME DO NOT CALL ANY OTHER SUBROUTINE.                   +
C +                                                                    +
C + IN CASE OF AN OVERLAY STRUCTURE IT IS PART OF THE MAIN-OVERLAY     +
C +                                                                    +
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C
C---- INPUT VARIABLES
C     ---------------
C
C   - N       FIRST OR SECOND CALL BY ONE OF THE PROGRAMMES
C             (BEGIN OR END OF THE COVER TO BE PRINTED)
C   - IB      LENTH OF THE TEXT BLOCK ON THE COVER OF THIS PROGRAMME
C
C---- FORMAT STATEMENTS
C     -----------------
C
   10 FORMAT (4X,18('REFINE',1X))
   40 FORMAT (A1)
C
C---- EXECUTABLE STATEMENTS
C     ---------------------
C
C---- BEGIN OR END OF THE COVER
      IF (N .EQ. 2) GO TO 20
C
C---- FIRST LINE OF THE COVER
      WRITE (IO,10)
C
C---- NUMBER OF EMPTY LINES TILL START OF TEXT BLOCK
   20 RMAXLI = FLOAT(MAXLIN)
      IS = IFIX(RMAXLI/3.)
      IF (MAXLIN - IS - IB - 4 .LT. 4) IS = MAXLIN - IB - 8
C
C---- BEGIN OR END OF THE COVER
      IF (N .EQ. 2) GO TO 50
C
C---- EMPTY LINES
      WRITE (IO,40) ('  ',I=1,IS)
C
      RETURN
C
C---- NUMBER OF EMPTY LINES BEHIND THE TEXT BLOCK
   50 IS = MAXLIN - IS - IB - 4
C
C---- EMPTY LINES
      WRITE (IO,40) ('  ',I=1,IS)
C
C---- LAST LINE OF THE COVER
      WRITE (IO,10)
C
      RETURN
      END


	SUBROUTINE EXIT
C
	STOP 'Possible error detected, see listing file'
	END
