C+
C NAME:
C	SunFlux
C PURPOSE:
C	Reads file SUN10.DAT from Neckel & Labs 1984 Sol. Phys.
C	90, 205 and converts into photons/sq m/sec/band for a
C	solar-type star of V mag = 15.00.
C CATEGORY:
C CALLING SEQUENCE:
	program SunFlux		! Conversion of solar irradiance to photons.
C INPUTS:
C OUTPUTS:
C CALLS:
C PROCEDURE:
C MODIFICATION HISTORY:
C	Written 90 Apr 24 by Robert S. McMillan, LPL/U. Arizona
C-
	implicit real*8 (A-H, O-Z)
	character HEADER*72

	SUNMAG = -26.71d0		! J. Hardorp 1980 Astron. & Ap. 91,221.
	STARMAG = 15.d0
	DIMNESS = 10.d0**(0.4d0 * (SUNMAG - STARMAG))
	H = 6.6262d-34			! Planck's const in joule sec
	C = 2.997925d8			! speed of light in m/s

	open (7, file='sun10.dat', status='OLD')
	open (8, file='sunflux.txt', status='NEW', carriagecontrol='LIST')

	read  (7,'(   A72)') HEADER
	write (8,'(1X,A72)') HEADER
	write (8,'(A)') '  WL(A) SLAMDA   PHOTSUN  BAND  STARPHOT/m**2/sec/band'

	read (7,*,iostat=I)  WL, SLAMBDA

	L = 0
	do while (I .eq. 0 .and. L .le. LMAX)
	    L = L+1

C WL = air wavelength in A for center of band.
C      bands are 10 A wide for 3305 .LE. WL .LT.  6310
C      bands are 20 A wide for 6310 .LE. WL .LT.  8725
C      bands are 50 A wide for 8725 .LE. WL
C SLAMBDA = irradiance in vacuum @ mean distance in microwatts per sq. cm per A.

	    ENERPHOT = H*C/(WL/1.d10) ; energy of 1 photon in joules

C Photons per sq m per sec per A from whole solar disk:

	    PN = SLAMBDA*1.d4/(1.d6 * ENERPHOT)

	    BAND = 10.d0		! 10 A bandpass unless otherwise defined:
	    if (WL .ge. 6309.d0 ) BAND = 20.d0
	    if (WL .ge. 8724.d0 ) BAND = 50.d0

	    PHOTSTAR = PN*BAND*DIMNESS	! phot/m**2/s/band for V=15 star.

	    write (8,'(1X,F6.0,F7.3,D12.4,F4.0,F10.0)') WL,SLAMBDA,PN,BAND,PHOTSTAR

	    read (7,*,iostat=I)  WL, SLAMBDA
	end do

	close (7)
	close (8)

	end
