OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
solar_irr_PC.f
Go to the documentation of this file.
1 ********************************************************************************
2 * *
3 * Name: SOLAR_IRR *
4 * Purpose: obtain solar irradiances above the atmosphere corresponding *
5 * to the measurement time and geographic location. *
6 * Parameters: none *
7 * Global used: WAVOBS - wavelengths of input imaging spectrometer data *
8 * FWHM - FWHM for each of the channels *
9 * SOLZNI - solar zenith angle *
10 * IDAY - the day number in the year when the measurement *
11 * was made *
12 * Global output: YIRR - Solar irradiances just above the atmosphere *
13 * Return Codes: none *
14 * Special Considerations: *
15 * 1. The solar irradiance curve is contained in the file 'sun_binary'. *
16 * It is now based on the "thuillier_atlas3.dat" in the 0.2 - 2.4 *
17 * micron range (Thuillier, G., et al., Solar irradiance reference *
18 * spectra for two solar active levels, Adv. in Space Research, 34, *
19 * 256-261, 2004). Above 2.4 micron, the solar curve contained *
20 * in the data file "SUN01kurucz2005.dat" inside the MODTRAN 5.2 code *
21 * & multiplied by a factor of 1.02 is adopted. Previously, ATREMi *
22 * used a solar curve converted from the file "sun_kur" in MODTRAN3.5. *
23 * 2. The solar irradiance curve must have enough entries starting at *
24 * about .30 so that the interpolation and smoothing will work *
25 * correctly. *
26 * 3. This subroutine doesn't contain the statement INCLUDE 'COMMONS_INC'.*
27 * As a result, the variables, such as NP_HI, NP_MED, WAVNO_HI, *
28 * TRAN_HI, WAVLN_MED, TRAN_MED, and DWAVNO are all local variables *
29 * used for smoothing the 1 cm-1 resolution solar irradiance data from *
30 * MODTRAN3.5 to the desired resolutions of imaging spectrometers. *
31 * These variables have different meanings in most of other *
32 * subroutines. *
33 * *
34 ********************************************************************************
35  SUBROUTINE solar_irr_pc
36 
37 C Declarations for common variables
38  dimension wavobs(1024),fwhm(1024)
39  COMMON /getinput4/ wavobs,fwhm
40 
41  dimension yirr(1024)
42  COMMON /solar_irr1/yirr
43 
44  COMMON /getinput5/ nobs,hsurf,dlt,dlt2
45  COMMON /geometry1/ solzni,solaz,obszni,obsphi,iday
46 
47 
48 C Arrays for wavelength positions and FWHM of measured imaging spectrometer
49 C data and for smoothing the medium resolution spectrum (FWHM = 0.2 nm,
50 C and point spacing = 0.1 nm) to match coarser resolution spectrum
51 C of imaging spectrometer data
52 
53  parameter(nobs_max = 1024, ninstr_max = 3001)
54 
55  REAL FINSTR(NINSTR_MAX)
56  INTEGER NCVHF(NOBS_MAX)
57 
58 
59  parameter(np_hi=49933) !Number of solar irradiance spectral points,
60  ! covering 51 cm-1 to 49,983 cm-1 at
61  ! point spacing of 1.00 cm-1
62 
63  parameter(np_med = 28001) !Number of medium resolution spectral
64  ! points from 0.30 um to 3.1 um at 0.1 nm
65  ! point spacing and 0.2 nm full width at
66  ! half maximum (FWHM)
67 
68  REAL WAVNO_HI(NP_HI) !Wavenumber of solar irradiance data at a
69  ! point spacing of 1.0 cm-1
70  REAL WAVLN_MED(NP_MED) !Wavelength of medium resolution data
71  ! from 0.30 to 3.1 um (0.1 nm point spacing).
72  REAL TRAN_HI(NP_HI) !Solar irradiance data at 1.0 cm-1 point
73  ! spacing
74  REAL TRAN_MED(NP_MED) !Solar irradiance data at medium resolution
75  ! from 0.30 to 3.1 um (0.1 nm point spacing).
76 
77  REAL VSTART, VEND, DWAVLN !VSTART: Starting wavelength for calculations
78  !VEND: Ending wavelength for calculations
79  !DWAVLN: Interval between wavelengths
80  parameter(vstart = 0.30, vend = 3.1, dwavln = 0.0001)
81 
82  REAL DWAVNO
83  parameter(dwavno = 1.00) !Point spacing of input solar irradiance
84  ! data ( 1.0 cm-1).
85 
86  REAL DLT_MED ! 0.2-nm medium resolution spectrum.
87  parameter(dlt_med = 0.0002)
88 
89  REAL FACDLT !Factor to multiply DLT by to determine the
90  parameter(facdlt = 2.0) ! range used in the Gaussian function
91 
92 
93 C Programmer's note: CONST2=DLT*SQRT(3.1415926/CONST1) CONST2=total
94 C area of gaussian curve = DLT*SQRT(pi/(4.0*ln(2)))
95  REAL CONST1
96  parameter(const1 = 2.7725887) ! CONST1=4.0*ln(2)=2.7725887
97 
98  INTEGER INDEX_MED(NP_MED)
99  REAL WAVLN_MED_INDEX(NP_MED), TRAN_MED_INDEX(NP_MED)
100 C
101  REAL FINSTR_WAVNO(5000), FWHM_WAVNO(NP_MED)
102  INTEGER NCVHF_WAVNO(NP_MED)
103 
104  DATA pi,dtorad /3.1415926,0.0174533/
105 
106 C--- Temp Code ---
107  OPEN(31,file='sun_binary_PC',status='old',
108  & form='unformatted',access='direct',recl=4*49933)
109  read(31,rec=1) (wavno_hi(i), i = 1, 49933)
110  read(31,rec=2) (tran_hi(i), i = 1, 49933)
111  close(31)
112 C--- End of Temp Code
113 
114  DO i = 1, np_med
115  wavln_med(i) = vstart + float(i-1)*dwavln ! Wavelength of medium
116  ! resolution spectrum,
117  tran_med(i) = 1.0 ! FWHM=.2 nm, .30-3.1 um.
118  END DO
119 
120 
121 C Note: The grids of WAVNO_HI do not match the grids of 10000./WAVLN_MED.
122 C INDEX_MED is a specially designed index for finding close matches
123 C between the two kinds of grids.
124 C
125  DO i = 1, np_med
126  index_med(i) = ( (10000./wavln_med(i) - 51.)/dwavno + 1.)
127  END DO
128 C
129 C Note: WAVLN_MED_INDEX(I) is very close to WAVLN_MED(I),
130 C and WAVLN_MED_INDEX(I) >= WAVLN_MED(I)
131 C
132  DO i = 1, np_med
133  wavln_med_index(i) = 10000. /(float(index_med(i)-1)*dwavno
134  & + 51.)
135  END DO
136 
137 C
138  DO i = 1, np_med
139  fwhm_wavno(i) = 10000.*dlt_med
140  & /(wavln_med_index(i)*wavln_med_index(i))
141  IF(fwhm_wavno(i).LT.1.0) fwhm_wavno(i) = 1.0
142  END DO
143 C
144 
145  DO i = 1, np_med
146  ncvhf_wavno(i) = ( facdlt * fwhm_wavno(i) / dwavno + 1.)
147  END DO
148 
149 C Initialize arrays for smoothing medium resolution spectrum (FWHM = 0.2 nm,
150 C and point spacing = 0.1 nm) to coarser spectral resolution data
151 C from imaging spectrometers.
152 
153  DO i = 1, nobs
154  ncvhf(i) = ( facdlt * fwhm(i) / dwavln + 1.)
155  END DO
156 
157 
158 C First stage of smoothing - smooth solar irradiance spectrum with 49,933
159 C points at a point spacing of 1 cm-1 to medium resolution spectrum
160 C (resolution of 0.2 nm and point spacing of 0.1 nm) with about
161 C 25,000 points.
162 C
163 C The smoothing is done in wavenumber domain. For a spectrum with a
164 C constant 0.2 nm resolution in wavelength domain, it has variable
165 C resolution in wavenumber domain. This effect is properly taken care of
166 C in the design of smoothing functions.
167 C
168 C Because the input solar spectrum is in wavenumber units (cm-1), while
169 C the medium resolution spectrum is in wavelength units, the two kinds of
170 C grids do not automatically match. In order to match the grids, arrays
171 C of INDEX_MED and TRAN_MED_INDEX are specially designed. The desired
172 C medium resolution spectrum, TRAN_MED, at constant 0.1 nm point spacing
173 C and 0.2 nm resolution is obtained through linear interpolation of
174 C TRAN_MED_INDEX array.
175 C
176  DO 466 j = 1, np_med
177 
178  tran_med_index(j) = 0.0
179  ncvtot_wavno = 2 * ncvhf_wavno(j) - 1
180 
181  sumins = 0.0
182 
183  DO 560 i = ncvhf_wavno(j), ncvtot_wavno
184  finstr_wavno(i) =
185  & exp( -const1*(float(i-ncvhf_wavno(j))*dwavno
186  & /fwhm_wavno(j))**2.0)
187  sumins = sumins + finstr_wavno(i)
188  560 CONTINUE
189 
190  DO 565 i = 1, ncvhf_wavno(j)-1
191  finstr_wavno(i) = finstr_wavno(ncvtot_wavno-i+1)
192  sumins = sumins + finstr_wavno(i)
193  565 CONTINUE
194 
195  sumins = sumins * dwavno
196 
197  DO 570 i = 1, ncvtot_wavno
198  finstr_wavno(i) = finstr_wavno(i)*dwavno/sumins
199  570 CONTINUE
200 
201 
202  DO 491 k = index_med(j)-(ncvhf_wavno(j)-1),
203  & index_med(j)+ncvhf_wavno(j)-1
204  tran_med_index(j) = tran_med_index(j) + tran_hi(k)*
205  & finstr_wavno(k-index_med(j)+ncvhf_wavno(j))
206  491 CONTINUE
207 
208  466 CONTINUE
209 
210 C
211 C Linear interpolation to get TRAN_MED from TRAN_MED_INDEX:
212 C (Note that WAVLN_MED_INDEX(J) >= WAVLN_MED(J) )
213 C
214  tran_med(1) = tran_med_index(1)
215  tran_med(np_med) = tran_med_index(np_med)
216 
217  DO j = 2, np_med-1
218  dlt = wavln_med_index(j) - wavln_med_index(j-1)
219  IF(dlt.LT.1.0e-06) THEN
220  tran_med(j) = tran_med_index(j)
221  ELSE
222  fjm1 = (wavln_med_index(j) - wavln_med(j)) /dlt
223  fj = (wavln_med(j) - wavln_med_index(j-1))/dlt
224  tran_med(j) = fjm1*tran_med_index(j-1) + fj*tran_med_index(j)
225  END IF
226  END DO
227 
228 
229 C Second stage of smoothing - smooth the medium resolution spectrum (resolution
230 C of 0.2 nm and point spacing of 0.1 nm) with about 28,000 points to match
231 C the coarser and variable resolution spectrum from imaging spectrometers.
232 C
233 C Initialize some index parameters:
234  ia = 1000
235 C
236  DO 1466 j =1, nobs
237 
238  yirr(j) = 0.0
239  tran_ia = 0.0
240  tran_iap1 = 0.0
241 
242  ncvtot = 2 * ncvhf(j) - 1
243 
244 C Calculate instrumental response functions...
245  sumins = 0.0
246 
247  DO 1560 i = ncvhf(j), ncvtot
248  finstr(i) =
249  & exp( -const1*(float(i-ncvhf(j))*dwavln
250  & /fwhm(j))**2.0)
251  sumins = sumins + finstr(i)
252 1560 CONTINUE
253 
254  DO 1565 i = 1, ncvhf(j)-1
255  finstr(i) = finstr(ncvtot-i+1)
256  sumins = sumins + finstr(i)
257 1565 CONTINUE
258 
259  sumins = sumins * dwavln
260 
261  DO 1570 i = 1, ncvtot
262  finstr(i) = finstr(i)*dwavln/sumins
263 1570 CONTINUE
264 
265 C Index searching...
266 C
267  CALL hunt(wavln_med, np_med, wavobs(j), ia)
268 
269 
270 C Smoothing...
271 C
272  DO 1491 k = ia-(ncvhf(j)-1), ia+ncvhf(j)-1
273  tran_ia = tran_ia + tran_med(k)*
274  & finstr(k-ia+ncvhf(j))
275 1491 CONTINUE
276 
277  ia_p1 = ia + 1
278  DO 1492 k = ia_p1-(ncvhf(j)-1), ia_p1+ncvhf(j)-1
279  tran_iap1 = tran_iap1 + tran_med(k)*
280  & finstr(k-ia_p1+ncvhf(j))
281 1492 CONTINUE
282 C
283 C Linear interpolation to get YIRR from TRAN_IA and TRAN_IAP1:
284 C
285  dlt_ia = wavln_med(ia_p1) - wavln_med(ia)
286  fia = (wavln_med(ia_p1) - wavobs(j)) /dlt_ia
287 C FIA_P1 = (WAVOBS(J) - WAVLN_MED(IA))/DLT_IA
288  fia_p1 = 1. - fia
289  yirr(j) = fia*tran_ia + fia_p1*tran_iap1
290 C
291 1466 CONTINUE
292 
293 
294 C-- DO I = 1, NOBS
295 C-- print*,WAVOBS(I),YIRR(I)
296 C-- END DO
297 
298  cossol=cos(solzni)
299 
300 C The Sun-earth distance correction factor, a function of the day in the year
301 C (see reference: IQBAL, p.3)
302 
303  gamm=2.0*pi*float(iday-1)/365.
304  e0=1.000110+0.034221*cos(gamm)+0.001280*sin(gamm)
305  & + 0.000719*cos(2.0*gamm)+0.000077*sin(2.0*gamm)
306 
307  DO 20 i=1,nobs
308  yirr(i)=yirr(i)*cos(solzni)*e0
309  20 CONTINUE
310 
311 C WRITE(*,*)'SOLZNI=',SOLZNI,'COSSOL= ',COS(SOLZNI),'GAMM=',GAMM,
312 C &'IDAY=',IDAY,' E0= ',E0
313 
314 C-- WRITE(*,*)'SOLZNI=',SOLZNI,'COSSOL= ',COS(SOLZNI),'GAMM=',GAMM,
315 C-- &'IDAY=',IDAY,' E0= ',E0
316 C-- DO 23 I=1,NOBS
317 C-- 23 WRITE(*,*)'I=',I,' WAVOBS(I)=',WAVOBS(I),' YIRR(I)=',YIRR(I),
318 C-- &YIRR(I)/(COS(SOLZNI)*E0)
319 
320 
321  RETURN
322  END
int32_t hunt(double *xx, int32_t n, double x, int32_t jlo)
README for MOD_PR03(V6.1.0) 2. POINTS OF CONTACT it can be either SDP Toolkit or MODIS Packet for Terra input files The orbit validation configuration parameter(LUN 600281) must be either "TRUE" or "FALSE". It needs to be "FALSE" when running in Near Real Time mode
#define pi
Definition: vincenty.c:23
void solar_irr_pc()
Definition: solar_irr_PC.f:36