!+ Subroutine to remove neative continuum p-scalings.
!
! Method:
!       The exponent of the pressure-scaling of gaseous transmission
!        is examined, and if neagtive it is reset to 0.
!
! 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 REMOVE_NEGATIVE_GAS(N_BAND, N_BAND_ABSORB
     &   , INDEX_ABSORB, TYPE_ABSORB
     &   , I_SCALE_FNC, I_BAND_ESFT, SCALE_VECTOR
     &   )
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES
      INCLUDE 'incl/def_std_io.icf'
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/scale_fnc.pcf'
!
!     DUMMY ARGUMENTS.
      INTEGER	!, INTENT(IN)
     &     N_BAND
!             NUMBER OF BANDS
     &   , N_BAND_ABSORB(NPD_BAND)
!             NUMBER OF ABSORBERS IN BANDS
     &   , INDEX_ABSORB(NPD_SPECIES, NPD_BAND)
!             LIST OF ACTIVE ABSORBS
     &   , I_SCALE_FNC(NPD_BAND, NPD_SPECIES)
!             SCALING FUNCTIONS
     &   , I_BAND_ESFT(NPD_BAND, NPD_SPECIES)
!             NUMBER OF ESFT TERMS IN BAND
     &   , TYPE_ABSORB(NPD_SPECIES)
!             TYPES OF ABSORBERS
      REAL*8	!, INTENT(INOUT)
     &     SCALE_VECTOR(NPD_SCALE_VARIABLE, NPD_ESFT_TERM, NPD_BAND
     &        , NPD_SPECIES)
!             SCALING PARAMETERS FOR GASES
!
!     LOCAL VARIABLES.
      INTEGER
     &     I
!             LOOP VARIABLE
     &   , J
!             LOOP VARIABLE
     &   , K
!             LOOP VARIABLE
     &   , L
!             LOOP VARIABLE
!
!
!     LOOP THROUGH THE BANDS CHECKING THE SCALING DATA DEPENDING ON
!     THE SCALING FUNCTION USED.
      DO I=1, N_BAND
         DO K=1, N_BAND_ABSORB(I)
            J=INDEX_ABSORB(K, I)
            IF (I_SCALE_FNC(I, J).EQ.IP_SCALE_POWER_LAW) THEN
               DO L=1, I_BAND_ESFT(I, J)
                  IF (SCALE_VECTOR(1, L, I, J).LT.0.0D+00) THEN
                     WRITE(IU_STDOUT, '(A, I5, /A, I5, 3X, A, I5)')
     &                  'RESETTING PRESSURE SCALING IN BAND ', I
     &                  , 'FOR GAS ', TYPE_ABSORB(J)
     &                  , 'AND TERM ', L
                     WRITE(IU_STDOUT, '(A, 1PE10.3)') 'OLD SCALING WAS '
     &                  , SCALE_VECTOR(1, L, I, J)
                     SCALE_VECTOR(1, L, I, J)=0.0D+00
                  ENDIF
               ENDDO
            ELSE IF (I_SCALE_FNC(I, J).EQ.IP_SCALE_POWER_QUAD) THEN
               DO L=1, I_BAND_ESFT(I, J)
                  IF (SCALE_VECTOR(1, L, I, J).LT.0.0D+00) THEN
                     WRITE(IU_STDOUT, '(A, I5, /A, I5, 3X, A, I5)')
     &                  'RESETTING PRESSURE SCALING IN BAND ', I
     &                  , 'FOR GAS ', J
     &                  , 'AND TERM ', L
                     WRITE(IU_STDOUT, '(A, 1PE10.3)') 'OLD SCALING WAS '
     &                  , SCALE_VECTOR(1, L, I, J)
                     SCALE_VECTOR(1, L, I, J)=0.0D+00
                  ENDIF
               ENDDO
            ELSE IF (I_SCALE_FNC(I, J).EQ.IP_SCALE_DOPPLER_QUAD) THEN
               DO L=1, I_BAND_ESFT(I, J)
                  IF (SCALE_VECTOR(1, L, I, J).LT.0.0D+00) THEN
                     WRITE(IU_STDOUT, '(A, I5, /A, I5, 3X, A, I5)')
     &                  'RESETTING PRESSURE SCALING IN BAND ', I
     &                  , 'FOR GAS ', J
     &                  , 'AND TERM ', L
                     WRITE(IU_STDOUT, '(A, 1PE10.3)') 'OLD SCALING WAS '
     &                  , SCALE_VECTOR(1, L, I, J)
                     SCALE_VECTOR(1, L, I, J)=0.0D+00
                  ENDIF
               ENDDO
            ENDIF
         ENDDO
      ENDDO
!
      RETURN
      END
