jsv5D.,
'Solar and Terrestrial Plank Function Spectral Irradiance Program. 
'Written by HEW 11FEB05

'Define Plank function for radiance in W/(m^2 uM)
PLKF(T,L) = 1.1191e+8/(L^5*(exp((1.439e+4)/(T*L))-1.0))

'Define constants
PI = 3.14159
RS = 696000      `Sun radius in km
DS = 150000000   'Sun distance in lm
ALB = 0.3        'Earth Albedo
SFAC = (1.0-ALB)*(PI*RS^2/DS^2)/4     'Scale factor for albedo and sloid angle
col("lamb",1 ,40) = 0.05*data(1,40)   'Set column of wavelengths in um
col("lamb",41,300) =  0.5*data(5,287) 

col("IRE")=PI*PLKF(288,col("lamb"))    'Compute Earth irradiance
col("IRS")=SFAC*PLKF(5900,col("lamb")) 'Compute Sun irradiance
col("IBB")=PI*PLKF(256.0,col("lamb"))  'Compute Earth BB irradiance

cell(8,2) = 0.0         'Inialize total irradiance and lable them
cell(8,3) = 0.0
cell(8,4) = 0.0
cell(7,2)= "Ave Earth"
cell(7,3)= "SUN"
cell(7,4)= "BB Earth"


'Loop over wavelengths to inegrate for total irradiance by Trap. Rule
for i = 2 to size(col("lamb")) do  
cell(7,1) = cell("lamb",i)-cell("lamb",i-1)
cell(8,2) = 0.5*cell(7,1)*(cell("IRE",i)+cell("IRE",i-1)) + cell(8,2)
cell(8,3) = 0.5*cell(7,1)*(cell("IRS",i)+cell("IRS",i-1)) + cell(8,3)
cell(8,4) = 0.5*cell(7,1)*(cell("IBB",i)+cell("IBB",i-1)) + cell(8,4)
end for
