C
C                            MAINPROGRAMME
C
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C +                                                                    +
C + THE MAINPROGRAMM READS THE SELECTION CARDS (SPSCAN,TDSCOR,ABSORB,  +
C + SPHERE,AVERAG,REFINE,FOURIE,ERRMAP,PDFMAP,POTCAL,ARBSEC,PLOTTE,    +
C + BONVIB,LISTFC,FINISH,NTITEL) AND CALLS THE CORRESPONDING OVERLAYS. +
C + WRITTEN BY E. PERENTHALER AND U. ZUCKER MPI-FKF (1979)             +
C +                                                                    +
C + (LAST UPDATE APRIL 1987 BY W.F.KUHS)                              +
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   - SAME FOR OUTPUT-UNIT
C   - NUMBER IS DIMENSION OF FIELDS IN COMMON/OVNAM/
C    -IN,IOUT       Nummern der PAR und LIS files (9,7)
C    -INUNIT,IOUNIT Nummern der Eingabe- und Ausgabe DAT files (31,20)
C
      DIMENSION LINE(11)
C
      DIMENSION IOVERL(19),IAY(19)
C
C---- DATA STATEMENTS
C
C---- DIMENSION OF FIELDS IN COMMON /OVNAM/
C
      DATA NUMBER/19/
C
C---- NAME OF RESPONSIBLE MAN
C
      DATA LINE/4H   W,4H.F. ,4HKUHS,4H   I,4HLL19,4H  RO,
     & 4HOM 2,4H14  ,4H  TE,4HL. 7,4H232 /
C
C---- LOGICAL UNITS FOR INPUT (IN) AND OUTPUT (IOUT)
C  9=PAR-file   7=LIS-File
      DATA IN,IOUT/9,7/
C
C---- TABLE OF LEGAL OVERLAY NAMES
C
      DATA IOVERL/4HSPSC,4HTDSC,4HABSO,4HSPHE,4HAVER,4HREFI,4HFOUR,
     &4HERRM,4HPDFM,4HPOTC,4HARBS,4HPLOT,4HBONV,4HLIST,4HPRED,4HFINI,
     &4HNTIT,4H    ,4HMULP/
      DATA IAY/2HAN,2HOR,2HRB,2HRE,2HAG,2HNE,2HIE,2HAP,2HAP,2HAL,2HEC,
     &2HTE,2HIB,2HFC,2HES,2HSH,2HLE,2H  ,2HDF/
C
C---- INITIALIZE
C
C---- LOGICAL UNIT OF THAT FILE ON WHICH PLOTTING ORDERS TO BE
C     WRITTEN.
C
      IPLOT=63
C
C---- MAXIMUM LINES PER PAGE OF PRINTER USED.
C
      MAXLIN = 59
C
C---- MARK .EQ. ZERO MEANS PRINTOUT OF PROGRAM TITLE PAGE
C
      MARK = 0
C
C---- OTHERS
C
      IREW19=0
      IZAEHL=0
      ILAB = 0
      IERR = 0
      ITITEL = 1
      ISTOP = 0
C
C---- THE VARIABLE ITOP IS SET TO 1, IF COVER IS PRINTED. OTHERWISE
C     IT COULD HAPPEN ERRORMESSAGES WILL PRINTED IN COVER.
C
      ITOP = 0
C**** INITIALIZE LPT-FILE ON MICRO-VAX
C
	OPEN (UNIT=7,TYPE='NEW')
	OPEN (UNIT=9,STATUS='OLD')
C
C---- READ LABEL OF OVERLAY. COMPARE WITH TABLE OF LEGAL NAMES AND
C     SWITCH.
C
C---- SET CLOCK TO START
C
   01 CALL ZEIT(ILAB,IOVERL,IAY,TTINI,TOVINI)
      IF(ITITEL.EQ.1) ITOP = 1
      IF(ISTOP.EQ.1) GO TO 3020
C

   02 CONTINUE
      ITITEL = 1
       GO TO 500
  500 CALL AVERAG(IN,IOUT,LINE,MAXLIN,MARK)
      ISTOP = 1
      GO TO 01
C
 2050 WRITE(IOUT,2060)
 2060 FORMAT(5(/),1X,45H*END OF FILE* WAS READ ON STANDARD INPUT UNIT,
     & 17H. JOB TERMINATED.)
      IERR = 1
C
 3000 IF(IREW19.NE.1)GOTO 3020
      WRITE(IOUT,3010) IPLOT
 3010 FORMAT(44H0*END OF FILE* WRITTEN TO THE PLOTTING FILE. ,
     & 14H (LOG.-NO. IS ,I4,1H) )
C
C---- THERE ARE TWO POSSIBILITIES OF GENERATING END OF FILE ON PLOTTER
C     FILE IPLOT. THE FIRST WAY IS BY CALLING OVERLAY PLOTT AGAIN  AND
C     AND DO IT THERE. (NOT POSSIBLE ON HONEYWELL BULL). THE SECOND IS
C     BY DOING IT HERE. ON SOME COMPUTERS LIKE UNIVAC 1110 ON EXEC  IT
C     IS NOT RECOMMEND, BECAUSE OF GREAT  COREALLOCATION  OF  PLOTTING
C     SOFTWARE.
C
 3020 CALL ENDE(1)
      CALL ZEIT (100,IOVERL,IAY,TTINI,TOVINI)
      IF(IERR.EQ.0) WRITE(IOUT,3030)
      IF(IERR.EQ.1) WRITE(IOUT,3040)
 3030 FORMAT(19H0NORMAL TERMINATION)
 3040 FORMAT(4(/),21H ABNORMAL TERMINATION)
      STOP
      END
                        SUBROUTINE ANFANG
     &                          (L)
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C +                                                                    +
C + SUBROUTINE ANFANG WITH THE ENTRY ENDE CALLS THE ACTUAL TIME WITH   +
C +                                                                    +
C + ******* THE HONEYWELL BULL COMMAND   DATIM   ********              +
C +                                                                    +
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 + UPDATED AND ADAPTED TO THE D9 MICROVAX BY W.F.KUHS (APRIL 1987)    +
C +                                                                    +
C + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C---- TYPE STATEMENTS
C     ---------------
C
      CHARACTER*8 ZEIT
      CHARACTER*9 IDATE
C
      K = 1
      GO TO 1
      ENTRY ENDE (L)
      K = 2
    1 CALL DATE(IDATE)
      CALL TIME(ZEIT)
c
      IF (K .EQ. 2) GO TO 15
      IF (L .EQ. 1) GO TO 6
      WRITE (7,10) IDATE
   10 FORMAT(19H PROGRAM STARTED   ,A9,4X,4H    ,5X,3X,5X)
      GO TO 30
    6 WRITE (7,11) IDATE,ZEIT
   11 FORMAT(1X,18HPROGRAM STARTED   ,A9,4X,4HAT  ,A8)
   30 RETURN
   15 IF (L .EQ. 1) GO TO 7
      WRITE (7,20) IDATE
   20 FORMAT(21H0PROGRAM FINISHED    ,A9,4X,4H    ,5X,3X,5X)
      GO TO 40
    7 WRITE (7,21) IDATE,ZEIT
   21 FORMAT(1H0,20HPROGRAM FINISHED    ,A9,4X,4HAT  ,A8)
   40 RETURN
      END
                          SUBROUTINE  ZEIT
     &              (IND,IOVERL,IAY,TTINI,TOVINI)
C
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C +                                                                    +
C +   THIS SUBROUTINE CALCULATES WITH HELP OF THE                      +
C +                                                                    +
C +   ****** HONEYWELL BULL COMMAND   PTIME   ******                   +
C +                                                                    +
C +   THE CPU-TIME USED FOR EACH OVERLAY AND THE TOTAL RUN AND         +
C +   PRINTS IT.                                                       +
C +   WRITTEN BY E. PERENTHALER MPI-FKF (FEBRUARY 1980)                +
C +                                                                    +
C ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
C---- DIMENSION STATEMENTS
C     --------------------
C
C     DIMENSION IOVERL(17),IAY(17)
C
C---- ASKING FOR THE CPU-TIME IN HOURS USED SINCE STARTING THIS RUN
C     CALL PTIME(T)
C
C     STARTING POINT OF THE RUN
C     IF (IND .NE. 0) GO TO 10
C     TTINI = T
C     TOVINI = T
      RETURN
C
C---- CALCULATING THE TIME IN HOURS, MINUTES, AND SECONDS
C  10 IF (IND .EQ. 100) TOVINI = TTINI
C     G = T - TOVINI
C     I1 = INT (G)
C     I2 = INT ((G - AINT (G)) * 60.)
C     T3 = (G - AINT (G) - FLOAT (I2) / 60.) * 3600.
C     TOVINI = T
C     IF (IND .LT. 15) WRITE (06,20) IOVERL(IND),IAY(IND),I1,I2,T3
C  20 FORMAT(3(/),31H CPU-TIME USED FOR THE OVERLAY ,A4,A2,3H = ,
C    &I3,6H HOURS,I3,8H MINUTES,F10.6,9H SECONDS.)
C     IF (IND .EQ. 100) WRITE (06,100) I1,I2,T3
C 100 FORMAT(3(/),38H CPU-TIME USED FOR THE COMPLETE RUN = ,
C    &I3,6H HOURS,I3,8H MINUTES,F10.6,9H SECONDS.)
C     RETURN
      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   - IOV     NUMBER OF THE CALLING PROGRAMME
C   - IB      LENTH OF THE TEXT BLOCK ON THE COVER OF THIS PROGRAMME
C
C---- DIMENSION STATEMENTS
C     --------------------
C
      DIMENSION IOVERL(14),IAY(14)
C
C---- DATA STATEMENTS
C     ---------------
C
C---- TABLE OF LEGAL OVERLAY NAMES
C
      DATA IOVERL/4HSPSC,4HTDSC,4HABSO,4HSPHE,4HAVER,4HREFI,4HFOUR,
     &4HERRM,4HPDFM,4HPOTC,4HARBS,4HPLOT,4HBONV,4HLIST/
C
      DATA IAY/2HAN,2HOR,2HRB,2HRE,2HAG,2HNE,2HIE,2HAP,2HAP,2HAL,2HEC,
     &2HTE,2HIB,2HFC/
      DATA INIX/1H /
C
C---- FORMAT STATEMENTS
C     -----------------
C
   10 FORMAT (1H1,3X,18(A4,A2,1X))
   40 FORMAT (A1)
   70 FORMAT (4X,18(A4,A2,1X))
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) (IOVERL(IOV),IAY(IOV),I=1,18)
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) (INIX,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) (INIX,I=1,IS)
C
C---- LAST LINE OF THE COVER
      WRITE (IO,70) (IOVERL(IOV),IAY(IOV),I=1,18)
C
      RETURN
      END
