OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
simpsn.f
Go to the documentation of this file.
1 C
2 C@***s* PROJECT_PFSST/l2gen_both/simpsn.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 simpsn.f
25 C
26 C LOCATION
27 C $OCSSWROOT
28 C
29 C PURPOSE
30 C Calculate atmospheric pathlength from viewing geometry.
31 C
32 C DESCRIPTION
33 C The function simpsn is used to integrate over a given set of ordinates for
34 C equally spaced abscissas using simpson(s) method or using entry point simpne to integrate
35 C analytically a 3-point lagrangian interpolation polynomial fitting the ordinates.
36 C
37 C NOAA PFSST-SEADAS BUILD VERSION
38 C Pathfinder SST V5.2 code built with SEADAS version 6.3 64 bit l2gen_both for
39 C CDR processed at University of Miami/RSMAS.
40 C
41 C PRIMARY SEADAS CODE DOCUMENTATION NASA
42 C For complete documentation of multi sensor SEADAS code see
43 C http://seadas.gsfc.nasa.gov/doc/l2gen/l2gen.html
44 C
45 C AUTHOR
46 C
47 C
48 C PFSST project embedded code
49 C Susan Walsh
50 C University of Miami/RSMAS
51 C
52 C CREATION DATE
53 C 2010
54 C
55 C COPYRIGHT
56 C THIS SOFTWARE AND ITS DOCUMENTATION ARE CONSIDERED TO BE IN THE PUBLIC DOMAIN AND
57 C THUS ARE AVAILABLE FOR UNRESTRICTED PUBLIC USE. THEY ARE FURNISHED "AS IS." THE
58 C AUTHORS, THE UNITED STATES GOVERNMENT, ITS INSTRUMENTALITIES, OFFICERS, EMPLOYEES,
59 C AND AGENTS MAKE NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE USEFULNESS OF THE
60 C SOFTWARE AND DOCUMENTATION FOR ANY PURPOSE. THEY ASSUME NO RESPONSIBILITY (1) FOR
61 C THE USE OF THE SOFTWARE AND DOCUMENTATION; OR (2) TO PROVIDE TECHNICAL SUPPORT
62 C TO USERS.
63 C
64 C MODIFICATION HISTORY
65 C
66 C See CVS revision control history embedded in actual file.
67 C
68 C
69 C INPUTS
70 C X5(real) - Angle PHI (solar zenith angle)
71 C X(real) - FOR SIMPSN, THIS IS A SINGLE VARIABLE SPECIFYING THE INCREMENT
72 C FOR THE EQUALLY SPACED ABSCISSAS.
73 C - FOR SIMPNE, THIS IS A VECTOR OF LENGTH NUM
74 C SPECIFYING THE UNEQUALLY SPACED ABSCISSAS.
75 C
76 C Y(real) - VECTOR OF ORDINATES.
77 C
78 C NUM(integer) - LENGTH OF VECTOR Y (SHOULD BE .GT. 2).
79 C
80 C
81 C OUTPUTS
82 C IER(integer) - ERROR FLAG.
83 C = 32 NUM IS .LT. 3, NO EXECUTION.
84 C = 0 NO ERROR.
85 C
86 C
87 C
88 C LANGUAGE
89 C Fortran
90 C
91 C@*****
92 c*************************************************************
93 c
94 c !F77
95 c
96 c FUNCTION SIMPSN (X,Y,NUM,IER)
97 c !Description:
98 c TO INTEGRATE OVER A GIVEN SET OF ORDINATES FOR
99 C EQUALLY SPACED ABSCISSAS USING SIMPSON(S)
100 c METHOD OR USING ENTRY POINT SIMPNE TO INTEGRATE
101 C ANALYTICALLY A 3-POINT LAGRANGIAN INTERPOLATION
102 C POLYNOMIAL FITTING THE ORDINATES.
103 c !Input Parameters:
104 c REAL X
105 C . FOR SIMPSN, THIS IS A SINGLE VARIABLE
106 C SPECIFYING THE INCREMENT FOR THE EQUALLY
107 C SPACED ABSCISSAS.
108 C . FOR SIMPNE, THIS IS A VECTOR OF LENGTH NUM
109 C SPECIFYING THE UNEQUALLY SPACED ABSCISSAS.
110 C
111 C REAL Y
112 C VECTOR OF ORDINATES.
113 C
114 C INTEGER NUM
115 C LENGTH OF VECTOR Y (SHOULD BE .GT. 2).
116 C
117 c
118 c !Output Parameters:
119 c INTEGER IER
120 C ERROR FLAG.
121 C = 32 NUM IS .LT. 3, NO EXECUTION.
122 C = 0 NO ERROR.
123 c
124 c !Revision History:
125 c
126 c
127 c $Id: simpsn.f,v 1.4 2012/06/14 21:54:49 sue Exp $
128 c
129 c $Log: simpsn.f,v $
130 c Revision 1.4 2012/06/14 21:54:49 sue
131 c Fix extra comment starts in the .c files, and remove tabs in the .f
132 c files to get rid of compiler warnings.
133 c
134 c Revision 1.3 2012/05/07 20:10:15 sue
135 c Add or modify the PFSST headers.
136 c
137 c Revision 1.2 2012/04/26 18:55:32 sue
138 c Changes made by seadas group for seadas6.3, newer fortran, and/or 64 bit mode.
139 c
140 c Revision 1.1 2010/08/07 18:44:49 sue
141 c seadas 6.1 l2gen with modis dust and avhrr.
142 c
143 c Revision 1.1 2008/08/15 20:30:36 sue
144 c NODC versions of the pathfinder processing programs.
145 c
146 c Revision 1.3 2002/08/23 20:53:07 sue
147 c Update copyright notices to year 2002.
148 c
149 c Revision 1.2 1997/11/20 19:39:20 jim
150 c Fix prologs.
151 c
152 c Revision 1.1 1996/09/12 17:44:20 sue
153 c Modis version of ulib.
154 c
155 c Revision 1.1 1992/02/26 19:57:42 angel
156 c Initial revision
157 c
158 c
159 c !Team-unique Header:
160 C
161 C Copyright 1988-2002 by Rosenstiel School of Marine and Atmospheric Science,
162 C University of Miami, Miami, Florida.
163 C
164 C All Rights Reserved
165 C
166 C Permission to use, copy, modify, and distribute this software and its
167 C documentation for non-commercial purposes and without fee is hereby granted,
168 C provided that the above copyright notice appear in all copies and that both
169 C that copyright notice and this permission notice appear in supporting
170 C documentation, and that the names of University of Miami and/or RSMAS not be
171 C used in advertising or publicity pertaining to distribution of the software
172 C without specific, written prior permission.
173 C
174 C UNIVERSITY OF MIAMI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
175 C INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
176 C SHALL UNIVERSITY OF MIAMI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
177 C DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
178 C WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
179 C OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
180 c
181 c !References and Credits:
182 c
183 c Written by:
184 c University of Miami
185 c Rosensteil School for Marine and Atmospheric Science
186 c Division of Meteorology and Physical Oceanography
187 c 4600 Rickenbacker Cswy
188 c Miami,Fl
189 c 33149
190 c
191 c contact: SWalsh@rsmas.miami.edu
192 c
193 c !Design Notes:
194 c
195 c !ENDcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
196 C
197 C NCAR SCIENTIFIC SUBROUTINE LIBRARY ROUTINE@ SIMPSN
198  FUNCTION simpsn (X,Y,NUM,IER)
199 C
200 C
201 C DIMENSION OF X(NUM),Y(NUM)
202 C ARGUMENTS
203 C
204 C LATEST REVISION MAY, 1974
205 C
206 C PURPOSE TO INTEGRATE OVER A GIVEN SET OF ORDINATES FOR
207 C EQUALLY SPACED ABSCISSAS USING SIMPSON(S)
208 C METHOD OR USING ENTRY POINT SIMPNE TO INTEGRATE
209 C ANALYTICALLY A 3-POINT LAGRANGIAN INTERPOLATION
210 C POLYNOMIAL FITTING THE ORDINATES.
211 C
212 C ACCESS CARDS *FORTRAN,S=ULIB,N=SIMPSN
213 C *COSY
214 C
215 C USAGE FOR EQUALLY SPACED ABSCISSAS, USE
216 C YINT = SIMPSN(X,Y,NUM,IER) .
217 C FOR UNEQUALLY SPACED ABSCISSAS, USE
218 C YINT = SIMPNE(X,Y,NUM,IER) .
219 C
220 C ARGUMENTS
221 C
222 C ON INPUT X
223 C . FOR SIMPSN, THIS IS A SINGLE VARIABLE
224 C SPECIFYING THE INCREMENT FOR THE EQUALLY
225 C SPACED ABSCISSAS.
226 C . FOR SIMPNE, THIS IS A VECTOR OF LENGTH NUM
227 C SPECIFYING THE UNEQUALLY SPACED ABSCISSAS.
228 C
229 C Y
230 C VECTOR OF ORDINATES.
231 C
232 C NUM
233 C LENGTH OF VECTOR Y (SHOULD BE .GT. 2).
234 C
235 C ON OUTPUT IER
236 C ERROR FLAG.
237 C = 32 NUM IS .LT. 3, NO EXECUTION.
238 C = 0 NO ERROR.
239 C
240 C ENTRY POINTS SIMPSN, SIMPNE
241 C
242 C SPECIAL CONDITIONS IF NUM IS AN EVEN NUMBER, SIMPSON(S) RULE IS
243 C APPLIED TO INTERVAL X(1) THROUGH X(NUM-1) AND
244 C THE RESULT IS ADDED TO THE INTEGRAL OVER
245 C X(NUM-1) TO X(NUM) OF THE THREE-POINT
246 C LAGRANGIAN INTERPOLATING POLYNOMIAL THROUGH
247 C X(NUM-2), X(NUM-1) AND X(NUM).
248 C
249 C COMMON BLOCKS NONE
250 C
251 C I/O NONE
252 C
253 C PRECISION SINGLE
254 C
255 C REQUIRED ULIB NONE
256 C ROUTINES
257 C
258 C SPECIALIST WILLIAM B. FRYE, NCAR, BOULDER, COLORADO 80303
259 C
260 C LANGUAGE FORTRAN
261 C
262 C HISTORY STANDARDIZED MAY 1974.
263 C
264 C
265 C
266 C
267 C IMPLICIT DOUBLE PRECISION (A-H,O-Z)
268 
269  INTEGER num
270  INTEGER ier, lim, i
271  real*8 ssum
272  REAL x(num) ,y(num) ,simpsn, simpne
273  real*8 del(3) ,pi(3) ,g(3)
274  real*8 third, half, two3r, e, f, feints, delprd
275  real*8 x1, x2, x3
276  INTEGER n
277  DATA third,half,two3r/0.333333333333333,0.5,0.666666666666666/
278 
279  IF (num .GT. 2) GO TO 101
280  ier = 32
281  simpsn = 0.
282  RETURN
283  101 CONTINUE
284  ier = 0
285  n = num
286  IF (mod(num,2) .EQ. 0) n = num-1
287  simpsn = half*(y(1)+y(n))+2.*y(n-1)
288  IF (n .EQ. 3) GO TO 103
289  lim = n-2
290  DO 102 i=2,lim,2
291  simpsn = simpsn+2.*y(i)+y(i+1)
292  102 CONTINUE
293  103 simpsn = two3r*x(1)*simpsn
294  IF (mod(num,2) .EQ. 1) RETURN
295  e = x(1)*x(1)
296  f = x(1)*e
297  feints = x(1)
298  del(1) = x(1)
299  del(2) = -2.*x(1)
300  del(3) = x(1)
301  g(1) = x(1)
302  g(2) = 0.0
303  g(3) = -x(1)
304  pi(1) = 0.0
305  pi(2) = -e
306  pi(3) = 0.0
307  delprd = -2.*f
308  n = n-1
309  GO TO 107
310  entry simpne(x,y,num,ier)
311 C
312 C X AND Y ARE COORDINATES OF THE POINTS (IN ARRAY FORM)
313 C
314  IF (num .GT. 2) GO TO 104
315  ier = 32
316  simpsn = 0.
317  RETURN
318  104 CONTINUE
319  ier = 0
320  simpsn = 0.
321  n = 1
322  105 CONTINUE
323  x1 = x(n)
324  x2 = x(n+1)
325  x3 = x(n+2)
326  e = x3*x3-x1*x1
327  f = x3*x3*x3-x1*x1*x1
328  feints = x3-x1
329  del(1) = x3-x2
330  del(2) = -feints
331  del(3) = x2-x1
332  g(1) = x2+x3
333  g(2) = x1+x3
334  g(3) = x1+x2
335  pi(1) = x2*x3
336  pi(2) = x1*x3
337  pi(3) = x1*x2
338  delprd = del(1)*del(2)*del(3)
339  ssum = 0.0d0
340  DO 106 i=1,3
341  ssum = ssum+y(n-1+i)*del(i)*(third*f-g(i)*half*e+pi(i)*feints)
342  106 CONTINUE
343  simpsn = simpsn-ssum/delprd
344  n = n+2
345  IF (num .GT. (n+1)) GO TO 105
346  IF (mod(num,2) .NE. 0) RETURN
347  n = num-2
348  x3 = x(num)
349  x2 = x(num-1)
350  x1 = x(num-2)
351  e = x3*x3-x2*x2
352  f = x3*x3*x3-x2*x2*x2
353  feints = x3-x2
354  del(1) = feints
355  del(2) = x1-x3
356  del(3) = x2-x1
357  g(1) = x2+x3
358  g(2) = x1+x3
359  g(3) = x1+x2
360  pi(1) = x2*x3
361  pi(2) = x1*x3
362  pi(3) = x1*x2
363  delprd = del(1)*del(2)*del(3)
364  107 ssum = 0.0d0
365  DO 108 i=1,3
366  ssum = ssum+y(n-1+i)*del(i)*(third*f-g(i)*half*e+pi(i)*feints)
367  108 CONTINUE
368  simpsn = simpsn-ssum/delprd
369  RETURN
370  END
#define real
Definition: DbAlgOcean.cpp:26
real function simpsn(X, Y, NUM, IER)
Definition: simpsn.f:199
#define pi
Definition: vincenty.c:23
#define f
Definition: l1_czcs_hdf.c:702