



      PROGRAM AAMAIN






































      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INCLUDE       'STACK.INC'
      LOGICAL       DONTRUN
      CHARACTER*13  GETVERSION, VERSION
      DATA WCVERSION   /'WHATCHECK 8.0'/



      DONTRUN=.FALSE.
      INQUIRE (FILE='DONT.RUN',EXIST=DONTRUN) 
      IF (DONTRUN) THEN
         STOP 'Do not run in this directory, sufferd                   '
      END IF



      IU100  = 83 
      IU21   = 89 
      IU54   = 61
      KLOUNT = 13
      OUTUNT = 0
      OUTONF = .FALSE.




      DAVBUG=1



      CALL OPENFIG



      CALL OPENUNIT88



      CALL GVSCTB (DBGSTK,10*MAXSTK)
      NUMSTK=0 
      CALL GVSCTB (MEN3COD,3*MAXMEN)
      CALL GVSCTB (MEN3COM,3*MAXMEN)
      CALL GVSCTB (OPTION ,6*MAXMEN)
      CALL GVSCTB (MEN6COD,6*MAXMEN)
      CALL GVSCTB (MENCHAP,6*MAXMEN)
      CALL GVSCTB (MEN8COD,6*MAXMEN)



      CALL GVSCTB (DBEXT,2)



      CALL GVSNL6 (3)
      CALL GVSTT6 ('?T0002')



         VERSION=WCVERSION

      CALL GVSFMT ('?T0001')
      WRITE (6,FMT,ERR=999) VERSION




         CALL WCHECK








 999  CONTINUE

      END
      SUBROUTINE OPENFIG

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'QUALTY.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IPOS, I, L, GVFPOS, IERR, GVFPLS
      LOGICAL       GVFFOP, GVFISF







      L=0



      IF (GVFISF('WHATIF.FIG')) THEN
         CALL GVSOPF ('WHATIF.FIG',11,'OLD')
      END IF






      IF (.NOT.GVFFOP(11)) THEN
         CALL GETARG (0,LINE250)
         IPOS=GVFPLS(LINE250,'/')
         IF (IPOS.GT.0) THEN
            CALL GVSSTX (LINE250(IPOS+1:),'WHATIF.FIG')
            L=IPOS+10
            IF (GVFISF(LINE250(1:L))) THEN
               CALL GVSOPF (LINE250(1:L),11,'OLD')
            END IF
            IF (.NOT.GVFFOP(11).AND.IPOS.GT.2) THEN



               IPOS=GVFPLS(LINE250(1:IPOS-1),'/')
               IF (IPOS.GT.0) THEN
                  CALL GVSSTX (LINE250(IPOS+1:),'WHATIF.FIG')
                  L=IPOS+10
                  IF (GVFISF(LINE250(1:L))) THEN
                     CALL GVSOPF (LINE250(1:L),11,'OLD')
                  END IF
               END IF 
            END IF 



            IF (.NOT.GVFFOP(11)) THEN
               CALL GVSCCC (WHERIS,LINE250(1:IPOS),'dbdata/')
               CALL GVSCCC (QUAFLC,LINE250(1:IPOS),'qualty/')
               DO 4 I=1,20
                  IRISFLAGS(I)=.FALSE.
    4          CONTINUE
               IRISFLAGS(3)=.TRUE.
               JUNIOR=.FALSE.
               CALL GVSCCC (LINE2,LINE250(1:IPOS),'ascdata/MUTDB.IND')
               IF (.NOT.GVFISF(LINE2(1:IPOS+17))) THEN
                  WIFPAR(12)=1
                  CALL GVSTT6 ('MUTDB.IND not found; database disabled')
               ELSE
                  WIFPAR(12)=0
                  CALL PRP_READ_MUTDB (IERR)
                  IF (IERR.NE.0) GOTO 999
               END IF
               GOTO 998
            END IF
         END IF
         CALL GVST6C ('?T0003',LINE(1:L),.FALSE.)
      END IF

      IF (.NOT.GVFFOP(11)) THEN
         CALL GVSTT6 ('?T0016')
         CALL GVSNL6 (2)
         STOP '         '
      END IF



      READ (11,'(A80)',ERR=999,END=999) WHERIS



      IPOS=GVFPLS(WHERIS,'dbdata')
      IF (IPOS.LE.0) THEN
         CALL GVSKIL
         STOP
      END IF



   10 CONTINUE
      WIFPAR(12)=0
      CALL GETLINE (11,LINE,IERR)
      IF (IERR.EQ.0) THEN
         CALL GVSCUC (LINE)
         IF (GVFPOS(LINE,'DATABASE').EQ.0) GOTO 10
         IF (GVFPOS(LINE,'NO').NE.0) WIFPAR(12)=1
         JUNIOR=GVFPOS(LINE,'JUNIOR').NE.0
      ELSE
         CALL GVSTT6 ('?ERDBIN')
      END IF






      CALL GETLINE (11,QUAFLC,IERR)
      IF (IERR.NE.0) CALL GVSTTE ('?ERQBIN')



      CALL GETLINE (11,LINE,IERR)
      IF (IERR.NE.0) CALL GVSTTE ('?ERFBIN')
      CALL GVSCUC (LINE)
      CALL GVSFMT ('?FMT1537')
      READ (LINE,FMT,ERR=999) (IRISFLAGS(I),I=1,20)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('OPENFIG')



  998 CONTINUE
      CALL GVSCLF (11)


      RETURN
      END   

      SUBROUTINE WCHECK


















      IMPLICIT      NONE







      CALL REALINI
      CALL TIMESTAMP



      CALL PDBCHECK (.FALSE.)



      CALL FULLSTOP
      CALL GVSNL6 (5)
      CALL GVSTT6 ('?T0004')
      CALL GVSNL6 (3)


      STOP '          '
      END

      SUBROUTINE WHATIFLOOP


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       UKKELCNT
      LOGICAL       DONE







      DONE=.FALSE.
      UKKELCNT=0



   10 CONTINUE
         CALL ONECMD (DONE)




         IF (WIFPAR(67).NE.0) THEN
            WIFPAR(67)=0 
            GOTO 998
         END IF
      GOTO 10



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ONECMD (DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IERR
      LOGICAL       AHEAD, INTERRUPTED, DONE







      IF (.NOT.AHEAD()) THEN
         CALL WPROMPT
         CALL GETLINE5 (OPTINP,IERR)




         IF (WIFPAR(914).EQ.1) THEN
            CALL WIFPUSHPPP (914,2)
         ELSE
            CALL WIFPUSHPPP (914,WIFPAR(914))
         END IF

      END IF





      CALL ONE005



      IF (.NOT.AHEAD()) THEN
         IF (USE300) THEN
            WIFPAR(264)=0

               CALL IRI000

         END IF
         CALL WIF104 (OPTION,MAXOPT)
         GOTO 10
      END IF



      DONE=.FALSE.
      IF (WIFPAR(1105).NE.0) WIFPAR(1012)=0



      CALL ONE001 (IERR)
      IF (IERR.NE.0) THEN
         GOTO 999
      END IF



      CALL ONE002 (DONE,IERR)
      IF (DONE) GOTO 10
      IF (IERR.NE.0) THEN
         GOTO 999
      END IF



      IF (OPTINP(1:1).EQ.'$') THEN
         IF (WIFPAR(1072).EQ.0) THEN
            CALL GVSSPL (OPTINP)
         ELSE
            CALL SHOWTEXT ('?M0994')
            CALL GVST6C ('?M2457',OPTINP,.FALSE.)
         END IF
         CALL GVSCTB (OPTINP,LEN(OPTINP))
         DONE=.TRUE.
         GOTO 998
      END IF



      IF (OPTINP(1:1).EQ.'%') THEN
         CALL WIFPCT (DONE)
         IF (.NOT.DONE.AND.IRSTAT(6).NE.1) THEN
            CALL GVSBOX ('?BUGG19')
            CALL FLUSHAHEAD
         END IF
         IF (IRSTAT(99).EQ.0) DONE=.TRUE.
         GOTO 10
      END IF



      IF (OPTINP(1:1).EQ.'@') THEN
         OPTINP(1:1)=' '
         CALL GETWORD (LINE2,IERR)
         IF (IERR.EQ.0) CALL WIF002 (LINE2)
         DONE=.TRUE.
         GOTO 10
      END IF



      CALL GETWORD (OPTIN,IERR)
      IF (IERR.EQ.2) THEN
         GOTO 999
      END IF
      CALL GVSCUC (OPTIN)
      CALL W00002



      CALL ONE003 (DONE,IERR)
      IF (DONE) GOTO 10
      IF (IERR.NE.0) THEN
         GOTO 999
      END IF



      CALL MEN099 (OPTIN,DONE)
      IF (DONE) GOTO 10



      CALL ONE004 (DONE,IERR)
      IF (DONE) GOTO 10
      IF (IERR.NE.0) GOTO 999




         IF (OPTIN.EQ.'INIALL') THEN
            CALL INIALL
            GOTO 10
         END IF




      IF (OPTIN.EQ.'QUIT  ') THEN
         CALL WIF014
         GOTO 10
      END IF



      CALL DO_END (DONE)
      IF (DONE) GOTO 10










      IF (WIFPAR(1193).EQ.0) THEN
         CALL MEN000 (OPTIN)
      ELSE
         CALL GVSCCC (OPTINP,'%',OPTIN)
         CALL GVST6C ('?M2458',OPTINP,.FALSE.)
         CALL WIFPCT (DONE)
         IF (.NOT.DONE.AND.IRSTAT(6).NE.1) THEN
            CALL GVSBOX ('?BUGG19')
            CALL FLUSHAHEAD
         END IF
         IF (IRSTAT(99).EQ.0) DONE=.TRUE.
         IF (.NOT.DONE) CALL MEN000 (OPTIN)
      END IF



   10 CONTINUE
      IF (DONE.AND.JUNIOR.AND.USE300) CALL JUN001
      IF (WIFPAR(1179).EQ.1) THEN
         CALL MOL200
         WIFPAR(1179)=0
      END IF
      GOTO 998

  999 CONTINUE



  998 CONTINUE


      RETURN
      END

      SUBROUTINE DO_END (DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       I, WIF072, IERR
      LOGICAL       GVFEND, DONE







      IF (.NOT.GVFEND(OPTIN)) THEN  
         DONE=.FALSE.
         GOTO 998
      END IF



      DONE=.FALSE.



      IF (WIF072().GT.2) THEN
         MENULV(WIF072()-1)='      '



         IF (WIF072().LT.2) THEN
            MENNOW=1
            MENULV(1)=MEN8COD(1)
         ELSE
            DO 11 I=1,MAXMEN
               IF (MENULV(WIF072()-1).EQ.MEN8COD(I)) THEN
                  MENNOW=I
               END IF
 11         CONTINUE
         END IF
      ELSE
         CALL FULLSTOP
      END IF
      CALL ONE001 (IERR)
      CALL WIF104 (OPTION,MAXOPT)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE INIALL

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR








      WIFPAR(810)=0
      WIFPAR(276)=WIFPAR(294)
      CALL ITM013 (-1)
      CALL WIF023
      CALL WIF109


         IF (WIFPAR(12).EQ.0) THEN
            CALL PRP_READ_MUTDB (IERR)

            CALL WIFRDF
            CALL WIF103
            CALL WIF021
            CALL WIF112
         END IF

      CALL C1234567 ('In INIALL')










      CALL WIF024





      RETURN
      END   

      SUBROUTINE ONE001 (IERR)

















      IMPLICIT      NONE
      INCLUDE       'OPTION.INC'
      INTEGER       IERR
      CHARACTER*8   TMP







      IERR=0



      IF (MENMORE(MENNOW)) THEN
         CALL GVSSTX (TMP(1:3),MEN3COD(MENNOW))
         CALL GVSSTX (TMP(4:7),'MORE')
         CALL GETOPT (TMP(1:7),IERR)
      ELSE
         CALL GVSSTX (TMP(1:3),MEN3COD(MENNOW))
         CALL GVSSTX (TMP(4:8),'SHORT')
         CALL GETOPT (TMP(1:8),IERR)
      END IF





      RETURN
      END
      SUBROUTINE ONE002 (DONE,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      LOGICAL       DONE
      INTEGER       IERR










      CALL WIFHIS (OPTINP,IERR)
      IF (IERR.NE.0) THEN
         DONE=.TRUE.
      ELSE
         DONE=.FALSE.
      END IF





      RETURN
      END   
      SUBROUTINE ONE003 (DONE,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      LOGICAL       DONE
      INTEGER       IERR, I, GVFFCP







      DONE=.FALSE.
      IERR=0



      IF (OPTIN(1:5).EQ.'MORE ') THEN
         DONE=.TRUE.
         IF (.NOT.MENMORE(MENNOW)) THEN
            I=GVFFCP(OPTION,'MORE  ',MAXOPT,6)
            IF (I.EQ.0) THEN
               CALL GVSBOX ('?M0207')
               IERR=1
               GOTO 998
            END IF
            MENMORE(MENNOW)=.TRUE.
            CALL ONE001 (IERR)
            CALL WIF104 (OPTION,MAXOPT)
         END IF
      END IF



      IF (OPTIN(1:5).EQ.'LESS ') THEN
         DONE=.TRUE.
         IF (MENMORE(MENNOW)) THEN
            MENMORE(MENNOW)=.FALSE. 
            CALL ONE001 (IERR)
            CALL WIF104 (OPTION,MAXOPT)
         ELSE
            CALL GVSBOX ('?M0208')
         END IF
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ONE004 (DONE,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INTEGER       IERR, IPOS, GVFFCP
      LOGICAL       DONE
      CHARACTER*10  TMP







      IERR=0
      DONE=.FALSE.



      IF (OPTIN(1:5).EQ.'HELP ') THEN
         DONE=.TRUE.
         CALL IPROMPT ('?M0730')
         CALL GETWORD (HITEM,IERR)
         IF (IERR.NE.0) GOTO 998
         CALL GVSCUC (HITEM)
         IPOS=GVFFCP(MEN6COD,HITEM,MAXMEN,6)
         IF (IPOS.NE.0) THEN
            CALL INF006 (HITEM,IERR)
            IF (IERR.EQ.0) GOTO 998
         END IF
         IF (HITEM.NE.'      ') THEN
            IF (WIFPAR(621).NE.0) THEN
               CALL INF004 ('TEACH',HITEM)
               GOTO 998
            END IF
            CALL INF002 (HITEM,OPTION,MAXOPT,MEN3COM(MENNOW),IERR)
            CALL INF004 (MENCHAP(MENNOW),HITEM)
            IF (IERR.EQ.0) GOTO 998
         ELSE
            CALL SHOWTEXT ('?HLPHLP')
         END IF
         GOTO 998
      END IF



      IF (OPTIN(1:5).EQ.'INFO ') THEN
         DONE=.TRUE.
         CALL IPROMPT ('?M0730')
         CALL GETWORD (HITEM,IERR)
         IF (IERR.NE.0) GOTO 998
         CALL GVSCUC (HITEM)
         IPOS=GVFFCP(MEN6COD,HITEM,MAXMEN,6)
         IF (IPOS.NE.0) THEN
            CALL INF006 (HITEM,IERR)
            IF (IERR.EQ.0) GOTO 998
         END IF
         IF (HITEM.NE.'      ') THEN
            IF (WIFPAR(621).NE.0) THEN
               CALL INF001 ('TEACH',HITEM)
               GOTO 998
            END IF
            CALL INF002 (HITEM,OPTION,MAXOPT,MEN3COM(MENNOW),IERR)
            CALL INF001 (MENCHAP(MENNOW),HITEM)
            GOTO 998
         ELSE
            CALL SHOWTEXT ('?INFINF')
            DONE=.TRUE.
         END IF
         GOTO 998
      END IF



      IF (OPTIN.EQ.'SHORT ') THEN
         DONE=.TRUE.
         TMP(1:1)='?'
         CALL GVSSTX (TMP(2:4),MEN3COD(MENNOW))
         IF (MENMORE(MENNOW)) THEN
            CALL GVSSTX (TMP(5:8),'MORE')
            CALL SHOWTEXT (TMP(1:8))
         ELSE
            CALL GVSSTX (TMP(5:9),'SHORT')
            CALL SHOWTEXT (TMP(1:9))
         END IF
         GOTO 998
      END IF



      IF (OPTIN(1:5).EQ.'FIND ') THEN
         DONE=.TRUE.
         CALL IPROMPT ('?M0730')
         CALL GETWORD (HITEM,IERR)
         IF (IERR.NE.0) GOTO 998
         CALL GVSCUC (HITEM)
         IPOS=GVFFCP(MEN6COD,HITEM,MAXMEN,6)
         IF (IPOS.NE.0) THEN
            CALL INF006 (HITEM,IERR)
            IF (IERR.EQ.0) GOTO 998
         END IF
         IF (HITEM.NE.'      ') THEN
            CALL INF007 (HITEM)
         ELSE
            CALL SHOWTEXT ('?HLPHLP')
            DONE=.TRUE.
         END IF
         GOTO 998
      END IF



      IF (OPTIN(1:6).EQ.'MAN-K '.OR.OPTIN(1:6).EQ.'MAN -K') THEN
         CALL INF005 (1,IERR)
         DONE=.TRUE.
         GOTO 998
      END IF



      IF (OPTIN(1:6).EQ.'MAN-KK') THEN
         CALL INF005 (2,IERR)
         DONE=.TRUE.
         GOTO 998
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ONE005

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR, GVFLEN, I
      LOGICAL       GVFICN
      CHARACTER*250 PEEKWD








 10   CONTINUE
      IF (OPTINP(1:2).EQ.'%%') THEN
         OPTINP(1:1)=' '
         CALL GVSSHL (OPTINP)
         GOTO 10
      END IF



      IF (GVFICN(OPTINP(1:1))) THEN
         CALL GVSCTB (PEEKWD,250)
         CALL PEEKWORD (PEEKWD,IERR)
         IF (IERR.EQ.0) THEN
            IF (GVFLEN(PEEKWD).GT.6) THEN
               DO 20 I=7,GVFLEN(PEEKWD)
                  OPTINP(I:I)=' '
 20            CONTINUE
            END IF
         END IF
      END IF





      RETURN
      END   
      SUBROUTINE REALINI

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IERR
      LOGICAL       FIRST
      SAVE          FIRST
      DATA FIRST    /.TRUE./








         CALL GVSNL6 (3)
         CALL GVSTT6 ('?T0008')

      CALL GVSNL6 (5)



      CALL WIF000
      CALL TOP001
      WIFPAR(1104)=WIFPAR(276)



      CALL WIF014



      WIFPAR(536)=0










      RETURN
      END   
      SUBROUTINE W00000

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       I, NLINES
      CHARACTER*80  BUF(MAXMEN)
      EQUIVALENCE   (BUF(1),ESPACE(60001))







      CALL ESPSET (60001,60000+80*MAXMEN/4,9)



      CALL GVSCTB (BUF,MAXMEN*80)
      CALL GVSBTF (MENMORE,MAXMEN)
      CALL GVSBTF (MENUSED,MAXMEN)
      CALL GVSIT0 (MENSTAT,MAXMEN)
      CALL GVSCTB (MENULV,8*100)



      CALL CGETTEXT ('?GLOB',5,BUF,NLINES,MAXMEN) 
      DO 10 I=1,NLINES
         CALL GVSSTX (MEN3COD(I),BUF(I)(10:12))
         CALL GVSSTX (MEN3COM(I),BUF(I)(14:16))
         CALL GVSSTX (MEN6COD(I),BUF(I)(1:6))
         CALL GVSSTX (MENCHAP(I),BUF(I)(27:32))
         CALL GVSSTX (MEN8COD(I),BUF(I)(18:25))
   10 CONTINUE



      CALL ESPKIL (60001,60000+80*MAXMEN/4,9,'W00000')





      RETURN
      END   

      SUBROUTINE W00002

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'OPTION.INC'
      INTEGER       I, GVFFCP, IERR, GVFPOS







      IF (MENNOW.EQ.1.AND.OPTIN.EQ.'SHORT ')CALL GVSSTX (OPTIN,'SHORTT')
      IF (OPTIN.EQ.'PARAMS') THEN
         CALL GVSCCC (OPTIN,'PAR',MEN3COD(MENNOW))
         IF (OPTIN.EQ.'PARGR2') CALL GVSSTX (OPTIN,'PARCON')
         IF (OPTIN.EQ.'PARS3D') CALL GVSSTX (OPTIN,'PARSCN')
         IF (OPTIN.EQ.'PARSDB') CALL GVSSTX (OPTIN,'PARSCN')
         IF (OPTIN.EQ.'PAR3SP') CALL GVSSTX (OPTIN,'PARSUP')
         I=GVFFCP(MEN6COD,OPTIN,MAXMEN,6)
         IF (I.EQ.0) THEN
            CALL GVSBOX ('?M0209')
            CALL GVSSTX (OPTIN,'SETPAR')
         END IF
      END IF
      IF (OPTIN.EQ.'GRAPHI'.OR.OPTIN.EQ.'GARFIC'.OR.
     +    OPTIN.EQ.'GRFAIC') CALL GVSSTX (OPTIN,'GRAFIC')
      IF (OPTIN.EQ.'QUALIT') CALL GVSSTX (OPTIN,'QUALTY')
      IF (OPTIN.EQ.'SPECIA') CALL GVSSTX (OPTIN,'SPCIAL')
      IF (OPTIN.EQ.'COLOR ') CALL GVSSTX (OPTIN,'COLOUR')
      IF (OPTIN.EQ.'CLUSTE') CALL GVSSTX (OPTIN,'CLUFAM')
      IF (OPTIN.EQ.'FAMILY') CALL GVSSTX (OPTIN,'CLUFAM')
      IF (OPTIN.EQ.'MAKDB ') CALL GVSSTX (OPTIN,'SEQ3D ')
      IF (OPTIN.EQ.'CLUSTR') CALL GVSSTX (OPTIN,'CLUFAM')
      IF (OPTIN.EQ.'CLSTER') CALL GVSSTX (OPTIN,'CLUFAM')
      IF (OPTIN.EQ.'COLSS ') CALL GVSSTX (OPTIN,'COLSCH')
      IF (OPTIN.EQ.'ZONE  ') CALL GVSSTX (OPTIN,'ZONES ')
      IF (OPTIN.EQ.'SYM   ') CALL GVSSTX (OPTIN,'SYMTRY')
      IF (OPTIN.EQ.'PLIM  ') CALL GVSSTX (OPTIN,'GRID  ')
      IF (OPTIN.EQ.'MAP   ') CALL GVSSTX (OPTIN,'MAPMEN')
      IF (OPTIN.EQ.'NMR   ') CALL GVSSTX (OPTIN,'NMRNMR')
      IF (OPTIN.EQ.'ROB   ') CALL GVSSTX (OPTIN,'ROBROB')
      IF (OPTIN.EQ.'SS    ') CALL GVSSTX (OPTIN,'GRASCH')
      IF (OPTIN.EQ.'SUGAR ') CALL GVSSTX (OPTIN,'SUGARS')
      IF (OPTIN.EQ.'SCNPDB') CALL GVSSTX (OPTIN,'PDBSCN')
      IF (OPTIN.EQ.'MAN   ') THEN
         CALL GVSCTB (LINE,80)
         CALL GETWORD (LINE,IERR)
         CALL GVSSHL (LINE)
         IF (GVFPOS(LINE,'-K').EQ.0) THEN
            CALL GVSTTE ('?T0012')
            CALL GVSTTE ('?T0013')
         END IF
         CALL GVSSTX (OPTIN,'MAN-K')
      END IF





      RETURN
      END   
      SUBROUTINE WIF000


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INTEGER       IPOS, L, GVFPLS







      CALL GVSCTB (TPTXLN,LENTPT)
      CALL GVSCTB (FILNMS,80*100)
      CALL SET1234567
      L=0




      CALL GVSCTB (FILDIR,100*80)




         IPOS=GVFPLS(WHERIS,'/dbdata')
         IF (IPOS.LE.0) THEN
            CALL GVSTT6 ('?HIERAR')
            STOP
         END IF
         CALL GVSCCC (FILDIR(1), WHERIS(1:IPOS),'newdb/')
         CALL GVSCCC (FILDIR(2), WHERIS(1:IPOS),'gromacs/')
         CALL GVSCCC (FILDIR(3), WHERIS(1:IPOS),'dssp/')
         CALL GVSCCC (FILDIR(4), WHERIS(1:IPOS),'delphi/')
         CALL GVSCCC (FILDIR(5), WHERIS(1:IPOS),'bin/')
         CALL GVSCCC (FILDIR(6), WHERIS(1:IPOS),'grid/')
         CALL GVSCCC (FILDIR(7), WHERIS(1:IPOS),'concrd/')
         CALL GVSCCC (FILDIR(8), WHERIS(1:IPOS),'jmol/')
         CALL GVSCCC (FILDIR(9), WHERIS(1:IPOS),'david/')
         CALL GVSCCC (FILDIR(10),WHERIS(1:IPOS),'prodrug/')
         CALL GVSCCC (FILDIR(11),WHERIS(1:IPOS),'scatter/')
         CALL GVSCCC (FILDIR(13),WHERIS(1:IPOS),'plotit/')
         CALL GVSCCC (FILDIR(14),WHERIS(1:IPOS),'seddon/')
         CALL GVSCCC (FILDIR(15),WHERIS(1:IPOS),'usegro/')
         CALL GVSCCC (FILDIR(16),WHERIS(1:IPOS),'pluton/')
         CALL GVSCCC (FILDIR(17),WHERIS(1:IPOS),'pdbfinder/')
         CALL GVSCCC (FILDIR(18),WHERIS(1:IPOS),'blast/')
         CALL GVSCCC (FILDIR(19),WHERIS(1:IPOS),'plim/')
         CALL GVSCCC (FILDIR(20),WHERIS(1:IPOS),'seddon/files/')
         CALL GVSCCC (FILDIR(22),WHERIS(1:IPOS),'ribbons/')

         CALL GVSCCC (FILDIR(25),WHERIS(1:IPOS),'helpfil/')
         CALL GVSCCC (FILDIR(26),WHERIS(1:IPOS),'poth2o/')



         CALL SETDBE (.FALSE.)

         CALL GVSCCC (FILDIR(30),WHERIS(1:IPOS),'nqual/')

         CALL GVSCCC (FILDIR(31),WHERIS(1:IPOS),'tmp/')
         CALL GVSSTX (FILDIR(100),WHERIS(1:IPOS))




      CALL WIF023
      CALL WIF024



      CALL W00000




      CALL WIF109



      CALL WIF001C





      RETURN
      END
      SUBROUTINE WIF001C

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CCPINC.INC'
      INTEGER       IERR, GVFLEN
      LOGICAL       GVFFOP, GVFISF







      CALL GVSCLF (11)
      CALL SETFILNAM (LINE,'CCONFI.FIG',IERR)
      IF (IERR.NE.0) THEN
         CALL GVSTT6 ('?T0014')
         GOTO 998
      END IF



      CALL GVSOPF (LINE,11,'OLD')
      IF (.NOT.GVFFOP(11)) THEN
         CALL GVSTT6 ('?T0014')
         GOTO 998
      END IF

















      CALL GVSFMT ('?FMT1207A')
      READ (11,FMT,END=999,ERR=999) FILNMS(61)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(64)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(65)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(66)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(67)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(68)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(69)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(70)(1:50)
      READ (11,FMT,END=999,ERR=999) FILNMS(71)(1:50)
      CALL GVSFMT ('?FMT1535')
      READ (11,FMT,END=999,ERR=999) FILNMS(75)(1:60)
      READ (11,FMT,END=999,ERR=999) FILNMS(79)(1:60)
      CALL GVSCTB (CCP4_SETUP,80)
      READ (11,FMT,END=999,ERR=999) CCP4_SETUP
      READ (11,FMT,END=999,ERR=999) FILNMS(82)(1:60)

      GOTO 998



  999 CONTINUE
      CALL GVSTTE ('?T0015')



  998 CONTINUE
      CALL GVSCLF (11)


      RETURN
      END
      SUBROUTINE WIF002 (TEXT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IERR, GVFLEN, OLDIU54
      LOGICAL       GVFFOP, GVFISF
      CHARACTER*(*) TEXT
      CHARACTER*80  LOCLIN







      CALL GVSSTX (LOCLIN,TEXT)
   10 CONTINUE
      IF (GVFLEN(LOCLIN).LE.0) THEN
         CALL IPROMPT ('?SCRNAM')
         CALL NEEDWORD (LOCLIN,'SCRIPT.FIL',IERR)
         IF (IERR.NE.0) GOTO 998
      END IF
      CALL GVSSHL (LOCLIN)



      CALL FLUSHAHEAD



      IF (.NOT.GVFISF(LOCLIN)) THEN
         CALL GVSTTE ('?SCFNOT')
         CALL GVSTT6 (LOCLIN)
         CALL GVSCTB (LOCLIN,80)
         GOTO 10
      END IF



      OLDIU54=IU54
      IF (GVFFOP(IU54)) THEN
         IF (IU54.LE.64) THEN
            IU54=IU54+1
         ELSE
            CALL GVSTTI ('?M0172',IU54)
            GOTO 998
         END IF
      ELSE
         IF (IU54.NE.61) CALL GVSTTI ('?M0172',IU54)
         IU54=61
         CALL GVSTTI ('?M0173',IU54)
      END IF



      CALL GVSCLF (IU54)
      OPEN (UNIT=IU54,FILE=LOCLIN(1:GVFLEN(LOCLIN)),
     + ACCESS='SEQUENTIAL',STATUS='OLD')



      IF (.NOT.GVFFOP(IU54)) THEN
         CALL GVSTTE ('?SCFNOF')
         IU54=OLDIU54
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF002A (LOCLIN)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      LOGICAL       DONE
      CHARACTER*(*) LOCLIN







      CALL WIF002 (LOCLIN)



      IF (WIFPAR(946).NE.0) THEN
         CALL GVSTTB ('?M2051')
         GOTO 998
      END IF
      WIFPAR(946)=IU54



      DONE=.FALSE.



   10 CONTINUE
      CALL ONECMD (DONE)



      IF (WIFPAR(946).EQ.-1) THEN
         WIFPAR(946)=0
         GOTO 998
      END IF
      GOTO 10



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF043

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       GVFLEN, I, J








      DO 10 I=20,1,-1
         IF (HISTOR(I)(1:4).NE.'    ') THEN
            CALL GVSFMT ('?M0907')
            CALL GVSCTB (LINE,80)
            WRITE (LINE,FMT,ERR=999) I,(HISTOR(I)(J:J),J=1,
     +       MIN(GVFLEN(HISTOR(I)),75))
            CALL GVSTT6 (LINE)
         ELSE
            GOTO 998
         END IF
   10 CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('WIF043')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF059

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'SYMINC.INC'
      INTEGER       I, IERR, GVFFFF
      REAL          RMAT(3,3), TVEC(3), PNT1(3), PNT2(3), ANGLE, GVFDTR
      CHARACTER*4   CHOICE
      LOGICAL       WASIR6, GVFYON







      IF (NUMAAF.LE.0) THEN
         CALL GVSTT6 ('?SOULOW')
         GOTO 998
      END IF
      IF (IRSTAT(6).EQ.1) THEN
         WASIR6=.TRUE.
         CALL GRTKON
      ELSE
         WASIR6=.FALSE.
      END IF



      CALL WIFWTF ('?RNGTRN',IERR)
      IF (IERR.NE.0) GOTO 110
      CALL WRK1TFCOMPLETE



    2 CONTINUE
      CALL IPROMPT ('?TRNVEC')
      CALL GVSRT0 (TVEC,3)
      I=GVFFFF(3,TVEC)
      IF (I.EQ.0) THEN
         CALL WIFBO0
         CALL GVSTT6 ('?IN3NUM')
         GOTO 2
      END IF
      CALL WIFBO1 (0,' ')
      IF (I.EQ.1.AND.ABS(TVEC(1)).LT.0.00001) GOTO 110



    1 CONTINUE
      CALL GVSTT6 ('?MCHO01')
      CALL GVSTT6 ('?MCHO02')
      CALL GVSTT6 ('?MCHO03')
      CALL GVSTT6 ('?MCHO04')
      CALL GVSTT6 ('?MCHO05')
      CALL GVSTT6 ('?MCHO06')
      CALL IPROMPT ('?RXRYRZ')
      CALL NEEDWORD (CHOICE,' ',IERR)
      IF (IERR.NE.0) GOTO 110



      CALL GVSSHL (CHOICE)
      CALL GVSCUC (CHOICE)



      IF (CHOICE(1:2).EQ.'RX') THEN
   10    CONTINUE
         CALL IPROMPT ('?ANGDEG')
         I=GVFFFF(1,ANGLE)
         IF (I.EQ.0) THEN
            CALL GVSTT6 ('?ZERNRO')
            GOTO 10
         END IF
         CALL GVSMXM (RMAT,GVFDTR(ANGLE))



      ELSE IF (CHOICE(1:2).EQ.'RY') THEN
   20    CONTINUE
         CALL IPROMPT ('?ANGDEG')
         I=GVFFFF(1,ANGLE)
         IF (I.EQ.0) THEN
            CALL GVSTT6 ('?ZERNRO')
            GOTO 20
         END IF
         CALL GVSMYM (RMAT,GVFDTR(ANGLE))



      ELSE IF (CHOICE(1:2).EQ.'RZ') THEN
   30    CONTINUE
         CALL IPROMPT ('?ANGDEG')
         I=GVFFFF(1,ANGLE)
         IF (I.EQ.0) THEN
            CALL GVSTT6 ('?ZERNRO')
            GOTO 30
         END IF
         CALL GVSMZM (RMAT,GVFDTR(ANGLE))



      ELSE IF (CHOICE(1:3).EQ.'MAT') THEN
         CALL GVSMTI (RMAT,TVEC,IERR)
         IF (IERR.NE.0) GOTO 998



      ELSE IF (CHOICE.EQ.'AXIS') THEN
         CALL GVSRT0 (PNT1,3)
  101    CONTINUE
         CALL IPROMPT ('?POINT1')
         I=GVFFFF(3,PNT1)
         IF (I.EQ.1.AND.ABS(PNT1(1)).LT.0.0001) GOTO 998
         IF (I.NE.3) THEN
            CALL GVSTTE ('?IN3CRD')
            GOTO 101
         END IF
         CALL GVSRT0 (PNT2,3)
  102    CONTINUE
         CALL IPROMPT ('?POINT2')
         I=GVFFFF(3,PNT2)
         IF (I.EQ.1.AND.ABS(PNT2(1)).LT.0.0001) GOTO 998
         IF (I.NE.3) THEN
            CALL GVSTT6 ('?IN3CRD')
            GOTO 102
         END IF
  103    CONTINUE
         CALL IPROMPT ('?ANGDEG')
         I=GVFFFF(1,ANGLE)
         IF (I.EQ.0) THEN
            CALL GVSTT6 ('?ZERNRO')
            GOTO 103
         END IF



         CALL GVSTV3 (CV,PNT2,PNT1)
         CALL GVSMGM (RMAT,CV,GVFDTR(ANGLE))
      ELSE
         CALL GVSTT6 ('?CHOXYZ')
         GOTO 1 
      END IF



      CALL GVSTT6 ('?MATAPL')
      CALL GVSWM4 (RMAT,TVEC)
      IF (.NOT.GVFYON('?IMATOK',' ')) GOTO 1



      CALL WIF059X (RMAT,TVEC)



      SYMHAS=.FALSE.
      WIFPAR(591)=0



      CALL MOL200



  110 CONTINUE
      IF (WASIR6) CALL GRTKOF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE WIF059X (RMAT,TVEC)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'JUNIOR.INC'
      INTEGER       IAA, IAT
      REAL          RMAT(3,3), TVEC(3)







      DO 40 IAA=1,NUMAAT
         IF (WRK1TF(IAA)) THEN
            DO 30 IAT=PNTAAS(IAA),PNTAAE(IAA)
               XYZ(1)=XCOORD(IAT)
               XYZ(2)=YCOORD(IAT)
               XYZ(3)=ZCOORD(IAT)
               CALL GVSMPV (XYZ,RMAT,TVEC)
               XCOORD(IAT)=XYZ(1)
               YCOORD(IAT)=XYZ(2)
               ZCOORD(IAT)=XYZ(3)
   30       CONTINUE
            PREVSHOW(IAA)=-1
         END IF
   40 CONTINUE



      IF (JUNIOR) CALL JUN001





      RETURN
      END
      SUBROUTINE WIF059A (RMAT,TVEC)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'JUNIOR.INC'
      INTEGER       IAA, IUSED, IAT
      REAL          RMAT(3,3), XYZCEN(3), TVEC(3)







      IUSED=0
      CALL GVSRT0 (XYZCEN,3)
      DO 20 IAA=1,NUMAAT
         IF (WRK1TF(IAA)) THEN
            DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
               XYZCEN(1)=XYZCEN(1)+XCOORD(IAT)
               XYZCEN(2)=XYZCEN(2)+YCOORD(IAT)
               XYZCEN(3)=XYZCEN(3)+ZCOORD(IAT)
               IUSED=IUSED+1
   10       CONTINUE
         END IF
   20 CONTINUE
      IF (IUSED.LT.1) THEN
         CALL GVSTTE ('?ROTSHR')
         GOTO 998
      END IF
      CALL GVSVDI (XYZCEN,IUSED,3)



      DO 40 IAA=1,NUMAAT
         IF (WRK1TF(IAA)) THEN
            DO 30 IAT=PNTAAS(IAA),PNTAAE(IAA)
               XYZ(1)=XCOORD(IAT)-XYZCEN(1)
               XYZ(2)=YCOORD(IAT)-XYZCEN(2)
               XYZ(3)=ZCOORD(IAT)-XYZCEN(3)
               CALL GVSMPV (XYZ,RMAT,XYZCEN)
               XCOORD(IAT)=XYZ(1)+TVEC(1)
               YCOORD(IAT)=XYZ(2)+TVEC(2)
               ZCOORD(IAT)=XYZ(3)+TVEC(3)
   30       CONTINUE
            PREVSHOW(IAA)=-1
         END IF
   40 CONTINUE



      IF (JUNIOR) CALL JUN001
      IUSED=0
      CALL GVSRT0 (XYZCEN,3)
      DO 60 IAA=1,NUMAAT
         IF (WRK1TF(IAA)) THEN
            DO 50 IAT=PNTAAS(IAA),PNTAAE(IAA)
               XYZCEN(1)=XYZCEN(1)+XCOORD(IAT)
               XYZCEN(2)=XYZCEN(2)+YCOORD(IAT)
               XYZCEN(3)=XYZCEN(3)+ZCOORD(IAT)
               IUSED=IUSED+1
   50       CONTINUE
         END IF
   60 CONTINUE
      IF (IUSED.LT.1) THEN
         CALL GVSTTE ('?ROTSHR')
         GOTO 998
      END IF
      CALL GVSVDI (XYZCEN,IUSED,3)



  998 CONTINUE


      RETURN
      END

      SUBROUTINE SETDBE (RESET)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INTEGER       IPOS, GVFPLS, IERR,  I, GVFLEN
      LOGICAL       RESET, GVFICN, GVFISF, MAKNEW







      MAKNEW=.FALSE.



      IPOS=GVFPLS(WHERIS,'dbdata')-1
      IF (IPOS.LE.0) THEN
         CALL GVSKIL
         GOTO 999
      END IF



      IF (RESET) THEN
         CALL GVSCTB (DBEXT,2)
 10      CONTINUE
         CALL IPROMPT ('?M3661A')
         CALL GVSCTB (LINE,80)
         CALL GETWORD (LINE,IERR)
         IF (IERR.NE.0) GOTO 998
         IF (GVFLEN(LINE).GT.2) THEN
            CALL GVSTT6 ('?M3662A')
            GOTO 10
         END IF
         DO 20 I=1,GVFLEN(LINE)
            IF (.NOT.GVFICN(LINE(I:I))) THEN
               CALL GVSTT6 ('?M3663')
               GOTO 10
            END IF
 20      CONTINUE
         CALL GVSSTX (DBEXT,LINE)
      END IF



      IF (GVFLEN(DBEXT).GT.0) THEN
         CALL GVSCC4 (FILDIR(27),WHERIS(1:IPOS),'ascdata',DBEXT,'/')
         CALL GVSCC4 (FILDIR(28),WHERIS(1:IPOS),'bindata',DBEXT,'/')




      ELSE
         CALL GVSCCC (FILDIR(27),WHERIS(1:IPOS),'ascdata/')
         CALL GVSCCC (FILDIR(28),WHERIS(1:IPOS),'bindata/')
      END IF



      IF (.NOT.GVFISF(FILDIR(27))) THEN
         CALL GVSMKD (FILDIR(27),BIGLIN)
         MAKNEW=.TRUE.
      END IF
      IF (.NOT.GVFISF(FILDIR(28))) THEN
         CALL GVSMKD (FILDIR(28),BIGLIN)
         MAKNEW=.TRUE.
      END IF




         IF (.NOT.MAKNEW.AND.WIFPAR(12).EQ.0) THEN
            CALL PRP_READ_MUTDB (IERR)
            CALL WIFRDF
            CALL WIF103
            CALL WIF021
            CALL WIF112
         END IF

      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('SETDBE')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE GENCLN

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'







      CALL GVSDEL ('core.*')
      CALL GVSDEL ('eps*.eps')
      CALL GVSDEL ('fort.*')
      CALL GVSDEL ('*_ION.OUT')
      CALL GVSDEL ('a.out')
      CALL GVSDEL ('sct*.eps')
      CALL GVSDEL ('pdbout.*')
      CALL GVSDEL ('i')
      CALL GVSDEL ('x')
      CALL GVSDEL ('x.*')
      CALL GVSDEL ('X.*')
      CALL GVSDEL ('#*#')
      CALL GVSDEL ('*~')
      CALL GVSDEL ('supertab.sty')
      CALL GVSDEL ('SCATTER.*')
      CALL GVSDEL ('*.WPL')
      CALL GVSDEL ('check.db')
      CALL GVSDEL ('TEXSTORE.*')
      CALL GVSDEL ('MOVEDH2O.*')
      CALL GVSDEL ('NMRALT.ATM')





      RETURN
      END   
      BLOCK DATA MUT
      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'TRANSL.INC'

      DATA DIPBCK  /
     + 5.259, 5.498, 6.005, 5.929, 6.358, 5.055,
     + 6.304, 5.578, 3.799, 6.900, 4.390, 3.989,
     + 7.331, 3.607, 2.791, 6.116, 3.210, 1.915/

      DATA DNABCK  /
     +  8.2,  -3.5,   4.7, 
     +  8.2,   0.3,   6.1,  
     +  5.8,   0.5,   6.3,  
     +  8.7,   2.0,   8.1, 
     +  6.5,   5.1,   9.5,  
     +  4.4,   3.8,   9.7/

      DATA RNABCK  /
     + -3.357,  -4.388,  -8.008,
     + -6.843,  -1.920,  -6.272,
     + -8.163,  -3.725,  -5.514,
     + -6.129,   0.604,  -6.026,
     + -8.393,   2.300,  -2.745,
     + -9.357,   0.333,  -1.912/

      DATA ISL /
     +  -1,0,0, 0,0,1, 0,1,0, 0,0,-1, 0,-1,0, 1,0,0/

      DATA ISL26 /
     +  -1,-1,-1, -1,-1, 0, -1,-1, 1, 
     +  -1, 0,-1, -1, 0, 0, -1, 0, 1,
     +  -1, 1,-1, -1, 1, 0, -1, 1, 1, 
     +   0,-1,-1,  0,-1, 0,  0,-1, 1, 
     +   0, 0,-1,            0, 0, 1, 
     +   0, 1,-1,  0, 1, 0,  0, 1, 1, 
     +   1,-1,-1,  1,-1, 0,  1,-1, 1, 
     +   1, 0,-1,  1, 0, 0,  1, 0, 1, 
     +   1, 1,-1,  1, 1, 0,  1, 1, 1/

      DATA RISL /
     +  -1.0,0.0,0.0, 0.0,0.0,1.0, 0.0,1.0,0.0, 0.0,0.0,-1.0, 
     +  0.0,-1.0,0.0, 1.0,0.0,0.0/

      DATA CHADEF /
     + '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'/

      DATA CHADES /
     + '1234567890abcdefghijklmnopqrstuvwxyz'/

      DATA CHADEF2 /
     + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'/

      DATA CHADEF3 /
     + '.,;: ?!+-*'/

      DATA TURNAM   /'I  ','IP ','II ','IIP','VIA','VIB','VII','IV '/
      DATA TANGLE   /-60, -30, -90,  0,
     +                60,  30,  90,  0,
     +               -60, 120,  80,  0,
     +                60,-120, -80,  0,
     +               -60, 120, -90,  0,
     +               -135,135, -75,160,
     +               -60, -30,-120,120,
     +               -180,180,-180,180/

      END
