      SUBROUTINE TYPE58(TIME,XIN,OUT,T,DTDT,PAR,INFO,ICNTRL,*)
C      SUBROUTINE DIVISIM (M1Lvg,M2Lvg,MEnt,ErrStat)
C***********************************************************************
C*    Copyright ASHRAE.  Toolkit for HVAC System Energy Calculations
C***********************************************************************
C*    SUBROUTINE:             DIVISIM
C*
C*    LANGUAGE:               FORTRAN 77
C*
C*    PURPOSE:                Calculate entering flow rate to a flow
C*                            diverter from leaving flow rates.
C***********************************************************************
C*    INPUT VARIABLES  DESCRIPTION(UNITS)                      SAMPLE VALUES
C*    XIN(1)  M1Lvg  Mass flow rate of leaving stream 1(kg/s)      3.0
C*    XIN(2)  M2Lvg  Mass flow rate of leaving stream 2(kg/s)      2.0
C*
C*    OUTPUT VARIABLES
C*    OUT(1)   MEnt  Mass flow rate of entering stream(kg/s)       5.0
C*    OUT(2) ErrStat Error flag (0=ok,1=error)(-)
C***********************************************************************
C     MAJOR RESTRICTION:      None
C
C     DEVELOPER:              Shauna Gabel
C                             Michael J. Brandemuehl, PhD, PE
C                             University of Colorado at Boulder
C
C     DATE:                   January 1, 1992
C
C     INCLUDE FILES:          None
C     SUBROUTINES CALLED:     None
C     FUNCTIONS REQUIRED:     None
C
C     REVISION HISTORY:       None
C
C     REFERENCE:              None
C***********************************************************************

      INTEGER ErrStat, INFO, IOPT, NI, NP, ND
      DOUBLE PRECISION XIN, OUT
      DIMENSION XIN(2),OUT(2), INFO(15)
	CHARACTER*3 YCHECK(2), OCHECK(2)

	DATA YCHECK/'MF2','MF2'/
	DATA OCHECK/'MF2','DM1'/

      M1LVG = XIN(1)
      M2LVG = XIN(2)

      ErrStat = 0
	IOPT	= -1
	NI		= 2		!CORRECT NUMBER OF INPUTS
	NP		= 0		!CORRECT NUMBER OF PARAMETERS
	ND		= 0		!CORRECT NUMBER OF DERIVATIVES

	IF(INFO(7).EQ.-1) THEN
		CALL TYPECK(IOPT,INFO,NI,NP,ND)
C	 CHECKS TO SEE IF USER'S INFO MATCHES CORRECT NUMBERS
		CALL RCHECK(INFO,YCHECK,OCHECK)
C	 CHECKS TO SEE IF INPUT AND OUTPUT UNITS MATCH
	ENDIF

C1*** Calculate the mass flow rate of entering stream.

      MEnt = M1Lvg+M2Lvg

      OUT(1) = MENT
      OUT(2) = ERRSTAT
      RETURN 1
      END
