OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
avhrrsub5h.f
Go to the documentation of this file.
1 C
2 C@***s* PROJECT_PFSST/l2gen_both/avhrrsub5.f
3 C
4 C This header contains documentation required by the NOAA Climate Data Record
5 C Program (CDRP), which is managed at the NOAA National Climatic Data Center (NCDC).
6 C Only the code that applies to AVHRR SST data is documented in this header.
7 C
8 C The AVHRR Pathfinder Sea Surface Temperature (PFSST) processing code was originally
9 C developed at the University of Miami. In 2010, the code was integrated into
10 C the multi-sensor SeaWiFS Data Analysis System (SeaDAS) obtained from NASA GSFC.
11 C SeaDAS was used for processing the PFSST beginning with the Pathfinder Version
12 C 5.2 (PFV5.2) dataset, produced jointly by the University of Miami and the NOAA
13 C National Oceanographic Data Center (NODC). These data are provided to the
14 C public and archived at NODC, and have been transitioned along with the production
15 C code and documentation to the CDRP at NCDC.
16 C
17 C This NOAA required header is specifically written for Pathfinder SST and may
18 C not be relevant to other sensors or products processed by SeaDAS. Please
19 C review the SEADAS software distribution policy for public domain software
20 C located at http://seadas.gsfc.nasa.gov/copying.html for more information and
21 C documentation
22 C
23 C NAME
24 C avhrrsub5.f
25 C
26 C LOCATION
27 C $OCSSWROOT
28 C
29 C PURPOSE
30 C Collection of subroutines needed to compute various atmospheric parameters
31 C for AVHRR visible channels 1 and 2.
32 C
33 C DESCRIPTION
34 C Functions and subroutines to Compute Rayleigh/atmospheric parameters for satellite pass.
35 C This is the implementation for avhrr channels 1 and 2.
36 C
37 C subroutine AVLOOPH (satz, solz, delphi, RAYLY, AERSOL, AGLINT) - The subroutine AVLOOPH calculates
38 C and collects coefficients and parameters need for the atmospheric correction.
39 C
40 C subroutine AVCONSH, is the constant initializer for the subroutine AVLOOPH.
41 C
42 C function AVHRRSUB5H -wrapper for the subroutines AVCONSH, AVINITH, and AVLOOPH,for persistent
43 C storage. This routine is never called directly.
44 C
45 C
46 C NOAA PFSST-SEADAS BUILD VERSION
47 C Pathfinder SST V5.2 code built with SEADAS version 6.3 64 bit L2gen_both for
48 C CDR processed at University of Miami/RSMAS
49 C
50 C PRIMARY SEADAS CODE DOCUMENTATION NASA
51 C For complete documentation of multi sensor SEADAS code see
52 C http://seadas.gsfc.nasa.gov/seadas/doc/toplevel/sds_program.html
53 C
54 C AUTHOR
55 C
56 C
57 C PFSST project embedded code
58 C Susan Walsh
59 C University of Miami/RSMAS
60 C
61 C CREATION DATE
62 C 2010
63 C
64 C COPYRIGHT
65 C THIS SOFTWARE AND ITS DOCUMENTATION ARE CONSIDERED TO BE IN THE PUBLIC DOMAIN AND
66 C THUS ARE AVAILABLE FOR UNRESTRICTED PUBLIC USE. THEY ARE FURNISHED "AS IS." THE
67 C AUTHORS, THE UNITED STATES GOVERNMENT, ITS INSTRUMENTALITIES, OFFICERS, EMPLOYEES,
68 C AND AGENTS MAKE NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE USEFULNESS OF THE
69 C SOFTWARE AND DOCUMENTATION FOR ANY PURPOSE. THEY ASSUME NO RESPONSIBILITY (1) FOR
70 C THE USE OF THE SOFTWARE AND DOCUMENTATION; OR (2) TO PROVIDE TECHNICAL SUPPORT
71 C TO USERS.
72 C
73 C MODIFICATION HISTORY
74 C
75 C See CVS revision control history embedded in actual file.
76 C
77 C LANGUAGE
78 C Fortran
79 C
80 C*****
81 C#############################################################
82 C
83 C !F90
84 C
85 C !Description:
86 C Function to Compute Rayleigh/atmospheric parameters for satellite pass.
87 C This is the implementation for avhrr channels 1 and 2.
88 C
89 C Subroutines and Functions:
90 C integer function AVHRRSUB5H
91 C !Description:
92 C Wrapper for the subroutines AVCONSH, AVINITH, and AVLOOPH,for persistent
93 C storage. This routine is never called directly.
94 C !Input Parameters:
95 C none
96 C !Output Parameters:
97 C None
98 C
99 C entry AVCONSH (LUNDK, inpixsiz, JDAY)
100 C !Decsription:
101 C The subroutine AVCONSH, is the constant initializer for the subroutine
102 C AVLOOPH. The subroutine AVCON begins by obtaining ozone optical
103 C thickness with a call to getozone. Clear water radiance values and
104 C the solar constant are then corrected for time of year. The subroutine
105 C rayget is then called to obtain the Rayleigh optical thickness, tau.
106 C The subroutine AVCONSH then converts epsilon values to an internal form.
107 C !Input Parameters:
108 C LUNDK(integer) - Logical unit for file access
109 C inpixsiz(integer) - number of pixels per line
110 C JDAY(integer) - julian day of start of data
111 C !Return value:
112 C (integer) - status error messages from subroutines
113 C
114 C entry AVLOOPH (satz, solz, delphi, RAYLY, AERSOL, AGLINT)
115 C !Decsription:
116 C The subroutine AVLOOPH calculates and collects coefficients and
117 C parameters need for the atmospheric correction.
118 C The subroutine begins by calculating solar angles and the "airmass"
119 C parameters. The routine then calculates the Rayleigh radiance,
120 C <rayly>, given the present geometry.
121 C The sun glitter coefficent, <aglint>, is obtained by a call to the
122 C subroutine gliter. The routine then calls the subroutine hmf8 to obtain
123 C the aerosol radiance coefficient and calculates the aerosol structure
124 C function, <aerosol>.
125 C !Input Parameters:
126 C satz(real array, size ANCHOR_1) - satellite zenith angle in degrees
127 C solz(real array, size ANCHOR_1) - solar zenith angle in degrees
128 C delphi(real array, size ANCHOR_1) - delta azimuth angle in degrees
129 C !Output Parameters:
130 C RAYLY(real array, size ANCHOR_1,2) - Rayleigh radiance by channel
131 C AERSOL(real array, size ANCHOR_1) - Aerosol structure factor
132 C AGLINT(real array, size ANCHOR_1) - Sun glitter coefficient
133 C
134 C !Revision History:
135 C
136 
137 C !Team Unique Header:
138 C
139 C Copyright 1988-1998 by Rosenstiel School of Marine and Atmospheric Science,
140 C University of Miami, Miami, Florida.
141 C
142 C All Rights Reserved
143 C
144 C Permission to use, copy, modify, and distribute this software and its
145 C documentation for non-commercial purposes and without fee is hereby granted,
146 C provided that the above copyright notice appear in all copies and that both
147 C that copyright notice and this permission notice appear in supporting
148 C documentation, and that the names of University of Miami and/or RSMAS not be
149 C used in advertising or publicity pertaining to distribution of the software
150 C without specific, written prior permission.
151 C
152 C UNIVERSITY OF MIAMI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
153 C INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
154 C SHALL UNIVERSITY OF MIAMI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
155 C DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
156 C WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
157 C OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
158 C
159 C !References and Credits:
160 C Written by:
161 C University of Miami
162 C Rosensteil School for Marine and Atmospheric Sciences
163 C Division of Meteorology and Oceanography
164 C 4600 Rickenbacker Cswy
165 C Miami,Fl
166 C 33149
167 C Contact: SWalsh@rsmas.miami.edu
168 C
169 C !Design Notes:
170 C
171 C !End###############################################################
172 
173  function avhrrsub5h (jdummy)
174  implicit none
175 
176 C $COMSIZ - Maximum message length
177 C $NAMSIZ - Maximum filename length
178 C $ARRSIZ - Maximum pixels per line (lines/screen)
179 
180  integer, parameter :: c_omsiz = 512
181  integer, parameter :: n_amsiz = 384
182  integer, parameter :: a_rrsiz = 8704
183 
184  integer, parameter :: anchor_c = 1
185  integer, parameter :: anchor_ = 2048
186 
187  integer, parameter :: mult_ = 1
188 
189  integer, parameter :: mx_boxsiz = 9
190 
191 C Local definitions.
192 
193  integer, parameter :: numgeo = 5
194 
195  real*8, parameter :: p_i = 3.1415926535898d0
196 
197 C Read Rayleigh multiple scattering polarization data
198 
199  integer, parameter :: m_m = 41
200  integer, parameter :: n_n = 45
201  integer, parameter :: c_h = 2
202 
203  integer*4 jdummy;
204  integer*4 lenstr;
205  integer*4 isflag(c_h);
206  real*4 theta(m_m);
207  real*4 theta0(n_n);
208  real*4 tau(n_n,c_h);
209  real*4 phi0(m_m,n_n,c_h);
210  real*4 phi1(m_m,n_n,c_h);
211  real*4 phi2(m_m,n_n,c_h);
212  real*4 phicof(c_h);
213 
214  integer*4 avhrrsub5h, avconsh, avlooph;
215 
216  logical needray;
217  integer*4 lundk;
218  integer*4 inpixsiz;
219  integer*4 ii;
220  integer*4 nk, ianchr;
221  integer*4 ni, nj, jnpixsiz;
222  integer*4 jday;
223  real*8 thesat;
224  real*4 thesatd, thesund, fsun, fsat;
225  real*4 phi00, phi01, phi10, phi11, phi21, phi23;
226  real*4 thesun, sunmui, aercof;
227  real*4 deg;
228  real*4 rad;
229  real*4 angle, c00;
230  real*4 to(c_h)
231  real*4 f1ln(c_h)
232  real*4 f0var, x, fday, gday;
233  real*8 x8;
234  real*4 b00;
235 
236 C ANLY CALEPS
237 C
238 C
239 C
240 
241  real*4 rayly(c_h); ! Rayleigh radiance by channel
242  real*4 aglint;
243  real*4 aersol(c_h);
244 
245  real*4 satz
246  real*4 solz
247  real*4 delphi
248 
249  real*8 deg8;
250 
251 C System common blocks.
252 
253 C Variables to save across calls
254 
255  save f1ln;
256  save to;
257  save needray;
258  save theta, theta0, phi0, phi1, phi2, tau, isflag;
259  save ianchr;
260  save jnpixsiz;
261 
262 C TO - Ozone absorbtion
263 
264  data to(1), to(2) / .090, .000 /;
265 
266  data needray / .true. /; ! Load tables first time
267 
268 C
269 C ASF's
270 C
271 C NOTE: The earth is closer to the sun in the winter.
272 C
273 C f0var: 7 % yearly variation
274  f0var(x,fday)=x*(
275  . (1.0+.0167*sngl(dcos(2.0d0*p_i*(dble(fday)-3.0d0)/365.0d0)))**2 );
276 C deg(x) = x*180./sngl(p_i)
277  deg8(x8) = x8*180.0d0/p_i
278  rad(x) = x*sngl(p_i)/180.
279 
280  stop 'AVHRRSUB5H is a package'
281 
282 C
283 C Constant initializer
284 C
285 
286  entry avconsh(lundk, inpixsiz, jday)
287 
288 C calibration information must be in cal1... for calaryin and
289 C cal7... for calaryout
290  jnpixsiz = inpixsiz; ! Local copy
291  ianchr = jnpixsiz; ! do it for every pixel now
292 
293 C Get ozone optical thickness.
294 
295 C Correct solar constant and clear water radiance for time of year.
296 
297  gday = amod(float(jday),1000.); ! Pick out julian day of year
298  do ii=1,c_h
299  f1ln(ii) = f0var(sngl(p_i)*100.,gday); ! Percent albedo
300  end do
301 
302  if (needray) then
303 
304  ! Just load tables first time through.
305 
306  call rayget(lundk,theta,theta0,phi0,phi1,phi2,tau,isflag)
307  do nk=1,c_h
308 
309  if (tau(1,nk) .eq. 0.) then
310  tau(1,nk) = 1. ! Fake up missing channels
311  end if
312 
313  end do
314 
315  needray = .false.
316  end if
317 
318  avconsh=(1);
319  return
320 
321 C
322 
323  entry avlooph(satz, solz, delphi, rayly, aersol, aglint)
324 
325 C THESAT Zenith angle to satellite from ground element
326 C B00 Air-mass between satellite and viewed ground element
327 
328 C use value from class file instead of calculated value
329  thesat = rad(satz)
330  b00 = 1./sngl(dcos(thesat)); ! Air-mass to sat from ground
331 
332 C THESUN Zenith angle to sun from ground element
333 C SUNMUI Air-mass between sun and viewed ground element
334 
335 C Geocentric latitude for SUNANG
336  thesun = rad(solz) ! airmass_avhrr needs solz as radians, not degrees
337  call airmass_avhrr(thesun, sunmui)
338 
339 C C00 Total air-mass from sun to ground to satellite
340 
341  c00 = b00+sunmui; ! Sun path + satellite path
342 
343 C ANGLE Azimuth between view from satellite at ground and sun
344 C RAYLY Rayleigh radiance by channel
345 
346  angle = rad(delphi)
347 
348  if (sunmui .eq. 0.) then
349  do nk=1,c_h
350  phicof(nk) = 0.; ! Out of range
351  end do
352 
353  else
354  thesatd = sngl(deg8(thesat));
355  if (thesatd > theta(m_m)) then
356  go to 901 ! Value out of range!
357  end if
358 
359  ni=int((((thesatd-theta(1))/(theta(m_m)-theta(1)))*float(m_m-1))+1.);
360  do while (ni >= 1 .and. ni < m_m)
361  if (theta(ni) <= thesatd .and.
362  . theta(ni+1) >= thesatd) then
363  exit;
364 
365  else if (theta(ni+1) < thesatd) then
366  ni = ni+1;
367 
368  else !if (THETA(NI) > THESATD)
369  ni = ni-1;
370  end if
371 
372  end do
373 
374 C thesund = deg(thesun);
375  thesund = solz;
376  if (thesund > theta0(n_n)) then
377  go to 901 ! Value out of range!
378  end if
379 
380  nj=int((((thesund-theta0(1))/(theta0(n_n)-theta0(1)))*float(n_n-1))+1.);
381  do while (nj >= 1 .and. nj < n_n)
382  if (theta0(nj) <= thesund .and.
383  . theta0(nj+1) >= thesund) then
384  exit;
385 
386  else if (theta0(nj+1) < thesund) then
387  nj = nj+1;
388 
389  else !if (THETA0(NJ) > THESUND)
390  nj = nj-1;
391  end if
392 
393  end do
394 
395  if (ni >= 1 .and. ni < m_m .and.
396  . nj >= 1 .and. nj < n_n) then
397  fsat = (thesatd-theta(ni))/(theta(ni+1)-theta(ni));
398  fsun = (thesund-theta0(nj))/(theta0(nj+1)-theta0(nj));
399  do nk=1,c_h
400 
401  if (isflag(nk) .eq. 0) then
402  phi00 = phi0(ni ,nj ,nk)+
403  . phi1(ni ,nj ,nk)*cos(angle)+
404  . phi2(ni ,nj ,nk)*cos(2*angle);
405  phi10 = phi0(ni+1,nj ,nk)+
406  . phi1(ni+1,nj ,nk)*cos(angle)+
407  . phi2(ni+1,nj ,nk)*cos(2*angle);
408  phi01 = phi0(ni ,nj+1,nk)+
409  . phi1(ni ,nj+1,nk)*cos(angle)+
410  . phi2(ni ,nj+1,nk)*cos(2*angle);
411  phi11 = phi0(ni+1,nj+1,nk)+
412  . phi1(ni+1,nj+1,nk)*cos(angle)+
413  . phi2(ni+1,nj+1,nk)*cos(2*angle);
414  phi21 = phi00*(1-fsun)+phi01*fsun;
415  phi23 = phi10*(1-fsun)+phi11*fsun;
416  phicof(nk) = phi21*(1.-fsat)+phi23*fsat;
417 
418  else
419  phicof(nk) = 0. ! No data for this channel
420  end if
421 
422  end do
423 
424  else
425  go to 901 ! Value out of range!
426  end if
427 
428  end if
429 
430  go to 902
431 
432 901 continue
433  ! Handle value out of range
434  do nk=1,c_h
435  phicof(nk) = 0.; ! Out of range
436  end do
437 
438 902 continue
439  rayly(1) = phicof(1)*f1ln(1)*exp(-to(1)*c00);
440  rayly(2) = phicof(2)*f1ln(2)*exp(-to(2)*c00);
441 
442  ! Compute an aerosol radiance -> tau conversion coefficient
443 
444  call hmf8(sngl(thesat),thesun,angle,1.,1.,aercof);
445  aersol(1) = aercof*f1ln(1)*exp(-to(1)*c00);
446  aersol(2) = aercof*f1ln(2)*exp(-to(2)*c00);
447 
448  ! Compute gliter coefficient
449  ! Not sure why use getglint here instead of letting atmocor1 call getglint_iqu as it does for modis
450  ! Only difference between the two is that getglint_iqu returns more variables.
451 
452 C call gliter(sngl(thesat),thesun,angle,6.,0.,aglint);
453  call getglint(satz, solz, delphi, 6.0, 0.0, aglint);
454 
455  avlooph=(1)
456  return
457 
458  end
subroutine airmass_avhrr(X5, X7)
integer *4 function lenstr(string)
Definition: lenstr.f:2
int32_t jday(int16_t i, int16_t j, int16_t k)
Definition: jday.c:4
#define real
Definition: DbAlgOcean.cpp:26
subroutine rayget(lun, theta, theta0, phi0, phi1, phi2, tau, isflag)
Definition: raygetpol.f:137
subroutine getglint(X1, X2, X3, X4, X5, X6)
Definition: getglint.f:31
subroutine hmf8(X1, X2, X3, X4, X5, X6)
Definition: hmf8.f:192
integer *4 function avhrrsub5h(jdummy)
Definition: avhrrsub5h.f:174