C
C User specifies non-irrigation, NI, and irrigation, I, season lengths.  
C Months are entered as 1-12 for January-December.  NIBEG and NIEND are the 
C first and last months of the NI season; IBEG and IEND are the first and last 
C months of the I season, respectively.  NICNT and ICNT are the number of 
C months per NI and I season.
C  
      PROGRAM POSTMAIN
C      
      INTEGER NIBEG,NIEND,IBEG,IEND,IEND9,NICNT,ICNT,ICNT9
C        
C User input.  Historically, NIBEG=11, NIEND=2, IBEG=3, IEND=10.  If the user
C chooses year-round irrigation, use January as the non-irrigation season to 
C allow current MODFLOW set-up to be used.  If there is a non-irrigation 
C season, it must begin in October or later.  Send error message otherwise.
C
      WRITE(*,*) 'Enter 1 for Historic Simulation, 0 for Forecasting Sim
     !ulation: '
      READ(*,*) IHIST
  10  WRITE(*,*) 'Enter months as 1-12 for January-December.'
      WRITE(*,*)
      WRITE(*,*) 'Beginning month of the non-irrigation season'
      WRITE(*,*) 'Non-irrigation season must be at least 1 month in leng
     !th): '
      READ(*,*) NIBEG
      IF (NIBEG.LT.10 .AND. NIBEG .GT. 3) THEN
        WRITE(*,*)
        WRITE(*,*) 'THE NON-IRRIGATION SEASON MUST BEGIN IN OR AFTER OCT
     'OBER.'
        WRITE(*,*) 'PLEASE RE-ENTER DATA.'
        WRITE(*,*)
        GOTO 10
      ENDIF
      WRITE(*,*) 'Ending month of the non-irrigation season: '
      READ(*,*) NIEND
      WRITE(*,*) 'Beginning month of the irrigation season: '
      READ(*,*) IBEG
      IF (IBEG.EQ.0) THEN
        WRITE(*,*) 
        WRITE(*,*) 'AN IRRIGATION SEASON MUST BE SPECIFIED.'
        WRITE(*,*) 'PLEASE RE-ENTER DATA.'
        WRITE(*,*)
        GOTO 10
      ENDIF
      WRITE(*,*) 'Ending month of the irrigation season: '
      READ(*,*) IEND
C
C Calculate non-irrigation and irrigation season lengths.  BESTSM uses water      
C years -- data begins in month 10 and ends in month 9.  Use IEND 9 and ICNT9 
C variables to calculate the months of BESTSM data available for the irrigation
C season of the last year if it ends after month 9.
C
      IF(NIBEG.LE.NIEND) THEN
        NICNT = NIEND - NIBEG + 1
      ELSEIF(NIBEG.GT.NIEND) THEN
        NICNT = 12 - NIBEG + 1 + NIEND
      ENDIF
C
      IF(IBEG.LE.IEND) THEN
        ICNT = IEND - IBEG + 1
        IF(IEND.GT.9) THEN 
          IEND9 = 9
          ICNT9 = IEND9 - IBEG + 1
        ELSE
          IEND9 = IEND
          ICNT9 = ICNT
        ENDIF
      ELSEIF(IBEG.GT.IEND) THEN                                
        ICNT = 12 - IBEG + 1 + IEND
        IF(IEND.GT.9) THEN
          IEND9 = 9
          ICNT9 = IEND9 - IBEG + 1
        ELSE
          IEND9 = IEND
          ICNT9 = ICNT
        ENDIF
      ENDIF
C
C Check to make sure total season lengths add to one year.
C
      YEAR = NICNT + ICNT
      IF (YEAR.NE.12) THEN
        WRITE(*,*) 
        WRITE(*,*) 'NON-IRRIGATION AND IRRIGATION SEASON LENGTHS MUST AD
     'D UP TO 12 MONTHS.'  
        WRITE(*,*) 'PLEASE RE-ENTER DATA.'
        WRITE(*,*)
        GOTO 10
      ENDIF
C      
C Call MODBEST subroutine.
C

   20 CALL MODBEST(NIBEG,NIEND,IBEG,IEND,IEND9,NICNT,ICNT,ICNT9,IHIST)
C      
      END
 

