FUNCTION CONFLX,TE_6,WAVE,OPT,ERG=ERG,APPROX=APPROX

;   Convert TE_6 and WAVE to 1-d vectors:

    TE_x = Te_6*replicate(1.,n_elements(Te_6)) & TE_x(0) = TE_x(0:*)
    WAVV = WAVE*replicate(1.,n_elements(WAVE)) & WAVV(0) = WAVV(0:*)

    if N_elements(OPT) eq 0 then begin
       OPT = 2
       if keyword_set(approx) then OPT = 0      ; Keywords do not override
       if keyword_set(erg)    then OPT = OPT + 1    ;- OPT if it is supplied
        endif
    if (OPT and 2) eq 2 then begin

;   Mean gaunt factor Gaunt:    Gaunt = Mean Gaunt factor

;   Use the new approximation:
      nx = n_elements(Te_x) & ny = n_elements(WAVV)
      Gaunt = fltarr(nx,ny)             ; Set up output variable
      GAUNT = acgaunt(wavv,te_x)    ; call ACGAUNT directly
      if ny eq 1 then Gaunt = Gaunt(0:*)        ; Collapse 2-d array if
        endif else begin                ;-  only 1-d input.

;   Use the old approximation  (Eq (3) from Paper V)
      Gaunt1= 27.83*(Te_x+0.65)^(-1.33) 
      Gaunt2= 0.15 * ( Te_x^0.422 # wavv^0.34 )
      Gaunt1= Gaunt1 # replicate(1.,n_elements(wavv)); Make 2-d if necessary
      Gaunt = Gaunt1 + Gaunt2
    endelse
;  
;   gf=Gaunt         ; for a test purpose
;
;   Y  Factor (the Boltzman factor)
    Y = 143.9/(TE_x#wavv)       ; wavv in Ang, TE_x in MK

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;   Flux calculation:  (photons sec-1 A-1)
    if (OPT and 1) eq 0 then begin
; This stuff ought to be done in logs, jmm 9/22/94
           clog = alog(2.051e28 * 5.034e7)
                
           FLUX =  exp(clog-Y) * Gaunt/(sqrt(TE_x)#wavv)
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;   Flux calculation:  (erg sec-1 A-1)
    endif else begin

           clog = alog(2.051e28)
           FLUX =  exp(clog-Y) * Gaunt/(sqrt(TE_x)#(wavv^2))
        endelse
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    IF N_ELEMENTS(TE_x) EQ 1 THEN FLUX = FLUX(0:*) ; Make (1,N) a (N) vector

    return, FLUX
    end