!+ Subroutine to write continuum transmissions to a file.
!
! Method:
!	Straightforward.
!
! 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 WRITE_CONTINUUM(TRANS_TYPE
     &   , I_SET, LENGTH_SET, BAND_SET, INDEX_CONTINUUM
     &   , P_SET, T_SET
     &   , U_SET, DENSITY_BROAD, TRANS_SET
     &   , WAVE_LENGTH_SHORT_SET, WAVE_LENGTH_LONG_SET
     &   , N_PER_TRANS_RECORD, I_FIRST_RECORD
     &   )
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/dimensions_pp.ucf'
      INCLUDE 'incl/def_pp_io.icf'
      INCLUDE 'incl/continuum.pcf'
      INCLUDE 'incl/continuum.ncf'
      INCLUDE 'incl/file_type.pcf'
!
!     DUMMY ARGUMENTS.
      CHARACTER	!, INTENT(IN)
     &     TRANS_TYPE*4
!             TYPE OF TRANSMITTANCE
      INTEGER	!, INTENT(INOUT)
     &     I_FIRST_RECORD
!             NUMBER OF FIRST RECORD
     &   , N_PER_TRANS_RECORD
!             NUMBER OF VALUES IN A RECORD
      INTEGER	!, INTENT(IN)
     &     BAND_SET
!             ARRAY OF BANDS
     &   , LENGTH_SET
!             LENGTHS OF THE SETS
     &   , INDEX_CONTINUUM
!             TYPE OF CONTINUUM
     &   , I_SET
!             ORDINAL OF SET
      REAL*8	!, INTENT(IN)
     &     P_SET
!             PRESSURES
     &   , T_SET
!             TEMPERATURES
     &   , U_SET(NPD_AMOUNT)
!             AMOUNT OF WATER VAPOUR
     &   , DENSITY_BROAD(NPD_AMOUNT)
!             DENSITY OF BROADENER
     &   , TRANS_SET(NPD_AMOUNT)
!             TRANSMITTANCES
     &   , WAVE_LENGTH_SHORT_SET
!             SHORTER WAVELENGTHS
     &   , WAVE_LENGTH_LONG_SET
!             LONGER WAVELENGTHS
!
!     LOCAL VARIABLES
      INTEGER
     &     I
!             LOOP VARIABLE
     &   , J
!             LOOP VARIABLE
     &   , N_RECORD
!             NUMBER OF RECORDS
     &   , N_EXCESS
!             NUMBER OF EXCESS DATA
!
!     SET NAMES OF CONTINUA.
      INCLUDE 'incl/continuum_names.dcf'
!
!
      WRITE(IU_C_TRANSMISSION_SUMMARY, '(A13, I5, //)') '*FILE TYPE = '
     &   , IT_FILE_CONT_TRANS_SUMMARY
      WRITE(IU_C_TRANSMISSION_SUMMARY, '(A10, I5, 3X, A14, I6)')
     &   'DATA SET: ', I_SET, 'FIRST RECORD: ', I_FIRST_RECORD
      WRITE(IU_C_TRANSMISSION_SUMMARY, '(A4, 1X, A/)')
     &   TRANS_TYPE, 'TRANSMITTANCE AGAINST AMOUNT OF ABSORBER:'
      WRITE(IU_C_TRANSMISSION_SUMMARY, '(A15, 1X, A20, 2X, A6, 1X, I5)')
     &   'CONTINUUM TYPE:', NAME_CONTINUUM(INDEX_CONTINUUM)
     &   , 'INDEX:', INDEX_CONTINUUM
      WRITE(IU_C_TRANSMISSION_SUMMARY
     &   , '(A13, 1X, 1PE10.3, 1X, A2, 2X, A17, 1X, 1PE10.3, 1X, A2)')
     &   'AT PRESSURE =', P_SET, 'Pa'
     &   , 'AND TEMPERATURE =', T_SET, 'K.'
      WRITE(IU_C_TRANSMISSION_SUMMARY
     &   , '(A8, I5, A1, 3X, 1PE10.3, A4, 2X, 1PE10.3, A2, /)')
     &   'IN BAND ', BAND_SET, ':'
     &   , WAVE_LENGTH_SHORT_SET, 'm TO', WAVE_LENGTH_LONG_SET, 'm.'
      WRITE(IU_C_TRANSMISSION_SUMMARY, '(I5, 1X, A)' ) LENGTH_SET
     &   , 'POINTS OF DATA.'
      WRITE(IU_C_TRANSMISSION_SUMMARY, '(6X)')
!
!     WRITE THE ACTUAL DATA VALUES.
      N_RECORD=LENGTH_SET/N_PER_TRANS_RECORD
      DO I=1, N_RECORD
         WRITE(IU_C_TRANSMISSION, REC=I_FIRST_RECORD+(I-1))
     &      (U_SET(J), DENSITY_BROAD(J), TRANS_SET(J)
     &      , J=N_PER_TRANS_RECORD*(I-1)+1, N_PER_TRANS_RECORD*I)
      ENDDO
!     CHECK WHETHER ANY EXCESS REMAINS TO BE WRITTEN.
      N_EXCESS=LENGTH_SET-N_RECORD*N_PER_TRANS_RECORD
      IF (N_EXCESS.GT.0) THEN
         WRITE(IU_C_TRANSMISSION, REC=I_FIRST_RECORD+N_RECORD)
     &      (U_SET(J), DENSITY_BROAD(J), TRANS_SET(J)
     &      , J=LENGTH_SET-N_EXCESS+1, LENGTH_SET)
         N_RECORD=N_RECORD+1
      ENDIF
      I_FIRST_RECORD=I_FIRST_RECORD+N_RECORD
!
!
      RETURN
      END
