



      SUBROUTINE ENVINI




















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INCLUDE       'SYMINC.INC'







      CALL GVSIT0 (USESOU,MAXMOL)
      USEBCKPNT=0



      CALL GVSIT0 (USEBCK,10*MAXMOL)



      NEADST=-1000.0





      RETURN
      END
      SUBROUTINE ENVPUSH (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IERR







      IF (USEBCKPNT.GT.9) THEN
         CALL GVSTTB ('?M3891')
         IERR=1
         CALL GVSKIL
         GOTO 998
      END IF



      IERR=0



      USEBCKPNT=USEBCKPNT+1
      CALL GVSCPI (USEBCK(1,USEBCKPNT),USESOU,MAXMOL)



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ENVPOP (IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IERR







      IF (USEBCKPNT.LE.0) THEN
         CALL GVSTTB ('?M3304')
         IERR=1
         CALL GVSKIL
         GOTO 998
      END IF



      IERR=0



      CALL GVSCPI (USESOU,USEBCK(1,USEBCKPNT),MAXMOL)
      USEBCKPNT=USEBCKPNT-1



  998 CONTINUE


      RETURN
      END   
      SUBROUTINE ENVPROT



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP
      LOGICAL       WIFISA







      CALL GVSIT0 (USESOU,MAXMOL)



      DO 10 ISOUP=1,NUMSOU
         IF (WIFISA(ISOUP)) USESOU(ISOUP)=ISOUP
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVMOD (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP, IAA
      LOGICAL       WIFISO, WIFISH, WIFIRI







      IF (.NOT.WIFIRI(IAA)) THEN
         CALL GVSKIL
         GOTO 998
      END IF



      CALL GVSIT0 (USESOU,MAXMOL)



      IF (WIFPAR(846).EQ.0) THEN
         CALL ENVTOT
         GOTO 998
      END IF



      DO 10 ISOUP=1,NUMSOU
         IF (WIFISO(ISOUP)) GOTO 10
         IF (WIFISH(ISOUP)) GOTO 10
         IF (MODNMB(SOUADM(1,ISOUP)).EQ.MODNMB(IAA)) THEN
            USESOU(ISOUP)=ISOUP
         END IF
   10 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ENVPROTNOT

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP
      LOGICAL       WIFISA







      DO 10 ISOUP=1,NUMSOU
         IF (WIFISA(ISOUP)) USESOU(ISOUP)=0
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVSOUPNOT (ISOUP)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP
      LOGICAL       GVFIBN







      IF (.NOT.GVFIBN(ISOUP,1,NUMSOU)) THEN
         CALL GVSKIL
         GOTO 998
      END IF



      USESOU(ISOUP)=0



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ENVSET (ISOUPIN)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP, ISOUPIN
      LOGICAL       GVFIBN







      IF (.NOT.GVFIBN(ISOUPIN,1,NUMSOU)) THEN
         CALL GVSKIL
         GOTO 998
      END IF



      CALL GVSIT0 (USESOU,MAXMOL)



      DO 10 ISOUP=1,NUMSOU
         IF (WIFPAR(846).NE.0) THEN
            IF (MODNMB(SOUADM(1,ISOUPIN)).NE.
     +       MODNMB(SOUADM(1,ISOUP))) GOTO 10
         END IF
         IF (SOUNAM(SOUPNT(SOUADM(1,ISOUP))).EQ.
     +    SOUNAM(SOUPNT(SOUADM(1,ISOUPIN)))) USESOU(ISOUP)=ISOUP
   10 CONTINUE



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ENVWTF 

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IAA







      CALL GVSIT0 (USESOU,MAXMOL)



      DO 10 IAA=1,NUMAAT
         IF (WRK1TF(IAA)) USESOU(CHAINN(2,IAA))=CHAINN(2,IAA)
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVSETC (TEXT,FOUND)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP, GVFLEN, LEN1, LEN2
      CHARACTER*(*) TEXT
      LOGICAL       WIFISW, FOUND







      CALL GVSIT0 (USESOU,MAXMOL)
      FOUND=.FALSE.



      DO 10 ISOUP=1,NUMSOU
         IF (WIFISW(ISOUP)) GOTO 10
         LEN1=GVFLEN(SOUNAM(SOUPNT(SOUADM(1,ISOUP))))
         LEN2=GVFLEN(TEXT)
         IF (LEN1.NE.LEN2) GOTO 10
         IF (SOUNAM(SOUPNT(SOUADM(1,ISOUP)))(1:LEN1).EQ.
     +        TEXT(1:LEN2)) THEN
            USESOU(ISOUP)=ISOUP
            FOUND=.TRUE.
         END IF
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVALL



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP
      LOGICAL       WIFISR







      CALL GVSIT0 (USESOU,MAXMOL)



      DO 10 ISOUP=1,NUMSOU
         IF (WIFISR(ISOUP)) USESOU(ISOUP)=ISOUP
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVALLNOT

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP
      LOGICAL       WIFISR





      DO 10 ISOUP=1,NUMSOU
         IF (WIFISR(ISOUP)) USESOU(ISOUP)=0
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVRNG (IAA,JAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP, IAA, JAA
      LOGICAL       WIFIRI







      IF (.NOT.WIFIRI(IAA)) THEN
         CALL GVSTTI ('?M3902',IAA)
         CALL GVSKIL
         GOTO 998
      END IF
      IF (.NOT.WIFIRI(JAA)) THEN
         CALL GVSTTI ('?M3902',JAA)
         CALL GVSKIL
         GOTO 998
      END IF



      CALL GVSIT0 (USESOU,MAXMOL)



      IF (JAA.GE.IAA) THEN
         DO 10 ISOUP=CHAINN(2,IAA),CHAINN(2,JAA)
            USESOU(ISOUP)=ISOUP
   10    CONTINUE
      ELSE
         DO 20 ISOUP=CHAINN(2,JAA),CHAINN(2,IAA)
            USESOU(ISOUP)=ISOUP
   20    CONTINUE
      END IF



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ENVNOWAT



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       ISOUP
      LOGICAL       WIFISW







      CALL GVSIT0 (USESOU,MAXMOL)



      DO 10 ISOUP=1,NUMSOU
         IF (.NOT.WIFISW(ISOUP)) USESOU(ISOUP)=ISOUP
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVREMWAT

















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







      DO 10 ISOU=1,NUMSOU
         ISOUP=USESOU(ISOU)
         IF (ISOUP.GT.0) THEN
            IF (WIFISW(ISOUP)) USESOU(ISOU)=0
         END IF
   10 CONTINUE





      RETURN
      END
      SUBROUTINE ENVTOT



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'







      CALL GVSITI (USESOU,NUMSOU)





      RETURN
      END
      SUBROUTINE ENVIAA (IAA)



















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IAA
      LOGICAL       WIFIRI







      IF (.NOT.WIFIRI(IAA)) THEN
         CALL GVSTTB ('?M0107')
         CALL GVSIT0 (USESOU,MAXMOL)
         USESOU(1)=1
         GOTO 998
      END IF



      CALL GVSIT0 (USESOU,MAXMOL)
      USESOU(CHAINN(2,IAA))=CHAINN(2,IAA)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE ENVADDIAA (IAA)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IAA
      LOGICAL       WIFIRI







      IF (.NOT.WIFIRI(IAA)) THEN
         CALL GVSTTB ('?M0107')
         GOTO 998
      END IF



      USESOU(CHAINN(2,IAA))=CHAINN(2,IAA)



  998 CONTINUE


      RETURN
      END
      SUBROUTINE DO_ENV (IFT1,IERR)

















      IMPLICIT      NONE
      INCLUDE       'BIGINC.INC'
      INCLUDE       'ENVIRO.INC'
      INTEGER       IFT1, GVFFIP, IERR
      LOGICAL       GVFIBN







      IF (.NOT.GVFIBN(IFT1,0,NUMAAT)) THEN
         CALL GVSTTI ('?ACCB11',IFT1)
         CALL ENVINI
         USESOU(1)=1
         IERR=0
         GOTO 998
      END IF



      IERR=0




      CALL GETUSESOU ('?ACCEN2A','?M1288',IERR)
      IF (IERR.NE.0) GOTO 998



      IF (WIFPAR(461).EQ.0.AND.IFT1.GT.0) THEN
         IF (GVFFIP(USESOU,CHAINN(2,IFT1),MAXMOL).EQ.0) THEN
            USESOU(CHAINN(2,IFT1))=CHAINN(2,IFT1)
         END IF
      END IF



  998 CONTINUE


      RETURN
      END
