!+ Subroutine to set amounts of gases interactively.
!
! Method:
!	The user sets the number of amounts to be used. For each
!	gas the user may elect to set data or omit the gas. If
!	data for the gas are to be generated, minium and maximum
!	amounts of the absorber are needed.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE SET_AMOUNT_INTERACTIVE(IERR
     &   , N_ABSORB, TYPE_ABSORB, L_GEN_LOWTRAN
     &   , N_AMOUNT, L_GAS_REQUIRED, U
     &   )
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/gas_list.pcf'
      INCLUDE 'incl/gas_list.ncf'
      INCLUDE 'incl/error.pcf'
!
!     DUMMY ARGUMENTS.
      INTEGER	!, INTENT(OUT)
     &     IERR
!             ERROR FLAG
      INTEGER	!, INTENT(IN)
     &     N_ABSORB
!             NUMBER OF ABSORBERS
     &   , TYPE_ABSORB(NPD_SPECIES)
!             TYPE NUMBERS OF ABSORBERS
      LOGICAL	!, INTENT(IN)
     &     L_GEN_LOWTRAN(NPD_GASES)
!             FLAG TO GENERATE LOWTRAN DATA
      INTEGER	!, INTENT(OUT)
     &     N_AMOUNT
!             NUMBER OF AMOUNTS
      LOGICAL	!, INTENT(OUT)
     &     L_GAS_REQUIRED(NPD_SPECIES)
!             GASES FOR WHICH DATA ARE REQUIRED
      REAL*8	!, INTENT(OUT)
     &     U(NPD_GASES, NPD_AMOUNT)
!             AMOUNTS OF GASES
!
!     LOCAL VARIABLES.
!
      LOGICAL
     &     LOCK_CODE
!             LOGICAL TO FORBID INTERACTIVE LOOPING
      EXTERNAL
     &     LOCK_CODE
!
      CHARACTER
     &     CHAR_YN*1
!             INTERACTIVE RESPONSE
      INTEGER
     &     IGAS
!             TYPE NUMBER OF GAS
     &   , IOS
!             I/O ERROR FLAG
     &   , I
!             LOOP VARIABLE
     &   , J
!             LOOP VARIABLE
      REAL*8
     &     AMOUNT_MIN
!             MINIMUM AMOUNT
     &   , AMOUNT_MAX
!             MAXIMUM AMOUNT
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/gas_names.dcf'
!
!
      WRITE(IU_USER, '(/A)') 'ENTER THE NUMBER OF VALUES '
     &   //'OF AMOUNT AT WHICH DATA WILL BE GENERATED.'
4     READ(IU_STDIN, *, IOSTAT=IOS) N_AMOUNT
      IF (IOS.NE.0) THEN
         WRITE(IU_ERR, '(A)') '+++ ERRONEOUS RESPONSE.'
         IF (LOCK_CODE(.TRUE.)) THEN
            INCLUDE 'batch_error.finc'
         ELSE
            WRITE(IU_USER, '(A)') 'PLEASE RE-ENTER.'
            GOTO 4
         ENDIF
      ENDIF
      IF (N_AMOUNT.GT.NPD_AMOUNT) THEN
         WRITE(IU_ERR, '(A)')
     &      '+++ NUMBER SPECIFIED IS TOO LARGE'
         WRITE(IU_ERR, '(A21, I5)')
     &      'MAXIMUM PERMITTED IS ', NPD_AMOUNT
         IF (LOCK_CODE(.TRUE.)) THEN
               INCLUDE 'batch_error.finc'
         ELSE
            WRITE(IU_USER, '(A)') 'PLEASE RE-SPECIFY.'
            GOTO 4
         ENDIF
      ENDIF
!     DETERMINE THE ACTIVE GASES AND CONTINUA.
      DO I=1, N_ABSORB
         IF (L_GEN_LOWTRAN(I)) THEN
            IGAS=TYPE_ABSORB(I)
            WRITE(IU_USER, '(/A, 2A)') 'DO YOU REQUIRE DATA FOR '
     &         , NAME_ABSORB(IGAS), ' ? (Y/N)'
5           READ(IU_STDIN, *) CHAR_YN
            IF ( (CHAR_YN.EQ.'Y').OR.(CHAR_YN.EQ.'y') ) THEN
               L_GAS_REQUIRED(I)=.TRUE.
               IF (N_AMOUNT.GT.1) THEN
                  WRITE(IU_USER, '(/A, A)') 'ENTER THE MAXIMUM AND '
     &               //'MINIMUM AMOUNTS FOR ', NAME_ABSORB(IGAS)
6                 READ(IU_STDIN, *, IOSTAT=IOS)
     &               AMOUNT_MIN, AMOUNT_MAX
                  IF (IOS.NE.0) THEN
                     WRITE(IU_ERR, '(A)') '+++ ERRONEOUS RESPONSE.'
                     IF (LOCK_CODE(.TRUE.)) THEN
                        INCLUDE 'batch_error.finc'
                     ELSE
                        WRITE(IU_USER, '(A)') 'PLEASE RE-ENTER.'
                        GOTO 6
                     ENDIF
                  ENDIF
                  DO J=1, N_AMOUNT
                     U(IGAS, J)=EXP((1.0D+00/DBLE(N_AMOUNT-1))
     &                  *(DBLE(J-1)*LOG(AMOUNT_MAX)
     &                  +DBLE(N_AMOUNT-J)*LOG(AMOUNT_MIN)))
                  ENDDO
               ELSE
                  WRITE(IU_USER, '(/A, A)') 'ENTER THE '
     &               //'AMOUNT FOR ', NAME_ABSORB(IGAS)
7                 READ(IU_STDIN, *, IOSTAT=IOS) U(IGAS, 1)
                  IF (IOS.NE.0) THEN
                     WRITE(IU_ERR, '(A)') '+++ ERRONEOUS RESPONSE.'
                     IF (LOCK_CODE(.TRUE.)) THEN
                        INCLUDE 'batch_error.finc'
                     ELSE
                        WRITE(IU_USER, '(A)') 'PLEASE RE-ENTER.'
                        GOTO 7
                     ENDIF
                  ENDIF
               ENDIF
            ELSE IF ( (CHAR_YN.EQ.'N').OR.(CHAR_YN.EQ.'n') ) THEN
               L_GAS_REQUIRED(I)=.FALSE.
            ELSE
               WRITE(IU_ERR, '(A)') '+++ ERRONEOUS RESPONSE.'
               IF (LOCK_CODE(.TRUE.)) THEN
                  INCLUDE 'batch_error.finc'
               ELSE
                  WRITE(IU_USER, '(A)') 'PLEASE RE-ENTER.'
                  GOTO 5
               ENDIF
            ENDIF
         ENDIF
      ENDDO
!
!
      RETURN
      END
