!     Last change:  TEC  17 Mar 2000    4:18 pm
      PROGRAM DOS_LBRM
!
!     This program is a DOS program stub to enable use of the LBRM under DOS.
!     Set "cCons" to "0" to run the model in a production mode setting (a
!     simulation run).
!
!     Compile and link as follows (Lahey Fortran 95 used here):
!
!     lf95 ErrorProcessDOS.f95 -c
!     lf95 GLERLutil.f95       -c
!     lf95 LBRM.f95            -c
!     lf95 DOSmodel.f95        -c
!     lf95 DOSmodel.obj LBRM.obj GLERLutil.obj ErrorProcessDOS -out LBRM.EXE
!
      USE LBRM_Main
      IMPLICIT NONE
      REAL :: cCons
      REAL :: NSGlt, RUNlt, INTlt, GWFlt, UEVlt, LEVlt

      cCons = 0               ! will do a "simulation run" instead of a "calibration run"
      CALL AllocateFromDOS
      CALL ClearFilesOpen()
!
!     Read information from the LBRM.CFG file
!
      CALL ReadLBRMCFGfile             
      IF (ErrorLevel .NE. 0) GOTO 899
!
!     Read and store all inputs for LBRM.
!
      CALL InputLBRMdata(BC, DS, iBCD, Upper, Lower, Ground, Surface,     &
     &                   Snow, Tmx, TMn, Prc)
      IF (ErrorLevel .NE. 0) GOTO 899
!
!     Perform Large Basin Runoff Model calculations.
!
      CALL LBRM_Engine(cCons, BC, DS,                                     &
     &                 iBCD, Upper, Lower, Ground, Surface, Snow,         &
     &                 Tmx, TMn, Prc, OutRunoff, OutUszm,                 &
     &                 OutLszm, OutGzm, OutSs, OutSnw,                    &
     &                 NSGlt, RUNlt, INTlt, GWFlt, UEVlt, LEVlt)  ! variables presently unused
      IF (ErrorLevel .NE. 0) GOTO 899
!
!     Write model outputs to file.
!
      CALL WriteLBRMOutputFile(OutRunoff, OutUszm,  OutLszm, OutGzm,      &
     &                         OutSs, OutSnw)
      IF (ErrorLevel .EQ. 0) GOTO 898
  899 CALL PassMsg             ! Error Handling: WinHandle and ErrorMessage must have been set.
  898 CALL CloseAllFiles()     ! Final cleanup and return
      CALL DeallocateFromDOS
      END PROGRAM DOS_LBRM
