



      SUBROUTINE ION000 (DONE)


















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'OPTION.INC'
      INCLUDE       'ESPACE.INC'
      LOGICAL       DONE







      IF (OPTIN.EQ.MEN6COD(108)) GOTO 998
      CALL MEN069 (OPTIN,DONE)





      IF (OPTIN.EQ.'HIDDEN') THEN
         CALL SHOWTEXT ('?M4943')
         DONE=.TRUE.
      END IF



      IF (OPTIN.EQ.'ALLION') THEN
         CALL ION220
         DONE=.TRUE.
      END IF



      IF (OPTIN.EQ.'ISBEST') THEN
         CALL ION006
         DONE=.TRUE.
      END IF
      IF (OPTIN.EQ.'STEP-5') THEN
         CALL ION002 (3)
         DONE=.TRUE.
      END IF
      IF (OPTIN.EQ.'STEP-7') THEN
         CALL ION002 (5)
         DONE=.TRUE.
      END IF



      IF (OPTIN.EQ.'STEP-8') THEN
         CALL ION002 (7)
         DONE=.TRUE.
      END IF
      IF (OPTIN.EQ.'SRTTYP') THEN
         CALL ION007
         DONE=.TRUE.
      END IF
      IF (OPTIN.EQ.'BLOODY') THEN
         CALL ION200
         DONE=.TRUE.
      END IF



      IF (OPTIN.EQ.'GIJSMA') THEN
         CALL ION002 (6)
         DONE=.TRUE.
      END IF
      IF (OPTIN.EQ.'GIJSVI') THEN
         CALL ION205
         DONE=.TRUE.
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ION002 (MODE)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'HISTOG.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, IUNIT, JUNIT, KUNIT, IDON, MODE, GVFLEN
      LOGICAL       INTERRUPTED, GVFISF, GOTFILE, MOLKIL1, MOLKIL2, OK,
     +              GVFFOP
      CHARACTER*80  FILNAM







      IDON=0
      IUNIT=0
      JUNIT=0
      JRPNTS=0
      CALL GVSRT0 (XYZJRS,3*5*250)
      CALL GRTVIN
      OK=MOLKIL1('OPEN','DUMY')
      CALL WIFPUSHPPP (590,WIFPAR(467))
      CALL GHS031 (IERR)
      IF (IERR.NE.0) GOTO 998
      IF (.NOT.GVFFOP(STAUNT)) THEN
         CALL GVSTT6 ('Fatal, STAUNT not open')
         GOTO 998
      END IF
      WIFPAR(377)=0



      CALL GVSROF (IUNIT,IERR)
      IF (IUNIT.LE.0.OR.IERR.NE.0) GOTO 998
      CALL GETFILE (IUNIT,' ','?ION503',IERR)
      IF (IERR.NE.0) GOTO 998



      CALL GVSROF (JUNIT,IERR)
      IF (JUNIT.LE.0.OR.IERR.NE.0) GOTO 998
      CALL GETFILN (JUNIT,' ','?ION504',IERR)
      IF (IERR.NE.0) GOTO 998
      IF (MODE.EQ.6) THEN
         IF (GVFISF('?ION508')) CALL GVSDEL ('?ION508')
         IF (.NOT.GOTFILE(KUNIT,'?ION508')) GOTO 998
      END IF







 10   CONTINUE
         WIFPAR(466)=0
         IF (INTERRUPTED()) GOTO 998
         CALL GETLINE (IUNIT,FILNAM,IERR)
         IF (IERR.NE.0) GOTO 998
         IF (FILNAM(1:4).EQ.'*END') GOTO 998
         IF (MOLKIL1('SJEK',FILNAM(1:4))) THEN
            CALL GVSTT6 ('?ION509')
            GOTO 10
         END IF
         IF (GVFLEN(FILNAM).LE.0) GOTO 10
         CALL GVSLIN
         CALL GVSLUN (JUNIT)
         IDON=IDON+1
         CALL GVSTTI ('?M4246',IDON)
         CALL GVSTTIU (JUNIT,'?M4246',IDON)
         CALL GVSTUC (JUNIT,'?M4885',FILNAM,.TRUE.)
         CALL PRP201 (FILNAM)
         CALL GVSSTX (FILNMS(62),FILNAM)
         CALL WIFPUSHPPP (365,1)
         CALL WIFPUSHPPP (642,1)
         CALL WIFPUSHPPP (622,0)
         CALL WIFPUSHPPP (1105,1)
         WIFPAR(416)=JUNIT
         CALL PDBL05 (FILNAM,.TRUE.)
         WIFPAR(416)=0
         CALL WIFPOPPPP (1105)
         CALL WIFPOPPPP (622)
         CALL WIFPOPPPP (642)
         CALL WIFPOPPPP (365)
         IF (MOLKIL2()) THEN
            CALL GVSTT6 ('?ION510')
            GOTO 10
         END IF
         IF (NUMAAF.LE.0) THEN
            CALL GVSTT6 ('?ION511')
            GOTO 10
         END IF
         CALL WIFPUSHPPP (1012,1)
         CALL SHOSOU
         CALL WIFPOPPPP (1012)
         CALL PRP202 ('?M4886')



         IF (MODE.EQ.7) THEN
            CALL ION211 (KUNIT)
         ELSE IF (MODE.EQ.6) THEN
            CALL ION210 (KUNIT)
         ELSE IF (MODE.EQ.5) THEN
            CALL ION201
         ELSE
            CALL ION003 (JUNIT)
         END IF
      GOTO 10



  998 CONTINUE



      CALL WIFPOPPPP (590)
      OK=MOLKIL1('CLOS','DUMY')
      IF (IUNIT.NE.0) CALL GVSCLF (IUNIT)
      IF (JUNIT.NE.0) CALL GVSCLF (JUNIT)


      RETURN
      END   
      SUBROUTINE ION003 (IUNIT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ISOUP, IAA, IAT, IERR, IUNIT, IONCNT
      LOGICAL       FOUND, ION_USE, INTERRUPTED







      FOUND=.FALSE.
      IONCNT=0



      CALL ION104 (IUNIT)



      CALL WIFPUSHPPP (1265,1)
      CALL HBO010
      CALL HB2RED
      CALL HB2LFR
      CALL WIFPOPPPP (1265)



      CALL GVSNL6 (2)
      CALL GVSTT6 ('=== Start of ion list ===')
      DO 10 ISOUP=1,NUMSOU
         IF (INTERRUPTED()) GOTO 998
         IAA=SOUADM(1,ISOUP)
         IAT=PNTAAS(IAA)



         IF (.NOT.ION_USE(IAA)) GOTO 10



         IONCNT=IONCNT+1
         CALL GVSNL6 (2)
         CALL GVSTTI ('Ion analysis #',IONCNT)
         IF (IUNIT.NE.6) CALL GVSNLU (IUNIT,1)
         CALL SHOIAA (IAA)
         CALL PRP203 (IAA,' ')
         CALL ENVSET (ISOUP)



         CALL ION004 (IUNIT,IAT,IERR)
         IF (IERR.EQ.0) FOUND=.TRUE.
   10 CONTINUE



      IF (.NOT.FOUND.AND.IUNIT.EQ.6) THEN
         IF (IONTYP.EQ.'**') THEN
            CALL GVSTT6 ('?M4912A')
         ELSE
            CALL GVST6C ('?M4912',IONTYP,.TRUE.)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION004 (INUNIT,ION,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       INUNIT, IUNIT, ION, IERR
      REAL          DUMMY
      LOGICAL       WIFIRH, WIFIRO, CH2EQCH2







      IF (INUNIT.LT.1.OR.INUNIT.EQ.5.OR.INUNIT.GT.120) THEN
         IUNIT=6
      ELSE
         IUNIT=INUNIT
      END IF



      IERR=0
      NUMCONIAT=0
      CALL GVSIT0 (JR,10)
      CALL GVSRT0 (XYZJR,3*10)
      CALL GVSRT0 (XYZJRS,3*5*250)



      IF (WIFIRO(ATIAA(ION))) THEN
         IERR=1
         GOTO 998
      END IF
      IF (WIFIRH(ATIAA(ION))) THEN
         IERR=1
         GOTO 998
      END IF



      IF (IONTYP.NE.'**') THEN
         IF (.NOT.CH2EQCH2(ONESAT(ION)(1:2),IONTYP)) THEN
            IF (WIFPAR(470).EQ.1) THEN
               CALL ION_SETTYP (ONESAT(ION)(1:2))
            ELSE
               CALL GVSTT6 ('?ION536')
            END IF
         END IF
      END IF



      CALL IS_ION_OK (ION,IERR)



      CALL ION101 (IUNIT,ION,.TRUE.,IERR)



      CALL ION_ENV (IUNIT,ION,IERR)



      IF (WIFPAR(470).EQ.0) THEN



         IF (WIFPAR(455).GE.1) THEN
            IF (WIFPAR(468).EQ.0) THEN
               CALL GVSTTI ('?M4918',WIFPAR(455))
               GOTO 998
            END IF



         ELSE
            IF (WIFPAR(468).EQ.2) THEN
               CALL GVSTTI ('?M4918',WIFPAR(455))
               GOTO 998
            END IF
         END IF
      END IF



      CALL ION_WRIT_VALENCY (ION,NUMCONIAT,DUMMY,IUNIT)



      CALL ION005 (ION,NUMCONIAT,IUNIT)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION005 (ION,NUM,IUNIT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT
      LOGICAL       DONE 







      IF (NUM.EQ.0) THEN
         CALL DIF015 (IUNIT,'?M4888',ION)
         GOTO 998
      END IF



      IF (NUM.EQ.1) THEN
         CALL ION_ANAL_1_LIG (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998
      END IF



      IF (NUM.EQ.2) THEN
         CALL  ION_ANAL_2_LIG(ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998
      END IF



      IF (NUM.EQ.3) THEN



         CALL ION032 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



         CALL ION033 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



         CALL ION037 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



      ELSE IF (NUM.EQ.4) THEN



         CALL ION034 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



         CALL ION035 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



         CALL ION036 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



      ELSE IF (NUM.EQ.5) THEN



         CALL ION038 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



         CALL ION039 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



         CALL ION042 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



      ELSE IF (NUM.EQ.6) THEN



         CALL ION040 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



         CALL ION043 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998



      ELSE








         CALL ION044 (ION,NUM,IUNIT,DONE)
         IF (DONE) GOTO 998
      END IF



      CALL GVSTTI ('?M4344',NUM)
      IF (IUNIT.NE.6) CALL GVSTTIU (IUNIT,'?M4344',NUM)
      CALL GVSTT6 ('?M4345')
      IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4345')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION006 

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ISOUP, IAA, IAT, IERR
      REAL          SCODIF, SELF
      LOGICAL       FOUND, ION_USE, INTERRUPTED
      CHARACTER*2   BSTTYP







      FOUND=.FALSE.



      CALL ION104 (6)



      DO 10 ISOUP=1,NUMSOU
         IF (INTERRUPTED()) GOTO 998
         IAA=SOUADM(1,ISOUP)
         IAT=PNTAAS(IAA)



         IF (.NOT.ION_USE(IAA)) GOTO 10



         WIFPAR(482)=4
         CALL ION102C (IAT,SCODIF,SELF,BSTTYP,IERR)
         WIFPAR(482)=0
         IF (SCODIF.GT.0.01) THEN
            CALL DIF015B (6,IAT,'->'//BSTTYP,SCODIF)
         END IF
   10 CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION007

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ISOUP, IAA, IAT, IERR, IUNIT, PACCNT, I, IX(4), 
     +              I1, I2
      REAL          PACDST(4,1000), IONDST, D(4)
      LOGICAL       FOUND, ION_USE, INTERRUPTED
      CHARACTER*4   PACAA3(4,1000)
      CHARACTER*5   PACATT(4,1000)
      EQUIVALENCE   (PACCNT,WIFPAR(478))
      SAVE          PACDST, PACAA3, PACATT







      FOUND=.FALSE.



      CALL ION104 (IUNIT)



      DO 10 ISOUP=1,NUMSOU
         IF (INTERRUPTED()) GOTO 998
         IAA=SOUADM(1,ISOUP)
         IAT=PNTAAS(IAA)



         IF (.NOT.ION_USE(IAA)) GOTO 10



         CALL GVSNL6 (1)
         IF (IUNIT.NE.6) CALL GVSNLU (IUNIT,1)
         CALL SHOIAA (IAA)
         CALL PRP203 (IAA,' ')



         CALL GVSCTB (PACTYP,2)
         CALL ION004 (IUNIT,IAT,IERR)
         IF (IERR.EQ.0) FOUND=.TRUE.



         IF (PACTYP.EQ.'4r') THEN
            PACCNT=PACCNT+1
            DO 5 I=1,4
               PACDST(I,PACCNT)=IONDST(IAT,I)
               CALL GVSSTX (PACAA3(I,PACCNT),ONESA3(ATIAA(JR(I))))
               CALL GVSSTX (PACATT(I,PACCNT),ONESAT(JR(I)))
 5          CONTINUE
            i=paccnt
            D(1)=PACDST(1,I)
            D(2)=PACDST(2,I)
            D(3)=PACDST(3,I)
            D(4)=PACDST(4,I)
            CALL GVSITI (IX,4)
            DO 7 I1=1,3
               DO 6 I2=I1+1,4
                  IF (D(I1).LT.D(I2)) THEN
                     CALL GVSWAP (D(I1),D(I2))
                     CALL GVSWIP (IX(I1),IX(I2))
                  END IF
 6             CONTINUE
 7          CONTINUE
            WRITE (6,123,ERR=998) I,
     +       PACAA3(IX(1),I),PACATT(IX(1),I),PACDST(IX(1),I),
     +       PACAA3(IX(2),I),PACATT(IX(2),I),PACDST(IX(2),I),
     +       PACAA3(IX(3),I),PACATT(IX(3),I),PACDST(IX(3),I),
     +       PACAA3(IX(4),I),PACATT(IX(4),I),PACDST(IX(4),I)
         END IF
   10 CONTINUE



      IF (PACCNT.GE.1) THEN
         DO 20 I=1,PACCNT
            D(1)=PACDST(1,I)
            D(2)=PACDST(2,I)
            D(3)=PACDST(3,I)
            D(4)=PACDST(4,I)
            CALL GVSITI (IX,4)
            DO 17 I1=1,3
               DO 16 I2=I1+1,4
                  IF (D(I1).LT.D(I2)) THEN
                     CALL GVSWAP (D(I1),D(I2))
                     CALL GVSWIP (IX(I1),IX(I2))
                  END IF
 16            CONTINUE
 17         CONTINUE
 123        FORMAT (I4,3(A4,A5,F7.2,';  '),A4,A5,F7.2)
            WRITE (6,123,ERR=998) I,
     +       PACAA3(IX(1),I),PACATT(IX(1),I),PACDST(IX(1),I),
     +       PACAA3(IX(2),I),PACATT(IX(2),I),PACDST(IX(2),I),
     +       PACAA3(IX(3),I),PACATT(IX(3),I),PACDST(IX(3),I),
     +       PACAA3(IX(4),I),PACATT(IX(4),I),PACDST(IX(4),I)
 20      CONTINUE
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION011

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA
      LOGICAL       FOUND, ION_USE







      FOUND=.FALSE.



      DO 10 ISOUP=1,NUMSOU
         IAA=SOUADM(1,ISOUP)



         IF (.NOT.ION_USE(IAA)) GOTO 10



         CALL SHOIAA (SOUADM(1,ISOUP))
         FOUND=.TRUE.
   10 CONTINUE
      IF (.NOT.FOUND) CALL GVSTT6 ('?M2131')
      GOTO 998



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION012

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP, IAA, ION, JSOUP, JAA, JAT
      REAL          WIFDST
      LOGICAL       FOUND, WIFIRM, JFOUND







      FOUND=.FALSE.
      CALL WIFPUSHPPP (28,1)



      DO 100 ISOUP=1,NUMSOU
         IAA=SOUADM(1,ISOUP)



         IF (.NOT.WIFIRM(IAA)) GOTO 100



         CALL GVSNL6 (2)
         CALL GVSLIN
         CALL SHOIAA (SOUADM(1,ISOUP))
         FOUND=.TRUE.



         CALL GVSRT0 (ATTVAL,MAXAT)
         CALL GVSBTF (USEAT,NUMATF)
         ION=PNTAAS(SOUADM(1,ISOUP))



         DO 30 JSOUP=1,NUMSOU
            IF (JSOUP.EQ.ISOUP) GOTO 30
            DO 20 JAA=SOUADM(1,JSOUP),SOUADM(2,JSOUP)
               JFOUND=.FALSE.
               DO 10 JAT=PNTAAS(JAA),PNTAAE(JAA)
                  IF (WIFDST(JAT,ION).LT.2.75) THEN
                     ATTVAL(JAT)=WIFDST(JAT,ION)
                     USEAT(JAT)=.TRUE.
                     JFOUND=.TRUE.
                  END IF
   10          CONTINUE
               IF (JFOUND) CALL SHOIAT (JAA)
   20       CONTINUE
   30    CONTINUE
  100 CONTINUE
      IF (.NOT.FOUND) CALL GVSTT6 ('?M2131')
      GOTO 998



  998 CONTINUE
      CALL GVSRT0 (ATTVAL,MAXAT)
      CALL GVSBTF (USEAT,NUMATF)
      CALL WIFPOPPPP (28)


      RETURN
      END   
      SUBROUTINE ION014

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       ISOUP
      LOGICAL       HASWATER, WIFISW







      IF (.NOT.HASWATER()) THEN
         CALL GVSTTE ('?M2086')
         CALL SHOSOU
         GOTO 998
      END IF



      DO 10 ISOUP=1,NUMSOU
         IF (WIFISW(ISOUP)) CALL ION024 (6,ISOUP)
 10   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION015

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IATION, ISOUP, IERR, I







      IF (IONTYP.NE.'CA') THEN
         CALL GVSTT6 ('?M4322')
         GOTO 998
      END IF



      CALL GRTVIN



      CALL MOL310 (ISOUP,4,' ')
      IF (ISOUP.EQ.0) GOTO 998
      IATION=PNTAAS(SOUADM(1,ISOUP))
      CALL ENVSET (ISOUP)
      CALL ION004 (6,IATION,IERR)
      IF (IERR.NE.0) GOTO 998



      CALL GRTDSH (XCOORD(IATION),YCOORD(IATION),ZCOORD(IATION),
     + XCOORD(IATZ1),YCOORD(IATZ1),ZCOORD(IATZ1),300,9,IERR)
      CALL GRTDSH (XCOORD(IATION),YCOORD(IATION),ZCOORD(IATION),
     + XCOORD(IATZ2),YCOORD(IATZ2),ZCOORD(IATZ2),300,9,IERR)
      CALL GRTDSH (XCOORD(IATION),YCOORD(IATION),ZCOORD(IATION),
     + XCOORD(IATW),YCOORD(IATW),ZCOORD(IATW),300,9,IERR)
      CALL GRTDSH (XCOORD(IATION),YCOORD(IATION),ZCOORD(IATION),
     + XCOORD(IATE),YCOORD(IATE),ZCOORD(IATE),300,9,IERR)
      CALL GRTDSH (XCOORD(IATION),YCOORD(IATION),ZCOORD(IATION),
     + XCOORD(IATN),YCOORD(IATN),ZCOORD(IATN),300,9,IERR)
      CALL GRTDSH (XCOORD(IATION),YCOORD(IATION),ZCOORD(IATION),
     + XCOORD(IATT),YCOORD(IATT),ZCOORD(IATT),300,9,IERR)
      CALL GRTDSH (XCOORD(IATION),YCOORD(IATION),ZCOORD(IATION),
     + XCOORD(IATB),YCOORD(IATB),ZCOORD(IATB),300,9,IERR)



      CALL LAB019 (XCOORD(IATZ1),YCOORD(IATZ1),ZCOORD(IATZ1),'Z1',2)
      CALL LAB019 (XCOORD(IATZ2),YCOORD(IATZ2),ZCOORD(IATZ2),'Z2',2)
      CALL LAB019 (XCOORD(IATN),YCOORD(IATN),ZCOORD(IATN),'N',1)
      CALL LAB019 (XCOORD(IATE),YCOORD(IATE),ZCOORD(IATE),'E',1)
      CALL LAB019 (XCOORD(IATW),YCOORD(IATW),ZCOORD(IATW),'W',1)
      CALL LAB019 (XCOORD(IATT),YCOORD(IATT),ZCOORD(IATT),'T',1)
      CALL LAB019 (XCOORD(IATB),YCOORD(IATB),ZCOORD(IATB),'B',1)



      DO 10 I=1,21
         XYZ(1)=XCOORD(IATCGD)+0.05*(I-1)*(XCOORD(IATW)-XCOORD(IATCGD))
         XYZ(2)=YCOORD(IATCGD)+0.05*(I-1)*(YCOORD(IATW)-YCOORD(IATCGD))
         XYZ(3)=ZCOORD(IATCGD)+0.05*(I-1)*(ZCOORD(IATW)-ZCOORD(IATCGD))
         CV(1)=XCOORD(IATE)+0.05*(I-1)*(XCOORD(IATN)-XCOORD(IATE))
         CV(2)=YCOORD(IATE)+0.05*(I-1)*(YCOORD(IATN)-YCOORD(IATE))
         CV(3)=ZCOORD(IATE)+0.05*(I-1)*(ZCOORD(IATN)-ZCOORD(IATE))
         CALL GRTLIN (XYZ(1),XYZ(2),XYZ(3),CV(1),CV(2),CV(3),20,IERR)
   10 CONTINUE
      DO 20 I=1,21
         XYZ(1)=XCOORD(IATCGD)+0.05*(I-1)*(XCOORD(IATE)-XCOORD(IATCGD))
         XYZ(2)=YCOORD(IATCGD)+0.05*(I-1)*(YCOORD(IATE)-YCOORD(IATCGD))
         XYZ(3)=ZCOORD(IATCGD)+0.05*(I-1)*(ZCOORD(IATE)-ZCOORD(IATCGD))
         CV(1)=XCOORD(IATW)+0.05*(I-1)*(XCOORD(IATN)-XCOORD(IATW))
         CV(2)=YCOORD(IATW)+0.05*(I-1)*(YCOORD(IATN)-YCOORD(IATW))
         CV(3)=ZCOORD(IATW)+0.05*(I-1)*(ZCOORD(IATN)-ZCOORD(IATW))
         CALL GRTLIN (XYZ(1),XYZ(2),XYZ(3),CV(1),CV(2),CV(3),20,IERR)
   20 CONTINUE



      CALL GRAMOL (' ')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION_SETTYP (CHAR2IN)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'HISTOG.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR
      REAL          R0, DIV, N
      CHARACTER*2   CHAR2IN







      IF (CHAR2IN.NE.'  ') THEN
         CALL GVSSTX (IONTYP,CHAR2IN)
      ELSE
 10      CONTINUE
         CALL GVST6C ('?M4248',IONTYP,.TRUE.)
         CALL IPROMPT ('?M4249')
         CALL GVSCTB (IONTYP,2)
         CALL GETWORD (IONTYP,IERR)
         IF (IERR.NE.0) GOTO 10
         IF (IONTYP.EQ.'0 '.OR.IONTYP.EQ.' 0') CALL GVSSTX (IONTYP,'**')
         CALL ION_SHOTYP
      END IF
      CALL GVSCUC (IONTYP)



      IF (IONTYP(2:2).EQ.' ') THEN
         IONTYP(2:2)=IONTYP(1:1)
         IONTYP(1:1)=' '
      END IF



      CALL ION_SET_PAR (R0,N,DIV,IERR)



      WIFPAR(457)=IONRED





      RETURN
      END   
      SUBROUTINE ION017

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'HB2INC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ISOUP, IAA, ION, IAT, JAT, I, J, IERR
      LOGICAL       FOUND, ION_USE







      CALL WIFPUSHPPP (590,0)
      CALL WIFPUSHPPP (470,1)
      CALL WIFPUSHPPP (456,1)
      IF (WIFPAR(426).EQ.0) THEN
         CALL WIFPUSHPPP (1265,1)
         CALL HBO010
         CALL HB2RED
         CALL HB2LFR
         CALL WIFPOPPPP (1265)
      END IF



      FOUND=.FALSE.
      CALL GRTVIN



      DO 100 ISOUP=1,NUMSOU
         IAA=SOUADM(1,ISOUP)
         ION=PNTAAS(SOUADM(1,ISOUP))



         IF (.NOT.ION_USE(IAA)) GOTO 100
         CALL GVSNL6 (1)
         CALL SHOIAA (IAA)
         FOUND=.TRUE.



         CALL ENVSET (ISOUP)
         CALL ION004 (6,ION,IERR)



         CALL WIFPUSHPPP (457,1)
         CALL ENVTOT
         CALL SYMIPG (IERR,' ')
         CALL SYMNEA
         CALL FCONAT (ION,1.0)
         CALL FCONRED (ION,IONHGH)
         CALL FCONREC
         CALL ION105A (6)
         CALL WIFPOPPPP (457)
         IF (NUMCONIAT.GE.2) THEN
            DO 30 I=1,NUMCONIAT-1
               IAT=CONIAT(I)
               DO 20 J=I,NUMCONIAT
                  JAT=CONIAT(J)
                  IF (IAT.EQ.WIFPAR(459).OR.JAT.EQ.WIFPAR(459).OR.
     +                IAT.EQ.WIFPAR(460).OR.JAT.EQ.WIFPAR(460)) THEN
                     CALL GRTLIN (XCOORD(IAT),YCOORD(IAT),ZCOORD(IAT),
     +                XCOORD(JAT),YCOORD(JAT),ZCOORD(JAT),120,IERR)
                  ELSE
                     CALL GRTLIN (XCOORD(IAT),YCOORD(IAT),ZCOORD(IAT),
     +                XCOORD(JAT),YCOORD(JAT),ZCOORD(JAT),180,IERR)
                  END IF
 20            CONTINUE
 30         CONTINUE
         END IF
 100  CONTINUE
      IF (.NOT.FOUND) CALL GVSTT6 ('?M2131')
      CALL GRAMOL (' ')



      CALL WIFPOPPPP (456)
      CALL WIFPOPPPP (470)
      CALL WIFPOPPPP (590)
      CALL GVSRT0 (ATTVAL,MAXAT)
      CALL GVSBTF (USEAT,NUMATF)


      RETURN
      END   
      SUBROUTINE ION017S

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'HB2INC.INC'
      INCLUDE       'VECTOR.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ISOUP, IAA, ION, IAT, I, J, IERR, IS
      REAL          AR(3,12)
      LOGICAL       FOUND, ION_USE, DASH(12)







      CALL WIFPUSHPPP (590,1)
      CALL WIFPUSHPPP (470,1)
      CALL WIFPUSHPPP (456,1)
      IF (WIFPAR(426).EQ.0) THEN
         CALL WIFPUSHPPP (1265,1)
         CALL HBO010
         CALL HB2RED
         CALL HB2LFR
         CALL WIFPOPPPP (1265)
      END IF



      FOUND=.FALSE.
      CALL GRTVIN



      DO 100 ISOUP=1,NUMSOU
         IAA=SOUADM(1,ISOUP)
         ION=PNTAAS(SOUADM(1,ISOUP))



         IF (.NOT.ION_USE(IAA)) GOTO 100
         CALL GVSNL6 (1)
         CALL SHOIAA (IAA)
         FOUND=.TRUE.



         CALL ENVSET (ISOUP)
         CALL ION004 (6,ION,IERR)
         IF (IERR.NE.0) GOTO 100
         IF (NUMCONIAT.LE.0) GOTO 100
         DO 10 IAT=1,NUMCONIAT
            IF (IAT.GE.13) THEN
               CALL GVSTTI ('BUG. NUMCONIAT oor in IONS017S:',
     +          NUMCONIAT)
               GOTO 11
            END IF
            AR(1,IAT)=XCOORD(CONIAT(IAT))
            AR(2,IAT)=YCOORD(CONIAT(IAT))
            AR(3,IAT)=ZCOORD(CONIAT(IAT))
            IS=CONSYMAT(IAT)
            CALL GVSMPV (AR(1,IAT),SYMMAT(1,1,IS),SYMVEC(1,IS))
            DASH(IAT)=IS.NE.1
 10      CONTINUE
 11      CONTINUE



         IF (NUMCONIAT.GE.2) THEN
            DO 30 I=1,NUMCONIAT-1
               IF (I.GE.12) GOTO 30
               DO 20 J=I,NUMCONIAT
                  IF (I.GE.13) GOTO 20
                  IF (DASH(I).OR.DASH(J)) THEN
                     CALL GRTDSH (AR(1,I),AR(2,I),AR(3,I),AR(1,J),
     +                AR(2,J),AR(3,J),180,9,IERR)
                  ELSE
                     CALL GRTLIN (AR(1,I),AR(2,I),AR(3,I),AR(1,J),
     +                AR(2,J),AR(3,J),180,IERR)
                  END IF
 20            CONTINUE
 30         CONTINUE
         END IF
 100  CONTINUE
      IF (NUMGRV.GE.1) CALL GRAMOL (' ')



      IF (.NOT.FOUND) CALL GVSTT6 ('?M2131')
      CALL GVSRT0 (ATTVAL,MAXAT)
      CALL GVSBTF (USEAT,NUMATF)
      CALL WIFPOPPPP (456)
      CALL WIFPOPPPP (470)
      CALL WIFPOPPPP (590)


      RETURN
      END   
      SUBROUTINE ION021

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUPPOS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IPNT, IAA, IAT, I, IERR
      REAL          QRMS







      CALL WIF664
      IPNT=0
      CALL GVSBTF (WRK1TF,MAXAA)



   10 CONTINUE
         CALL GVSTTI ('?M2180',IPNT+1)
         CALL WIFGAT (' ',IAA,IAT,IERR)
         IF (IERR.NE.0) GOTO 20
         IRNG1(IPNT+1)=IAT
         XRNG1(1,IPNT+1)=XCOORD(IAT)
         XRNG1(2,IPNT+1)=YCOORD(IAT)
         XRNG1(3,IPNT+1)=ZCOORD(IAT)
         CALL GVSTTI ('?M2181',IPNT+1)
         CALL WIFGAT (' ',IAA,IAT,IERR)
         IF (IERR.NE.0) GOTO 20
         IPNT=IPNT+1
         IRNG2(IPNT)=IAT
         XRNG2(1,IPNT)=XCOORD(IAT)
         XRNG2(2,IPNT)=YCOORD(IAT)
         XRNG2(3,IPNT)=ZCOORD(IAT)
         WRK1TF(ATIAA(IAT))=.TRUE.
      GOTO 10



   20 CONTINUE
      CALL WRK1TFCOMPLETE



      IF (IPNT.GE.3) THEN
         DO 30 I=1,IPNT
            CALL DIF019 (IRNG1(I),IRNG2(I))
            CALL GVSTTR3 ('ATOM 1:',XRNG1(1,I),XRNG1(2,I),XRNG1(3,I))
            CALL GVSTTR3 ('ATOM 2:',XRNG2(1,I),XRNG2(2,I),XRNG2(3,I))
   30    CONTINUE
      END IF



      CALL GVSTTI ('?M2182',IPNT)
      CALL GVSSUP (IPNT,XRNG1,XRNG2,SUPMAT,SUPVEC,QRMS)
      CALL GVSTTR ('?M2183',QRMS)





      RETURN
      END   
      REAL FUNCTION ION023(IAT1,IAT2)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAT1, IAT2
      REAL          GVFANG, GVFRTD, GVFLNV







      ION023=-999.9



      IF (GVFLNV(CV).LE.0.0) THEN
         CALL GVSTTB ('?M2197')
         CALL GVSKIL
         GOTO 998
      END IF



      XYZ(1)=XCOORD(IAT1)-XCOORD(IAT2)
      XYZ(2)=YCOORD(IAT1)-YCOORD(IAT2)
      XYZ(3)=ZCOORD(IAT1)-ZCOORD(IAT2)
      ION023=GVFRTD(GVFANG(CV,XYZ))



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION024 (IUNIT,ISOUP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ISOUP, ION, IERR, IUNIT
      LOGICAL       WIFISW







      IF (.NOT.WIFISW(ISOUP)) THEN
         CALL GVSTTB ('?M4839')
         GOTO 999
      END IF



      DO 10 ION=PNTAAS(SOUADM(1,ISOUP)),PNTAAE(SOUADM(2,ISOUP))
         CALL DIF015 (IUNIT,'?ION512',ION)
         CALL ION102B (IUNIT,ION,IERR)
 10   CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('ION024')



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ION029

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HISTOG.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IPOL







      DO 10 IPOL=1,MAXPOL/2
         CALL ION029A (IPOL,LINE(1:60))
         CALL GVSSTX (POLCHR(IPOL),LINE(1:60))
 10   CONTINUE





      RETURN
      END   
      SUBROUTINE ION029A (IPOLIN,TEXT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'HISTOG.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IPOLIN, IPOL
      CHARACTER*7   CHAR7
      CHARACTER*60  TEXT







      IF (IPOLIN.LE.MAXPOL/2) THEN
         IPOL=IPOLIN
      ELSE
         IPOL=IPOLIN-100
      END IF



      IF (IPOL.LE.9) THEN
         CALL GVSFMT ('?ION500')
         WRITE (CHAR7,FMT,ERR=999) IPOL
      ELSE IF (IPOL.LE.99) THEN
         CALL GVSFMT ('?ION501')
         WRITE (CHAR7,FMT,ERR=999) IPOL
      ELSE IF (IPOL.LE.999) THEN
         CALL GVSFMT ('?ION502')
         WRITE (CHAR7,FMT,ERR=999) IPOL
      END IF



      CALL GVSSTX (TEXT,CHAR7)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('ION029A')



 998  CONTINUE


      RETURN
      END   
      SUBROUTINE ION032 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          IONANG, AP, BP, CP, DP, RMS, A1, A2, A3,
     +              D1, D2, D3, IONDST, DU, AT
      LOGICAL       GVFRIN, DONE







      DONE=.FALSE.
      IAD=0
      DU=0.0
      AT=FLOAT(WIFPAR(458))



      IF (NUM.NE.3) GOTO 998
      IF (WIFPAR(456).GE.1) THEN
         CALL GVSNL6 (1)
         CALL GVSTT6 ('?ION541')
      END IF












      CALL IONPL4 (1,2,3,0,ION,AP,BP,CP,DP,RMS)
      IF (RMS.GT.0.3) THEN
         IF (WIFPAR(456).NE.0) CALL GVSTTR ('Planarity RMS=',RMS)
         GOTO 998
      END IF



      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         GOTO 998
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      A1=IONANG(1,ION,2)
      A2=IONANG(2,ION,3)
      A3=IONANG(3,ION,1)
      IF (WIFPAR(456).GE.1) THEN
         CALL ION_WRIT_TEXT (IUNIT,'?ION539',A1,' ')
         CALL ION_WRIT_TEXT (IUNIT,'?ION539',A2,' ')
         CALL ION_WRIT_TEXT (IUNIT,'?ION539',A3,' ')
      END IF
      IF ((GVFRIN(A1,90.0-AT,90.0+AT).AND.GVFRIN(A2,90-AT,90+AT).AND.
     +     GVFRIN(A3,180.0-AT,180.0+AT)).OR.
     +    (GVFRIN(A1,90-AT,90+AT).AND.GVFRIN(A3,90-AT,90+AT).AND.
     +     GVFRIN(A2,180.0-AT,180.0+AT)).OR.
     +    (GVFRIN(A2,90-AT,90+AT).AND.GVFRIN(A3,90-AT,90+AT).AND.
     +     GVFRIN(A1,180.0-AT,180.0+AT))) THEN
      ELSE
         CALL GVSTT6 ('?ION547')
      END IF



      CALL ION105 (IUNIT,'?M4254A',D1,D2,D3,DU,DU,DU,DU)



      IF (RMS.LT.0.02) THEN
         CALL GVSTT6 ('?M4254')
         IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4254')
      ELSE IF (RMS.LT.0.2) THEN
         CALL GVSTT6 ('?M4255')
         IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4255')
      ELSE IF (RMS.LT.0.5) THEN
         CALL GVSTT6 ('?M4256')
         IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4256')
      END IF



      CALL GVSSTX (PACTYP,'T.')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE 


      RETURN
      END
      SUBROUTINE ION033 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IAA, IAT, ION, NUM, IUNIT, TAT, IAD
      REAL          WIFDST, IONDST, D1, D2, D3, A, B, C, D, RMS, LMIN,
     +              DIST, PDIST, ODIST, DU, IONDST2
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0



      IF (NUM.NE.3) GOTO 998
      IF (WIFPAR(456).NE.0) THEN
         CALL GVSNL6 (1)
         CALL GVSTT6 ('?ION542')
      END IF














      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      CALL IONPL4 (1,2,3,0,ION,A,B,C,D,RMS)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         GOTO 998
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      IF (RMS.GT.0.5) GOTO 998





      PDIST=ABS(D-A*XCOORD(ION)-B*YCOORD(ION)-C*ZCOORD(ION))
      XYZ(1)=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,3))/3.0
      XYZ(2)=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,3))/3.0
      XYZ(3)=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,3))/3.0
      ODIST=SQRT((XYZ(1)-XCOORD(ION))**2+(XYZ(2)-YCOORD(ION))**2+
     + (XYZ(3)-ZCOORD(ION))**2)



      IF (PDIST.GT.0.5.OR.ODIST.GT.0.5) GOTO 998



      CALL ION105 (IUNIT,'?M4323',D1,D2,D3,DU,DU,DU,DU)



      IF (PDIST.LT.0.25) THEN
         CALL GVSTT6 ('?M4328')
      ELSE IF (PDIST.LT.0.5) THEN
         CALL GVSTT6 ('?M4329')
      ELSE IF (PDIST.LT.1.0) THEN
         CALL GVSTT6 ('?M4330')
      ELSE
         CALL GVSTT6 ('?M4331')
      END IF
      IF (ODIST-PDIST.GT.0.25) THEN
         CALL GVSTT6 ('?M4332')
      ELSE IF (ODIST-PDIST.GT.0.75) THEN
         CALL GVSTT6 ('?M4333')
      END IF



      D1=IONDST2(1,2)
      D2=IONDST2(2,3)
      D3=IONDST2(3,1)



      IF (ABS(D1-D2).GT.1.0.OR.ABS(D2-D3).GT.1.0.OR.ABS(D1-D3).GT.1.0)
     +    THEN
         CALL GVSTT6 ('?M4334')
      ELSE IF (ABS(D1-D2).GT.0.5.OR.ABS(D2-D3).GT.0.5.OR.
     +    ABS(D1-D3).GT.0.5) THEN
         CALL GVSTT6 ('?M4335')
      ELSE IF (ABS(D1-D2).GT.0.25.OR.ABS(D2-D3).GT.0.25.OR.
     +    ABS(D1-D3).GT.0.25) THEN
         CALL GVSTT6 ('?M4336')
      END IF



      LMIN=999.9
      DO 100 IAA=1,NUMAAT
         IF (IAA.EQ.ATIAA(ION)) GOTO 100
         IF (IAA.EQ.ATIAA(JR(1))) GOTO 100
         IF (IAA.EQ.ATIAA(JR(2))) GOTO 100
         IF (IAA.EQ.ATIAA(JR(3))) GOTO 100



         DIST=SQRT((XCOORD(ION)-SPHRAD(1,IAA))**2+
     +             (YCOORD(ION)-SPHRAD(2,IAA))**2+
     +             (ZCOORD(ION)-SPHRAD(3,IAA))**2)
         IF (DIST.GT.SPHRAD(4,IAA)+3.2) GOTO 100



         DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
            DIST=WIFDST(IAT,ION)
            IF (DIST.LT.LMIN) THEN
               LMIN=DIST
               TAT=IAT
            END IF
 90      CONTINUE
 100  CONTINUE



      IF (LMIN.LT.IONHGH+0.75) THEN
         JR(4)=TAT
         NUM=4
         CALL GVSTT6 ('?M4337')
         CALL DIF015B (6,TAT,'?M4338',LMIN)
         PDIST=ABS(D-A*XCOORD(TAT)-B*YCOORD(TAT)-C*ZCOORD(TAT))
      END IF



      CALL GVSSTX (PACTYP,'Tr')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION035 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, I, JRMAX, JRMIN, J, JRL,
     +              JRR, IAD
      REAL          XS, YS, ZS, IONDST, D1, D2, D3, D4, IONANG, GVFRTD, 
     +              GVFANG, DIJ, DMAX, DMIN, VB1(3), VB2(3), VB3(3), D,
     +              VNORM(3), DU
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0



      IF (NUM.NE.4) GOTO 998
      IF (WIFPAR(456).NE.0) THEN
         CALL GVSNL6 (1)
         CALL GVSTT6 ('?ION543')
      END IF













      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         GOTO 998
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      XS=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,3))/3.0
      YS=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,3))/3.0
      ZS=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,3))/3.0
      CV(1)=XCOORD(ION)-XS
      CV(2)=YCOORD(ION)-YS
      CV(3)=ZCOORD(ION)-ZS
      XYZ(1)=XCOORD(JR(4))-XS
      XYZ(2)=YCOORD(JR(4))-YS
      XYZ(3)=ZCOORD(JR(4))-ZS
      IF (GVFRTD(GVFANG(CV,XYZ)).GT.90.0) THEN
         CALL GVSTT6 ('?ION548')
         GOTO 998
      END IF

      XS=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,4))/3.0
      YS=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,4))/3.0
      ZS=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,4))/3.0
      CV(1)=XCOORD(ION)-XS
      CV(2)=YCOORD(ION)-YS
      CV(3)=ZCOORD(ION)-ZS
      XYZ(1)=XCOORD(JR(3))-XS
      XYZ(2)=YCOORD(JR(3))-YS
      XYZ(3)=ZCOORD(JR(3))-ZS
      IF (GVFRTD(GVFANG(CV,XYZ)).GT.90.0) THEN
         CALL GVSTT6 ('?ION548')
         GOTO 998
      END IF

      XS=(XYZJR(1,1)+XYZJR(1,3)+XYZJR(1,4))/3.0
      YS=(XYZJR(2,1)+XYZJR(2,3)+XYZJR(2,4))/3.0
      ZS=(XYZJR(3,1)+XYZJR(3,3)+XYZJR(3,4))/3.0
      CV(1)=XCOORD(ION)-XS
      CV(2)=YCOORD(ION)-YS
      CV(3)=ZCOORD(ION)-ZS
      XYZ(1)=XCOORD(JR(2))-XS
      XYZ(2)=YCOORD(JR(2))-YS
      XYZ(3)=ZCOORD(JR(2))-ZS
      IF (GVFRTD(GVFANG(CV,XYZ)).GT.90.0) THEN
         CALL GVSTT6 ('?ION548')
         GOTO 998
      END IF

      XS=(XYZJR(1,2)+XYZJR(1,3)+XYZJR(1,4))/3.0
      YS=(XYZJR(2,2)+XYZJR(2,3)+XYZJR(2,4))/3.0
      ZS=(XYZJR(3,2)+XYZJR(3,3)+XYZJR(3,4))/3.0
      CV(1)=XCOORD(ION)-XS
      CV(2)=YCOORD(ION)-YS
      CV(3)=ZCOORD(ION)-ZS
      XYZ(1)=XCOORD(JR(1))-XS
      XYZ(2)=YCOORD(JR(1))-YS
      XYZ(3)=ZCOORD(JR(1))-ZS
      IF (GVFRTD(GVFANG(CV,XYZ)).GT.90.0) THEN
         CALL GVSTT6 ('?ION548')
         GOTO 998
      END IF



      CV(1)=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,3)+XYZJR(1,4))/4.0
      CV(2)=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,3)+XYZJR(2,4))/4.0
      CV(3)=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,3)+XYZJR(3,4))/4.0
      DIJ=SQRT((CV(1)-XCOORD(ION))**2+(CV(2)-YCOORD(ION))**2+
     + (CV(3)-ZCOORD(ION))**2)
      CALL ION_WRIT_TEXT (IUNIT,'?M4933',DIJ,' ')
      IF (DIJ.GT.0.75) THEN
         CALL ION107 (IUNIT,'?M4262')
         GOTO 998
      END IF





      CALL ION105 (IUNIT,'?M4257',D1,D2,D3,D4,DU,DU,DU)



      CALL ION107 (IUNIT,'?M4265')
      CALL DIF024C (6,JR(1),ION,JR(2),IONANG(1,ION,2))
      CALL DIF024C (6,JR(1),ION,JR(3),IONANG(1,ION,3))
      CALL DIF024C (6,JR(1),ION,JR(4),IONANG(1,ION,4))
      CALL DIF024C (6,JR(2),ION,JR(3),IONANG(2,ION,3))
      CALL DIF024C (6,JR(2),ION,JR(4),IONANG(2,ION,4))
      CALL DIF024C (6,JR(3),ION,JR(4),IONANG(3,ION,4))
      IF (IUNIT.NE.6) THEN
         CALL DIF024C (IUNIT,JR(1),ION,JR(2),IONANG(1,ION,2))
         CALL DIF024C (IUNIT,JR(1),ION,JR(3),IONANG(1,ION,3))
         CALL DIF024C (IUNIT,JR(1),ION,JR(4),IONANG(1,ION,4))
         CALL DIF024C (IUNIT,JR(2),ION,JR(3),IONANG(2,ION,3))
         CALL DIF024C (IUNIT,JR(2),ION,JR(4),IONANG(2,ION,4))
         CALL DIF024C (IUNIT,JR(3),ION,JR(4),IONANG(3,ION,4))
      END IF



      CALL ION107 (IUNIT,'?M4326')
      DMIN=999.9
      JRMIN=0
      DMAX=0.0
      JRMAX=0
      DO 20 I=1,4
         DIJ=IONDST(ION,I)
         IF (DIJ.GT.DMAX) THEN
            DMAX=DIJ
            JRMAX=I
         END IF
         IF (DIJ.LT.DMIN) THEN
            DMIN=DIJ
            JRMIN=I
         END IF
 20   CONTINUE
      CALL DIF015B (6,JR(JRMAX),'?M4266',DMAX)
      IF (IUNIT.NE.6) CALL DIF015B (IUNIT,JR(JRMAX),'?M4266',DMAX)
      CALL DIF015B (6,JR(JRMIN),'?M4267',DMIN)
      IF (IUNIT.NE.6) CALL DIF015B (IUNIT,JR(JRMIN),'?M4267',DMIN)



      J=0
      JRR=0
      JRL=0
      DO 50 I=1,4
        IF (I.EQ.JRMIN.OR.I.EQ.JRMAX) GOTO 50
        J=J+1
        CALL DIF015B (6,JR(I),'?M4327',IONDST(ION,I))
        IF (IUNIT.NE.6) CALL DIF015B (IUNIT,JR(I),'?M4327',
     +   IONDST(ION,I))
        IF (J.EQ.1) THEN
           JRR=JR(I)
        ELSE
           JRL=JR(I)
        END IF
 50   CONTINUE
      IF (JRL.LE.0) GOTO 998



      CALL DIF012D (6,ION,JR(JRMAX),'?M4263',IONDST(ION,JRMAX))
      IF (IUNIT.NE.6) CALL DIF012D (IUNIT,ION,JR(JRMAX),'?M4263',
     + IONDST(ION,JRMAX))
      VB1(1)=XCOORD(JRMIN)
      VB1(2)=YCOORD(JRMIN)
      VB1(3)=ZCOORD(JRMIN)
      VB2(1)=XCOORD(JRR)
      VB2(2)=YCOORD(JRR)
      VB2(3)=ZCOORD(JRR)
      VB3(1)=XCOORD(JRL)
      VB3(2)=YCOORD(JRL)
      VB3(3)=ZCOORD(JRL)
      CALL GVSNRV (VNORM,VB1,VB2,VB3)
      D=0.0-VB1(1)*VNORM(1)-VB1(2)*VNORM(2)-VB1(3)*VNORM(3)
      DIJ=ABS(D+VNORM(1)*XCOORD(ION)+VNORM(2)*YCOORD(ION)+
     + VNORM(3)*ZCOORD(ION))
      CALL ION_WRIT_TEXT (IUNIT,'?M4264',DIJ,' ')



      XS=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,3)+XYZJR(1,4))/4.0
      YS=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,3)+XYZJR(2,4))/4.0
      ZS=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,3)+XYZJR(3,4))/4.0
      DIJ=SQRT((XS-XCOORD(ION))**2+(YS-YCOORD(ION))**2+
     + (ZS-ZCOORD(ION))**2)
      CALL ION_WRIT_TEXT (IUNIT,'?M4268',DIJ,' ')



      CALL GVSSTX (PACTYP,'4r')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION034 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          IONDST, D(4), C, RMS, AP, BP, CP, DP, PDIST, AT,
     +              A12, A13, A14, A23, A24, A34, IONANG, DU
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0
      AT=FLOAT(WIFPAR(458))



      IF (NUM.NE.4) GOTO 998
      IF (WIFPAR(456).NE.0) THEN
         CALL GVSNL6 (1)
         CALL GVSTT6 ('?ION544')
      END IF














      D(1)=IONDST(ION,1)
      D(2)=IONDST(ION,2)
      D(3)=IONDST(ION,3)
      D(4)=IONDST(ION,4)
      CALL IONPL4 (1,2,3,4,ION,AP,BP,CP,DP,RMS)
      PDIST=ABS(DP-AP*XCOORD(ION)-BP*YCOORD(ION)-CP*ZCOORD(ION))



      IF (.NOT.GVFRIN(D(1),IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D(2),IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D(3),IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D(4),IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D(1),IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D(2),IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D(3),IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D(4),IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         GOTO 998
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      IF (RMS.GT.0.5) THEN
         IF (WIFPAR(456).GE.1) CALL GVSTTR ('Planarity RMS=',RMS)
         GOTO 998
      END IF



      IF (ABS(D(1)-D(2)).GT.0.3.OR.ABS(D(2)-D(3)).GT.0.3.OR.
     +    ABS(D(3)-D(4)).GT.0.3.OR.ABS(D(4)-D(1)).GT.0.3) THEN
         CALL ION107 (IUNIT,'?M4259')
      ELSE IF (RMS.GT.0.05) THEN
         CALL ION107 (IUNIT,'?M4259')
      END IF



      A12=IONANG(1,ION,2)
      A13=IONANG(1,ION,3)
      A14=IONANG(1,ION,4)
      A23=IONANG(2,ION,3)
      A24=IONANG(2,ION,4)
      A34=IONANG(3,ION,4)
      IF (WIFPAR(456).GE.1) CALL GVSTTR6U (6,'?ION513',A12,A13,A14,
     + A23,A24,A34)
      IF (.NOT.GVFRIN(A12,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A12,180.0-AT,180.0+AT)) GOTO 998
      IF (.NOT.GVFRIN(A13,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A13,180.0-AT,180.0+AT)) GOTO 998
      IF (.NOT.GVFRIN(A14,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A14,180.0-AT,180.0+AT)) GOTO 998
      IF (.NOT.GVFRIN(A23,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A23,180.0-AT,180.0+AT)) GOTO 998
      IF (.NOT.GVFRIN(A24,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A24,180.0-AT,180.0+AT)) GOTO 998
      IF (.NOT.GVFRIN(A34,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A34,180.0-AT,180.0+AT)) GOTO 998



      CALL ION105 (IUNIT,'?M4316',D(1),D(2),D(3),D(4),DU,DU,DU)



      CV(1)=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,3)+XYZJR(1,4))/4.0
      CV(2)=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,3)+XYZJR(2,4))/4.0
      CV(3)=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,3)+XYZJR(3,4))/4.0
      C=SQRT((CV(1)-XCOORD(ION))**2+
     +       (CV(2)-YCOORD(ION))**2+
     +       (CV(3)-ZCOORD(ION))**2)
      IF (C.GT.0.25) CALL ION107 (IUNIT,'?M4259')



      CALL GVSSTX (PACTYP,'4f')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION036 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          IONDST, D1, D2, D3, D4, DU
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0



      IF (NUM.NE.4) GOTO 998








      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      CALL ION105 (IUNIT,'?M4261A',D1,D2,D3,D4,DU,DU,DU)



      CALL GVSSTX (PACTYP,'4.')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION037 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          IONDST, D1, D2, D3, DU
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0



      IF (NUM.NE.3) GOTO 998








      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      CALL ION105 (IUNIT,'?M4261',D1,D2,D3,DU,DU,DU,DU)



      CALL GVSSTX (PACTYP,'3.')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION038 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD, I90, I5, I6
      REAL          IONDST, D1, D2, D3, D4, D5, RMS, A, B, C, DP, RN,
     +              A12, A13, A14, A23, A24, A34, IONANG, 
     +              GVFRAN, PDIST, AT, DU, VIONP, ION_VALENCY
      LOGICAL       DONE, PLANOK, GVFRIN, KILL
      CHARACTER*1   KILCHR(6)







      DONE=.FALSE.
      KILL=.FALSE.
      IAD=0
      DU=0.0
      AT=FLOAT(WIFPAR(458))
      CALL GVSCTB (KILCHR,6)



      IF (NUM.NE.5) GOTO 998
      IF (WIFPAR(456).NE.0) THEN
         CALL GVSNL6 (1)
         CALL GVSTT6 ('?ION545')
      END IF















      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)
      IF (WIFPAR(456).GE.1) CALL GVSTTR5 ('?M4923',D1,D2,D3,D4,D5)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      CALL ION055 (ION,NUM,0.25,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION055 (ION,NUM,0.35,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION055 (ION,NUM,0.5,PLANOK,A,B,C,DP,RMS)
      IF (WIFPAR(456).GE.1) CALL GVSTTR ('?M4924',RMS)
      IF (.NOT.PLANOK) GOTO 998



      A12=IONANG(1,ION,2)
      A13=IONANG(1,ION,3)
      A14=IONANG(1,ION,4)
      A23=IONANG(2,ION,3)
      A24=IONANG(2,ION,4)
      A34=IONANG(3,ION,4)
      IF (.NOT.GVFRIN(A12,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A12,180.0-AT,180.1)) THEN
         KILCHR(1)='*'
         KILL=.TRUE.
      END IF
      IF (.NOT.GVFRIN(A13,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A13,180.0-AT,180.1)) THEN
         KILCHR(2)='*'
         KILL=.TRUE.
      END IF
      IF (.NOT.GVFRIN(A14,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A14,180.0-AT,180.1)) THEN
         KILCHR(3)='*'
         KILL=.TRUE.
      END IF
      IF (.NOT.GVFRIN(A23,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A23,180.0-AT,180.1)) THEN
         KILCHR(4)='*'
         KILL=.TRUE.
      END IF
      IF (.NOT.GVFRIN(A24,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A24,180.0-AT,180.1)) THEN
         KILCHR(5)='*'
         KILL=.TRUE.
      END IF
      IF (.NOT.GVFRIN(A34,90.0-AT,90.0+AT).AND.
     +    .NOT.GVFRIN(A34,180.0-AT,180.1)) THEN
         KILCHR(6)='*'
         KILL=.TRUE.
      END IF
      IF (WIFPAR(456).GE.1) THEN
         CALL ION_WRIT_TEXT (IUNIT,'?M4925',A12,KILCHR(1))
         CALL ION_WRIT_TEXT (IUNIT,'?M4926',A13,KILCHR(2))
         CALL ION_WRIT_TEXT (IUNIT,'?M4927',A14,KILCHR(3))
         CALL ION_WRIT_TEXT (IUNIT,'?M4928',A23,KILCHR(4))
         CALL ION_WRIT_TEXT (IUNIT,'?M4929',A24,KILCHR(5))
         CALL ION_WRIT_TEXT (IUNIT,'?M4930',A34,KILCHR(6))
      END IF
      IF (KILL) GOTO 998



      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)



      CALL ION105 (IUNIT,'?M4340',D1,D2,D3,D4,D5,DU,DU)
      CALL ION_WRIT_TEXT (IUNIT,'?M4924',RMS,' ')
      VIONP=ION_VALENCY(ION)



      I90=0
      I5=0
      I6=0



      IF (WIFPAR(456).LE.0) THEN
         CALL ION_WRIT_TEXT (IUNIT,'?M4925',A12,' ')
         CALL ION_WRIT_TEXT (IUNIT,'?M4926',A13,' ')
         CALL ION_WRIT_TEXT (IUNIT,'?M4927',A14,' ')
         CALL ION_WRIT_TEXT (IUNIT,'?M4928',A23,' ')
         CALL ION_WRIT_TEXT (IUNIT,'?M4929',A24,' ')
         CALL ION_WRIT_TEXT (IUNIT,'?M4930',A34,' ')
      END IF



      PDIST=ABS(A*XCOORD(ION)+B*YCOORD(ION)+C*ZCOORD(ION)-DP)
      CALL ION_WRIT_TEXT (IUNIT,'?M4931',PDIST,' ')
      RN=GVFRAN(-5.0,5.0)
      IF (RN.LT.0.0) PDIST=(-1.0)*PDIST



      PDIST=IONDST(ION,5)
      CALL ION_WRIT_TEXT (IUNIT,'?M4932',PDIST,' ')



      CV(1)=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,3)+XYZJR(1,4))/4.0
      CV(2)=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,3)+XYZJR(2,4))/4.0
      CV(3)=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,3)+XYZJR(3,4))/4.0
      C=SQRT((CV(1)-XCOORD(ION))**2+
     +       (CV(2)-YCOORD(ION))**2+
     +       (CV(3)-ZCOORD(ION))**2)
      IF (C.GT.0.25) THEN
         CALL GVSTT6 ('?M4259')
         IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4259')
      END IF
      CALL ION_WRIT_TEXT (IUNIT,'?M4933',C,' ')
      RN=GVFRAN(-5.0,5.0)
      IF (RN.LT.0) C=(-1.0)*C



      CALL GVSSTX (PACTYP,'4p')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION039 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          A, B, C, DP, RMS, IONANG, IONDST, D1, D2, D3, D4, 
     +              D5, TIBANG, DOFF, DU, VIONP, ION_VALENCY, AT,
     +              IONDST2
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0
      AT=FLOAT(WIFPAR(458))



      IF (NUM.NE.5) GOTO 998
      IF (WIFPAR(456).NE.0) THEN
         CALL GVSNL6 (1)
         CALL GVSTT6 ('?ION546')
      END IF













      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF




      CALL ION058 (ION,NUM,TIBANG)
      IF (WIFPAR(456).GE.1) CALL GVSTTR ('?ION514',TIBANG)
      IF (ABS(TIBANG-180.0).GT.AT) GOTO 998
      CALL IONPL4 (1,2,3,0,ION,A,B,C,DP,RMS)
      IF (WIFPAR(456).GE.1) CALL GVSTTR ('?M4924',RMS)
      IF (RMS.GT.0.5) GOTO 998
      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)
      CALL ION105 (IUNIT,'?M4935',D1,D2,D3,D4,D5,DU,DU)
      WIFPAR(459)=JR(4)
      WIFPAR(460)=JR(5)



      TIBANG=IONANG(4,ION,5)
      IF (WIFPAR(456).GE.1) CALL GVSTTR ('?M4936',TIBANG)
      IF (.NOT.GVFRIN(TIBANG,180.0-AT,180.0+AT)) GOTO 998



      CALL ION105 (IUNIT,'?M4310',D1,D2,D3,D4,D5,DU,DU)
      VIONP=ION_VALENCY(ION)



      IF (D4.GT.D5) THEN
         CALL DIF015B (6,JR(4),'?M4266',D4)
         CALL DIF015B (6,JR(5),'?M4266A',D5)
         IF (IUNIT.NE.6) THEN
            CALL DIF015B (IUNIT,JR(4),'?M4266',D4)
            CALL DIF015B (IUNIT,JR(5),'?M4266A',D5)
         END IF
      ELSE
         CALL DIF015B (6,JR(5),'?M4266',D5)
         CALL DIF015B (6,JR(4),'?M4266A',D4)
         IF (IUNIT.NE.6) THEN
            CALL DIF015B (IUNIT,JR(5),'?M4266',D5)
            CALL DIF015B (IUNIT,JR(4),'?M4266A',D4)
         END IF
      END IF
      CALL DIF015B (6,JR(1),'?M4266D',D1)
      CALL DIF015B (6,JR(2),'?M4266D',D2)
      CALL DIF015B (6,JR(3),'?M4266D',D3)
      IF (IUNIT.NE.6) THEN
         CALL DIF015B (IUNIT,JR(1),'?M4266D',D1)
         CALL DIF015B (IUNIT,JR(2),'?M4266D',D2)
         CALL DIF015B (IUNIT,JR(3),'?M4266D',D3)
      END IF



      CALL GVSTTR ('?M4904',TIBANG)
      IF (IUNIT.NE.6) CALL GVSTUR (IUNIT,'?M4904',TIBANG)



      XYZ(1)=(XCOORD(JR(1))+XCOORD(JR(2))+XCOORD(JR(3)))/3.0
      XYZ(2)=(YCOORD(JR(1))+YCOORD(JR(2))+YCOORD(JR(3)))/3.0
      XYZ(3)=(ZCOORD(JR(1))+ZCOORD(JR(2))+ZCOORD(JR(3)))/3.0
      DOFF=SQRT((XCOORD(ION)-XYZ(1))**2+
     +          (YCOORD(ION)-XYZ(2))**2+
     +          (ZCOORD(ION)-XYZ(3))**2)
      CALL GVSTTR ('?M4269A',DOFF)
      IF (IUNIT.NE.6) CALL GVSTUR (IUNIT,'?M4269A',DOFF)



      D1=IONDST2(1,2)
      D2=IONDST2(2,3)
      D3=IONDST2(3,1)



      CALL GVSSTX (PACTYP,'3b')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION040 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IUNIT, IAT, JAT, NUM, ION, IAD, I3, I4
      REAL          ANG, IONANG, IONDST, D1, D2, D3, D4, VIONP, 
     +              ION_VALENCY,D5, D6, A, B, C, DP, RMS, DUMMY, 
     +              DOFF, DU, AT
      LOGICAL       DONE, GVFRIN, PLANOK, KILL







      DONE=.FALSE.
      IAD=0
      DUMMY=0.0
      I3=0
      I4=0
      AT=FLOAT(WIFPAR(458))



      IF (NUM.NE.6) GOTO 998
      IF (WIFPAR(456).GE.1) THEN
         CALL GVSNL6 (1)
         CALL GVSTT6 ('?ION540')
      END IF












      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)
      D6=IONDST(ION,6)
      IF (WIFPAR(456).GE.1) CALL ION105 (IUNIT,'?M4905',D1,D2,D3,
     + D4,D5,D6,DUMMY)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D6,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D6,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF




      CALL ION057 (ION,NUM,0.05,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.10,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.15,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.20,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.25,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.30,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.35,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.40,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.45,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) CALL ION057 (ION,NUM,0.50,PLANOK,A,B,C,DP,RMS)
      IF (.NOT.PLANOK) GOTO 998
      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)
      D6=IONDST(ION,6)
      CALL ION105 (IUNIT,'?M4935',D1,D2,D3,D4,D5,D6,DU)
      ANG=IONANG(5,ION,6)
      IF (WIFPAR(456).GE.1) CALL GVSTTR ('?ION514',ANG)



      KILL=.FALSE.
      DO 30 IAT=1,5
         DO 20 JAT=IAT+1,6
            ANG=IONANG(IAT,ION,JAT)
            IF (WIFPAR(456).GE.1) CALL DIF015G (6,'?ION515',JR(IAT),
     +       JR(JAT),ANG,CONSYMAT(IAT),CONSYMAT(JAT))
            IF (.NOT.GVFRIN(ANG,90.0-AT,90.0+AT)) THEN
               IF (.NOT.GVFRIN(ANG,180.0-AT,180.0+AT)) THEN
                  IF (WIFPAR(456).GE.1) THEN
                     KILL=.TRUE.
                  ELSE
                     GOTO 998
                  END IF
               END IF
            END IF
 20      CONTINUE
 30   CONTINUE
      IF (KILL) GOTO 998



      IF (WIFPAR(456).LE.0) CALL ION105 (IUNIT,'?M4905',D1,D2,D3,
     + D4,D5,D6,DUMMY)
      VIONP=ION_VALENCY(ION)



      XYZ(1)=(XYZJR(1,1)+XYZJR(1,2)+XYZJR(1,3)+XYZJR(1,4)+XYZJR(1,3)+
     + XYZJR(1,4))/6.0
      XYZ(2)=(XYZJR(2,1)+XYZJR(2,2)+XYZJR(2,3)+XYZJR(2,4)+XYZJR(2,3)+
     + XYZJR(2,4))/6.0
      XYZ(3)=(XYZJR(3,1)+XYZJR(3,2)+XYZJR(3,3)+XYZJR(3,4)+XYZJR(3,3)+
     + XYZJR(3,4))/6.0
      DOFF=SQRT((XCOORD(ION)-XYZ(1))**2+
     +          (YCOORD(ION)-XYZ(2))**2+
     +          (ZCOORD(ION)-XYZ(3))**2)
      CALL ION_WRIT_TEXT (IUNIT,'?M4268',DOFF,' ')









      CALL GVSSTX (PACTYP,'4b')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION041 (IATION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IATION, BIDCNT, IAT, IAA, ELMZ, IERR, IUNIT, NUM
      REAL          WIFDST, ION023, AT
      LOGICAL       DONE, GVFRIN







      IF (NUM.NE.7) GOTO 998



      AT=FLOAT(WIFPAR(458))
      IERR=1
      DONE=.FALSE.



      DO 20 IAA=1,NUMAAF



         IF (RESTYP(IAA).NE.3.AND.RESTYP(IAA).NE.4) GOTO 20
         IATZ1=0
         IATZ2=0
         DIONZ1=0.0
         DIONZ2=0.0
         BIDCNT=0



         DO 10 IAT=PNTAAS(IAA),PNTAAE(IAA)
            IF (ELMZ(IAT).NE.8) GOTO 10
            IF (.NOT.ISATOK(IAT)) GOTO 10
            IF (WIFDST(IATION,IAT).LT.IONHGH) THEN
               IF (BIDCNT.EQ.0) THEN
                  BIDCNT=BIDCNT+1
                  IATZ1=IAT
                  DIONZ1=WIFDST(IATION,IAT)
                  USEAT(IAT)=.TRUE.
               ELSE
                  BIDCNT=BIDCNT+1
                  IATZ2=IAT
                  DIONZ2=WIFDST(IATION,IAT)
                  USEAT(IAT)=.TRUE.



                  IF (RESTYP(IAA).EQ.3) THEN
                     IATCGD=PNTAAS(IAA)+5
                  ELSE
                     IATCGD=PNTAAS(IAA)+6
                  END IF
                  call shoiaa (iaa)
               END IF
            END IF
   10    CONTINUE



         IF (BIDCNT.EQ.2.AND.ABS(DIONZ1-DIONZ2).LT.0.3) THEN
            CALL DIF015B (6,IATZ1,'?M2184',DIONZ1)
            CALL DIF015B (6,IATZ2,'?M2185',DIONZ2)
            CALL DIF015B (IUNIT,IATZ1,'?M2184',DIONZ1)
            CALL DIF015B (IUNIT,IATZ2,'?M2185',DIONZ2)
            IF (USE300) THEN
               CALL GRTLIN (XCOORD(IATION),YCOORD(IATION),
     +          ZCOORD(IATION),XCOORD(IATZ1),YCOORD(IATZ1),
     +          ZCOORD(IATZ1),150,IERR)
               CALL GRTLIN (XCOORD(IATION),YCOORD(IATION),
     +          ZCOORD(IATION),XCOORD(IATZ2),YCOORD(IATZ2),
     +          ZCOORD(IATZ2),150,IERR)
            END IF
            DONE=.TRUE.
            GOTO 21
         END IF
   20 CONTINUE
   21 CONTINUE



      IF (.NOT.DONE) THEN
         CALL GVSTT6 ('?M2186')
         GOTO 998
      END IF



      SCRRW1(1)=XCOORD(IATZ2)-XCOORD(IATCGD)
      SCRRW1(2)=YCOORD(IATZ2)-YCOORD(IATCGD)
      SCRRW1(3)=ZCOORD(IATZ2)-ZCOORD(IATCGD)
      SCRRW2(1)=XCOORD(IATZ1)-XCOORD(IATCGD)
      SCRRW2(2)=YCOORD(IATZ1)-YCOORD(IATCGD)
      SCRRW2(3)=ZCOORD(IATZ1)-ZCOORD(IATCGD)
      CALL GVSCP3 (CV,SCRRW1,SCRRW2)
      CALL GVSNM3 (CV)
      print*,'1 cv=',cv



      DO 30 IAT=1,NUMATF
         IF (USEAT(IAT).OR.ELMZ(IAT).NE.8) GOTO 30
         IF (WIFDST(IATION,IAT).LT.IONHGH) THEN
      print*,'2 cv=',cv
            IF (GVFRIN(ION023(IATCGD,IAT),90-AT,90+AT)) THEN
               IF (WIFDST(IAT,IATZ1).LT.WIFDST(IAT,IATZ2).AND.
     +             WIFDST(IAT,IATZ1).LT.4.0) THEN
                  IATW=IAT
                  DIONW=WIFDST(IATION,IAT)
                  USEAT(IAT)=.TRUE.
                  CALL DIF015B (IUNIT,IATW,'?M2187',DIONW)
                  IF (USE300) THEN
                     CALL GRTLIN (XCOORD(IATION),YCOORD(IATION),
     +                ZCOORD(IATION),XCOORD(IATW),YCOORD(IATW),
     +                ZCOORD(IATW),120,IERR)
                  END IF
               ELSE IF(WIFDST(IAT,IATZ2).LT.4.0) THEN
                  IATE=IAT
                  DIONE=WIFDST(IATION,IAT)
                  USEAT(IAT)=.TRUE.
                  CALL DIF015B (IUNIT,IATE,'?M2188',DIONE)
                  IF (USE300) THEN
                     CALL GRTLIN (XCOORD(IATION),YCOORD(IATION),
     +                ZCOORD(IATION),XCOORD(IATE),YCOORD(IATE),
     +                ZCOORD(IATE),120,IERR)
                  END IF
               END IF
            END IF
         END IF
   30 CONTINUE
      IF (IATE.EQ.0) THEN
         CALL GVSTTU (IUNIT,'?M2189')
         GOTO 998
      END IF
      IF (IATW.EQ.0) THEN
         CALL GVSTTU (IUNIT,'?M2190')
         GOTO 998
      END IF



      XYZ(1)=0.5*(XCOORD(IATZ1)+XCOORD(IATZ2))
      XYZ(2)=0.5*(YCOORD(IATZ1)+YCOORD(IATZ2))
      XYZ(3)=0.5*(ZCOORD(IATZ1)+ZCOORD(IATZ2))
      SCRRW1(1)=XCOORD(IATE)-XYZ(1)
      SCRRW1(2)=YCOORD(IATE)-XYZ(2)
      SCRRW1(3)=ZCOORD(IATE)-XYZ(3)
      SCRRW2(1)=XCOORD(IATW)-XYZ(1)
      SCRRW2(2)=YCOORD(IATW)-XYZ(2)
      SCRRW2(3)=ZCOORD(IATW)-XYZ(3)
      CALL GVSCP3 (CV,SCRRW1,SCRRW2)
      CALL GVSNM3 (CV)
      print*,'3 cv=',cv



      DO 40 IAT=1,NUMATF
         IF (USEAT(IAT).OR.ELMZ(IAT).NE.8) GOTO 40
         IF (WIFDST(IATION,IAT).LT.IONHGH) THEN
      print*,'4 cv=',cv
            IF (GVFRIN(ION023(IATCGD,IAT),90-AT,90+AT)) THEN
               IF(WIFDST(IAT,IATZ1).GT.4.0.AND.
     +             WIFDST(IAT,IATZ2).GT.4.) THEN
                  IATN=IAT
                  DIONN=WIFDST(IATION,IAT)
                  USEAT(IAT)=.TRUE.
                  CALL DIF015B (IUNIT,IATN,'?M2191',DIONN)
                  IF (USE300) THEN
                     CALL GRTLIN (XCOORD(IATION),YCOORD(IATION),
     +                ZCOORD(IATION),XCOORD(IATN),YCOORD(IATN),
     +                ZCOORD(IATN),120,IERR)
                  END IF
               END IF
            ELSE IF (ION023(IATCGD,IAT).GT.90.0) THEN
               IATT=IAT
               DIONT=WIFDST(IATION,IAT)
               USEAT(IAT)=.TRUE.
               CALL DIF015B (IUNIT,IATT,'?M2192',DIONT)
               IF (USE300) THEN
                  CALL GRTLIN (XCOORD(IATION),YCOORD(IATION),
     +             ZCOORD(IATION),XCOORD(IATT),YCOORD(IATT),
     +             ZCOORD(IATT),240,IERR)
               END IF
            ELSE IF (ION023(IATCGD,IAT).LT.90.0) THEN
               IATB=IAT
               DIONB=WIFDST(IATION,IAT)
               USEAT(IAT)=.TRUE.
               CALL DIF015B (IUNIT,IATB,'?M2193',DIONB)
               IF (USE300) THEN
                  CALL GRTLIN (XCOORD(IATION),YCOORD(IATION),
     +             ZCOORD(IATION),XCOORD(IATB),YCOORD(IATB),
     +             ZCOORD(IATB),240,IERR)
               END IF
            END IF
         END IF
   40 CONTINUE



      IF (IATN.EQ.0) THEN
         CALL GVSTTU (IUNIT,'?M2194')
         GOTO 998
      END IF
      IF (IATT.EQ.0) THEN
         CALL GVSTTU (IUNIT,'?M2195')
         GOTO 998
      END IF
      IF (IATB.EQ.0) THEN
         CALL GVSTTU (IUNIT,'?M2196')
         GOTO 998
      END IF



  998 CONTINUE 


      RETURN
      END
      SUBROUTINE ION042 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          IONDST, D1, D2, D3, D4, D5, DU
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0



      IF (NUM.NE.5) GOTO 998








      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      CALL ION105 (IUNIT,'?M4905',D1,D2,D3,D4,D5,DU,DU)
      CALL GVSTTU (6,'?M4261B')
      IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4261B')



      CALL GVSSTX (PACTYP,'5.')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION043 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          IONDST, D1, D2, D3, D4, D5, D6, DU
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0
      DU=0.0



      IF (NUM.NE.6) GOTO 998








      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)
      D6=IONDST(ION,6)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D6,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D6,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      CALL ION105 (IUNIT,'?M4261C',D1,D2,D3,D4,D5,D6,DU)



      CALL GVSSTX (PACTYP,'6.')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION044 (ION,NUM,IUNIT,DONE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, IUNIT, IAD
      REAL          IONDST, D1, D2, D3, D4, D5, D6, D7
      LOGICAL       DONE, GVFRIN







      DONE=.FALSE.
      IAD=0



      IF (NUM.NE.7) GOTO 998








      D1=IONDST(ION,1)
      D2=IONDST(ION,2)
      D3=IONDST(ION,3)
      D4=IONDST(ION,4)
      D5=IONDST(ION,5)
      D6=IONDST(ION,6)
      D7=IONDST(ION,7)



      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D6,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D7,IONLOW,IONHGH)) IAD=IAD+1
      IF (.NOT.GVFRIN(D1,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D2,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D3,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D4,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D5,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D6,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (.NOT.GVFRIN(D7,IONLOW,IONHGH+0.25)) IAD=IAD+1
      IF (IAD.GE.2) THEN
         CALL GVSTT6 ('?M4903')
      ELSE IF (IAD.EQ.1) THEN
         CALL GVSTT6 ('?M4902')
      END IF



      CALL ION105 (IUNIT,'?M4261D',D1,D2,D3,D4,D5,D6,D7)



      CALL GVSSTX (PACTYP,'7.')
      CALL ION109 (ION)
      DONE=.TRUE.



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION055 (ION,NUM,CUTOFF,PLANOK,A,B,C,D,RMS)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM
      REAL          CUTOFF, RMS, A, B, C, D
      LOGICAL       PLANOK







      PLANOK=.FALSE.
      RMS=999.9



      IF (NUM.NE.5) GOTO 998




      CALL IONPL4 (1,2,3,4,ION,A,B,C,D,RMS)
      IF (RMS.LT.CUTOFF) THEN
         PLANOK=.TRUE.
      ELSE
         CALL IONPL4 (1,2,3,5,ION,A,B,C,D,RMS)
         IF (RMS.LT.CUTOFF) THEN
            PLANOK=.TRUE.
            CALL GVSWIP (JR(4),JR(5))
            CALL GVSWAP (XYZJR(1,4),XYZJR(1,5))
            CALL GVSWAP (XYZJR(2,4),XYZJR(2,5))
            CALL GVSWAP (XYZJR(3,4),XYZJR(3,5))
         ELSE
            CALL IONPL4 (1,2,4,5,ION,A,B,C,D,RMS)
            IF (RMS.LT.CUTOFF) THEN
               PLANOK=.TRUE.
               CALL GVSWIP (JR(3),JR(5))
               CALL GVSWAP (XYZJR(1,3),XYZJR(1,5))
               CALL GVSWAP (XYZJR(2,3),XYZJR(2,5))
               CALL GVSWAP (XYZJR(3,3),XYZJR(3,5))
            ELSE
               CALL IONPL4 (1,3,4,5,ION,A,B,C,D,RMS)
               IF (RMS.LT.CUTOFF) THEN
                  PLANOK=.TRUE.
                  CALL GVSWIP (JR(2),JR(5))
                  CALL GVSWAP (XYZJR(1,2),XYZJR(1,5))
                  CALL GVSWAP (XYZJR(2,2),XYZJR(2,5))
                  CALL GVSWAP (XYZJR(3,2),XYZJR(3,5))
               ELSE
                  CALL IONPL4 (2,3,4,5,ION,A,B,C,D,RMS)
                  IF (RMS.LT.CUTOFF) THEN
                     PLANOK=.TRUE.
                     CALL GVSWIP (JR(1),JR(5))
                     CALL GVSWAP (XYZJR(1,1),XYZJR(1,5))
                     CALL GVSWAP (XYZJR(2,1),XYZJR(2,5))
                     CALL GVSWAP (XYZJR(3,1),XYZJR(3,5))
                  END IF
               END IF
            END IF
         END IF
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION056 (ION,NUM,CUTOFF,PLANOK,A,B,C,D,RMS)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, KR(5), I1, I2, I3, I4, I5, I
      REAL          CUTOFF, RMS, A, B, C, D, XYZLOC(3,5)
      LOGICAL       PLANOK, USEDI(5)







      PLANOK=.FALSE.
      RMS=999.9
      I4=0
      I5=0
      I=0



      IF (NUM.NE.5) GOTO 998




      DO 50 I1=1,3
         DO 40 I2=I1+1,4
            DO 30 I3=I2+1,5



               CALL GVSBTF (USEDI,5)
               USEDI(I1)=.TRUE.
               USEDI(I2)=.TRUE.
               USEDI(I3)=.TRUE.
               DO 10 I=1,5
                  IF (.NOT.USEDI(I)) THEN
                     USEDI(I)=.TRUE.
                     I4=I
                     GOTO 11
                  END IF
 10            CONTINUE
 11            CONTINUE
               DO 20 I=1,5
                  IF (.NOT.USEDI(I)) THEN
                     USEDI(I)=.TRUE.
                     I5=I
                     GOTO 21
                  END IF
 20            CONTINUE
 21            CONTINUE



               CALL IONPL4 (I1,I2,I3,0,ION,A,B,C,D,RMS)
               IF (RMS.LT.CUTOFF) THEN



                  PLANOK=.TRUE.
                  KR(1)=JR(I1)
                  XYZLOC(1,1)=XYZJR(1,I1)
                  XYZLOC(2,1)=XYZJR(2,I1)
                  XYZLOC(3,1)=XYZJR(3,I1)
                  KR(2)=JR(I2)
                  XYZLOC(1,2)=XYZJR(1,I2)
                  XYZLOC(2,2)=XYZJR(2,I2)
                  XYZLOC(3,2)=XYZJR(3,I2)
                  KR(3)=JR(I3)
                  XYZLOC(1,3)=XYZJR(1,I3)
                  XYZLOC(2,3)=XYZJR(2,I3)
                  XYZLOC(3,3)=XYZJR(3,I3)
                  KR(4)=JR(I4)
                  XYZLOC(1,4)=XYZJR(1,I4)
                  XYZLOC(2,4)=XYZJR(2,I4)
                  XYZLOC(3,4)=XYZJR(3,I4)
                  KR(5)=JR(I5)
                  XYZLOC(1,5)=XYZJR(1,I5)
                  XYZLOC(2,5)=XYZJR(2,I5)
                  XYZLOC(3,5)=XYZJR(3,I5)
                  CALL GVSCPI (JR,KR,5)
                  CALL GVSCPR (XYZJR,XYZLOC,15)
                  GOTO 998
               END IF
 30         CONTINUE
 40      CONTINUE
 50   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION057 (ION,NUM,CUTOFF,PLANOK,A,B,C,D,RMS)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, KR(6), I1, I2, I3, I4, I5, I6, I
      REAL          CUTOFF, RMS, A, B, C, D, XYZLOC(3,6)
      LOGICAL       PLANOK, USEDI(6)







      PLANOK=.FALSE.
      RMS=999.9
      I5=0
      I6=0
      I=0



      IF (NUM.NE.6) GOTO 998




      DO 60 I1=1,3
         DO 50 I2=I1+1,4
            DO 40 I3=I2+1,5
               DO 30 I4=I3+1,6



                  CALL GVSBTF (USEDI,6)
                  USEDI(I1)=.TRUE.
                  USEDI(I2)=.TRUE.
                  USEDI(I3)=.TRUE.
                  USEDI(I4)=.TRUE.
                  DO 10 I=1,6
                     IF (.NOT.USEDI(I)) THEN
                        USEDI(I)=.TRUE.
                        I5=I
                        GOTO 11
                     END IF
 10               CONTINUE
 11               CONTINUE
                  DO 20 I=1,6
                     IF (.NOT.USEDI(I)) THEN
                        USEDI(I)=.TRUE.
                        I6=I
                        GOTO 21
                     END IF
 20               CONTINUE
 21               CONTINUE



                  CALL IONPL4 (I1,I2,I3,I4,ION,A,B,C,D,RMS)
                  IF (RMS.LT.CUTOFF) THEN



                     PLANOK=.TRUE.
                     KR(1)=JR(I1)
                     XYZLOC(1,1)=XYZJR(1,I1)
                     XYZLOC(2,1)=XYZJR(2,I1)
                     XYZLOC(3,1)=XYZJR(3,I1)
                     KR(2)=JR(I2)
                     XYZLOC(1,2)=XYZJR(1,I2)
                     XYZLOC(2,2)=XYZJR(2,I2)
                     XYZLOC(3,2)=XYZJR(3,I2)
                     KR(3)=JR(I3)
                     XYZLOC(1,3)=XYZJR(1,I3)
                     XYZLOC(2,3)=XYZJR(2,I3)
                     XYZLOC(3,3)=XYZJR(3,I3)
                     KR(4)=JR(I4)
                     XYZLOC(1,4)=XYZJR(1,I4)
                     XYZLOC(2,4)=XYZJR(2,I4)
                     XYZLOC(3,4)=XYZJR(3,I4)
                     KR(5)=JR(I5)
                     XYZLOC(1,5)=XYZJR(1,I5)
                     XYZLOC(2,5)=XYZJR(2,I5)
                     XYZLOC(3,5)=XYZJR(3,I5)
                     KR(6)=JR(I6)
                     XYZLOC(1,6)=XYZJR(1,I6)
                     XYZLOC(2,6)=XYZJR(2,I6)
                     XYZLOC(3,6)=XYZJR(3,I6)
                     CALL GVSCPI (JR,KR,6)
                     CALL GVSCPR (XYZJR,XYZLOC,18)
                     GOTO 998
                  END IF
 30            CONTINUE
 40         CONTINUE
 50      CONTINUE
 60   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION058 (ION,NUM,TIBANG)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NUM, KR(5), I1, I2, I3, I4, I5, I
      REAL          IONANG, ANG, TIBANG, XYZLOC(3,5)
      LOGICAL       USEDI(5)







      TIBANG=0.0
      I3=0
      I4=0
      I5=0



      IF (NUM.NE.5) GOTO 998




      DO 20 I1=1,4
         DO 10 I2=I1+1,5
            ANG=IONANG(I1,ION,I2)
            IF (ANG.GT.TIBANG) THEN
               TIBANG=ANG
               I4=I1
               I5=I2
            END IF
 10      CONTINUE
 20   CONTINUE



      CALL GVSBTF (USEDI,5)
      USEDI(I4)=.TRUE.
      USEDI(I5)=.TRUE.
      DO 30 I=1,5
         IF (.NOT.USEDI(I)) THEN
            USEDI(I)=.TRUE.
            I1=I
            GOTO 31
         END IF
 30   CONTINUE
 31   CONTINUE
      DO 40 I=1,5
         IF (.NOT.USEDI(I)) THEN
            USEDI(I)=.TRUE.
            I2=I
            GOTO 41
         END IF
 40   CONTINUE
 41   CONTINUE
      DO 50 I=1,5
         IF (.NOT.USEDI(I)) THEN
            USEDI(I)=.TRUE.
            I3=I
            GOTO 51
         END IF
 50   CONTINUE
 51   CONTINUE
      KR(1)=JR(I1)
      XYZLOC(1,1)=XYZJR(1,I1)
      XYZLOC(2,1)=XYZJR(2,I1)
      XYZLOC(3,1)=XYZJR(3,I1)
      KR(2)=JR(I2)
      XYZLOC(1,2)=XYZJR(1,I2)
      XYZLOC(2,2)=XYZJR(2,I2)
      XYZLOC(3,2)=XYZJR(3,I2)
      KR(3)=JR(I3)
      XYZLOC(1,3)=XYZJR(1,I3)
      XYZLOC(2,3)=XYZJR(2,I3)
      XYZLOC(3,3)=XYZJR(3,I3)
      KR(4)=JR(I4)
      XYZLOC(1,4)=XYZJR(1,I4)
      XYZLOC(2,4)=XYZJR(2,I4)
      XYZLOC(3,4)=XYZJR(3,I4)
      KR(5)=JR(I5)
      XYZLOC(1,5)=XYZJR(1,I5)
      XYZLOC(2,5)=XYZJR(2,I5)
      XYZLOC(3,5)=XYZJR(3,I5)
      CALL GVSCPI (JR,KR,5)
      CALL GVSCPR (XYZJR,XYZLOC,15)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION100 (ION,SPOS,WTOT,NFND)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, NFND, IERR, JAT, I
      REAL          WTOT
      LOGICAL       SPOS, WIFIRM







      SPOS=.FALSE.
      CALL WIFPUSHPPP (590,1)
      WTOT=WEIGHT(ION)
      NFND=1



      IF (.NOT.WIFIRM(ATIAA(ION))) GOTO 998



      CALL ENVTOT
      CALL SYMIPG (IERR,' ')
      CALL SYMNEA
      CALL FCONAT (ION,10.0)



      IF (NUMCONIAT.GE.1) THEN
         DO 10 I=1,NUMCONIAT
            JAT=CONIAT(I)
            IF (WIFIRM(ATIAA(JAT))) THEN
               IF (CONDSTAT(I).LT.0.25) THEN
                  WTOT=WTOT+WEIGHT(JAT)
                  NFND=NFND+1
               END IF
            END IF
 10      CONTINUE
      END IF
      SPOS=NFND.GE.2



  998 CONTINUE
      CALL WIFPOPPPP (590)


      RETURN
      END   
      SUBROUTINE ION101 (IUNIT,ION,PLOTIT,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'MAPINC.INC'
      INTEGER       IERR, IXM, IYM, IZM, ION, MAXDOT, IDOT, NWAT, ILOOP,
     +              IAT, IAA, ICOL, IUNIT
      REAL          DENMAX, XS, YS, ZS, XMAD, YMAD, ZMAD, LMIN, DIST
      LOGICAL       PLOTIT, ANYADD, NOWADD
      CHARACTER*4   CHAR4







      IERR=0
      ANYADD=.FALSE.
      RETURN
      IF (WIFPAR(427).EQ.0) GOTO 998



      ILOOP=0
 1    CONTINUE
      NOWADD=.FALSE.
      ILOOP=ILOOP+1
      IF (ILOOP.GE.3) THEN
         CALL GVSTT6 ('?M4303')
         GOTO 998
      END IF         



      DENMAX=-999.9
      MAXDOT=1
      IXM=0
      IYM=0
      IZM=0
      XMAD=0.0
      YMAD=0.0
      ZMAD=0.0
      NWAT=0
      CALL WIFPUSHPPP (6,1)
      CALL WIF083
      CALL WIFPOPPPP (6)



      DO 110 IDOT=1,WIFPAR(68)
         XS=XCOORD(ION)+2.0*XUACC(IDOT)
         YS=YCOORD(ION)+2.0*YUACC(IDOT)
         ZS=ZCOORD(ION)+2.0*ZUACC(IDOT)
         LMIN=999.9
         DO 100 IAA=1,NUMAAT
            IF (ATIAA(ION).EQ.IAA) GOTO 100



            DIST=SQRT((XS-SPHRAD(1,IAA))**2+
     +                (YS-SPHRAD(2,IAA))**2+
     +                (ZS-SPHRAD(3,IAA))**2)
            IF (DIST.GT.SPHRAD(4,IAA)+2.8) GOTO 100
            DO 90 IAT=PNTAAS(IAA),PNTAAE(IAA)
               DIST=SQRT((XS-XCOORD(IAT))**2+
     +                   (YS-YCOORD(IAT))**2+
     +                   (ZS-ZCOORD(IAT))**2)
               IF (DIST.LT.LMIN) LMIN=DIST
 90         CONTINUE
 100     CONTINUE



         IF (LMIN.GT.DENMAX) THEN
            DENMAX=LMIN
            XMAD=XS
            YMAD=YS
            ZMAD=ZS
         END IF



         IF (LMIN.GT.2.5) THEN
            NWAT=NWAT+1
            IF (PLOTIT.AND.USE300) THEN
               IF (LMIN.GT.10.0) THEN
                  ICOL=350
               ELSE
                  ICOL=NINT(60.0*(LMIN-1.5))
               END IF
               CALL GRTCRS (XS,YS,ZS,0.05,ICOL,IERR)
            END IF
         ELSE
            IF (PLOTIT.AND.USE300) THEN
                  ICOL=MAX(10,NINT(60.0*(LMIN-1.5)))
               CALL GRTCRS (XS,YS,ZS,0.05,ICOL,IERR)
            END IF            
         END IF
 110  CONTINUE



      IF (NWAT.GT.20) THEN
         CALL GVSTT6 ('?M4303')
         GOTO 998
      END IF



      IF (DENMAX.GT.2.5) THEN
         CALL KLONKSTART (IERR)
         IF (NUMAAT.GT.NUMAAF) THEN
            CALL WIFPUSHPPP (138,1)
            CALL KLONKUP
            CALL WIFPOPPPP (138)
         END IF
         CALL GVSFMT ('?FMT024')
         WRITE (CHAR4,FMT,ERR=999) MOD(NUMAAT+1,10000)
         CALL KLONKTOD ('ATOM  ',' O  ',' O  ',' ',
     +    ' HOH',CHANAM(NUMAAT),CHAR4,' ',XMAD,
     +    YMAD,ZMAD,1.0,12.0,' O',' HOH',NUMAAT+1,IERR)
         CALL KLONKDOWN
         CALL KLONKEND
         CALL MOL200
         USESOU(NUMSOU)=NUMSOU
         IF (WIFPAR(426).EQ.0) THEN
            CALL HBO010
            CALL HB2RED
         END IF
         IF (PLOTIT.AND.USE300) CALL GRTCRS(XMAD,YMAD,ZMAD,0.3,300,IERR)
         ANYADD=.TRUE.
         GOTO 1
      END IF
      GOTO 998



 999  CONTINUE
      CALL GVSEIW ('ION101')



  998 CONTINUE
      IF (ANYADD) THEN
         CALL GVSTT6 ('?M4308')
         IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4308')
      ELSE
         CALL GVSTT6 ('?M4309')
         IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,'?M4309')
      END IF


      RETURN
      END
      SUBROUTINE ION102A (IUNIT,ION,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       NUMTYP, IUNIT, ION, IERR, ITYPE, IMIN, ISELF, NFND
      REAL          VION(50), VSCO(50), SMIN, SELF, WTOT, ION_VALENCY
      LOGICAL       SPOS
      CHARACTER*2   CHAR2, CROW(50)







      CALL WIFPUSHPPP (590,1)
      CALL ION100 (ION,SPOS,WTOT,NFND)
      IF (WTOT.LT.0.8.OR.XBFACT(ION).GT.80.0) THEN
         CALL GVSTTR2 ('?M4302',WTOT,XBFACT(ION))
         IF (IUNIT.NE.6) CALL GVSTUR2 (IUNIT,'?M4302',WTOT,XBFACT(ION))
         IERR=1
         GOTO 998
      END IF 



      IERR=0
      IMIN=1
      ISELF=0
      CALL GVSSTX (CHAR2,IONTYP)
      CALL ION113 (CROW,NUMTYP)
      SMIN=999.9
      SELF=999.9



      CALL ENVTOT
      CALL SYMIPG (IERR,' ')
      CALL SYMNEA
      CALL FCONAT (ION,1.0)
      CALL FCONRED (ION,IONHGH)
      CALL FCONREC
      CALL ION105A (IUNIT)
      IF (NUMCONIAT.LE.3) GOTO 998



      DO 10 ITYPE=1,NUMTYP
         CALL GVSSTX (IONTYP,CROW(ITYPE))
         VION(ITYPE)=ION_VALENCY(ION)
         VSCO(ITYPE)=ABS(1.0-VION(ITYPE))
         IF (VSCO(ITYPE).LT.SMIN) THEN
            SMIN=VSCO(ITYPE)
            IMIN=ITYPE
         END IF
         IF (IONTYP.EQ.CHAR2) SELF=VSCO(ITYPE)
 10   CONTINUE
      DO 20 ITYPE=1,NUMTYP
         CALL GVSSTX (IONTYP,CROW(ITYPE))
         CALL GVSCTB (LINE,80)
         IF (IONTYP.EQ.CHAR2) THEN
            IF (ITYPE.EQ.IMIN) THEN
               CALL GVSFMT ('?ION521')
               WRITE (LINE,FMT,ERR=999) IONTYP,VION(ITYPE),VSCO(ITYPE)
            ELSE
               CALL GVSFMT ('?ION522')
               WRITE (LINE,FMT,ERR=999) IONTYP,VION(ITYPE),VSCO(ITYPE)
            END IF
         ELSE
            IF (ITYPE.EQ.IMIN) THEN
               IF (ABS(SELF-SMIN).GT.0.25.AND.SMIN.LT.0.25) THEN
                  CALL GVSFMT ('?ION523')
                  WRITE(LINE,FMT,ERR=999)IONTYP,VION(ITYPE),VSCO(ITYPE)
               ELSE
                  CALL GVSFMT ('?ION524')
                  WRITE(LINE,FMT,ERR=999)IONTYP,VION(ITYPE),VSCO(ITYPE)
               END IF
            ELSE
               CALL GVSFMT ('?ION525')
               WRITE (LINE,FMT,ERR=999) IONTYP,VION(ITYPE),VSCO(ITYPE)
            END IF
         END IF
         CALL ION107 (IUNIT,LINE)
 20   CONTINUE



      CALL GVSSTX (IONTYP,CHAR2)
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('ION102A')



  998 CONTINUE
      CALL WIFPOPPPP (590)


      RETURN
      END   
      SUBROUTINE ION102B (IUNIT,ION,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       NUMTYP, IUNIT, ION, IERR, ITYPE, IMIN, ISELF
      REAL          VION(50), SMIN, SELF, ION_VALENCY
      LOGICAL       ISHIT
      CHARACTER*2   CROW(50)







      CALL WIFPUSHPPP (590,1)
      IERR=0
      IMIN=1
      ISELF=0
      SMIN=999.9
      SELF=999.9
      ISHIT=.FALSE.
      CALL ION113 (CROW,NUMTYP)



      IF (NUMSYM.LE.1) THEN
         CALL ENVTOT
         CALL SYMIPG (IERR,' ')
         CALL SYMNEA
      END IF
      CALL FCONAT (ION,1.0)
      CALL FCONRED (ION,IONHGH)
      CALL FCONREC
      IF (NUMCONIAT.LT.5) GOTO 998



      DO 10 ITYPE=1,NUMTYP
         CALL GVSSTX (IONTYP,CROW(ITYPE))
         VION(ITYPE)=ION_VALENCY(ION)
         SMIN=MIN(SMIN,ABS(1.0-VION(ITYPE)))
 10   CONTINUE
      IF (SMIN.LT.0.25) THEN
         DO 20 ITYPE=1,NUMTYP
            CALL GVSCTB (LINE,80)
            WRITE (LINE,1000,ERR=999) CROW(ITYPE),VION(ITYPE)
            CALL ION105A (IUNIT)
            CALL ION107 (IUNIT,LINE)
 20      CONTINUE
      END IF
      GOTO 998



  999 CONTINUE
      CALL GVSEIW ('ION102B')



  998 CONTINUE
      CALL WIFPOPPPP (590)


 1000 FORMAT (A2,F6.2)

      RETURN
      END   
      SUBROUTINE ION102C (ION,SCODIF,SELF,BSTTYP,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       NUMTYP, ION, IERR, ITYPE, IMIN, NFND
      REAL          VION(50), VSCO(50), SMIN, SELF, WTOT, SCODIF, 
     +              ION_VALENCY
      LOGICAL       SPOS, CH2EQCH2
      CHARACTER*2   CHAR2, CROW(50), BSTTYP







      CALL WIFPUSHPPP (590,1)
      CALL ION100 (ION,SPOS,WTOT,NFND)
      IF (WTOT.LT.0.8.OR.XBFACT(ION).GT.80.0) THEN
         SCODIF=0.0
         IERR=1
         GOTO 998
      END IF 



      IERR=0
      IMIN=1
      CALL GVSSTX (CHAR2,IONTYP)
      CALL ION113 (CROW,NUMTYP)
      SMIN=999.9
      SELF=999.9
      SCODIF=0.0



      CALL ENVTOT
      CALL SYMIPG (IERR,' ')
      CALL SYMNEA
      IF (NUMCONIAT.LE.3) GOTO 998



      DO 10 ITYPE=1,NUMTYP




         CALL FCONAT (ION,1.0)
         CALL FCONRED (ION,IONHGH)
         CALL FCONREC



         CALL GVSSTX (IONTYP,CROW(ITYPE))
         VION(ITYPE)=ION_VALENCY(ION)



         IF (VION(ITYPE).LE.1.0) THEN
            VSCO(ITYPE)=ABS(1.0-VION(ITYPE))
         ELSE
            VSCO(ITYPE)=ABS(0.5*VION(ITYPE)-0.5)
         END IF
         IF (VSCO(ITYPE).LT.SMIN) THEN
            SMIN=VSCO(ITYPE)
            IMIN=ITYPE
            CALL GVSSTX (BSTTYP,CROW(ITYPE))
         END IF
         IF (CH2EQCH2(IONTYP,ONESAT(ION)(1:2))) THEN
            SELF=VSCO(ITYPE)
         ELSE
         END IF
 10   CONTINUE



      CALL GVSSTX (IONTYP,CHAR2)



      IF (SMIN.LT.SELF) SCODIF=SELF-SMIN



  998 CONTINUE
      CALL WIFPOPPPP (590)


      RETURN
      END   
      LOGICAL FUNCTION ION103(IUNIT,ION)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, I, JAT, IERR, IUNIT
      REAL          DIJ
      LOGICAL       ISMETAL, FIRST







      ION103=.FALSE.
      FIRST=.TRUE.
      CALL ENVTOT
      CALL SYMIPG (IERR,' ')
      CALL SYMNEA
      CALL FCONAT (ION,5.0)



      IF (NUMCONIAT.GE.1) THEN
         DO 10 I=1,NUMCONIAT
            JAT=CONIAT(I)
            IF (ISMETAL(JAT)) THEN
               DIJ=CONDSTAT(I)
               IF (DIJ.LT.5.0.AND.DIJ.GT.0.25) THEN
                  ION103=.TRUE.
                  CALL GRTLIN (XCOORD(ION),YCOORD(ION),ZCOORD(ION),
     +             XCOORD(JAT),YCOORD(JAT),ZCOORD(JAT),320,IERR)
                  IF (FIRST) THEN
                     FIRST=.FALSE.
                     CALL ION107 (IUNIT,'?ION535')
                  END IF
                  CALL DIF012S (6,ION,JAT,DIJ,CONSYMAT(I))
                  IF (IUNIT.NE.6) CALL DIF012S (IUNIT,ION,JAT,DIJ,
     +             CONSYMAT(I))
               END IF
            END IF
 10      CONTINUE
      END IF





      RETURN
      END   
      SUBROUTINE ION104 (IUNIT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'PDBINC.INC'
      INTEGER       IAT, ISOUP, ISYM, SYMNEG, JAT, JSYM, IAA, IUNIT
      REAL          TMP(3), ANYDST, OWNDST
      LOGICAL       WIFIRM







      IF (.NOT.SYMHAS) THEN
         CALL GVSTTE ('IONESYM')
         GOTO 998
      END IF



      CALL WIF225B



      CALL ENVNOWAT
      CALL WIFPUSHPPP (590,1)



      DO 100 ISOUP=1,NUMSOU
         IF (.NOT.WIFIRM(SOUADM(1,ISOUP))) GOTO 100



         DO 90 IAT=PNTAAS(SOUADM(1,ISOUP)),PNTAAE(SOUADM(2,ISOUP))
            IAA=ATIAA(IAT)
            CALL SC9011 (IAT,OWNDST,ANYDST,JAT,JSYM)



            IF (JSYM.GT.1.AND.OWNDST.GT.ANYDST+1.0) THEN
               ISYM=SYMNEG(JSYM)
               TMP(1)=XCOORD(IAT)
               TMP(2)=YCOORD(IAT)
               TMP(3)=ZCOORD(IAT)
               CALL GVSMPV (TMP,SYMMAT(1,1,ISYM),SYMVEC(1,ISYM))



               CALL GVSWAP (XCOORD(IAT),TMP(1))
               CALL GVSWAP (YCOORD(IAT),TMP(2))
               CALL GVSWAP (ZCOORD(IAT),TMP(3))



               CALL DIF015 (6,'?M4911',IAT)
               IF (IUNIT.NE.6) CALL DIF015 (IUNIT,'?M4911',IAT)
            END IF
 90      CONTINUE
 100  CONTINUE
      CALL WIFPOPPPP (590)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ION105 (IUNIT,TEXT,D1,D2,D3,D4,D5,D6,D7)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IUNIT
      REAL          D1, D2, D3, D4, D5, D6, D7
      LOGICAL       GVFIBN
      CHARACTER*(*) TEXT







      IF (.NOT.GVFIBN(NUMCONIAT,1,7)) THEN
         GOTO 998
      END IF



      CALL GVSTT6 (TEXT)
      IF (IUNIT.NE.6) CALL GVSTTU (IUNIT,TEXT)
      IF (DATOPE) CALL GVSTTU (DATLOG,TEXT)



      CALL DIF013 (6,JR(1),D1)
      IF (NUMCONIAT.GE.2) CALL DIF013 (6,JR(2),D2)
      IF (NUMCONIAT.GE.3) CALL DIF013 (6,JR(3),D3)
      IF (NUMCONIAT.GE.4) CALL DIF013 (6,JR(4),D4)
      IF (NUMCONIAT.GE.5) CALL DIF013 (6,JR(5),D5)
      IF (NUMCONIAT.GE.6) CALL DIF013 (6,JR(6),D6)
      IF (NUMCONIAT.GE.7) CALL DIF013 (6,JR(7),D7)



      IF (IUNIT.NE.6) CALL DIF013 (IUNIT,JR(1),D1)
      IF (IUNIT.NE.6.AND.NUMCONIAT.GE.2) CALL DIF013 (IUNIT,JR(2),D2)
      IF (IUNIT.NE.6.AND.NUMCONIAT.GE.3) CALL DIF013 (IUNIT,JR(3),D3)
      IF (IUNIT.NE.6.AND.NUMCONIAT.GE.4) CALL DIF013 (IUNIT,JR(4),D4)
      IF (IUNIT.NE.6.AND.NUMCONIAT.GE.5) CALL DIF013 (IUNIT,JR(5),D5)
      IF (IUNIT.NE.6.AND.NUMCONIAT.GE.6) CALL DIF013 (IUNIT,JR(6),D6)
      IF (IUNIT.NE.6.AND.NUMCONIAT.GE.7) CALL DIF013 (IUNIT,JR(7),D7)



      IF (DATOPE) CALL DIF013 (DATLOG,JR(1),D1)
      IF (DATOPE.AND.NUMCONIAT.GE.2) CALL DIF013 (DATLOG,JR(2),D2)
      IF (DATOPE.AND.NUMCONIAT.GE.3) CALL DIF013 (DATLOG,JR(3),D3)
      IF (DATOPE.AND.NUMCONIAT.GE.4) CALL DIF013 (DATLOG,JR(4),D4)
      IF (DATOPE.AND.NUMCONIAT.GE.5) CALL DIF013 (DATLOG,JR(5),D5)
      IF (DATOPE.AND.NUMCONIAT.GE.6) CALL DIF013 (DATLOG,JR(6),D6)
      IF (DATOPE.AND.NUMCONIAT.GE.7) CALL DIF013 (DATLOG,JR(7),D7)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION105A (IUNIT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'DATBAS.INC'
      INTEGER       IUNIT, IAT







      IF (NUMCONIAT.LE.0) GOTO 998



      DO 10 IAT=1,NUMCONIAT
         CALL DIF013E (IUNIT,CONIAT(IAT),CONDSTAT(IAT),CONSYMAT(IAT))
         IF (DATOPE) CALL DIF013E (DATLOG,CONIAT(IAT),CONDSTAT(IAT),
     +    CONSYMAT(IAT))
 10   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION107 (IUNIT,TEXT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INTEGER       IUNIT
      CHARACTER*(*) TEXT







      IF (IUNIT.NE.0) CALL GVSTTU (IUNIT,TEXT)
      IF (IUNIT.NE.6) CALL GVSTT6 (TEXT)
      IF (DATOPE) CALL GVSTTU (DATLOG,TEXT)





      RETURN
      END   
      SUBROUTINE ION109 (ION)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'HISTOG.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, ION







      CALL GVST6C ('Ligand packing class ',PACTYP,.TRUE.)



      IF (PACTYP.EQ.'4r') THEN
         CALL ION_4R (ION,IERR)
         IF (IERR.NE.0) GOTO 998
      END IF



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION_4R (ION,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, IWH, ION
      REAL          MAT(3,3), VEC(3), RMSE1, EMAX1, RMSE2, EMAX2, 
     +              XYZJSP(3,5)
      LOGICAL       CH4EQCH4, CH5EQCH5







      IF (IONTYP.NE.'CU') THEN
         IERR=1
         GOTO 998
      END IF



      IERR=0
      XYZJSP(1,1)=1.5767231
      XYZJSP(2,1)=-1.13749373
      XYZJSP(3,1)=1.16797316
      XYZJSP(1,2)=5.1125278
      XYZJSP(2,2)=-0.572694182
      XYZJSP(3,2)=2.41777563
      XYZJSP(1,3)=1.8182259
      XYZJSP(2,3)=0.741223156
      XYZJSP(3,3)=3.75465131
      XYZJSP(1,4)=2.1976967
      XYZJSP(2,4)=-3.02630353
      XYZJSP(3,4)=3.87362432
      XYZJSP(1,5)=3.9038277
      XYZJSP(2,5)=-0.671732903
      XYZJSP(3,5)=2.65697527



      DO 10 IWH=1,4
         IF (CH5EQCH5(ONESAT(JR(IWH)),' SD  ')) THEN
            IF (IWH.NE.1) THEN
               CALL GVSWIP (JR(1),JR(IWH))
               CALL GVSWAP (XYZJR(1,JR(1)),XYZJR(1,JR(IWH)))
               CALL GVSWAP (XYZJR(2,JR(1)),XYZJR(2,JR(IWH)))
               CALL GVSWAP (XYZJR(3,JR(1)),XYZJR(3,JR(IWH)))
            END IF
            GOTO 11
         END IF
 10   CONTINUE
      GOTO 998
 11   CONTINUE



      DO 20 IWH=2,4
         IF (CH5EQCH5(ONESAT(JR(IWH)),' SG  ')) THEN
            IF (IWH.NE.2) THEN
               CALL GVSWIP (JR(2),JR(IWH))
               CALL GVSWAP (XYZJR(1,JR(2)),XYZJR(1,JR(IWH)))
               CALL GVSWAP (XYZJR(2,JR(2)),XYZJR(2,JR(IWH)))
               CALL GVSWAP (XYZJR(3,JR(2)),XYZJR(3,JR(IWH)))
            END IF
            GOTO 21
         END IF
 20   CONTINUE
      GOTO 998
 21   CONTINUE



      IF (CH5EQCH5(ONESAT(JR(3)),' ND1 ').OR.
     +    CH5EQCH5(ONESAT(JR(3)),' NE2 ')) THEN
         IF (CH4EQCH4(ONESA3(ATIAA(JR(3))),' HIS')) THEN
            IF (CH5EQCH5(ONESAT(JR(4)),' ND1 ').OR.
     +          CH5EQCH5(ONESAT(JR(4)),' NE2 ')) THEN
               IF (CH4EQCH4(ONESA3(ATIAA(JR(4))),' HIS')) THEN
                  IF (JRPNTS.LT.250) THEN
                     JRPNTS=JRPNTS+1
                     DO 30 IWH=1,4
                        XYZJRS(1,IWH,JRPNTS)=XYZJR(1,IWH)
                        XYZJRS(2,IWH,JRPNTS)=XYZJR(2,IWH)
                        XYZJRS(3,IWH,JRPNTS)=XYZJR(3,IWH)
 30                  CONTINUE
                     XYZJRS(1,5,JRPNTS)=XCOORD(ION)
                     XYZJRS(2,5,JRPNTS)=YCOORD(ION)
                     XYZJRS(3,5,JRPNTS)=ZCOORD(ION)
                     GOTO 31
                  END IF
               END IF
            END IF
         END IF
      END IF
      GOTO 998
 31   CONTINUE
      CALL GVSSNP (5,XYZJSP(1,1),XYZJRS(1,1,JRPNTS),MAT,VEC,
     + RMSE1,EMAX1)
      CALL GVSWAP (XYZJRS(1,3,JRPNTS),XYZJRS(1,4,JRPNTS))
      CALL GVSWAP (XYZJRS(2,3,JRPNTS),XYZJRS(2,4,JRPNTS))
      CALL GVSWAP (XYZJRS(3,3,JRPNTS),XYZJRS(3,4,JRPNTS))
      CALL GVSSNP (5,XYZJSP(1,1),XYZJRS(1,1,JRPNTS),MAT,VEC,
     + RMSE2,EMAX2)
      IF (RMSE1.LT.RMSE2) THEN
         CALL GVSWAP (XYZJRS(1,3,JRPNTS),XYZJRS(1,4,JRPNTS))
         CALL GVSWAP (XYZJRS(2,3,JRPNTS),XYZJRS(2,4,JRPNTS))
         CALL GVSWAP (XYZJRS(3,3,JRPNTS),XYZJRS(3,4,JRPNTS))
         CALL GVSSNP (5,XYZJSP(1,1),XYZJRS(1,1,JRPNTS),MAT,VEC,
     +    RMSE1,EMAX1)
      END IF
      DO 40 IWH=1,5
         CALL GRTCRS (XYZJRS(1,IWH,JRPNTS),XYZJRS(2,IWH,JRPNTS),
     +    XYZJRS(3,IWH,JRPNTS),0.2,40*IWH,IERR)
 40   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION_GR

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'IRIGRA.INC'
      INCLUDE       'HISTOG.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IERR, IWH, JWH, IC, IO, IN
      LOGICAL       GRAPON







      IF (.NOT.GRAPON()) GOTO 998
      IF (JRPNTS.LE.2) GOTO 998



      CALL GRAMOL (' ')



      CALL GHS011
      DO 5 IWH=1,5
         CALL GRTVIN
         DO 4 IN=1,JRPNTS
            CALL GHS012 (IN,XYZJRS(1,IWH,IN),XYZJRS(2,IWH,IN),
     +       XYZJRS(3,IWH,IN))
 4       CONTINUE
         CALL GHS014 (1,JRPNTS,IERR)
         CALL GHS015
         CALL GHS016
         CALL GRADOT (' ')
 5    CONTINUE
      CALL GVSCLF (ELLUNT)
      ELLUNT=0



      DO 30 IN=2,JRPNTS
         DO 20 IO=1,5
            DO 10 IC=1,3
               XYZJRS(IC,IO,1)=XYZJRS(IC,IO,1)+XYZJRS(IC,IO,IN)
 10         CONTINUE
 20      CONTINUE
 30   CONTINUE
      DO 50 IO=1,5
         DO 40 IC=1,3
            XYZJRS(IC,IO,1)=XYZJRS(IC,IO,1)/FLOAT(JRPNTS)
 40      CONTINUE
 50   CONTINUE



      CALL GRTVIN
      DO 60 IWH=1,5
         CALL GRTCRS (XYZJRS(1,IWH,1),XYZJRS(2,IWH,1),XYZJRS(3,IWH,1),
     +    0.2,40*IWH,IERR)
 60   CONTINUE
      CALL GRAMOL (' ')
      ACONVC(1)=XYZJRS(1,5,1)
      ACONVC(2)=XYZJRS(2,5,1)
      ACONVC(3)=XYZJRS(3,5,1)
      CALL GRTCEN (IERR)



      CALL GRTVIN
      DO 80 IWH=1,4
         DO 70 JWH=IWH+1,5
            CALL GRTLIN (XYZJRS(1,IWH,1),XYZJRS(2,IWH,1),
     +       XYZJRS(3,IWH,1),XYZJRS(1,JWH,1),XYZJRS(2,JWH,1),
     +       XYZJRS(3,JWH,1),330,IERR)
 70      CONTINUE
 80   CONTINUE
      CALL GRAMOL (' ')



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION113 (CROW,NUMTYP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       NUMNOW, NUMTYP
      PARAMETER     (NUMNOW=11)
      CHARACTER*2   CROW(NUMNOW)







      CROW(1)='NA'
      CROW(2)='MG'
      CROW(3)=' K'
      CROW(4)='CA'
      CROW(5)='ZN'
      CROW(6)='LI'
      CROW(7)='MN'
      CROW(8)='CD'
      CROW(9)='N4'
      CROW(10)='CU'
      CROW(11)='SM'
      IF (WIFPAR(482).LE.0) THEN
         NUMTYP=NUMNOW
      ELSE
         NUMTYP=WIFPAR(482)
      END IF
      WIFPAR(480)=NUMNOW





      RETURN
      END
      SUBROUTINE ION114 (THSION,FOUND)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IAA, IAT
      CHARACTER*2   THSION
      LOGICAL       FOUND, WIFIRM, CH4EQCH4







      FOUND=.FALSE.



      IF (NUMAAT.LE.NUMAAF) GOTO 998



      DO 10 IAA=NUMAAF+1,NUMAAT
         IF (WIFIRM(IAA)) THEN
            IAT=PNTAAS(IAA)
            IF (ONESAT(IAT)(1:2).EQ.THSION) THEN
               FOUND=.TRUE.
               GOTO 998
            END IF
            IF (THSION.EQ.'N4') THEN
               IF (CH4EQCH4(ONESA3(IAA),' NH4')) THEN
                  FOUND=.TRUE.
                  GOTO 998
               END IF
            END IF
         END IF
 10   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION115 (THSION,FOUND)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       CARD, GVFPOS, IPOS
      CHARACTER*2   THSION
      LOGICAL       FOUND
















      FOUND=.FALSE.



      IF (NR280.LE.0) GOTO 998



      DO 100 CARD=1,NR280
         CALL GVSCTB (LINE,80)
         CALL GVSSTX (LINE,CRYSTL(CARD)(11:80))
         IF (THSION.EQ.'NA') THEN
            IF (GVFPOS(LINE,'K/NA PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-NACL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-NACL-').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NACL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NACL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NACL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NACL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA CL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NA CL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA CL,').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,',NA CL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACL;').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAH2PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAH2/K2HPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/KPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA FORMATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-FORMATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES_NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES-NA').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'HEPES NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES  NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES-NA+').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES-NAOH').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-HEPES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA HEPES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAHEPES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA+ ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACACODYLATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NASCN ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NASCN ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NASCN,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NASCN,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAOH ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NAOH ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAOH,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NAOH,').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' NAF ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NAF ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAF,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NAF,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAI ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NAI ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAI,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NAI,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NABR ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NABR ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' NABR,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',NABR,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NANO3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-CACODYL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA CACODYL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACH2COOH').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA CACODYRATE').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'M NAF ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'/NAOH ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'/NAOH,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-NAOH,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-NAOH ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAK TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAK-TARTRATE').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NAKTARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K-TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K-TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA/K-').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2HPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAKPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K PHOS').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NAC2H3O2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAAC ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K TARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CH3COONA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MES-NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-FORMIATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2SO4').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA AZIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAN3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MNAN3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2SO3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-TRICINE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAN(3)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAOAC').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'SODIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA3 CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA3CITRATE').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA-MES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA MES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAFORMATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NAOH)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-PYRUVATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA3VO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA(OAC)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA(CH3COO)').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'K NA PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA3PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'GLY-NAOH').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAHCO3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA- CHOLATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAH(2)PO(4)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K/NA TARTR.').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA.CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA CITR ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA CHLOR').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA MOPS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/CACODYL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' SODIUN ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' SODIU ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' SODUIM ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' SODUM ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' SODIM ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ACETATE_NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA(AC)').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA CADODAL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NATRIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'TRI-NA CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MOPSO-NA+').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NASEO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2MOO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NACACOD').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAHNO3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA3.CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-K PHOS').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'HEPES/NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K-PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA FORM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-AZIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA MALON').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA THYOCYA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2(SO4)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACOOH').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA ACETETE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA( CACODYLATE)').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA2MO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA DIHYDRO').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CITRATE_NA3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA BROMIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-CACODIL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA(CH3)2ASO').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CITRATE-NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA- ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAH2P04/').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' NA F;').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2WO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-CCODYLATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAPHOSPHATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA,CL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA)3-CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K - PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAEDTA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA MALEATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAKTART,').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' NA-AC,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2NO3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, K TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CITRATE-NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA3-CIT,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA AC,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2VO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-K TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-SCN').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-EDTA').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA, K-CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'C2H3NAO2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, POTASSIUM PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES - NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-ACETET').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA/H MES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA_POTASSIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K3PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'M NA3-CIT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA K TART').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA MONOBASIC PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K/NA L-TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'M MES NA ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA.ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES - NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2S2O4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA IODIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA PHOSPHATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, MG SALT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'TRICINE-NA').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA/MES/ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2 TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES.NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-K-PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, KPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAPHOSPH').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA MALATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-K-TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K/NA TARTRARE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'M MES_NA').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'MOPS-NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA_PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA_H2_PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA)3 CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA3)AU(S2O3)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2S203').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAKPHOSPHATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACH3CO2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(K+/NA+) PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-CITRAT').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA-SALT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NACN').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA ACATATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA SPERMINE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, HEPES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA,K)PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA CACOLDYL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA(FORM)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2HPO').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA/K)PO4').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA2 ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2B4O7').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NASO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, K, TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACHOCH3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'BICINE-NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ACETATE NA,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2KPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA SALT,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA OR K ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'TRIS_NA CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NAH2/K2H)PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA- PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, 1,8-DIAMINOOCTANE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NATARTRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAASO2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAK PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'T-NA CITRAT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAKHPO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'%NAN3').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA/ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA_CL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-MALONIC').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAH2 PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAK PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K.PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K/NA TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K,PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA DITHIONITE').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA2HPO').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA TARTARATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA_NITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'TRI-NA CITR').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAH2PO3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACITR.').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, K PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA CAODYLATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAAZIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HAC/NAAC').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA-CHOLATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAHCOO').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CACODYLATE-NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAAZID ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAAZID,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'TRIS-NA CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA4P2O7').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NACITRAT,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-BENZOATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K2PO4').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'NA CACODALYTE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA.K TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, K-TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA-L-LACTATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA/K2 PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA, K PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA2S2O3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA ETHYL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'WO4NA2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HAC-NAAC').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
         ELSE IF (THSION.EQ.'MG') THEN
 20         CONTINUE
            IPOS=0
            IF (GVFPOS(LINE,'MG/').NE.0) IPOS=GVFPOS(LINE,'MG/')
            IF (GVFPOS(LINE,'/MG').NE.0) IPOS=GVFPOS(LINE,'/MG')
            IF (GVFPOS(LINE,'MGS/').NE.0) IPOS=GVFPOS(LINE,'MGS/')
            IF (GVFPOS(LINE,'MG /').NE.0) IPOS=GVFPOS(LINE,'MG /')
            IF (GVFPOS(LINE,'0MG ').NE.0) IPOS=GVFPOS(LINE,'0MG ')
            IF (GVFPOS(LINE,'1MG ').NE.0) IPOS=GVFPOS(LINE,'1MG ')
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'2MG ').NE.0) IPOS=GVFPOS(LINE,'2MG ')
            IF (GVFPOS(LINE,'3MG ').NE.0) IPOS=GVFPOS(LINE,'3MG ')
            IF (GVFPOS(LINE,'4MG ').NE.0) IPOS=GVFPOS(LINE,'4MG ')
            IF (GVFPOS(LINE,'5MG ').NE.0) IPOS=GVFPOS(LINE,'5MG ')
            IF (GVFPOS(LINE,'6MG ').NE.0) IPOS=GVFPOS(LINE,'6MG ')
            IF (GVFPOS(LINE,'7MG ').NE.0) IPOS=GVFPOS(LINE,'7MG ')
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'8MG ').NE.0) IPOS=GVFPOS(LINE,'8MG ')
            IF (GVFPOS(LINE,'9MG ').NE.0) IPOS=GVFPOS(LINE,'9MG ')
            IF (GVFPOS(LINE,'0MG/').NE.0) IPOS=GVFPOS(LINE,'0MG/')
            IF (GVFPOS(LINE,'1MG/').NE.0) IPOS=GVFPOS(LINE,'1MG/')
            IF (GVFPOS(LINE,'2MG/').NE.0) IPOS=GVFPOS(LINE,'2MG/')
            IF (GVFPOS(LINE,'3MG/').NE.0) IPOS=GVFPOS(LINE,'3MG/')
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'4MG/').NE.0) IPOS=GVFPOS(LINE,'4MG/')
            IF (GVFPOS(LINE,'5MG/').NE.0) IPOS=GVFPOS(LINE,'5MG/')
            IF (GVFPOS(LINE,'6MG/').NE.0) IPOS=GVFPOS(LINE,'6MG/')
            IF (GVFPOS(LINE,'7MG/').NE.0) IPOS=GVFPOS(LINE,'7MG/')
            IF (GVFPOS(LINE,'8MG/').NE.0) IPOS=GVFPOS(LINE,'8MG/')
            IF (GVFPOS(LINE,'9MG/').NE.0) IPOS=GVFPOS(LINE,'9MG/')
            IF (IPOS.NE.0) THEN
               CALL GVSCTB (LINE(IPOS:IPOS+2),3)
               GOTO 20
            END IF
            IF (GVFPOS(LINE,'MAGNESIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MG ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-MG ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-MG,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MG(').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MGCL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MGSO4').NE.0) FOUND=.TRUE.
         ELSE IF (THSION.EQ.' K'.OR.THSION.EQ.'K ') THEN
            IF (GVFPOS(LINE,'K/NA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,', K ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K THIOCYANATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KTHIOCYANATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K ACETATE').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K-ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K-THIOCYANATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTASSIUM').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K-ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K CITRATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K-THIOCYANATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTASSIUM').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'POTASSIM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTASSSIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTTASIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTTASSIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTASIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTASIUN').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'POTASIU ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'POTASSIM CHLO').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-KOH').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'/KOH').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K/').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KF ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'M KI ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K2SO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KAC ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KBR ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K AC, ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K(+)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA/K ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA+/K+').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA K ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K-CACO ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'K-PO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'KPO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KNO3 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K2NO3 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'KSCN').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'K3CIRT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K3CITR').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K3 CITR').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAK PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAKPHOS').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' NA-K PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA,K-PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA,K,PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA,K.PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA-K-PHOS').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,':K-PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K-GLUTAMATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K-PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KPHOSPH').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K FORM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KFORMAT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'-K TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KTARTRA').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' TARTRATE_K').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KACETAT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KNA TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K-NA TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K,NA-TART').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K,NA TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA-K TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA-,K-TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA-K-TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NAKTART').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' NAK TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' NA,K TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'KCL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K2PTCL4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K-HEPES').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'K+HEPES').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES/K+').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'HEPES/K ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'KH2PO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K2HPO4 ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'K2HPO4,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K2H PO4,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA(K)H2PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K,NAH2PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NAH2/K2H)PO4').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'K(2)HPO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K(2)HPO(4)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'KH2PO4,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'KH(2)PO(4)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K2H PO4').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K2PO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K2PO4,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K3PO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K2HPO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K2HPO4,').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'(K+NA+) PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K2 H PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NA,K PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K NA PHOS').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'NAK-PHOS').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'KAU(CN)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA,K)PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K-NA-TART').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(NA/K)PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'(K+/NA+) PHOS').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' K2PT(CN)4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KH2PO3 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' KCN ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'K2(SO4)').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'K2_H_PO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K2CO3,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' K2CO3 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CYANIDE').NE.0) FOUND=.TRUE.
         ELSE IF (THSION.EQ.'CA') THEN
            IF (GVFPOS(LINE,' CACL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',CACL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CACL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',CACL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MCACL2 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'/CACL2 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CALCL2 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CACL2 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',CACL2 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CACL2,').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,',CACL2,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CL2CA ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',CL2CA ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CL2CA,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',CL2CA,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CALCUIM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CACIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CALUCIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CALCIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CALSIUM').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'CAACETA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA-ACETA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA_ACETA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CA ACETA').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'M CA(').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CA(AC)2 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CA(AC)2,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA(OAC)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA-CHLOR').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA CHLOR').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'CA CLORI').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA, CHLOR').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CAAC2,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CAAC2 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CAAC ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CASO4 ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CAOAC ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CAOAC2 ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,' CA2+,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CA2+ ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA(CH3COO)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA(ACE)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA(ACO)2,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA CL2,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CA(CF3COO)2').NE.0) FOUND=.TRUE.
         ELSE IF (THSION.EQ.'ZN') THEN
            IF (GVFPOS(LINE,'ZNCL2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZNCL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZNSO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZNAC').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN(ACO)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN(ACETATE)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' ZN+2 ').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'ZN ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN-ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN+2.').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN(II)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' ZINC').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' ZINK').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN(OAC)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN(OAC) ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN (AC)2').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'ZN(CH2H3O2)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'BABIM-ZN+2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZNOAC2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZNOAC ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' ZN2+').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN CHLOR').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN(AC)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'M ZN ACET').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'ZN(ACETATE)').NE.0) FOUND=.TRUE.
         ELSE IF (THSION.EQ.'LI') THEN
            IF (GVFPOS(LINE,' LI ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LICL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LITHIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LISIUM').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LI2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LI3').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LI(').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LISO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LICITRAT').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LISUL').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' LINO3').NE.0) FOUND=.TRUE.
         ELSE IF (THSION.EQ.'MN') THEN
            IF (GVFPOS(LINE,'MNCL2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MNSO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MN-AMP').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MN ACETATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MN ION').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MN2+ ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MN CHLORIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MNCL,').NE.0) FOUND=.TRUE.
            IF (FOUND) GOTO 998
            IF (GVFPOS(LINE,'MNCL(2)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MN(CH3COO)2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MNCL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MN2 ION').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'MN(2+)').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,',MNCL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MANGANESE ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MANGANES ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' MANGANE ').NE.0) FOUND=.TRUE.
         ELSE IF (THSION.EQ.'MN') THEN
            IF (GVFPOS(LINE,'CDCL2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CDSO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CD++ ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CD++,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CDCL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CD SULFATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CD2+,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CDCL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CD CHLORIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CADMIUM').NE.0) FOUND=.TRUE.
         END IF
         IF (FOUND) GOTO 998
 100  CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION120 (ION,CHGSUM)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'CHARGE.INC'
      INTEGER       ION, IAA, JAA, KAA, KAT, JAT
      REAL          CHGSUM, WIFDST, DIJ, CHGAT, ELMCHG
      LOGICAL       WIF040, WIFIRW







      CHGSUM=ELMCHG(ION)
      IAA=ATIAA(ION)
      CALL SHOIAA (IAA)
      DO 20 KAA=1,NUMAAT
         IF (RESTYP(KAA).LE.0) GOTO 20
         DO 10 KAT=PNTAAS(KAA),PNTAAE(KAA)
            ATTVAL(KAT)=CHGGRT(PINIAA(KAT),1,RESTYP(KAA))
 10      CONTINUE
 20   CONTINUE


















      DO 100 JAA=1,NUMAAT
         IF (WIFIRW(JAA)) GOTO 100
         IF (JAA.EQ.IAA) GOTO 100
         IF (RESTYP(JAA).LE.0) GOTO 100
         IF (.NOT.WIF040(IAA,JAA,6.0)) GOTO 100
         DO 90 JAT=PNTAAS(JAA),PNTAAE(JAA)
            DIJ=WIFDST(ION,JAT)
            CHGAT=CHGGRT(PINIAA(JAT),1,RESTYP(JAA))
            IF (DIJ.LE.3.0) THEN
               CHGSUM=CHGSUM+CHGAT
               CALL DIF015B (6,JAT,' + charge ',CHGAT)
            ELSE IF (DIJ.LE.6.0) THEN
               CHGSUM=CHGSUM+(6.0-DIJ)*CHGAT
               CALL DIF015B (6,JAT,' + F(charge) ',CHGAT)
            END IF
 90      CONTINUE
 100  CONTINUE





      RETURN
      END
      LOGICAL FUNCTION HASION()

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       NUMTYP, ISOUP, IAA, IAT, ION
      LOGICAL       WIFIRM, CH4EQCH4, WM, DOION
      CHARACTER*2   CROW(50)







      HASION=.FALSE.
      CALL ION113 (CROW,NUMTYP)
      IF (NUMSOU.LE.0) GOTO 998



      DO 100 ISOUP=1,NUMSOU
         IF (SOUADM(4,ISOUP).NE.1) GOTO 100
         IAA=SOUADM(1,ISOUP)
         IAT=PNTAAS(IAA)
         WM=WIFIRM(IAA)



         IF (.NOT.WIFIRM(IAA)) GOTO 100



         CALL ION115 (ONESAT(IAT)(1:2),DOION)
         IF (DOION) THEN
            HASION=.TRUE.
            GOTO 998
         END IF



         DO 90 ION=1,NUMTYP
            IF (ONESAT(IAT)(1:2).EQ.CROW(ION)) THEN
               HASION=.TRUE.
               GOTO 998
            ELSE IF (ONESAT(IAT).EQ.' N'.AND.
     +          CH4EQCH4(ONESA3(IAA),'NH4 ')) THEN
               HASION=.TRUE.
               GOTO 998
            END IF
 90      CONTINUE
 100  CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION200

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INTEGER       IUNIT, IERR, GVFPOS, ICNT, IFND
      LOGICAL       GRTFILE, FOUND, INTERRUPTED







      ICNT=0
      IFND=0
      IUNIT=0



      IF (.NOT.GRTFILE(IUNIT,'REM280')) GOTO 999



 10   CONTINUE
         CALL GETLINE (IUNIT,BIGLIN,IERR)
         IF (IERR.EQ.1) GOTO 999
         IF (IERR.EQ.2) GOTO 998
         IF (INTERRUPTED()) GOTO 999
         ICNT=ICNT+1
         IF (MOD(ICNT,10000).EQ.0) PRINT*,'Done',ICNT,
     +    '  from 350000  Found:',IFND
         IF (GVFPOS(BIGLIN(24:132),'CD').NE.0) THEN
            CALL GVSSTX (LINE,BIGLIN(25:105))
            FOUND=.FALSE.
            IF (GVFPOS(LINE,'CDS0').NE.0) GOTO 10

            IF (GVFPOS(LINE,'CDCL2').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CDSO4').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CD++ ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CD++,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CDCL,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CD SULFATE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CD2+,').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,' CDCL ').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CD CHLORIDE').NE.0) FOUND=.TRUE.
            IF (GVFPOS(LINE,'CADMIUM').NE.0) FOUND=.TRUE.
            IF (FOUND) THEN
               IFND=IFND+1
               GOTO 10
            END IF
            CALL GVSTT6 (BIGLIN)
         END IF
      GOTO 10



      IF (GVFPOS(BIGLIN(24:132),'K').NE.0.OR.
     +    GVFPOS(BIGLIN(24:132),'OTAS').NE.0) THEN
         CALL GVSSTX (LINE,BIGLIN(25:105))
         FOUND=.FALSE.
         IF (GVFPOS(LINE,'BUTANAMI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MALONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'FINAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NANO').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DNA').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NAEROBIC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ANAEROBIC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SUCCINATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ADDITIONALLY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TERMINAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'GLCNAC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAD+').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NAD,').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ZNAC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NADP+').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NADP,').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NADPH').NE.0) GOTO 10
         IF (GVFPOS(LINE,'VANADATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NATIV').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MALONA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAPI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ANAPOE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ETHENONADP').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NADH,').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBONA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAMES').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAG').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PROPONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RNA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PHOSPHONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NATURE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'THIOCYANATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NABICINE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBA-NAD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KINASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KYNURENINASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAPP').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CINNAMI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PROPIONAT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ACONA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TENA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PROPAN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CNNAS').NE.0) GOTO 10
         IF (GVFPOS(LINE,'GONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'REASONABLE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ADDITIONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAD;').NE.0) GOTO 10
         IF (GVFPOS(LINE,'GELDANAMY').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NADH ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SULFONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DROGENASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CINNAMIC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MCDONALD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'GALNAC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PENAMIDINE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NICOTINAMIDE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MUCONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SULFONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NICOTINAMIDE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ONATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'-NADP').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RECOMBINAT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ACNA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ETHANAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NA/KPI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ONALLY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PHENANTHROLINE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DIOXNAE').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NAD ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PRELIMINARY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ONENAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NADP ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'JONA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ADITIONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MYROSINASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PHONACET').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PROTEINASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'OXYGENATED').NE.0) GOTO 10
         IF (GVFPOS(LINE,'COORDINATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'(NADPH)').NE.0) GOTO 10
         IF (GVFPOS(LINE,'QUINAZOL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DICTIONARY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'INACCURA').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NAAD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NACACO').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TASCINAMINE').NE.0) GOTO 10
         IF (GVFPOS(LINE,' KINA ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ILLUMINATION').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NARINGENIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BREQUINAR').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SILDENAFIL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KANAMYCIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RECOMBINANT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PHENAC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PCNA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'-NAC-').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NACO,').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ETHENONAD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAPHTALIMIDE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CONVENTIONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NOMINAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NEUNAC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ANALOG').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ANALYS').NE.0) GOTO 10
         IF (GVFPOS(LINE,'METHONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NARBOMYCIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'HKYNASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PLECONARIL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PROTEINA,').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CANAVALIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ORIGINAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CONCANAVALIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAPHTHALEN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BARCELONA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ETHONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'COMBINATION').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TERMINAT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'THIOCYNANATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'FOLINATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BINARY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PONASTERONE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAMOLYBDATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAPHTHOQUINONE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'FLUCONAZOLE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'QUINATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CINNAMOYL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'QUINOLINATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BINAMIDE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TETRAHYDRONAD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NASA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MEXICANA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TRIETHANOL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DETERMINATION').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ALLIINASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAPASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NARL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NACAC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'THIOCIANATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ADDTIONAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NICOTINATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BINASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NAMPT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PROPIONAMIDE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'INACTIVATED').NE.0) GOTO 10
         IF (GVFPOS(LINE,'K/NA PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'-NACL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'-NACL-').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NACL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NACL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NACL,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NACL,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA CL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NA CL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA CL,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NA CL,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACL;').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAH2PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAH2/K2HPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/KPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA FORMATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-FORMATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES_NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES  NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES-NA+').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES-NAOH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-HEPES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA HEPES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAHEPES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA+ ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACACODYLATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NASCN ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NASCN ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NASCN,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NASCN,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAOH ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NAOH ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAOH,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NAOH,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAF ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NAF ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAF,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NAF,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAI ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NAI ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAI,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NAI,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NABR ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NABR ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NABR,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',NABR,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NANO3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-CACODYL').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA CACODYL').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACH2COOH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA CACODYRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'M NAF ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'/NAOH ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'/NAOH,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'-NAOH,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'-NAOH ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAK TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAK-TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAKTARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K-TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K-TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA/K-').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2HPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAKPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAC2H3O2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAAC ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K TARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CH3COONA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MES-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-FORMIATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2SO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA AZIDE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAN3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MNAN3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2SO3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-TRICINE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAN(3)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAOAC').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'SODIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA3 CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA3CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-MES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA MES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAFORMATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NAOH)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-PYRUVATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA3VO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA(OAC)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA(CH3COO)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K NA PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA3PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'GLY-NAOH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAHCO3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA- CHOLATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAH(2)PO(4)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K/NA TARTR.').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA.CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA CITR ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA CHLOR').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA MOPS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/CACODYL').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' SODIUN ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' SODIU ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' SODUIM ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' SODUM ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' SODIM ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ACETATE_NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA(AC)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA CADODAL').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NATRIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'TRI-NA CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MOPSO-NA+').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NASEO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2MOO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NACACOD').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAHNO3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA3.CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES/NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA FORM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-AZIDE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA MALON').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA THYOCYA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2(SO4)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACOOH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA ACETETE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA( CACODYLATE)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2MO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA DIHYDRO').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CITRATE_NA3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA BROMIDE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-CACODIL').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA(CH3)2ASO').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CITRATE-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA- ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAH2P04/').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA F;').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2WO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-CCODYLATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAPHOSPHATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA,CL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA)3-CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K - PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAEDTA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA MALEATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAKTART,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA-AC,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2NO3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CITRATE-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA3-CIT,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA AC,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2VO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-SCN').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-EDTA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, K-CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'C2H3NAO2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, POTASSIUM PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES - NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-ACETET').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA/H MES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA_POTASSIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K3PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'M NA3-CIT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA MONOBASIC PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K/NA L-TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'M MES NA ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA.ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES - NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2S2O4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA IODIDE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA PHOSPHATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, MG SALT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'TRICINE-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/MES/ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2 TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES.NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-K-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, KPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAPHOSPH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA MALATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-K-TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K/NA TARTRARE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'M MES_NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MOPS-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA_PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA_H2_PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA)3 CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA3)AU(S2O3)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2S203').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAKPHOSPHATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACH3CO2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(K+/NA+) PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-CITRAT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-SALT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NACN').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA ACATATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA SPERMINE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, HEPES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA,K)PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA CACOLDYL').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA(FORM)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2HPO').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA/K)PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2 ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2B4O7').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NASO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, K, TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACHOCH3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'BICINE-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ACETATE NA,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2KPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA SALT,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA OR K ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'TRIS_NA CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NAH2/K2H)PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA- PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, 1,8-DIAMINOOCTANE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NATARTRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAASO2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAK PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'T-NA CITRAT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAKHPO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'%NAN3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA_CL,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-MALONIC').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAH2 PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAK PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K.PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K/NA TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K,PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA DITHIONITE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2HPO').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA TARTARATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA_NITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'TRI-NA CITR').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAH2PO3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACITR.').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA CAODYLATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAAZIDE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HAC/NAAC').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-CHOLATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAHCOO').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CACODYLATE-NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAAZID ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAAZID,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'TRIS-NA CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA4P2O7').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NACITRAT,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-BENZOATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K2PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA CACODALYTE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA.K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, K-TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA-L-LACTATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA/K2 PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA, K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA2S2O3').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA ETHYL').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'WO4NA2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HAC-NAAC').NE.0) FOUND=.TRUE.



         IF (GVFPOS(LINE,'0 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'1 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'2 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'3 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'4 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'5 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'6 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'7 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'8 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'9 K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'0K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'1K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'2K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'3K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'4K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'5K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'6K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'7K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'8K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'9K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'STOCK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'LOCK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'HCK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DARK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BACK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'QUICK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MIKRO').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KETO').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'REMARK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'LIKE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KEPT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BUK2').NE.0) GOTO 10
         IF (GVFPOS(LINE,'BECKER').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TO ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TEMP').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NICKEL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NICKLE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KME').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ZINK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SHAKE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SKRZY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'HIKIM').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KINASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TERASAKI').NE.0) GOTO 10
         IF (GVFPOS(LINE,' KD ').NE.0) GOTO 10
         IF (GVFPOS(LINE,' PEK ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'-KD ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KENDREW').NE.0) GOTO 10
         IF (GVFPOS(LINE,'LINK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KPI ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'COCKTAIL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'KLPDC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SUMPK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'K15').NE.0) GOTO 10
         IF (GVFPOS(LINE,'-TK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MKL').NE.0) GOTO 10
         IF (GVFPOS(LINE,' KIT ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'STREAK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'WEEK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TOOK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SOAK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SOACK').NE.0) GOTO 10
         IF (GVFPOS(LINE,'.K').NE.0) GOTO 10
         IF (GVFPOS(LINE,'K/NA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,', K ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K THIOCYANATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KTHIOCYANATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K-ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K CITRATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K-THIOCYANATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'POTASSIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'POTASSSIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'POTTASIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'POTTASSIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'POTASIUM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'POTASSIM CHLO').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'-KOH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'/KOH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K/').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KF ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'M KI ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2SO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KAC ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KBR ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K AC, ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K(+)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA/K ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA+/K+').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA K ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K-CACO ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K-PO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'KPO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KNO3 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2NO3 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'KSCN').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K3CIRT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K3CITR').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K3 CITR').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAK PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAKPHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA-K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA,K-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA,K,PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA,K.PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA-K-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,':K-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K-GLUTAMATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KPHOSPH').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K FORM').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KFORMAT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'-K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KTARTRA').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' TARTRATE_K').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KACETAT').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KNA TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K-NA TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K,NA-TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K,NA TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA-K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA-,K-TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA-K-TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAKTART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NAK TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' NA,K TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'KCL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2PTCL4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K-HEPES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K+HEPES').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES/K+').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'HEPES/K ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'KH2PO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2HPO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2HPO4,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2H PO4,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA(K)H2PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K,NAH2PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NAH2/K2H)PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K(2)HPO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K(2)HPO(4)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'KH2PO4,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'KH(2)PO(4)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2H PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2PO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2PO4,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K3PO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2HPO4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2HPO4,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(K+NA+) PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2 H PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NA,K PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K NA PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'NAK-PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'KAU(CN)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA,K)PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K-NA-TART').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(NA/K)PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'(K+/NA+) PHOS').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2PT(CN)4 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KH2PO3 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' KCN ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2(SO4)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'K2_H_PO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2CO3,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' K2CO3 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CYANIDE').NE.0) FOUND=.TRUE.



         IF (GVFPOS(LINE,'CACODI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACOTY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAODYL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACOLY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACODALY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACODLY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARCODYL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACOLDY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACODY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACADY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CACODOY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'COCADY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CADODALY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CADODY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CADOME').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAPROIC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBAMA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBAMO').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBAZI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBONA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBOXA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBOXY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBOXIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBOHY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DECAN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAPILL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARPRAT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ACATATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'LOGICAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ICARIS').NE.0) GOTO 10
         IF (GVFPOS(LINE,'AICAR').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ATCASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAVPDYLATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NEACA ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CA.ATP').NE.0) GOTO 10
         IF (GVFPOS(LINE,' MCAR ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'A CAT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARLSBERG').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MICAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'4CABP').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBA-NAD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DECASACC').NE.0) GOTO 10
         IF (GVFPOS(LINE,' SCAN,').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARNITINE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAESIUM').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CASSETTE').NE.0) GOTO 10
         IF (GVFPOS(LINE,' CARRY ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CYLICATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CASOMORPHIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'(CAT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CABP)').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ZENECA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'NACAC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARRIE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAME ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CALLY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAPS').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAMP').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAGED').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CASPASE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAPRATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TRUNCATE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MERCAPTO').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MECAPTO').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CADMIUM').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAFFEIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARBON').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAMPHOR').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CATECHOL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ACARBOSE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CALMODULIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'ALBICAN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CASEIN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CIRCA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SERCA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CATALYTIC').NE.0) GOTO 10
         IF (GVFPOS(LINE,'INDICAT').NE.0) GOTO 10
         IF (GVFPOS(LINE,'IDENTICAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'GLUCAM').NE.0) GOTO 10
         IF (GVFPOS(LINE,'GLUCAN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CAMKI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CATHEP').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CANAVALI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CADAVERI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DECAHY').NE.0) GOTO 10
         IF (GVFPOS(LINE,'SCALE').NE.0) GOTO 10
         IF (GVFPOS(LINE,' TECAN').NE.0) GOTO 10
         IF (GVFPOS(LINE,' HCA ').NE.0) GOTO 10
         IF (GVFPOS(LINE,' CAP ').NE.0) GOTO 10
         IF (GVFPOS(LINE,' CAN ').NE.0) GOTO 10
         IF (GVFPOS(LINE,' CAIR ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RECA6').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RECA4').NE.0) GOTO 10
         IF (GVFPOS(LINE,'LACTONE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'GLCA').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RECA5').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CALIBRATION').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PURIFICATION').NE.0) GOTO 10
         IF (GVFPOS(LINE,'PUBLICATION').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CATECHI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CARTESI').NE.0) GOTO 10
         IF (GVFPOS(LINE,'TYPICAL').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CHEMICAL').NE.0) GOTO 10



         IF (GVFPOS(LINE,'ZNCL2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZNCL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZNSO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZNAC').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN(ACO)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN(ACETATE)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' ZN+2 ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN-ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN+2.').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN(II)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' ZINC').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' ZINK').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN(OAC)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN (AC)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN(CH2H3O2)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'BABIM-ZN+2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZNOAC2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZNOAC ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' ZN2+').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN CHLOR').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN(AC)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'M ZN ACET').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'ZN(ACETATE)').NE.0) FOUND=.TRUE.



         IF (GVFPOS(LINE,' FMN').NE.0) GOTO 10
         IF (GVFPOS(LINE,' NMN ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RHAMNULOSE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MMNAN').NE.0) GOTO 10
         IF (GVFPOS(LINE,' MNMN ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'AMMNONIUM').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MNSOD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DMNJ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MN12H2').NE.0) GOTO 10
         IF (GVFPOS(LINE,'RHAMNOSE').NE.0) GOTO 10
         IF (GVFPOS(LINE,'AMMNIUM').NE.0) GOTO 10
         IF (GVFPOS(LINE,'COLUMN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'AMMOMNIUM').NE.0) GOTO 10
         IF (GVFPOS(LINE,'VOLUMN').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MNCL2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MNSO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MN-AMP').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MN ACETATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' MN ION').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' MN2+ ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MN CHLORIDE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' MNCL,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MNCL(2)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MN(CH3COO)2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' MNCL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' MN2 ION').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'MN(2+)').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,',MNCL,').NE.0) FOUND=.TRUE.



         IF (GVFPOS(LINE,'CDS0').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CD4').NE.0) GOTO 10
         IF (GVFPOS(LINE,' CDP ').NE.0) GOTO 10
         IF (GVFPOS(LINE,' CDP,').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CDST').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CDK2').NE.0) GOTO 10
         IF (GVFPOS(LINE,' CDU ').NE.0) GOTO 10
         IF (GVFPOS(LINE,'DCDP').NE.0) GOTO 10
         IF (GVFPOS(LINE,'MCDONALD').NE.0) GOTO 10
         IF (GVFPOS(LINE,'CDCL2').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CDSO4').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' CD++ ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' CD++,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' CDCL,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CD SULFATE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' CD2+,').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,' CDCL ').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CD CHLORIDE').NE.0) FOUND=.TRUE.
         IF (GVFPOS(LINE,'CADMIUM').NE.0) FOUND=.TRUE.
      END IF



  999 CONTINUE
      CALL GVSEIR ('ION200')



  998 CONTINUE

      IF (IUNIT.GE.1) CALL GVSCLF (IUNIT)

      RETURN
      END   
      SUBROUTINE ION201

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       NUMTYP, IC
      LOGICAL       FND1, FND2
      CHARACTER*2   CROW(11)







      IF (NR280.LE.2) THEN
         CALL PDBMES ('NOR280')
         GOTO 998
      END IF



      CALL ION113 (CROW,NUMTYP)



      DO 10 IC=1,NR280
         CALL GVSTT6 (CRYSTL(IC))
 10   CONTINUE



      DO 20 IC=1,NUMTYP
         CALL ION114 (CROW(IC),FND1)
         CALL ION115 (CROW(IC),FND2)
         IF (FND1) THEN
            IF (FND2) THEN
               CALL GVST6C (CROW(IC),'?ION526',.TRUE.)
            ELSE
               CALL GVST6C (CROW(IC),'?ION527',.TRUE.)
            END IF
         ELSE
            IF (FND2) THEN
               CALL GVST6C (CROW(IC),'?ION528',.TRUE.)
            ELSE
               CALL GVST6C ('?ION529',CROW(IC),.TRUE.)
            END IF
         END IF
 20   CONTINUE



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ION205

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       CNTION
      PARAMETER     (CNTION=4000)
      INTEGER       IUNIT, IPNT, CPNT, GVFLEN, LENNAM, IR, GVFLFR, RS, 
     +              CCNT(9), IERR, NUM(CNTION), L1, L2, NS, GVFFFI, LT,
     +              AGAIN, NLH(2)
      REAL          SCORES(8,CNTION), DIST(8), GVFRSM, N, R0, STPBST,
     +              ONENOW, ONEBST, NNOW, R0NOW, GVFRAN, FACT, NRS, RRS,
     +              F1, F2, S1, S2, VION, TEMP(10), DIV, TMP
      LOGICAL       GRTFILE, INTERRUPTED
      CHARACTER*8   LOCLIN, NAME, LNAMES(CNTION)
      EQUIVALENCE   (NUM(1),     ESPACE(5000001))
      EQUIVALENCE   (SCORES(1,1),ESPACE(5100001))
      EQUIVALENCE   (LNAMES(1),  ESPACE(5400001))







      IF (IONTYP.EQ.'**') THEN
         CALL GVSTTE ('?ION530')
         GOTO 998
      END IF



      IPNT=0
      CPNT=0
      IUNIT=0
      CALL GVSCTB (NAME,8)
      CALL GVSCTB (LNAMES,8*CNTION)
      CALL GVSIT0 (CCNT,9)
      CALL GVSIT0 (NUM,CNTION)
      CALL GVSRT0 (SCORES,8*CNTION)




      IF (IONTYP.EQ.'N4') THEN
         IF (.NOT.GRTFILE(IUNIT,'search3.tab')) GOTO 998
      ELSE
         IF (.NOT.GRTFILE(IUNIT,'?ION508')) GOTO 998
      END IF



      IF (IONTYP.EQ.'N4') THEN
 10      CONTINUE



            CALL GETLINE (IUNIT,LOCLIN(1:8),IERR)
            IF (IERR.NE.0) GOTO 20
            IF (LOCLIN(1:1).NE.'#') GOTO 999



            CALL GETLINE (IUNIT,LOCLIN(1:8),IERR)
            IF (IERR.NE.0) GOTO 20



            CALL GETLINE (IUNIT,LOCLIN(1:8),IERR)
            IF (IERR.NE.0) GOTO 20
            LENNAM=GVFLEN(LOCLIN)



            IF (GVFLEN(NAME).NE.LENNAM.OR.NAME(1:LENNAM).NE.
     +          LOCLIN(1:LENNAM)) THEN
               CALL GVSSTX (NAME,LOCLIN)
               CPNT=CPNT+1
               CALL GVSSTX (LNAMES(CPNT),LOCLIN)
               IPNT=0
            END IF



            CALL GETLINE (IUNIT,LOCLIN(1:8),IERR)
            IF (IERR.NE.0) GOTO 20
            IR=GVFLFR(1,TMP,LOCLIN)
            IF (IR.NE.1) GOTO 999
            IPNT=MIN(IPNT+1,8)
            SCORES(IPNT,CPNT)=TMP
            NUM(CPNT)=IPNT
         GOTO 10
      ELSE
 15      CONTINUE
            CALL GETLINE (IUNIT,LINE,IERR)
            IF (IERR.NE.0) GOTO 20
            IR=GVFLFR(10,TEMP,LINE)
            CPNT=CPNT+1
            NUM(CPNT)=TEMP(1)
            CALL GVSCPR (SCORES(1,CPNT),TEMP(2),NUM(CPNT))
         GOTO 15
      END IF
 20   CONTINUE



      DO 30 IR=1,CPNT
         IF (GVFLEN(LNAMES(IR)).GE.1) CALL GVSTT6 (LNAMES(IR))
         WRITE (6,123,ERR=999) NUM(IR),(SCORES(IPNT,IR),IPNT=1,NUM(IR))
 123     FORMAT (I4,2X,8F7.3)
         IF (SCORES(8,IR).GT.0.001) THEN
            CCNT(8)=CCNT(8)+1
            DIST(8)=DIST(8)+GVFRSM(SCORES(1,IR),8)
         ELSE IF (SCORES(7,IR).GT.0.001) THEN
            CCNT(7)=CCNT(7)+1
            DIST(7)=DIST(7)+GVFRSM(SCORES(1,IR),7)
         ELSE IF (SCORES(6,IR).GT.0.001) THEN
            CCNT(6)=CCNT(6)+1
            DIST(6)=DIST(6)+GVFRSM(SCORES(1,IR),6)
         ELSE IF (SCORES(5,IR).GT.0.001) THEN
            CCNT(5)=CCNT(5)+1
            DIST(5)=DIST(5)+GVFRSM(SCORES(1,IR),5)
         ELSE IF (SCORES(4,IR).GT.0.001) THEN
            CCNT(4)=CCNT(4)+1
            DIST(4)=DIST(4)+GVFRSM(SCORES(1,IR),4)
         ELSE IF (SCORES(3,IR).GT.0.001) THEN
            CCNT(3)=CCNT(3)+1
            DIST(3)=DIST(3)+GVFRSM(SCORES(1,IR),3)
         ELSE IF (SCORES(2,IR).GT.0.001) THEN
            CCNT(2)=CCNT(2)+1
            DIST(2)=DIST(2)+GVFRSM(SCORES(1,IR),2)
         ELSE IF (SCORES(1,IR).NE.0) THEN
            CCNT(1)=CCNT(1)+1
            DIST(1)=DIST(1)+GVFRSM(SCORES(1,IR),1)
         ELSE
            CCNT(9)=CCNT(9)+1
         END IF
 30   CONTINUE
      PRINT*,CPNT,' : ',CCNT
      DO 40 IR=1,8
         IF (CCNT(IR).GE.1) PRINT*,IR,DIST(IR)/FLOAT(IR*CCNT(IR))
 40   CONTINUE
      CALL GVSTT6 ('?ION531')
      IR=GVFFFI(2,NLH)
      IF (IR.NE.2) GOTO 999



      CALL ION_SET_PAR (R0,N,DIV,IERR)
      NNOW=N
      R0NOW=R0
      ONEBST=99999999.9
      DO 45 IR=1,10
         CALL ION207 (SCORES(1,IR),NUM(IR),R0,N,DIV,FACT)
         PRINT*,IR,R0,N,FACT,(SCORES(L1,IR),L1=1,NUM(IR))
 45   CONTINUE
      CALL ION206(SCORES,NLH,NUM,CPNT,R0NOW,NNOW,DIV,FACT)
      PRINT*,'INITIAL SCORE:',FACT



      DO 500 LT=1,2
      DO 220 RS=22,6,-4
         PRINT*,'STEP=',RS/4-1
         RRS=FLOAT(RS)/10.0
         DO 210 NS=30,12,-4
            NRS=(-1.0)*FLOAT(NS)/10.0



            DO 200 L1=10,1,-1
               IF (INTERRUPTED()) GOTO 999
               FACT=FLOAT(L1)/10.0
               DO 190 L2=1,100



                  NNOW=NRS+FACT*GVFRAN(-1.0,1.0)
                  R0NOW=ABS(RRS+FACT*GVFRAN(-1.0,1.0))



                  CALL ION206(SCORES,NLH,NUM,CPNT,R0NOW,NNOW,DIV,ONENOW)




                  IF (ONENOW.LT.ONEBST) THEN
                     N=NNOW
                     R0=R0NOW
                     NRS=N
                     RRS=R0
                     ONEBST=ONENOW
                     PRINT*,'N, R0: ',N,R0,' ->',ONEBST
                  END IF
 190           CONTINUE
 200        CONTINUE



 210     CONTINUE
 220  CONTINUE
      PRINT*,'After round 1: N, R0: ',N,R0,' ->',ONEBST



      DO 300 L1=21,1,-2
         DO 290 L2=1,1000
            IF (INTERRUPTED()) GOTO 999



            R0NOW=ABS(R0+GVFRAN(-1.0,1.0)*FLOAT(L1)/100.0)
            NNOW =N     +GVFRAN(-1.0,1.0)*FLOAT(L1)/100.0



            CALL ION206(SCORES,NLH,NUM,CPNT,R0NOW,NNOW,DIV,ONENOW)



            IF (ONENOW.LT.ONEBST) THEN
               N=NNOW
               R0=R0NOW
               ONEBST=ONENOW
               PRINT*,'F) N, R0: ',N,R0,' ->',ONEBST
            END IF
 290     CONTINUE
 300  CONTINUE
      PRINT*,'After round 2: N, R0: ',N,R0,' ->',ONEBST



      DO 400 L1=1,1000
         NRS=N+GVFRAN((-0.25)*N,0.25*N)
         RRS=R0+GVFRAN((-0.25)*R0,0.25*R0)
         STPBST=999999.9
         F1=0.37*N
         F2=0.37*R0
 310     CONTINUE
         IF (INTERRUPTED()) GOTO 999
         DO 390 L2=1,6
            S1=0.0
            S2=0.0
            IF (L2.EQ.1) THEN
               S1=F1
            ELSE IF (L2.EQ.2) THEN
               S2=F2
            ELSE IF (L2.EQ.3) THEN
               S1=F1
               S2=F2
            ELSE IF (L2.EQ.4) THEN
               S1=(-1.0)*F1
            ELSE IF (L2.EQ.5) THEN
               S2=(-1.0)*F2
            ELSE IF (L2.EQ.6) THEN
               S1=(-1.0)*F1
               S2=(-1.0)*F2
            END IF
            AGAIN=-1
 320        CONTINUE
            AGAIN=AGAIN+1
            IF (AGAIN.EQ.10) THEN
               S1=S1*2.0
               S1=S2*2.0
               AGAIN=-1
            END IF
            NRS=NRS+S1
            RRS=ABS(RRS+S2)



            CALL ION206 (SCORES,NLH,NUM,CPNT,RRS,NRS,DIV,ONENOW)
            IF (ONENOW.LT.ONEBST) THEN
               R0=RRS
               N=NRS
               ONEBST=ONENOW
               PRINT*,'G) N, R0: ',N,R0,' ->',ONEBST
            END IF
            IF (ONENOW.LT.STPBST) THEN
               R0NOW=RRS
               NNOW=NRS
               STPBST=ONENOW
               GOTO 320
            END IF
 390     CONTINUE
         F1=F1*(-0.37)
         F2=F2*(-0.37)
         IF (ABS(F1).GT.0.000000001.AND.ABS(F2).GT.0.000000001) GOTO 310
 400  CONTINUE
      PRINT*,'After round 3: N, R0: ',N,R0,' ->',ONEBST
      DO 420 IR=1,CPNT
         IF (NUM(IR).LT.NLH(1).OR.NUM(IR).GT.NLH(2)) GOTO 420



         VION=0.0
         DO 410 L1=1,NUM(IR)
            VION=VION+(6.0/FLOAT(NUM(IR)))*(SCORES(L1,IR)/R0)**N
 410     CONTINUE



         WRITE (6,1000,ERR=998) IR,LNAMES(IR),NUM(IR),VION,ABS(1.0-VION)
         IF (ABS(1.0-VION).GT.2.0*ONEBST) NUM(IR)=0
 420  CONTINUE
 500  CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIR ('ION205')



  998 CONTINUE
      IF (IUNIT.NE.0) CALL GVSCLF (IUNIT)


 1000 FORMAT (I4,A8,I4,2F7.4)

      RETURN
      END   
      SUBROUTINE ION206 (SCORES,NLH,NUM,CPNT,R0,N,DIV,SCORE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       CNTION
      PARAMETER     (CNTION=4000)
      INTEGER       CPNT, II, IR, NUM(CNTION), NLH(2), NUMUSE
      REAL          SCORES(8,CNTION), N, R0, VION, SCORE, F1, F2, DIV







      NUMUSE=0



      DO 20 IR=1,CPNT
         IF (NUM(IR).LT.NLH(1).OR.NUM(IR).GT.NLH(2)) GOTO 20
         VION=0.0



         DO 10 II=1,NUM(IR)
            F1=(6.0/FLOAT(NUM(IR)))
            F2=(SCORES(II,IR)/R0)**N
            VION=VION+F1*F2/DIV
 10      CONTINUE



         SCORE=SCORE+ABS(1.0-VION)
         NUMUSE=NUMUSE+1
 20   CONTINUE



      SCORE=SCORE/FLOAT(NUMUSE)



      IF (R0.LT.0.001) SCORE=SCORE+(0.001-R0)
      IF (R0.GT.3.0) SCORE=SCORE+(R0-3.0)
      IF (N.GT.-0.25) SCORE=SCORE+0.25+N
      IF (N.LT.-10.0) SCORE=SCORE-10.0-N





      RETURN
      END   
      SUBROUTINE ION207 (SCORES,NUM,R0,N,DIV,SCORE)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       II, NUM
      REAL          SCORES(8), N, R0, VION, SCORE, F1, F2, DIV







      VION=0.0



      DO 10 II=1,NUM
         F1=(6.0/FLOAT(NUM))
         F2=(SCORES(II)/R0)**N
         VION=VION+F1*F2/DIV
 10   CONTINUE



      SCORE=ABS(1.0-VION)





      RETURN
      END   
      SUBROUTINE ION210 (IUNIT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IUNIT, ISOUP, IAA, ION, IERR, I
      LOGICAL       WIFIRM, CH4EQCH4







      CALL WIFPUSHPPP (590,1)



      CALL ENVTOT
      CALL SYMIPG (IERR,' ')
      CALL SYMNEA



      DO 100 ISOUP=1,NUMSOU
         IAA=SOUADM(1,ISOUP)
         ION=PNTAAS(IAA)



         IF (.NOT.WIFIRM(IAA)) GOTO 100
         IF (IONTYP.EQ.'N4') THEN
            IF (.NOT.CH4EQCH4(ONESA3(IAA),'NH4 ').OR.ONESAT(ION).NE.
     +       ' N   ') GOTO 100
         ELSE 
            IF (ONESAT(ION)(1:2).NE.IONTYP) GOTO 100
         END IF



         CALL FCONAT (ION,1.0)
         CALL FCONRED (ION,IONHGH)
         CALL FCONREC



         IF (NUMCONIAT.LE.3.OR.NUMCONIAT.GE.8) GOTO 100
         WRITE (IUNIT,1000,ERR=999)NUMCONIAT,(CONDSTAT(I),I=1,NUMCONIAT)
         WRITE (6,1000,ERR=999)NUMCONIAT,(CONDSTAT(I),I=1,NUMCONIAT)
 100  CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIR ('ION210')



  998 CONTINUE
      CALL WIFPOPPPP (590)


 1000 FORMAT (I5,10F7.3)

      RETURN
      END   
      SUBROUTINE ION211 (IUNIT)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IUNIT, ISOUP, IAA, ION, IERR, BIGCNT(14,21,2), J, 
     +              JAT, JATTYP, JAA, JAATYP
      REAL          R0, N, DIV
      LOGICAL       WIFIRM, GVFIBN, HASVIO







      CALL WIFPUSHPPP (590,1)



      CALL ION_SET_PAR (R0,N,DIV,IERR)
      IF (IERR.NE.0) GOTO 999
      CALL GVSIT0 (BIGCNT,14*21*2)



      CALL ENVTOT
      CALL SYMIPG (IERR,' ')
      CALL SYMNEA



      DO 100 ISOUP=1,NUMSOU
         IAA=SOUADM(1,ISOUP)
         ION=PNTAAS(IAA)



         IF (.NOT.WIFIRM(IAA)) GOTO 100
         IF (.NOT.HASVIO(ION)) GOTO 100





         CALL WIFPUSHPPP (590,0)
         CALL WIFPUSHPPP (457,0)
         CALL FCONAT (ION,1.0)
         CALL FCONRED (ION,IONHGH)
         CALL FCONREC
         CALL GVSCPI (JR,CONIAT,10)
         CALL WIFPOPPPP (457)
         CALL WIFPOPPPP (590)



         IF (NUMCONIAT.LE.0) GOTO 100
         DO 10 J=1,NUMCONIAT
            JAT=JR(J)
            JATTYP=PINIAA(JAT)
            JAA=ATIAA(JAT)
            JAATYP=RESTYP(JAA)
            IF (.NOT.GVFIBN(JAATYP,1,20)) JAATYP=21
            IF (JAATYP.EQ.21) THEN

            END IF
 10      CONTINUE



         CALL GVSTTU (IUNIT,'Option not yet ready')
 100  CONTINUE
      GOTO 998



  999 CONTINUE
      CALL GVSEIR ('ION211')



  998 CONTINUE
      CALL WIFPOPPPP (590)


      RETURN
      END   
      SUBROUTINE ION220

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ELMINC.INC'
      INCLUDE       'DATBAS.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IUNIT, ELMZ, ION, IERR, WITHOUT, IONCNT(2,MAXEL),
     +              ISOUP, IAA, IELM, IDON, KILROW(10), JUNIT
      LOGICAL       WIFIRM, ISMETAL, MOLKIL1, MOLKIL2, INTERRUPTED,
     +              GOTFILE, GVFISF, OK
      CHARACTER*80  FILNAM







      IDON=0
      IUNIT=0
      JUNIT=0
      OK=MOLKIL1('OPEN','DUMY')
      CALL GVSIT0 (IONCNT,2*MAXEL)
      CALL GVSIT0 (KILROW,10)





      WIFPAR(368)=1
      WIFPAR(454)=200
      WIFPAR(466)=0



      CALL PDBL01 (IUNIT,IERR)
      IF (IERR.NE.0) GOTO 998
      IF (GVFISF('USE.LIS')) CALL GVSDEL ('USE.LIS')
      IF (.NOT.GOTFILE(JUNIT,'USE.LIS')) GOTO 998







 10   CONTINUE
         WIFPAR(466)=0
         WIFPAR(276)=WIFPAR(294)
         IF (INTERRUPTED()) GOTO 998
         CALL GETLINE (IUNIT,FILNAM,IERR)
         IF (IERR.NE.0) GOTO 998
         IF (FILNAM(1:4).EQ.'*END') GOTO 998
         IF (MOLKIL1('SJEK',FILNAM(1:4))) THEN
            PRINT*,'Killed on its file name'
            KILROW(10)=KILROW(10)+1
            GOTO 10
         END IF
         CALL GVSLIN
         IDON=IDON+1
         IF (MOD(IDON,100).EQ.0) THEN
            DO 20 IELM=1,MAXEL
               WRITE (6,123) ELEM(IELM),IONCNT(1,IELM),IONCNT(2,IELM)
 123           FORMAT (A4,2I5)
 20         CONTINUE
         END IF
         CALL GVSTTI ('?M4246',IDON)
         CALL PRP201 (FILNAM)
         CALL GVSSTX (FILNMS(62),FILNAM)
         CALL WIFPUSHPPP (365,1)
         CALL WIFPUSHPPP (642,1)
         CALL WIFPUSHPPP (622,0)
         CALL WIFPUSHPPP (1105,1)
         CALL PDBL05 (FILNAM,.TRUE.)
         CALL WIFPOPPPP (1105)
         CALL WIFPOPPPP (622)
         CALL WIFPOPPPP (642)
         CALL WIFPOPPPP (365)
         IF (MOLKIL2()) THEN
            IF (WIFPAR(466).EQ.0) THEN
               KILROW(8)=KILROW(8)+1
            ELSE
               KILROW(WIFPAR(466))=KILROW(WIFPAR(466))+1
            END IF
            CALL GVSTT6 ('?ION510')
            GOTO 10
         END IF
         IF (NUMAAF.LE.0) THEN
            CALL GVSTT6 ('?ION511')
            KILROW(7)=KILROW(7)+1
            GOTO 10
         END IF
         CALL GVSTTU (JUNIT,FILNAM)
         CALL SHOSOU
         CALL PRP202 ('?M4886')



         DO 30 ISOUP=1,NUMSOU
            IAA=SOUADM(1,ISOUP)
            IF (.NOT.WIFIRM(IAA)) GOTO 30
            ION=PNTAAS(IAA)
            IF (.NOT.ISMETAL(ION)) GOTO 30
            IELM=ELMZ(ION)



            CALL WIFPUSHPPP (590,0)
               CALL ENVTOT
               CALL SYMIPG (IERR,' ')
               CALL SYMNEA
               CALL FCONAT (ION,1.0)
               CALL FCONRED (ION,IONHGH)
               CALL FCONREC
            CALL WIFPOPPPP (590)
            WITHOUT=NUMCONIAT



            CALL WIFPUSHPPP (590,1)
               CALL ENVTOT
               CALL SYMIPG (IERR,' ')
               CALL SYMNEA
               CALL FCONAT (ION,1.0)
               CALL FCONRED (ION,IONHGH)
               CALL FCONREC
            CALL WIFPOPPPP (590)



            CALL DIF013D (6,ION,WITHOUT,NUMCONIAT)
            IF (WITHOUT.LT.NUMCONIAT) THEN
               IONCNT(1,IELM)=IONCNT(1,IELM)+1
            ELSE
               IONCNT(2,IELM)=IONCNT(2,IELM)+1
            END IF
 30      CONTINUE
      GOTO 10



  998 CONTINUE
      CALL PDBL02 (IUNIT)
      IF (JUNIT.NE.0) CALL GVSCLF (JUNIT)
      CALL GVSTT6 ('?ION532')
      DO 40 IELM=1,MAXEL
         WRITE (6,123) ELEM(IELM),IONCNT(1,IELM),IONCNT(2,IELM)
 40   CONTINUE
      CALL GVSTT6 ('?ION533')
      DO 50 IELM=1,10
         WRITE (6,*) KILROW(IELM)
 50   CONTINUE
      OK=MOLKIL1('CLOS','DUMY')


      RETURN
      END   
      REAL FUNCTION IONDST(ION,IJR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, IJR







      IF (IJR.GT.NUMCONIAT) THEN
         CALL GVSTTI2 ('?ION534',IJR,NUMCONIAT)
         IONDST=0.0
         CALL GVSKIL
         GOTO 998
      END IF



      IONDST=SQRT((XCOORD(ION)-XYZJR(1,IJR))**2+
     +            (YCOORD(ION)-XYZJR(2,IJR))**2+
     +            (ZCOORD(ION)-XYZJR(3,IJR))**2)



  998 CONTINUE


      RETURN
      END   
      REAL FUNCTION IONDST2(IJ1,IJ2)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       IJ1, IJ2







      IF (IJ1.GT.NUMCONIAT.OR.IJ2.GT.NUMCONIAT) THEN
         CALL GVSTTI3 ('?ION537',IJ1,IJ2,NUMCONIAT)
         IONDST2=0.0
         GOTO 998
      END IF



      IONDST2=SQRT((XYZJR(1,IJ1)-XYZJR(1,IJ2))**2+
     +             (XYZJR(2,IJ1)-XYZJR(2,IJ2))**2+
     +             (XYZJR(3,IJ1)-XYZJR(3,IJ2))**2)



  998 CONTINUE


      RETURN
      END   
      REAL FUNCTION IONANG(IJ1,ION,IJ2)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       ION, IJ1, IJ2
      REAL          V1(3), V2(3), GVFANG, GVFRTD







      IONANG=0.0



      IF (IJ1.GT.NUMCONIAT.OR.IJ2.GT.NUMCONIAT.OR.IJ1.EQ.IJ2) THEN
         CALL GVSTTE ('?WRATAN')
         CALL GVSTTI3 ('?M1307',IJ1,ION,IJ2)
         CALL GVSKIL
         GOTO 998
      END IF



      V1(1)=XCOORD(ION)-XYZJR(1,IJ1)
      V1(2)=YCOORD(ION)-XYZJR(2,IJ1)
      V1(3)=ZCOORD(ION)-XYZJR(3,IJ1)
      V2(1)=XCOORD(ION)-XYZJR(1,IJ2)
      V2(2)=YCOORD(ION)-XYZJR(2,IJ2)
      V2(3)=ZCOORD(ION)-XYZJR(3,IJ2)



      IONANG=GVFRTD(GVFANG(V1,V2))



  998 CONTINUE


      RETURN
      END
      SUBROUTINE IONPL4 (IJ1,IJ2,IJ3,IJ4,ION,A,B,C,D,RMS)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'
      INCLUDE       'CNTINC.INC'
      INCLUDE       'SUGARS.INC'
      INCLUDE       'ESPACE.INC'
      INTEGER       I, ICNT, IJ1, IJ2, IJ3, IJ4, NUM, ION
      REAL          XYZL(3,5), A, B, C, D, RMS, CENTROID(3), RMAT(3,3),
     +              EVEC(3,3), V(3), DIST, GVFRAN







      ICNT=0
      NUM=3



      XYZL(1,1)=XYZJR(1,IJ1)
      XYZL(2,1)=XYZJR(2,IJ1)
      XYZL(3,1)=XYZJR(3,IJ1)
      XYZL(1,2)=XYZJR(1,IJ2)
      XYZL(2,2)=XYZJR(2,IJ2)
      XYZL(3,2)=XYZJR(3,IJ2)
      XYZL(1,3)=XYZJR(1,IJ3)
      XYZL(2,3)=XYZJR(2,IJ3)
      XYZL(3,3)=XYZJR(3,IJ3)
      IF (IJ4.EQ.0) THEN
         NUM=4
      ELSE
         XYZL(1,4)=XYZJR(1,IJ4)
         XYZL(2,4)=XYZJR(2,IJ4)
         XYZL(3,4)=XYZJR(3,IJ4)
         NUM=5
      END IF
      IF (ION.NE.0) THEN
         XYZL(1,NUM)=XCOORD(ION)
         XYZL(2,NUM)=YCOORD(ION)
         XYZL(3,NUM)=ZCOORD(ION)
      END IF



      CALL GVSRT0 (CENTROID,3)
      DO 10 I=1,NUM
         CENTROID(1)=CENTROID(1)+XYZL(1,I)
         CENTROID(2)=CENTROID(2)+XYZL(2,I)
         CENTROID(3)=CENTROID(3)+XYZL(3,I)
 10   CONTINUE

      CENTROID(1)=CENTROID(1)/FLOAT(NUM)
      CENTROID(2)=CENTROID(2)/FLOAT(NUM)
      CENTROID(3)=CENTROID(3)/FLOAT(NUM)



 15   CONTINUE
      CALL GVSRT0 (RMAT,9)
      DO 20 I=1,NUM
         IF (ICNT.EQ.0) THEN
            V(1)=XYZL(1,I)-CENTROID(1)
            V(2)=XYZL(2,I)-CENTROID(2)
            V(3)=XYZL(3,I)-CENTROID(3)
         ELSE
            V(1)=XYZL(1,I)-CENTROID(1)+FLOAT(ICNT)*GVFRAN(-0.002,0.002)
            V(2)=XYZL(2,I)-CENTROID(2)+FLOAT(ICNT)*GVFRAN(-0.002,0.002)
            V(3)=XYZL(3,I)-CENTROID(3)+FLOAT(ICNT)*GVFRAN(-0.002,0.002)
         END IF
         RMAT(1,1)=RMAT(1,1)+V(1)*V(1)
         RMAT(2,1)=RMAT(2,1)+V(2)*V(1)
         RMAT(3,1)=RMAT(3,1)+V(3)*V(1)
         RMAT(1,2)=RMAT(1,2)+V(1)*V(2)
         RMAT(2,2)=RMAT(2,2)+V(2)*V(2)
         RMAT(3,2)=RMAT(3,2)+V(3)*V(2)
         RMAT(1,3)=RMAT(1,3)+V(1)*V(3)
         RMAT(2,3)=RMAT(2,3)+V(2)*V(3)
         RMAT(3,3)=RMAT(3,3)+V(3)*V(3)
 20   CONTINUE



      CALL GVSEIG2 (3,RMAT,V,EVEC)



      IF (ABS(EVEC(1,1)).LT.0.0001.OR.
     +    ABS(EVEC(1,2)).LT.0.0001.OR.
     +    ABS(EVEC(1,3)).LT.0.0001.OR.
     +    ABS(EVEC(2,1)).LT.0.0001.OR.
     +    ABS(EVEC(2,2)).LT.0.0001.OR.
     +    ABS(EVEC(2,3)).LT.0.0001.OR.
     +    ABS(EVEC(3,1)).LT.0.0001.OR.
     +    ABS(EVEC(3,2)).LT.0.0001.OR.
     +    ABS(EVEC(3,3)).LT.0.0001) THEN
         IF (ICNT.LT.5) THEN
            ICNT=ICNT+1
            CALL GVSTT6 ('?M3400')
            GOTO 15
         END IF
      END IF
      A=EVEC(1,3)
      B=EVEC(2,3)
      C=EVEC(3,3)
      D=A*CENTROID(1)+B*CENTROID(2)+C*CENTROID(3)



      RMS=0.0
      DO 30 I=1,NUM
         DIST=D-A*XYZL(1,I)-B*XYZL(2,I)-C*XYZL(3,I)
         RMS=RMS+DIST**2
 30   CONTINUE
      RMS=SQRT(RMS/FLOAT(NUM))
      CALL PLN004A (XYZL,NUM,A,B,C,D,RMS)





      RETURN
      END
