!--------------------------------------------------------------------------------------------------
!  DOXYGEN
!> @brief READ CO2 TRANSMISSION DATA FROM UNIT (NFILE) FOR NEW VERTICAL COORDINATE TESTS THESE 
!! ARRAYS USED TO BE IN BLOCK DATA.
!> @details THE FOLLOWING COMMON BLOCKS CONTAIN PRETABULATED CO2 TRANSMISSION FUNCTIONS, EVALUATED
!! USING THE METHODS OF FELS AND SCHWARZKOPF (1981) AND SCHWARZKOPF AND FELS (1985).
!! THE 2-DIMENSIONAL ARRAYS ARE CO2 TRANSMISSION FUNCTIONS AND THEIR DERIVATIVES FROM 109-LEVEL 
!! LINE-BY-LINE CALCULATIONS MADE USING THE 1982 MCCLATCHY TAPE (12511 LINES), CONSOLIDATED, 
!! INTERPOLATED TO THE NMC MRF VERTICAL COORDINATTE, AND RE-CONSOLIDATED TO A 200 CM-1 BANDWIDTH. 
!! THE INTERPOLATION METHOD IS DESCRIBED IN SCHWARZKOPF AND FELS (J.G.R., 1985).
!!
!> THE 1-DIM ARRAYS ARE CO2 TRANSMISSION FUNCTIONS AND THEIR DERIVATIVES FOR TAU(I,I+1), I=1, L, 
!! WHERE THE VALUES ARE NOT OBTAINED BY QUADRATURE,BUT ARE THE ACTUAL TRANSMISSIVITIES, ETC, 
!! BETWEEN A PAIR OF PRESSURES.
!! THESE USED ONLY FOR NEARBY LAYER CALCULATIONS INCLUDING QH2O.
!!
!> THE WEIGHTING FUNCTION GTEMP = P(K) ** 0.2 * (1. + P(K) / 30000.) ** 0.8 / 1013250.,
!! WHERE P(K) = PRESSURE, NMC MRF(NEW) L18 DATA LEVELS FOR PSTAR = 1013250.
!!
!> STEMP IS US STANDARD ATMOSPHERES, 1976, AT DATA PRESSURE LEVELS USING NMC MRF SIGMAS, 
!! WHERE PSTAR = 1013.25 MB (PTZ PROGRAM)
!!
!> MODULE CO2BD3 CONTAINS CO2 TRANSMISSION FUNCTIONS AND TEMPERATURE AND PRESSURE DERIVATIVES FOR 
!! THE 560-800 CM-1 BAND. 
!! ALSO INCLUDED ARE THE STANDARD TEMPERATURES AND THE WEIGHTING FUNCTION. THESE DATA ARE IN BLOCK
!! DATA BD3:
!!
!! @arg @c CO251  - TRANSMISSION FCTNS FOR T0 (STD. PROFILE) WITH P(SFC)=1013.25 MB
!! @arg @c CO258  - TRANSMISSION FCTNS. FOR T0 (STD. PROFILE)WITH P(SFC)= 810 MB
!! @arg @c CDT51  - FIRST TEMPERATURE DERIVATIVE OF CO251
!! @arg @c CDT58  - FIRST TEMPERATURE DERIVATIVE OF CO258
!! @arg @c C2D51  - SECOND TEMPERATURE DERIVATIVE OF CO251
!! @arg @c C2D58  - SECOND TEMPERATURE DERIVATIVE OF CO251
!! @arg @c CO2M51 - TRANSMISSION FCTNS FOR T0 FOR ADJACENT PRESSURE LEVELS, WITH NO PRESSURE 
!!                  QUADRATURE. USED FOR NEARBY LAYER COMPUTATIONS. P(SFC)=1013.25 MB
!! @arg @c CO2M58 - SAME AS CO2M51,WITH P(SFC)= 810 MB
!! @arg @c CDTM51 - FIRST TEMPERATURE DERIVATIVE OF CO2M51
!! @arg @c CDTM58 - FIRST TEMPERATURE DERIVATIVE OF CO2M58
!! @arg @c C2DM51 - SECOND TEMPERATURE DERIVATIVE OF CO2M51
!! @arg @c C2DM58 - SECOND TEMPERATURE DERIVATIVE OF CO2M58
!! @arg @c STEMP  - STANDARD TEMPERATURES FOR MODEL PRESSURE LEVEL STRUCTURE WITH P(SFC)=1013.25 MB
!! @arg @c GTEMP  - WEIGHTING FUNCTION FOR MODEL PRESSURE LEVEL STRUCTURE WITH P(SFC)=1013.25 MB.
!!
!> THE FOLLOWING ARE STILL IN BLOCK DATA
!!
!! @arg @c B0 - TEMP. COEFFICIENT USED FOR CO2 TRANS. FCTN. CORRECTION FOR T(K). (SEE REF. 4 AND BD3)
!! @arg @c B1 - TEMP. COEFFICIENT, USED ALONG WITH B0
!! @arg @c B2 - TEMP. COEFFICIENT, USED ALONG WITH B0
!! @arg @c B3 - TEMP. COEFFICIENT, USED ALONG WITH B0
!> @author ORIGINATOR - K.CAMPANA 
!> @date 90-03-?? \n
!> @author LUCCI 
!> @date 18-03-20 \n
!> @version V1.1.0
!> @details MODERNIZATION OF THE CODE, INCLUDING:
!!                      * F77 TO F90/F95
!!                      * INDENTATION & UNIFORMIZATION CODE
!!                      * REPLACEMENT OF COMMONS BLOCK FOR MODULES
!!                      * DOCUMENTATION WITH DOXYGEN
!!                      * OPENMP FUNCTIONALITY
!<
!> @details <b>Use Module:</b> 
!! @arg @c CO2DTA
!! @arg @c F77KINDS
!! @arg @c HCON
!! @arg @c MPPSTAFF
!! @arg @c PARMETA
!> @details <b>Driver:</b> 
!! @arg @c GRADFS
!> @details <b>Calls:</b>
!! @arg @c TABLE
!<
!--------------------------------------------------------------------------------------------------
    SUBROUTINE CONRAD
!-------------------------------------------------------------------------------------------------- 
! SUBROUTINE CONRAD 
!
! SUBROUTINE: CONRAD - READ CO2 TRANSMISSION DATA FROM UNIT (NFILE) FOR NEW VERTICAL COORDINATE 
!                      TESTS THESE ARRAYS USED TO BE IN BLOCK DATA.     
! PROGRAMMER: K.CAMPANA
! ORG: ?????
! DATE: 90-03-??
!
! ABSTRACT:
! CO2 DATA TABLES FOR USER'S VERTICAL COORDINATE.
!
! THE FOLLOWING COMMON BLOCKS CONTAIN PRETABULATED CO2 TRANSMISSION FUNCTIONS, EVALUATED USING THE
! METHODS OF FELS AND SCHWARZKOPF (1981) AND SCHWARZKOPF AND FELS (1985).
! THE 2-DIMENSIONAL ARRAYS ARE CO2 TRANSMISSION FUNCTIONS AND THEIR DERIVATIVES FROM 109-LEVEL 
! LINE-BY-LINE CALCULATIONS MADE USING THE 1982 MCCLATCHY TAPE (12511 LINES), CONSOLIDATED, 
! INTERPOLATED TO THE NMC MRF VERTICAL COORDINATTE, AND RE-CONSOLIDATED TO A 200 CM-1 BANDWIDTH. 
! THE INTERPOLATION METHOD IS DESCRIBED IN SCHWARZKOPF AND FELS (J.G.R., 1985).
!
! THE 1-DIM ARRAYS ARE CO2 TRANSMISSION FUNCTIONS AND THEIR DERIVATIVES FOR TAU(I,I+1), I=1, L, 
! WHERE THE VALUES ARE NOT OBTAINED BY QUADRATURE,BUT ARE THE ACTUAL TRANSMISSIVITIES, ETC, 
! BETWEEN A PAIR OF PRESSURES.
! THESE USED ONLY FOR NEARBY LAYER CALCULATIONS INCLUDING QH2O.
!
! THE WEIGHTING FUNCTION GTEMP = P(K) ** 0.2 * (1. + P(K) / 30000.) ** 0.8 / 1013250.,
! WHERE P(K) = PRESSURE, NMC MRF(NEW) L18 DATA LEVELS FOR PSTAR = 1013250.
!
! STEMP IS US STANDARD ATMOSPHERES, 1976, AT DATA PRESSURE LEVELS USING NMC MRF SIGMAS, 
! WHERE PSTAR = 1013.25 MB (PTZ PROGRAM)
!
! MODULE CO2BD3 CONTAINS CO2 TRANSMISSION FUNCTIONS AND TEMPERATURE AND PRESSURE DERIVATIVES FOR 
! THE 560-800 CM-1 BAND. 
! ALSO INCLUDED ARE THE STANDARD TEMPERATURES AND THE WEIGHTING FUNCTION. THESE DATA ARE IN BLOCK
! DATA BD3:
!
! CO251  - TRANSMISSION FCTNS FOR T0 (STD. PROFILE) WITH P(SFC)=1013.25 MB
! CO258  - TRANSMISSION FCTNS. FOR T0 (STD. PROFILE)WITH P(SFC)= 810 MB
! CDT51  - FIRST TEMPERATURE DERIVATIVE OF CO251
! CDT58  - FIRST TEMPERATURE DERIVATIVE OF CO258
! C2D51  - SECOND TEMPERATURE DERIVATIVE OF CO251
! C2D58  - SECOND TEMPERATURE DERIVATIVE OF CO251
! CO2M51 - TRANSMISSION FCTNS FOR T0 FOR ADJACENT PRESSURE LEVELS, WITH NO PRESSURE QUADRATURE. 
!          USED FOR NEARBY LAYER COMPUTATIONS. P(SFC)=1013.25 MB
! CO2M58 - SAME AS CO2M51,WITH P(SFC)= 810 MB
! CDTM51 - FIRST TEMPERATURE DERIVATIVE OF CO2M51
! CDTM58 - FIRST TEMPERATURE DERIVATIVE OF CO2M58
! C2DM51 - SECOND TEMPERATURE DERIVATIVE OF CO2M51
! C2DM58 - SECOND TEMPERATURE DERIVATIVE OF CO2M58
! STEMP  - STANDARD TEMPERATURES FOR MODEL PRESSURE LEVEL STRUCTURE WITH P(SFC)=1013.25 MB
! GTEMP  - WEIGHTING FUNCTION FOR MODEL PRESSURE LEVEL STRUCTURE WITH P(SFC)=1013.25 MB.
!
! THE FOLLOWING ARE STILL IN BLOCK DATA
!
! B0 - TEMP. COEFFICIENT USED FOR CO2 TRANS. FCTN. CORRECTION FOR T(K). (SEE REF. 4 AND BD3)
! B1 - TEMP. COEFFICIENT, USED ALONG WITH B0
! B2 - TEMP. COEFFICIENT, USED ALONG WITH B0
! B3 - TEMP. COEFFICIENT, USED ALONG WITH B0
!
! PROGRAM HISTORY LOG:
! 00-01-20  K.CAMPANA - ORIGINATOR
! 18-01-15  LUCCI     - MODERNIZATION OF THE CODE, INCLUDING:
!                       * F77 TO F90/F95
!                       * INDENTATION & UNIFORMIZATION CODE
!                       * REPLACEMENT OF COMMONS BLOCK FOR MODULES
!                       * DOCUMENTATION WITH DOXYGEN
!                       * OPENMP FUNCTIONALITY
!
! INPUT ARGUMENT LIST:
! NONE
!
! OUTPUT ARGUMENT LIST:
! NONE 
!
! INPUT/OUTPUT ARGUMENT LIST:
! NONE 
!
! USE MODULES: CO2DTA
!              F77KINDS
!              HCON
!              MPPSTAFF
!              PARMETA
!
! DRIVER     : GRADFS
!
! CALLS      : TABLE
!--------------------------------------------------------------------------------------------------
    USE CO2DTA
    USE F77KINDS
    USE HCON
    USE MPPSTAFF
    USE PARMETA
!
    IMPLICIT NONE
!
    INTEGER(KIND=I4)                                                                            ::&
    & I       , II1     , II2     , J       , K       , KK      , N       , RSIZE
!
    INTEGER(KIND=I4)    , PARAMETER :: IX   = 2 * IM - 1
    INTEGER(KIND=I4)    , PARAMETER :: KX   = LM
    INTEGER(KIND=I4)    , PARAMETER :: KP   = KX + 1
    INTEGER(KIND=I4)    , PARAMETER :: LP12 = LP1 * LP1
!
    REAL   (KIND=R4)    , DIMENSION(LP1, 2)                                                     ::&
    & SGTMP
!
    REAL   (KIND=R4)    , DIMENSION(LM, 6)                                                      ::&
    & CO21D
!
    REAL   (KIND=R4)    , DIMENSION(LP1, LP1, 6)                                                ::&
    & CO22D
!
    REAL   (KIND=R4)    , DIMENSION(LP1, 6)                                                     ::&
    & CO21D3  , CO21D7
!
    REAL   (KIND=R4)    , DIMENSION(LP12)                                                       ::&
    & DATA2   
!
    INTEGER(KIND=I4)    , DIMENSION(3)                                                          ::&
    & RSZE
!
    INTEGER(KIND=I4)                                                                            ::&
    & NFILE
!
    CHARACTER(LEN=180)                                                                          ::&
    & CFILE
!------------------------------------------------------------------------------------------------
! B0,B1,B2,B3 ARE COEFFICIENTS USED TO CORRECT FOR THE USE OF 250K IN THE PLANCK FUNCTION USED IN
! EVALUATING PLANCK-WEIGHTED CO2 TRANSMISSION FUNCTIONS. (SEE REF. 4)
!------------------------------------------------------------------------------------------------
    B0 = -.51926410E-4
    B1 = -.18113332E-3
    B2 = -.10680132E-5
    B3 = -.67303519E-7
!
    NFILE = 100
!---------------------------------------------------
! THE ABOVE NOT USED IN CURRENT VERSION OF RADIATION
!---------------------------------------------------
!
!--------------------------------------------------
! BEGIN HERE TO GET CONSTANTS FOR RADIATION PACKAGE
!--------------------------------------------------
!
!----------------
! CFILE='CO2.DAT'
!----------------
    CFILE = 'co2.dat'
!
    OPEN(UNIT=NFILE, FORM='UNFORMATTED', STATUS='OLD', FILE=CFILE)
!
    REWIND NFILE
!----------------------------------------------------------------------
! READ IN PRE-COMPUTED CO2 TRANSMISSION DATA AND CONVERT TO CYBER WORDS
!----------------------------------------------------------------------
    RSZE(1) = LP1
    RSZE(2) = LM
    RSZE(3) = LP1 * LP1
!
    RSIZE = RSZE(1)
!
    DO KK=1,2
        READ(NFILE) (SGTMP(I,KK), I=1,RSIZE)
    END DO
!
      RSIZE = RSZE(2)
!
    DO KK=1,6
        READ(NFILE) (CO21D(I,KK), I=1,RSIZE)
    END DO
!
      RSIZE = RSZE(3)
!
    DO KK=1,6
        READ(NFILE) (DATA2(I),I=1, RSIZE)
!
        N = 0
!
        DO II1=1,LP1
            DO II2=1,LP1
                N = N + 1
                CO22D(II1,II2,KK) = DATA2(N)
            END DO
        END DO
!
    END DO
!
      RSIZE = RSZE(1)
!
    DO KK=1,6
        READ(NFILE) (CO21D3(I,KK), I=1,RSIZE)
    END DO
!
    DO KK=1,6
      READ(NFILE) (CO21D7(I,KK), I=1,RSIZE)
    END DO
!
    REWIND NFILE
!
    DO K=1,LP1
        STEMP(K) = SGTMP(K,1)
        GTEMP(K) = SGTMP(K,2)
    END DO
!
    DO K=1,LM
        CDTM51(K) = CO21D(K,1)
        CO2M51(K) = CO21D(K,2)
        C2DM51(K) = CO21D(K,3)
        CDTM58(K) = CO21D(K,4)
        CO2M58(K) = CO21D(K,5)
        C2DM58(K) = CO21D(K,6)
    END DO
!
    DO J=1,LP1
        DO I=1,LP1
            CDT51(I,J) = CO22D(I,J,1)
            CO251(I,J) = CO22D(I,J,2)
            C2D51(I,J) = CO22D(I,J,3)
            CDT58(I,J) = CO22D(I,J,4)
            CO258(I,J) = CO22D(I,J,5)
            C2D58(I,J) = CO22D(I,J,6)
        END DO 
    END DO
!
    DO K=1,LP1
        CDT31(K) = CO21D3(K,1)
        CO231(K) = CO21D3(K,2)
        C2D31(K) = CO21D3(K,3)
        CDT38(K) = CO21D3(K,4)
        CO238(K) = CO21D3(K,5)
        C2D38(K) = CO21D3(K,6)
    END DO 
!
    DO K=1,LP1
        CDT71(K) = CO21D7(K,1)
        CO271(K) = CO21D7(K,2)
        C2D71(K) = CO21D7(K,3)
        CDT78(K) = CO21D7(K,4)
        CO278(K) = CO21D7(K,5)
        C2D78(K) = CO21D7(K,6)
    END DO
!
    IF (MYPE == 0) PRINT 66, NFILE
 66 FORMAT (1H ,'----READ CO2 TRANSMISSION FUNCTIONS FROM UNIT ', I3)
! 
    CLOSE (NFILE)
!-------------------------------
! DEFINE TABLES FOR LW RADIATION
!-------------------------------
    CALL TABLE
!
    RETURN
!
    END SUBROUTINE CONRAD
