OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
tmq.lp.f
Go to the documentation of this file.
1 
2 this result was generated by the code in its current setting.
3 
4 ncheck=1
5 randomly oriented oblate spheroids, a/b= 2.0000000
6 lam= .500000 mrr= .1330d+01 mri= .1000d-02
7 accuracy of computations ddelt = .10d-02
8 power law distribution of hansen & travis 1974
9 r1= .546765 r2= 1.653235
10 equal-surface-area-sphere reff= 1.0000 veff= .1000
11 number of gaussian quadrature points in SIZE averaging = 7
12 test of van der mee & hovenier is satisfied
13 cext= .620059d+01 csca= .608811d+01 w= .981861d+00 <cos>= .795853d+00
14 
15  s alpha1 alpha2 alpha3 alpha4 beta1 beta2
16  0 1.00000 .00000 .00000 .94701 .00000 .00000
17  1 2.38756 .00000 .00000 2.40317 .00000 .00000
18  2 3.44047 4.22550 4.14121 3.44978 .00518 .14199
19  3 4.30784 4.52938 4.47654 4.30075 -.06700 .00061
20  4 4.80175 5.22540 5.18611 4.77897 -.07461 -.04857
21  5 5.01955 5.30004 5.29356 5.01550 -.03166 -.00095
22  6 5.20044 5.40802 5.40301 5.21102 -.04963 .03442
23  7 5.38064 5.54781 5.52966 5.38320 -.07723 -.03423
24  8 5.44501 5.61122 5.58415 5.43366 -.06418 -.07369
25  9 5.38994 5.53497 5.52494 5.39340 -.04911 -.06812
26  10 5.30885 5.43390 5.42481 5.31525 -.06113 -.07484
27  11 5.17481 5.29188 5.27444 5.17434 -.06655 -.11320
28  12 4.97178 5.08303 5.06276 4.96487 -.04977 -.12667
29  13 4.72347 4.81759 4.81172 4.72934 -.03833 -.12035
30  14 4.46612 4.55484 4.54481 4.46935 -.04693 -.12703
31  15 4.18891 4.26669 4.25410 4.18946 -.04134 -.14121
32  16 3.89903 3.97221 3.95599 3.89420 -.03223 -.14110
33  17 3.60608 3.66490 3.65715 3.60738 -.01908 -.12943
34  18 3.33839 3.39259 3.38341 3.33836 -.01783 -.12134
35  19 3.07906 3.12521 3.11950 3.08222 -.01682 -.11384
36  20 2.83593 2.87894 2.86939 2.83473 -.02121 -.11290
37  21 2.59089 2.62667 2.61851 2.59005 -.01798 -.10778
38  22 2.35901 2.39386 2.38536 2.35686 -.01420 -.10238
39  23 2.13152 2.15936 2.15669 2.13463 -.01221 -.09111
40  24 1.92719 1.95493 1.94712 1.92542 -.01460 -.09125
41  25 1.72730 1.74913 1.74417 1.72716 -.00846 -.08019
42  26 1.55255 1.57218 1.56664 1.55139 -.01261 -.07069
43  27 1.38960 1.40551 1.40243 1.39042 -.01655 -.06411
44  28 1.24209 1.25881 1.25242 1.23950 -.01708 -.06463
45  29 1.09356 1.10609 1.10493 1.09581 -.01618 -.05606
46  30 .96469 .97814 .97202 .96161 -.01519 -.05859
47  31 .83777 .84762 .84634 .83921 -.00963 -.04780
48  32 .73508 .74432 .74017 .73340 -.01009 -.04482
49  33 .63980 .64648 .64486 .64002 -.00898 -.03741
50  34 .55901 .56592 .56303 .55828 -.01224 -.03509
51  35 .48236 .48737 .48754 .48451 -.01467 -.03293
52  36 .41721 .42356 .41848 .41401 -.01304 -.03843
53  37 .34674 .35079 .35055 .34808 -.00841 -.02956
54  38 .29376 .29824 .29524 .29220 -.00766 -.03002
55  39 .24175 .24475 .24412 .24220 -.00422 -.02486
56  40 .19831 .20150 .19936 .19725 -.00225 -.02311
57  41 .15699 .15882 .15929 .15815 -.00105 -.01718
58  42 .12641 .12892 .12638 .12466 -.00144 -.01831
59  43 .09392 .09522 .09581 .09518 -.00006 -.01285
60  44 .07194 .07377 .07139 .07019 -.00016 -.01455
61  45 .04664 .04752 .04759 .04714 .00131 -.00887
62  46 .03170 .03279 .03082 .03018 .00028 -.00796
63  47 .01815 .01858 .01833 .01809 .00085 -.00418
64  48 .01168 .01213 .01091 .01067 .00087 -.00397
65  49 .00612 .00629 .00548 .00539 .00137 -.00204
66  50 .00362 .00375 .00254 .00246 .00117 -.00132
67  51 .00132 .00137 .00135 .00131 .00042 -.00029
68  52 .00080 .00084 .00072 .00070 .00035 -.00025
69  53 .00041 .00042 .00029 .00028 .00028 -.00012
70  54 .00023 .00023 .00010 .00009 .00020 -.00005
71  55 -.00001 -.00001 -.00002 -.00002 .00000 .00003
72  56 .00000 .00000 .00000 .00000 .00000 .00000
73  57 .00000 .00000 .00000 .00000 .00000 .00000
74  58 .00000 .00000 .00000 .00000 .00000 .00000
75 
76  < f11 f22 f33 f44 f12 f34
77  .00 110.2658 110.2341 110.2341 110.2025 .0000 .0000
78  10.00 23.6825 23.6703 23.6349 23.6304 .2337 .7009
79  20.00 4.8125 4.8052 4.7649 4.7664 .1925 .0423
80  30.00 2.0213 2.0137 1.9813 1.9836 .0881 -.0595
81  40.00 .9749 .9679 .9405 .9429 .0558 -.0385
82  50.00 .4846 .4782 .4519 .4540 .0340 -.0372
83  60.00 .2596 .2534 .2239 .2257 .0327 -.0370
84  70.00 .2006 .1931 .1535 .1550 .0132 -.0644
85  80.00 .2069 .1978 .1490 .1496 .0072 -.0952
86  90.00 .2490 .2375 .1704 .1714 -.0266 -.1384
87  100.00 .2368 .2217 .1662 .1692 -.0474 -.1096
88  110.00 .1793 .1595 .1168 .1251 -.0316 -.0589
89  120.00 .1412 .1126 .0653 .0832 -.0163 -.0415
90  130.00 .1201 .0788 .0298 .0600 -.0059 -.0309
91  140.00 .1045 .0532 .0041 .0447 .0008 -.0229
92  150.00 .0882 .0383 -.0142 .0281 .0008 -.0175
93  160.00 .0791 .0348 -.0208 .0189 .0002 -.0128
94  170.00 .0754 .0468 -.0171 .0080 .0056 -.0061
95  180.00 .1404 .0653 -.0653 .0097 .0000 .0000
96 
97 power law distribution of hansen & travis 1974
98 r1= .273383 r2= .826617
99 equal-surface-area-sphere reff= .5000 veff= .1000
100 number of gaussian quadrature points in SIZE averaging = 4
101 test of van der mee & hovenier is satisfied
102 cext= .173748d+01 csca= .172372d+01 w= .992080d+00 <cos>= .837254d+00
103 
104  s alpha1 alpha2 alpha3 alpha4 beta1 beta2
105  0 1.00000 .00000 .00000 .96133 .00000 .00000
106  1 2.51176 .00000 .00000 2.51910 .00000 .00000
107  2 3.49636 4.33696 4.27436 3.48836 .02198 .06483
108  3 4.06342 4.52880 4.50112 4.05338 -.06414 -.01285
109  4 4.23806 4.71668 4.69771 4.23276 -.05219 -.07709
110  5 4.13236 4.50467 4.49117 4.13400 -.03610 -.08912
111  6 3.86520 4.17435 4.15638 3.86421 -.05188 -.10175
112  7 3.50844 3.75244 3.73735 3.50750 -.04031 -.12583
113  8 3.11901 3.31220 3.30076 3.12128 -.03132 -.11254
114  9 2.72759 2.87978 2.87048 2.73212 -.04365 -.11080
115  10 2.34961 2.47532 2.46112 2.34827 -.04691 -.12001
116  11 1.97824 2.07695 2.06801 1.98063 -.02986 -.11621
117  12 1.64863 1.72767 1.71815 1.64894 -.02985 -.09926
118  13 1.35245 1.41252 1.40499 1.35315 -.02988 -.09096
119  14 1.08940 1.13961 1.13177 1.08836 -.02730 -.08448
120  15 .84868 .88749 .88297 .84915 -.02075 -.07558
121  16 .63643 .66904 .66340 .63513 -.01352 -.06865
122  17 .45239 .47584 .47284 .45262 -.00289 -.05384
123  18 .31306 .33021 .32625 .31133 -.00111 -.04100
124  19 .20413 .21430 .21251 .20383 .00108 -.02688
125  20 .13219 .14030 .13779 .13084 -.00050 -.02051
126  21 .07694 .08129 .08041 .07647 .00141 -.01300
127  22 .04280 .04582 .04471 .04212 .00096 -.00843
128  23 .02029 .02194 .02162 .02022 .00148 -.00402
129  24 .01036 .01130 .01084 .01002 .00049 -.00274
130  25 .00285 .00311 .00299 .00276 .00072 -.00085
131  26 .00086 .00095 .00090 .00081 .00026 -.00023
132  27 .00020 .00023 .00021 .00019 .00008 -.00004
133  28 .00003 .00004 .00003 .00003 .00002 .00000
134  29 .00000 .00000 .00000 .00000 .00000 .00000
135  30 .00000 .00000 .00000 .00000 .00000 .00000
136 
137  < f11 f22 f33 f44 f12 f34
138  .00 43.8217 43.7953 43.7953 43.7689 .0000 .0000
139  10.00 25.7096 25.6858 25.6793 25.6622 .1209 .4479
140  20.00 7.6985 7.6819 7.6544 7.6474 .1490 .3276
141  30.00 2.7576 2.7466 2.7192 2.7169 .0704 .1134
142  40.00 1.0872 1.0790 1.0549 1.0541 .0577 .0262
143  50.00 .5419 .5354 .5122 .5122 .0322 -.0192
144  60.00 .3062 .3003 .2766 .2770 .0200 -.0436
145  70.00 .2236 .2175 .1937 .1938 -.0045 -.0575
146  80.00 .1727 .1657 .1409 .1414 -.0147 -.0499
147  90.00 .1361 .1285 .0999 .1009 -.0182 -.0523
148  100.00 .1147 .1048 .0702 .0730 -.0315 -.0525
149  110.00 .0982 .0855 .0481 .0536 -.0446 -.0360
150  120.00 .0799 .0634 .0270 .0366 -.0368 -.0143
151  130.00 .0643 .0438 .0058 .0206 -.0206 -.0065
152  140.00 .0574 .0345 -.0067 .0109 -.0128 -.0055
153  150.00 .0480 .0287 -.0138 .0013 -.0057 -.0051
154  160.00 .0432 .0289 -.0152 -.0036 -.0009 -.0073
155  170.00 .0404 .0277 -.0211 -.0100 .0049 .0009
156  180.00 .0623 .0318 -.0318 -.0013 .0000 .0000
157 
158  time = 1.25 min
159 
160 c new release including the lapack matrix inversion procedure.
161 c we thank cory davis(university of edinburgh) for pointing
162 c out the possibility of replacing the proprietary nag matrix
163 c inversion routine by the public-domain lapack equivalent.
164 
165 c calculation of light scattering by polydisperse, randomly
166 c oriented particles of identical axially symmetric shape
167 
168 c this version of the code uses extended precision variables
169 c and must be used along with the accompanying files tmq.par.f
170 c and lpq.f.
171 
172 c last update 08/06/2005
173 
174 c the code has been developed by michael mishchenko at the nasa
175 c goddard institute for space studies, new york. this research
176 c was funded by the nasa radiation sciences program.
177 
178 c the code can be used without limitations in any not-for-
179 c profit scientific research. we only request that in any
180 c publication using the code the source of the code be acknowledged
181 c and relevant references(see below) be made.
182 
183 c this version of the code is applicable to spheroids,
184 c chebyshev particles, and finite circular cylinders.
185 
186 c the computational method is based on the watermsn's T-matrix
187 C approach and is described in detail in the following papers:
188 C
189 C 1. M. I. Mishchenko, Light scattering by randomly oriented
190 C axially symmetric particles, J. Opt. Soc. Am. A,
191 C vol. 8, 871-882 (1991).
192 C
193 C 2. M. I. Mishchenko, Light scattering by size-shape
194 C distributions of randomly oriented axially symmetric
195 C particles of a size comparable to a wavelength,
196 C Appl. Opt., vol. 32, 4652-4666 (1993).
197 C
198 C 3. M. I. Mishchenko and L. D. Travis, T-matrix computations
199 C of light scattering by large spheroidal particles,
200 C Opt. Commun., vol. 109, 16-21 (1994).
201 C
202 C 4. M. I. Mishchenko, L. D. Travis, and A. Macke, Scattering
203 C of light by polydisperse, randomly oriented, finite
204 C circular cylinders, Appl. Opt., vol. 35, 4927-4940 (1996).
205 C
206 C 5. D. J. Wielaard, M. I. Mishchenko, A. Macke, and B. E. Carlson,
207 C Improved T-matrix computations for large, nonabsorbing and
208 C weakly absorbing nonspherical particles and comparison
209 C with geometrical optics approximation, Appl. Opt., vol. 36,
210 C 4305-4313 (1997).
211 C
212 C A general review of the T-matrix approach can be found in
213 C
214 C 6. M. I. Mishchenko, L. D. Travis, and D. W. Mackowski,
215 C T-matrix computations of light scattering by nonspherical
216 C particles: a review, J. Quant. Spectrosc. Radiat.
217 C Transfer, vol. 55, 535-575 (1996).
218 C
219 C The following paper provides a detailed user guide to the
220 C T-matrix code:
221 C
222 C 7. M. I. Mishchenko and L. D. Travis, Capabilities and
223 C limitations of a current FORTRAN implementation of the
224 C T-matrix method for randomly oriented, rotationally
225 C symmetric scatterers, J. Quant. Spectrosc. Radiat. Transfer,
226 C vol. 60, 309-324 (1998).
227 C
228 C These papers are available in the .pdf format at the web site
229 C
230 C http://www.giss.nasa.gov/~crmim/publications/
231 C
232 C or in hardcopy upon request from Michael Mishchenko
233 C Please e-mail your request to crmim@giss.nasa.gov.
234 C
235 C A comprehensive book "Scattering, Absorption, and Emission of
236 C Light by Small Particles" (Cambridge University Press, Cambridge,
237 C 2002) is also available in the .pdf format at the web site
238 C
239 C http://www.giss.nasa.gov/~crmim/books.html
240 
241 C Analytical averaging over particle orientations (Ref. 1) makes
242 C this method the fastest exact technique currently available.
243 C The use of an automatic convergence procedure
244 C (Ref. 2) makes the code convenient in massive computations.
245 C Ref. 4 describes features specific for finite cylinders as
246 C particles with sharp rectangular edges. Ref. 5 describes further
247 C numerical improvements.
248 
249 C Since this code uses extended precision variables, it is slower
250 C than the equivalent double-precision code. The double-precision
251 C code is also available, but it cannot compute as large particles
252 C for the same shape, refractive index, and wavelength as this code.
253 
254 C This is the first part of the full T-matrix code. The second part,
255 C lpq.f, is completely independent of the first part. It contains no
256 C T-matrix-specific subroutines and can be compiled separately.
257 C The second part of the code replaces the previously implemented
258 C standard matrix inversion scheme based on Gaussian elimination
259 C by a scheme based on the LU factorization technique.
260 C As described in Ref. 5 above, the use of the LU factorization is
261 C especially beneficial for nonabsorbing or weakly absorbing particles.
262 C In this code we use the LAPACK implementation of the LU factorization
263 C scheme. LAPACK stands for Linear Algebra PACKage. The latter is
264 C publicly available at the following internet site:
265 C
266 C http://www.netlib.org/lapack/
267 
268 C INPUT PARAMETERS:
269 C
270 C RAT = 1 - particle size is specified in terms of the
271 C equal-volume-sphere radius
272 .NE.C RAT1 - particle size is specified in terms of the
273 C equal-surface-area-sphere radius
274 C NDISTR specifies the distribution of equivalent-sphere radii
275 C NDISTR = 1 - modified gamma distribution
276 C [Eq. (40) of Ref. 7]
277 C AXI=alpha
278 C B=r_c
279 C GAM=gamma
280 C NDISTR = 2 - log-normal distribution
281 C [Eq. 41) of Ref. 7]
282 C AXI=r_g
283 C B=[ln(sigma_g)]**2
284 C NDISTR = 3 - power law distribution
285 C [Eq. (42) of Ref. 7]
286 C AXI=r_eff (effective radius)
287 C B=v_eff (effective variance)
288 C Parameters R1 and R2 (see below) are calculated
289 C automatically for given AXI and B
290 C NDISTR = 4 - gamma distribution
291 C [Eq. (39) of Ref. 7]
292 C AXI=a
293 C B=b
294 C NDISTR = 5 - modified power law distribution
295 C [Eq. (24) in M. I. Mishchenko et al.,
296 C Bidirectional reflectance of flat,
297 C optically thick particulate laters: an efficient radiative
298 C transfer solution and applications to snow and soil surfaces,
299 C J. Quant. Spectrosc. Radiat. Transfer, Vol. 63, 409-432 (1999)].
300 C B=alpha
301 C
302 C The code computes NPNAX size distributions of the same type
303 C and with the same values of B and GAM in one run.
304 C The parameter AXI varies from AXMAX to AXMAX/NPNAX in steps of
305 C AXMAX/NPNAX. To compute a single size distribution, use
306 C NPNAX=1 and AXMAX equal to AXI of this size distribution.
307 C
308 C R1 and R2 - minimum and maximum equivalent-sphere
309 C radii in the size distribution.
310 C They are calculated automatically
311 C for the power law distribution with given AXI and B
312 C but must be specified for other distributions
313 C after the lines
314 C
315 C DO 600 IAX=1,NPNAX
316 C AXI=AXMAX-DAX*DFLOAT(IAX-1)
317 C
318 C in the main program.
319 C For the modified power law distribution (NDISTR=5), the
320 C minimum radius is 0, R2 is the maximum radius,
321 C and R1 is the intermediate radius at which the
322 C n(r)=const dependence is replaced by the power law
323 C dependence.
324 C
325 .LE.C NKMAX988 is such that NKMAX+2 is the
326 C number of Gaussian quadrature points used in
327 C integrating over the size distribution for particles with
328 C AXI=AXMAX. For particles with AXI=AXMAX-AXMAX/NPNAX,
329 C AXMAX-2*AXMAX/NPNAX, etc. the number of Gaussian points
330 C linearly decreases.
331 C For the modified power law distribution, the number
332 C of integration points on the interval [0,R1] is also
333 C equal to NKMAX.
334 C
335 C LAM - wavelength of light
336 C MRR and MRI - real and imaginary parts of the refractive
337 .GE.C index (MRI0)
338 C EPS and NP - specify the shape of the particles.
339 C For spheroids NP=-1 and EPS is the ratio of the
340 C horizontal to rotational axes. EPS is larger than
341 C 1 for oblate spheroids and smaller than 1 for
342 C prolate spheroids.
343 C For cylinders NP=-2 and EPS is the ratio of the
344 C diameter to the length.
345 C For Chebyshev particles NP must be positive and
346 C is the degree of the Chebyshev polynomial, while
347 C EPS is the deformation parameter
348 C [Eq. (33) of Ref. 7].
349 C DDELT - accuracy of the computations
350 C NPNA - number of equidistant scattering angles (from 0
351 C to 180 deg) for which the scattering matrix is
352 C calculated.
353 C NDGS - parameter controlling the number of division points
354 C in computing integrals over the particle surface.
355 C For compact particles, the recommended value is 2.
356 C For highly aspherical particles larger values (3, 4,...)
357 C may be necessary to obtain convergence.
358 C The code does not check convergence over this parameter.
359 C Therefore, control comparisons of results obtained with
360 C different NDGS-values are recommended.
361 
362 
363 C OUTPUT PARAMETERS:
364 C
365 C REFF and VEFF - effective radius and effective variance of
366 C the size distribution as defined by Eqs. (43)-(45) of
367 C Ref. 7.
368 C CEXT - extinction cross section per particle
369 C CSCA - scattering cross section per particle
370 C W - single scattering albedo
371 C <cos> - asymmetry parameter of the phase function
372 C ALPHA1,...,BETA2 - coefficients appearing in the expansions
373 C of the elements of the scattering matrix in
374 C generalized spherical functions
375 C [Eqs. (11)-(16) of Ref. 7].
376 C F11,...,F44 - elements of the normalized scattering matrix [as
377 C defined by Eqs. (1)-(3) of Ref. 7] versus scattering angle
378 
379 C Note that LAM, r_c, r_g, r_eff, a, R1, and R2 must
380 C be given in the same units of length, and that
381 C the dimension of CEXT and CSCA is that of LAM squared (e.g., if
382 C LAM and AXI are given in microns, then CEXT and CSCA are
383 C calculated in square microns).
384 
385 C The physical correctness of the computed results is tested using
386 C the general inequalities derived by van der Mee and Hovenier,
387 C Astron. Astrophys., vol. 228, 559-568 (1990). Although
388 C the message that the test of van der Mee and Hovenier is satisfied
389 C does not guarantee that the results are absolutely correct,
390 C the message that the test is not satisfied can mean that something
391 C is wrong.
392 
393 C The convergence of the T-matrix method for particles with
394 C different sizes, refractive indices, and aspect ratios can be
395 C dramatically different. Usually, large sizes and large aspect
396 C ratios cause problems. The user of this code
397 C should first experiment with different input parameters in
398 C order to get an idea of the range of applicability of this
399 C technique. Sometimes decreasing the aspect ratio
400 C from 3 to 2 can increase the maximum convergent equivalent-
401 C sphere size parameter by a factor of several (Ref. 7).
402 C The CPU time required rapidly increases with increasing ratio
403 C radius/wavelength and/or with increasing particle asphericity.
404 C This should be taken into account in planning massive computations.
405 C Using an optimizing compiler on IBM RISC workstations saves
406 C about 70% of CPU time.
407 
408 C Execution can be automatically terminated if dimensions of certain
409 C arrays are not big enough or if the convergence procedure decides
410 C that the accuracy of extended precision variables is insufficient
411 C to obtain a converged T-matrix solution for given particles.
412 C In all cases, a message appears explaining the cause of termination.
413 
414 C The message
415 C "WARNING: W IS GREATER THAN 1"
416 C means that the single-scattering albedo exceeds the maximum
417 C possible value 1. If W is greater than 1 by more than
418 C DDELT, this message can be an indication of numerical
419 C instability caused by extreme values of particle parameters.
420 
421 C The message "WARNING: NGAUSS=NPNG1" means that convergence over
422 C the parameter NG (see Ref. 2) cannot be obtained for the NPNG1
423 C value specified in the PARAMETER statement in the file tmq.par.f.
424 C Often this is not a serious problem, especially for compact
425 C particles.
426 
427 C Larger and/or more aspherical particles may require larger
428 C values of the parameters NPN1, NPN4, and NPNG1 in the file
429 C tmq.par.f. It is recommended to keep NPN1=NPN4+25 and
430 C NPNG1=3*NPN1. Note that the memory requirement increases
431 C as the third power of NPN4. If the memory of
432 C a computer is too small to accomodate the code in its current
433 C setting, the parameters NPN1, NPN4, and NPNG1 should be
434 C decreased. However, this will decrease the maximum size parameter
435 C that can be handled by the code.
436 
437 C In some cases any increases of NPN1 will not make the T-matrix
438 C computations convergent. This means that the particle is just
439 C too "bad" (extreme size parameter and/or extreme aspect ratio
440 C and/or extreme refractive index; see Ref. 7).
441 C The main program contains several PRINT statements which are
442 C currently commentd out. If uncommented, these statements will
443 C produce numbers which show the convergence rate and can be
444 C used to determine whether T-matrix computations for given particle
445 C parameters will converge at all.
446 
447 C Some of the common blocks are used to save memory rather than
448 C to transfer data. Therefore, if a compiler produces a warning
449 C message that the lengths of a common block are different in
450 C different subroutines, this is not a real problem.
451 
452 C The recommended value of DDELT is 0.001. For bigger values,
453 C false convergence can be obtained.
454 
455 C In computations for spheres use EPS=1.000001 instead of EPS=1.
456 C The use of EPS=1 can cause overflows in some rare cases.
457 
458 C To calculate a monodisperse particle, use the options
459 C NPNAX=1
460 C AXMAX=R
461 C B=1D-1
462 C NKMAX=-1
463 C NDISTR=4
464 C ...
465 C DO 600 IAX=1,NPNAX
466 C AXI=AXMAX-DAX*DFLOAT(IAX-1)
467 C R1=0.9999999*AXI
468 C R2=1.0000001*AXI
469 C ...
470 C where R is the equivalent-sphere radius.
471 
472 C It is recommended to use the power law rather than the
473 C gamma size distribution, because in this case convergent solution
474 C can be obtained for larger REFF and VEFF assuming the same
475 C maximal R2 (Mishchenko and Travis, Appl. Opt., vol. 33, 7206-7225,
476 C 1994).
477 
478 C For some compilers, DACOS must be raplaced by DARCOS and DASIN
479 C by DARSIN.
480 
481 C If many different size distributions are computed and the
482 C refractive index is fixed, then another approach can be more
483 C efficient than running this code many times. Specifically,
484 C scattering results should be computed for monodisperse particles
485 C with sizes ranging from essentially zero to some maximum value
486 C with a small step size (say, 0.02 microns). These results
487 C should be stored on disk and can be used along with spline
488 C interpolation to compute scattering by particles with intermediate
489 C sizes. Scattering patterns for monodisperse nonspherical
490 C particles in random orientation are (much) smoother than for
491 C monodisperse spheres, and spline interpolation usually gives good
492 C results. In this way, averaging over any size distribution is a
493 C matter of seconds. For more on size averaging, see Refs. 2 and 4.
494 
495 C We would highly appreciate informing me of any problems encountered
496 C with this code. Please send your message to the following
497 C e-mail address: CRMIM@GISS.NASA.GOV.
498 
499 C WHILE THE COMPUTER PROGRAM HAS BEEN TESTED FOR A VARIETY OF CASES,
500 C IT IS NOT INCONCEIVABLE THAT IT CONTAINS UNDETECTED ERRORS. ALSO,
501 C INPUT PARAMETERS CAN BE USED WHICH ARE OUTSIDE THE ENVELOPE OF
502 C VALUES FOR WHICH RESULTS ARE COMPUTED ACCURATELY. FOR THIS REASON,
503 C THE AUTHORS AND THEIR ORGANIZATION DISCLAIM ALL LIABILITY FOR
504 C ANY DAMAGES THAT MAY RESULT FROM THE USE OF THE PROGRAM.
505 
506 
507  IMPLICIT REAL*8 (A-H,O-Z)
508  INCLUDE 'tmq.par.f'
509  REAL*16 LAM,MRR,MRI,X(NPNG2),W(NPNG2),S(NPNG2),SS(NPNG2),
510  * AN(NPN1),R(NPNG2),DR(NPNG2),PPI,PIR,PII,P,EPS,A,
511  * DDR(NPNG2),DRR(NPNG2),DRI(NPNG2),ANN(NPN1,NPN1)
512  REAL*8 XG(1000),WG(1000),TR1(NPN2,NPN2),TI1(NPN2,NPN2),
513  & ALPH1(NPL),ALPH2(NPL),ALPH3(NPL),ALPH4(NPL),BET1(NPL),
514  & BET2(NPL),XG1(2000),WG1(2000),
515  & AL1(NPL),AL2(NPL),AL3(NPL),AL4(NPL),BE1(NPL),BE2(NPL)
516  REAL*4
517  & RT11(NPN6,NPN4,NPN4),RT12(NPN6,NPN4,NPN4),
518  & RT21(NPN6,NPN4,NPN4),RT22(NPN6,NPN4,NPN4),
519  & IT11(NPN6,NPN4,NPN4),IT12(NPN6,NPN4,NPN4),
520  & IT21(NPN6,NPN4,NPN4),IT22(NPN6,NPN4,NPN4)
521 
522  COMMON /CT/ TR1,TI1
523  COMMON /TMAT/ RT11,RT12,RT21,RT22,IT11,IT12,IT21,IT22
524  P=QARCOS(-1Q0)
525  PIN=P
526 
527 C OPEN FILES *******************************************************
528 
529  OPEN (6,FILE='test')
530  OPEN (10,FILE='tmatr.write')
531 
532 C INPUT DATA ********************************************************
533 
534  RAT=0.5D0
535  NDISTR=3
536  AXMAX=1D0
537  NPNAX=2
538  B=1D-1
539  GAM=0.5D0
540  NKMAX=5
541  EPS=2D0
542  NP=-1
543  LAM=0.5D0
544  MRR=1.33D0
545  MRI=0.001D0
546  DDELT=0.001D0
547  NPNA=19
548  NDGS=2
549 
550  NCHECK=0
551 .EQ..OR..EQ. IF (NP-1NP-2) NCHECK=1
552 .GT..AND..EQ. IF (NP0(-1)**NP1) NCHECK=1
553  WRITE (6,5454) NCHECK
554  5454 FORMAT ('ncheck=',I1)
555  DAX=AXMAX/NPNAX
556  DLAM=LAM
557  DMRR=MRR
558  DMRI=MRI
559  DEPS=EPS
560 .GT..AND..EQ. IF (DABS(RAT-1D0)1D-8NP-1) CALL SAREA (DEPS,RAT)
561 .GT..AND..GE. IF (DABS(RAT-1D0)1D-8NP0) CALL SURFCH(NP,DEPS,RAT)
562 .GT..AND..EQ. IF (DABS(RAT-1D0)1D-8NP-2) CALL SAREAC (DEPS,RAT)
563 C PRINT 8000, RAT
564  8000 FORMAT ('rat=',F8.6)
565 .EQ..AND..GE. IF(NP-1EPS1D0) PRINT 7000,EPS
566 .EQ..AND..LT. IF(NP-1EPS1D0) PRINT 7001,EPS
567 .GE. IF(NP0) PRINT 7100,NP,EPS
568 .EQ..AND..GE. IF(NP-2EPS1D0) PRINT 7150,EPS
569 .EQ..AND..LT. IF(NP-2EPS1D0) PRINT 7151,EPS
570  PRINT 7400, LAM,MRR,MRI
571  PRINT 7200,DDELT
572  7000 FORMAT('randomly oriented oblate spheroids, a/b=',F11.7)
573  7001 FORMAT('randomly oriented prolate spheroids, a/b=',F11.7)
574  7100 FORMAT('randomly oriented chebyshev particles, t',
575  & I1,'(',F5.2,')')
576  7150 FORMAT('randomly oriented oblate cylinders, d/l=',F11.7)
577  7151 FORMAT('randomly oriented prolate cylinders, d/l=',F11.7)
578  7200 FORMAT ('accuracy of computations ddelt = ',d8.2)
579  7400 FORMAT('lam=',F10.6,3X,'mrr=',D10.4,3X,'mri=',D10.4)
580  DDELT=0.1D0*DDELT
581  DO 600 IAX=1,NPNAX
582  AXI=AXMAX-DAX*DFLOAT(IAX-1)
583  R1=0.89031D0*AXI
584  R2=1.56538D0*AXI
585  NK=IDINT(AXI*NKMAX/AXMAX+2)
586 .GT. IF (NK1000) PRINT 8001,NK
587 .GT. IF (NK1000) STOP
588 .EQ. IF (NDISTR3) CALL POWER (AXI,B,R1,R2)
589  8001 FORMAT ('nk=',I4,' i.e., is greater than 1000. ',
590  & 'execution terminated.')
591  CALL GAUSS (NK,0,0,XG,WG)
592  Z1=(R2-R1)*0.5D0
593  Z2=(R1+R2)*0.5D0
594  Z3=R1*0.5D0
595 .EQ. IF (NDISTR5) GO TO 3
596  DO I=1,NK
597  XG1(I)=Z1*XG(I)+Z2
598  WG1(I)=WG(I)*Z1
599  ENDDO
600  GO TO 4
601  3 DO I=1,NK
602  XG1(I)=Z3*XG(I)+Z3
603  WG1(I)=WG(I)*Z3
604  ENDDO
605  DO I=NK+1,2*NK
606  II=I-NK
607  XG1(I)=Z1*XG(II)+Z2
608  WG1(I)=WG(II)*Z1
609  ENDDO
610  NK=NK*2
611  4 CALL DISTRB (NK,XG1,WG1,NDISTR,AXI,B,GAM,R1,R2,
612  & REFF,VEFF,PIN)
613  PRINT 8002,R1,R2
614  8002 FORMAT('r1=',F10.6,' r2=',F10.6)
615 .LE. IF (DABS(RAT-1D0)1D-6) PRINT 8003, REFF,VEFF
616 .GT. IF (DABS(RAT-1D0)1D-6) PRINT 8004, REFF,VEFF
617  8003 FORMAT('equal-volume-sphere reff=',F8.4,' veff=',F7.4)
618  8004 FORMAT('equal-surface-area-sphere reff=',F8.4,
619  & ' veff=',F7.4)
620  PRINT 7250,NK
621  7250 FORMAT('number of gaussian quadrature points ',
622  & 'in SIZE averaging =',I4)
623  DO I=1,NPL
624  ALPH1(I)=0D0
625  ALPH2(I)=0D0
626  ALPH3(I)=0D0
627  ALPH4(I)=0D0
628  BET1(I)=0D0
629  BET2(I)=0D0
630  ENDDO
631  CSCAT=0D0
632  CEXTIN=0D0
633  L1MAX=0
634  DO 500 INK=1,NK
635  I=NK-INK+1
636  A=RAT*XG1(I)
637  XEV=2D0*PIN*A/DLAM
638  IXXX=XEV+4.05D0*XEV**0.333333D0
639  INM1=MAX0(4,IXXX)
640 .GE. IF (INM1NPN1) PRINT 7333, NPN1
641 .GE. IF (INM1NPN1) STOP
642  7333 FORMAT('convergence is not obtained for npn1=',I3,
643  & '. execution terminated')
644  QEXT1=0D0
645  QSCA1=0D0
646  DO 50 NMA=INM1,NPN1
647  NMAX=NMA
648  MMAX=1
649  NGAUSS=NMAX*NDGS
650 .GT. IF (NGAUSSNPNG1) PRINT 7340, NGAUSS
651 .GT. IF (NGAUSSNPNG1) STOP
652  7340 FORMAT('ngauss =',I3,' i.e. is greater than npng1.',
653  & ' execution terminated')
654  7334 FORMAT(' nmax =', I3,' dc2=',D8.2,' dc1=',D8.2)
655  7335 FORMAT(' nmax1 =', I3,' dc2=',D8.2,
656  & ' dc1=',D8.2)
657  CALL CONST(NGAUSS,NMAX,MMAX,P,X,W,AN,ANN,S,SS,NP,EPS)
658  CALL VARY(LAM,MRR,MRI,A,EPS,NP,NGAUSS,X,P,PPI,PIR,PII,R,
659  & DR,DDR,DRR,DRI,NMAX)
660  CALL TMATR0 (NGAUSS,X,W,AN,ANN,S,SS,PPI,PIR,PII,R,DR,
661  & DDR,DRR,DRI,NMAX,NCHECK)
662  QEXT=0D0
663  QSCA=0D0
664  DO N=1,NMAX
665  N1=N+NMAX
666  TR1NN=TR1(N,N)
667  TI1NN=TI1(N,N)
668  TR1NN1=TR1(N1,N1)
669  TI1NN1=TI1(N1,N1)
670  DN1=DFLOAT(2*N+1)
671  QSCA=QSCA+DN1*(TR1NN*TR1NN+TI1NN*TI1NN
672  & +TR1NN1*TR1NN1+TI1NN1*TI1NN1)
673  QEXT=QEXT+(TR1NN+TR1NN1)*DN1
674  ENDDO
675  DSCA=DABS((QSCA1-QSCA)/QSCA)
676  DEXT=DABS((QEXT1-QEXT)/QEXT)
677 C PRINT 7334, NMAX,DSCA,DEXT
678  QEXT1=QEXT
679  QSCA1=QSCA
680  NMIN=DFLOAT(NMAX)/2D0+1D0
681  DO 10 N=NMIN,NMAX
682  N1=N+NMAX
683  TR1NN=TR1(N,N)
684  TI1NN=TI1(N,N)
685  TR1NN1=TR1(N1,N1)
686  TI1NN1=TI1(N1,N1)
687  DN1=DFLOAT(2*N+1)
688  DQSCA=DN1*(TR1NN*TR1NN+TI1NN*TI1NN
689  & +TR1NN1*TR1NN1+TI1NN1*TI1NN1)
690  DQEXT=(TR1NN+TR1NN1)*DN1
691  DQSCA=DABS(DQSCA/QSCA)
692  DQEXT=DABS(DQEXT/QEXT)
693  NMAX1=N
694 .LE..AND..LE. IF (DQSCADDELTDQEXTDDELT) GO TO 12
695  10 CONTINUE
696  12 CONTINUE
697 c PRINT 7335, NMAX1,DQSCA,DQEXT
698 .LE..AND..LE. IF(DSCADDELTDEXTDDELT) GO TO 55
699 .EQ. IF (NMANPN1) PRINT 7333, NPN1
700 .EQ. IF (NMANPN1) STOP
701  50 CONTINUE
702  55 NNNGGG=NGAUSS+1
703 .EQ. IF (NGAUSSNPNG1) PRINT 7336
704  MMAX=NMAX1
705  DO 150 NGAUS=NNNGGG,NPNG1
706  NGAUSS=NGAUS
707  NGGG=2*NGAUSS
708  7336 FORMAT('warning: ngauss=npng1')
709  7337 FORMAT(' ng=',I3,' dc2=',D8.2,' dc1=',D8.2)
710  CALL CONST(NGAUSS,NMAX,MMAX,P,X,W,AN,ANN,S,SS,NP,EPS)
711  CALL VARY(LAM,MRR,MRI,A,EPS,NP,NGAUSS,X,P,PPI,PIR,PII,R,
712  & DR,DDR,DRR,DRI,NMAX)
713  CALL TMATR0 (NGAUSS,X,W,AN,ANN,S,SS,PPI,PIR,PII,R,DR,
714  & DDR,DRR,DRI,NMAX,NCHECK)
715  QEXT=0D0
716  QSCA=0D0
717  DO 104 N=1,NMAX
718  N1=N+NMAX
719  TR1NN=TR1(N,N)
720  TI1NN=TI1(N,N)
721  TR1NN1=TR1(N1,N1)
722  TI1NN1=TI1(N1,N1)
723  DN1=DFLOAT(2*N+1)
724  QSCA=QSCA+DN1*(TR1NN*TR1NN+TI1NN*TI1NN
725  & +TR1NN1*TR1NN1+TI1NN1*TI1NN1)
726  QEXT=QEXT+(TR1NN+TR1NN1)*DN1
727  104 CONTINUE
728  DSCA=DABS((QSCA1-QSCA)/QSCA)
729  DEXT=DABS((QEXT1-QEXT)/QEXT)
730 c PRINT 7337, NGGG,DSCA,DEXT
731  QEXT1=QEXT
732  QSCA1=QSCA
733 .LE..AND..LE. IF(DSCADDELTDEXTDDELT) GO TO 155
734 .EQ. IF (NGAUSNPNG1) PRINT 7336
735  150 CONTINUE
736  155 CONTINUE
737  QSCA=0D0
738  QEXT=0D0
739  NNM=NMAX*2
740  DO 204 N=1,NNM
741  QEXT=QEXT+TR1(N,N)
742  204 CONTINUE
743 .GT. IF (NMAX1NPN4) PRINT 7550, NMAX1
744  7550 FORMAT ('nmax1 = ',I3, ', i.e. greater than npn4.',
745  & ' execution terminated')
746 .GT. IF (NMAX1NPN4) STOP
747  DO 213 N2=1,NMAX1
748  NN2=N2+NMAX
749  DO 213 N1=1,NMAX1
750  NN1=N1+NMAX
751  ZZ1=TR1(N1,N2)
752  RT11(1,N1,N2)=ZZ1
753  ZZ2=TI1(N1,N2)
754  IT11(1,N1,N2)=ZZ2
755  ZZ3=TR1(N1,NN2)
756  RT12(1,N1,N2)=ZZ3
757  ZZ4=TI1(N1,NN2)
758  IT12(1,N1,N2)=ZZ4
759  ZZ5=TR1(NN1,N2)
760  RT21(1,N1,N2)=ZZ5
761  ZZ6=TI1(NN1,N2)
762  IT21(1,N1,N2)=ZZ6
763  ZZ7=TR1(NN1,NN2)
764  RT22(1,N1,N2)=ZZ7
765  ZZ8=TI1(NN1,NN2)
766  IT22(1,N1,N2)=ZZ8
767  QSCA=QSCA+ZZ1*ZZ1+ZZ2*ZZ2+ZZ3*ZZ3+ZZ4*ZZ4
768  & +ZZ5*ZZ5+ZZ6*ZZ6+ZZ7*ZZ7+ZZ8*ZZ8
769  213 CONTINUE
770 C PRINT 7800,0,DABS(QEXT),QSCA,NMAX
771  DO 220 M=1,NMAX1
772  CALL TMATR(M,NGAUSS,X,W,AN,ANN,S,SS,PPI,PIR,PII,R,DR,
773  & DDR,DRR,DRI,NMAX,NCHECK)
774  NM=NMAX-M+1
775  NM1=NMAX1-M+1
776  M1=M+1
777  QSC=0D0
778  DO 214 N2=1,NM1
779  NN2=N2+M-1
780  N22=N2+NM
781  DO 214 N1=1,NM1
782  NN1=N1+M-1
783  N11=N1+NM
784  ZZ1=TR1(N1,N2)
785  RT11(M1,NN1,NN2)=ZZ1
786  ZZ2=TI1(N1,N2)
787  IT11(M1,NN1,NN2)=ZZ2
788  ZZ3=TR1(N1,N22)
789  RT12(M1,NN1,NN2)=ZZ3
790  ZZ4=TI1(N1,N22)
791  IT12(M1,NN1,NN2)=ZZ4
792  ZZ5=TR1(N11,N2)
793  RT21(M1,NN1,NN2)=ZZ5
794  ZZ6=TI1(N11,N2)
795  IT21(M1,NN1,NN2)=ZZ6
796  ZZ7=TR1(N11,N22)
797  RT22(M1,NN1,NN2)=ZZ7
798  ZZ8=TI1(N11,N22)
799  IT22(M1,NN1,NN2)=ZZ8
800  QSC=QSC+(ZZ1*ZZ1+ZZ2*ZZ2+ZZ3*ZZ3+ZZ4*ZZ4
801  & +ZZ5*ZZ5+ZZ6*ZZ6+ZZ7*ZZ7+ZZ8*ZZ8)*2D0
802  214 CONTINUE
803  NNM=2*NM
804  QXT=0D0
805  DO 215 N=1,NNM
806  QXT=QXT+TR1(N,N)*2D0
807  215 CONTINUE
808  QSCA=QSCA+QSC
809  QEXT=QEXT+QXT
810 C PRINT 7800,M,DABS(QXT),QSC,NMAX
811  7800 FORMAT(' m=',I3,' qxt=',D12.6,' qsc=',D12.6,
812  & ' nmax=',I3)
813  220 CONTINUE
814  COEFF1=LAM*LAM*0.5D0/P
815  CSCA=QSCA*COEFF1
816  CEXT=-QEXT*COEFF1
817 c PRINT 7880, NMAX,NMAX1
818  7880 FORMAT ('nmax=',I3,' nmax1=',I3)
819  CALL GSP (NMAX1,CSCA,LAM,AL1,AL2,AL3,AL4,BE1,BE2,LMAX)
820  L1M=LMAX+1
821  L1MAX=MAX(L1MAX,L1M)
822  WGII=WG1(I)
823  WGI=WGII*CSCA
824  DO 250 L1=1,L1M
825  ALPH1(L1)=ALPH1(L1)+AL1(L1)*WGI
826  ALPH2(L1)=ALPH2(L1)+AL2(L1)*WGI
827  ALPH3(L1)=ALPH3(L1)+AL3(L1)*WGI
828  ALPH4(L1)=ALPH4(L1)+AL4(L1)*WGI
829  BET1(L1)=BET1(L1)+BE1(L1)*WGI
830  BET2(L1)=BET2(L1)+BE2(L1)*WGI
831  250 CONTINUE
832  CSCAT=CSCAT+WGI
833  CEXTIN=CEXTIN+CEXT*WGII
834 C PRINT 6070, I,NMAX,NMAX1,NGAUSS
835  6070 FORMAT(4I6)
836  500 CONTINUE
837  DO 510 L1=1,L1MAX
838  ALPH1(L1)=ALPH1(L1)/CSCAT
839  ALPH2(L1)=ALPH2(L1)/CSCAT
840  ALPH3(L1)=ALPH3(L1)/CSCAT
841  ALPH4(L1)=ALPH4(L1)/CSCAT
842  BET1(L1)=BET1(L1)/CSCAT
843  BET2(L1)=BET2(L1)/CSCAT
844  510 CONTINUE
845  WALB=CSCAT/CEXTIN
846  CALL HOVENR(L1MAX,ALPH1,ALPH2,ALPH3,ALPH4,BET1,BET2)
847  ASYMM=ALPH1(2)/3D0
848  PRINT 9100,CEXTIN,CSCAT,WALB,ASYMM
849  9100 FORMAT('cext=',D12.6,2X,'csca=',D12.6,2X,
850  & 2X,'w=',D12.6,2X,'<cos>=',D12.6)
851 .GT. IF (WALB1D0) PRINT 9111
852  9111 FORMAT ('warning: w is greater than 1')
853  WRITE (10,580) WALB,L1MAX
854  DO L=1,L1MAX
855  WRITE (10,575) ALPH1(L),ALPH2(L),ALPH3(L),ALPH4(L),
856  & BET1(L),BET2(L)
857  ENDDO
858  575 FORMAT(6D14.7)
859  580 FORMAT(D14.8,I8)
860  LMAX=L1MAX-1
861  CALL MATR (ALPH1,ALPH2,ALPH3,ALPH4,BET1,BET2,LMAX,NPNA)
862  600 CONTINUE
863  ITIME=MCLOCK()
864  TIME=DFLOAT(ITIME)/6000D0
865  PRINT 1001,TIME
866  1001 FORMAT (' time =',F8.2,' min')
867  STOP
868  END
869 
870 C**********************************************************************
871 C *
872 C INPUT PARAMETERS: *
873 C *
874 C NG = 2*NGAUSS - number of quadrature points on the *
875 .LE.C interval (-1,1). NGAUSSNPNG1 *
876 .LE.C NMAX,MMAX - maximum dimensions of the arrays. NMAXNPN1 *
877 .LE.C MMAXNPN1 *
878 C P - pi *
879 C *
880 C OUTPUT PARAMETERS: *
881 C *
882 C X,W - points and weights of the quadrature formula *
883 C AN(N) = n*(n+1) *
884 C ANN(N1,N2) = (1/2)*sqrt((2*n1+1)*(2*n2+1)/(n1*(n1+1)*n2*(n2+1))) *
885 C S(I)=1/sin(arccos(x(i))) *
886 C SS(I)=S(I)**2 *
887 C *
888 C**********************************************************************
889 
890  SUBROUTINE CONST (NGAUSS,NMAX,MMAX,P,X,W,AN,ANN,S,SS,NP,EPS)
891  IMPLICIT REAL*16 (A-H,O-Z)
892  INCLUDE 'tmq.par.f'
893  REAL*16 X(NPNG2),W(NPNG2),X1(NPNG1),W1(NPNG1),
894  * X2(NPNG1),W2(NPNG1),
895  * S(NPNG2),SS(NPNG2),
896  * AN(NPN1),ANN(NPN1,NPN1),DD(NPN1)
897 
898  DO 10 N=1,NMAX
899  NN=N*(N+1)
900  AN(N)=QFLOAT(NN)
901  D=QSQRT(QFLOAT(2*N+1)/QFLOAT(NN))
902  DD(N)=D
903  DO 10 N1=1,N
904  DDD=D*DD(N1)*0.5Q0
905  ANN(N,N1)=DDD
906  ANN(N1,N)=DDD
907  10 CONTINUE
908  NG=2*NGAUSS
909 .EQ. IF (NP-2) GO TO 11
910  CALL QGAUSS(NG,0,0,X,W)
911  GO TO 19
912  11 NG1=DFLOAT(NGAUSS)/2D0
913  NG2=NGAUSS-NG1
914  XX=-QCOS(QATAN(EPS))
915  CALL QGAUSS(NG1,0,0,X1,W1)
916  CALL QGAUSS(NG2,0,0,X2,W2)
917  DO 12 I=1,NG1
918  W(I)=0.5Q0*(XX+1Q0)*W1(I)
919  X(I)=0.5Q0*(XX+1Q0)*X1(I)+0.5Q0*(XX-1Q0)
920  12 CONTINUE
921  DO 14 I=1,NG2
922  W(I+NG1)=-0.5Q0*XX*W2(I)
923  X(I+NG1)=-0.5Q0*XX*X2(I)+0.5Q0*XX
924  14 CONTINUE
925  DO 16 I=1,NGAUSS
926  W(NG-I+1)=W(I)
927  X(NG-I+1)=-X(I)
928  16 CONTINUE
929  19 DO 20 I=1,NGAUSS
930  Y=X(I)
931  Y=1Q0/(1Q0-Y*Y)
932  SS(I)=Y
933  SS(NG-I+1)=Y
934  Y=QSQRT(Y)
935  S(I)=Y
936  S(NG-I+1)=Y
937  20 CONTINUE
938  RETURN
939  END
940 
941 C***************************************************************
942 
943  SUBROUTINE QGAUSS ( N,IND1,IND2,Z,W )
944  IMPLICIT REAL*16 (A-H,P-Z)
945  REAL*16 Z(N),W(N)
946  A=1Q0
947  B=2Q0
948  C=3Q0
949  IND=MOD(N,2)
950  K=N/2+IND
951  F=QFLOAT(N)
952  DO 100 I=1,K
953  M=N+1-I
954 .EQ. IF(I1) X=A-B/((F+A)*F)
955 .EQ. IF(I2) X=(Z(N)-A)*4Q0+Z(N)
956 .EQ. IF(I3) X=(Z(N-1)-Z(N))*1.6Q0+Z(N-1)
957 .GT. IF(I3) X=(Z(M+1)-Z(M+2))*C+Z(M+3)
958 .EQ..AND..EQ. IF(IKIND1) X=0Q0
959  NITER=0
960  CHECK=1Q-32
961  10 PB=1Q0
962  NITER=NITER+1
963 .LE. IF (NITER100) GO TO 15
964 c PRINT 5000, CHECK
965  CHECK=CHECK*10Q0
966  15 PC=X
967  DJ=A
968  DO 20 J=2,N
969  DJ=DJ+A
970  PA=PB
971  PB=PC
972  20 PC=X*PB+(X*PB-PA)*(DJ-A)/DJ
973  PA=A/((PB-X*PC)*F)
974  PB=PA*PC*(A-X*X)
975  X=X-PB
976 .GT. IF(QABS(PB)CHECK*QABS(X)) GO TO 10
977  Z(M)=X
978  W(M)=PA*PA*(A-X*X)
979 .EQ. IF(IND10) W(M)=B*W(M)
980 .EQ..AND..EQ. IF(IKIND1) GO TO 100
981  Z(I)=-Z(M)
982  W(I)=W(M)
983  100 CONTINUE
984  5000 format ('qgauss does not converge, check=',Q10.3)
985 .NE. IF(IND21) GO TO 110
986  PRINT 1100,N
987  1100 FORMAT(' *** points and weights of gaussian quadrature formula',
988  * ' of ',I4,'-th order')
989  DO 105 I=1,K
990  ZZ=-Z(I)
991  105 PRINT 1200,I,ZZ,I,W(I)
992  1200 FORMAT(' ',4X,'x(',I4,') = ',F17.14,5X,'w(',I4,') = ',F17.14)
993  GO TO 115
994  110 CONTINUE
995 C PRINT 1300,N
996  1300 FORMAT(' gaussian quadrature formula of ',I4,'-th order is used')
997  115 CONTINUE
998 .EQ. IF(IND10) GO TO 140
999  DO 120 I=1,N
1000  120 Z(I)=(A+Z(I))/B
1001  140 CONTINUE
1002  RETURN
1003  END
1004 
1005 C**********************************************************************
1006 C *
1007 C INPUT PARAMETERS: *
1008 C *
1009 C LAM - wavelength of light *
1010 C MRR and MRI - real and imaginary parts of the refractive index *
1011 C A,EPS,NP - specify shape of the particle *
1012 C (see subroutines RSP1, RSP2, and RSP3) *
1013 C NG = NGAUSS*2 - number of gaussian quadrature points on the *
1014 C interval (-1,1) *
1015 C X - gaussian division points *
1016 C P - pi *
1017 C *
1018 C OUTPUT INFORMATION: *
1019 C *
1020 C PPI = PI**2 , where PI = (2*P)/LAM (wavenumber) *
1021 C PIR = PPI*MRR *
1022 C PII = PPI*MRI *
1023 C R and DR - see subroutines RSP1, RSP2, and RSP3 *
1024 C DDR=1/(PI*SQRT(R)) *
1025 C DRR+I*DRI=DDR/(MRR+I*MRI) *
1026 C NMAX - dimension of T(m)-matrices *
1027 C arrays J,Y,JR,JI,DJ,DY,DJR,DJI are transferred through *
1028 C COMMON /CBESS/ - see subroutine BESS *
1029 C *
1030 C**********************************************************************
1031 
1032  SUBROUTINE VARY (LAM,MRR,MRI,A,EPS,NP,NGAUSS,X,P,PPI,PIR,PII,
1033  * R,DR,DDR,DRR,DRI,NMAX)
1034  INCLUDE 'tmq.par.f'
1035  IMPLICIT REAL*16 (A-H,O-Z)
1036  REAL*16 X(NPNG2),R(NPNG2),DR(NPNG2),MRR,MRI,LAM,
1037  * Z(NPNG2),ZR(NPNG2),ZI(NPNG2),
1038  * J(NPNG2,NPN1),Y(NPNG2,NPN1),JR(NPNG2,NPN1),
1039  * JI(NPNG2,NPN1),DJ(NPNG2,NPN1),
1040  * DJR(NPNG2,NPN1),DJI(NPNG2,NPN1),DDR(NPNG2),
1041  * DRR(NPNG2),DRI(NPNG2),
1042  * DY(NPNG2,NPN1)
1043  COMMON /CBESS/ J,Y,JR,JI,DJ,DY,DJR,DJI
1044  NG=NGAUSS*2
1045 .EQ. IF (NP-1) CALL RSP1(X,NG,NGAUSS,A,EPS,NP,R,DR)
1046 .GE. IF (NP0) CALL RSP2(X,NG,A,EPS,NP,R,DR)
1047 .EQ. IF (NP-2) CALL RSP3(X,NG,NGAUSS,A,EPS,R,DR)
1048  PI=P*2Q0/LAM
1049  PPI=PI*PI
1050  PIR=PPI*MRR
1051  PII=PPI*MRI
1052  V=1Q0/(MRR*MRR+MRI*MRI)
1053  PRR=MRR*V
1054  PRI=-MRI*V
1055  TA=0Q0
1056  DO 10 I=1,NG
1057  VV=QSQRT(R(I))
1058  V=VV*PI
1059  TA=MAX(TA,V)
1060  VV=1Q0/V
1061  DDR(I)=VV
1062  DRR(I)=PRR*VV
1063  DRI(I)=PRI*VV
1064  V1=V*MRR
1065  V2=V*MRI
1066  Z(I)=V
1067  ZR(I)=V1
1068  ZI(I)=V2
1069  10 CONTINUE
1070 .GT. IF (NMAXNPN1) PRINT 9000,NMAX,NPN1
1071 .GT. IF (NMAXNPN1) STOP
1072  9000 FORMAT(' nmax = ',I2,', i.e., greater than ',I3)
1073  TB=TA*QSQRT(MRR*MRR+MRI*MRI)
1074  TB=QMAX1(TB,QFLOAT(NMAX))
1075  NNMAX1=8.0Q0*QSQRT(QMAX1(TA,QFLOAT(NMAX)))+3Q0
1076  NNMAX2=(TB+4Q0*(TB**0.33333Q0)+8.0Q0*QSQRT(TB))
1077  NNMAX2=NNMAX2-NMAX+5
1078  CALL BESS(Z,ZR,ZI,NG,NMAX,NNMAX1,NNMAX2)
1079  RETURN
1080  END
1081 
1082 C**********************************************************************
1083 C *
1084 C Calculation of the functions R(I)=r(y(I))**2 and *
1085 C DR(I)=((d/dy)r(y))/r(y) and horizontal semi-axis A *
1086 C for a spheroid specified by the parameters REV (equal-volume- *
1087 C sphere radius) and EPS=A/B (ratio of the semi-axes). *
1088 C Y(I)=arccos(X(I)) *
1089 .LE..LE.C 1ING *
1090 C X - arguments *
1091 C *
1092 C**********************************************************************
1093 
1094  SUBROUTINE RSP1 (X,NG,NGAUSS,REV,EPS,NP,R,DR)
1095  IMPLICIT REAL*16 (A-H,O-Z)
1096  REAL*16 X(NG),R(NG),DR(NG)
1097  A=REV*EPS**(1Q0/3Q0)
1098  AA=A*A
1099  EE=EPS*EPS
1100  EE1=EE-1Q0
1101  DO 50 I=1,NGAUSS
1102  C=X(I)
1103  CC=C*C
1104  SS=1Q0-CC
1105  S=QSQRT(SS)
1106  RR=1Q0/(SS+EE*CC)
1107  R(I)=AA*RR
1108  R(NG-I+1)=R(I)
1109  DR(I)=RR*C*S*EE1
1110  DR(NG-I+1)=-DR(I)
1111  50 CONTINUE
1112  RETURN
1113  END
1114 
1115 C**********************************************************************
1116 C *
1117 C Calculation of the functions R(I)=r(y(i))**2 and *
1118 C DR(I)=((d/dy)r(y))/r(y) and parameter R0 for a Chebyshev *
1119 C particle specified by the parameters REV (equal-volume-sphere *
1120 C radius), EPS, and N. *
1121 C Y(I)=arccos(X(I)) *
1122 .LE..LE.C 1ING *
1123 C X - arguments *
1124 C *
1125 C**********************************************************************
1126 
1127  SUBROUTINE RSP2 (X,NG,REV,EPS,N,R,DR)
1128  IMPLICIT REAL*16 (A-H,O-Z)
1129  REAL*16 X(NG),R(NG),DR(NG)
1130  DNP=QFLOAT(N)
1131  DN=DNP*DNP
1132  DN4=DN*4Q0
1133  EP=EPS*EPS
1134  A=1Q0+1.5Q0*EP*(DN4-2Q0)/(DN4-1Q0)
1135  I=(DNP+0.1Q0)*0.5Q0
1136  I=2*I
1137 .EQ. IF (IN) A=A-3Q0*EPS*(1Q0+0.25Q0*EP)/
1138  * (DN-1Q0)-0.25Q0*EP*EPS/(9Q0*DN-1Q0)
1139  R0=REV*A**(-1Q0/3Q0)
1140  DO 50 I=1,NG
1141  XI=QARCOS(X(I))*DNP
1142  RI=R0*(1Q0+EPS*QCOS(XI))
1143  R(I)=RI*RI
1144  DR(I)=-R0*EPS*DNP*QSIN(XI)/RI
1145  50 CONTINUE
1146  RETURN
1147  END
1148 
1149 C**********************************************************************
1150 C *
1151 C Calculation of the functions R(I)=R(Y(I))**2 and *
1152 C DR(I)=((d/dy)r(y))/r(y) *
1153 C for a cylinder specified by the parameters REV (equal-volume- *
1154 C sphere radius) and EPS=A/H (ratio of radius to semi-length) *
1155 C Y(I)=arccos(X(I)) *
1156 .LE..LE.C 1ING *
1157 C X - arguments *
1158 C *
1159 C**********************************************************************
1160 
1161  SUBROUTINE RSP3 (X,NG,NGAUSS,REV,EPS,R,DR)
1162  IMPLICIT REAL*16 (A-H,O-Z)
1163  REAL*16 X(NG),R(NG),DR(NG)
1164  H=REV*( (2Q0/(3Q0*EPS*EPS))**(1Q0/3Q0) )
1165  A=H*EPS
1166  DO 50 I=1,NGAUSS
1167  CO=-X(I)
1168  SI=QSQRT(1Q0-CO*CO)
1169 .GT. IF (SI/COA/H) GO TO 20
1170  RAD=H/CO
1171  RTHET=H*SI/(CO*CO)
1172  GO TO 30
1173  20 RAD=A/SI
1174  RTHET=-A*CO/(SI*SI)
1175  30 R(I)=RAD*RAD
1176  R(NG-I+1)=R(I)
1177  DR(I)=-RTHET/RAD
1178  DR(NG-I+1)=-DR(I)
1179  50 CONTINUE
1180  RETURN
1181  END
1182 
1183 C**********************************************************************
1184 C *
1185 C Calculation of spherical Bessel functions of the first kind *
1186 C J(I,N) = j_n(x) and second kind Y(I,N) = y_n(x) *
1187 C of real-valued argument X(I) and first kind JR(I,N)+I*JI(I,N) = *
1188 C = j_n(z) of complex argument Z(I)=XR(I)+I*XI(I), as well as *
1189 C the functions *
1190 C *
1191 C DJ(I,N) = (1/x)(d/dx)(x*j_n(x)) , *
1192 C DY(I,N) = (1/x)(d/dx)(x*y_n(x)) , *
1193 C DJR(I,N) = Re ((1/z)(d/dz)(z*j_n(x)) , *
1194 C DJI(I,N) = Im ((1/z)(d/dz)(z*j_n(x)) . *
1195 C *
1196 .LE..LE.C 1NNMAX *
1197 .LE.C NMAXNPN1 *
1198 C X,XR,XI - arguments *
1199 .LE..LE.C 1ING *
1200 C Arrays J,Y,JR,JI,DJ,DY,DJR,DJI are in *
1201 C COMMON /CBESS/ *
1202 C Parameters NNMAX1 and NMAX2 determine computational accuracy *
1203 C *
1204 C**********************************************************************
1205 
1206  SUBROUTINE BESS (X,XR,XI,NG,NMAX,NNMAX1,NNMAX2)
1207  INCLUDE 'tmq.par.f'
1208  IMPLICIT REAL*16 (A-H,O-Z)
1209  REAL*16 X(NG),XR(NG),XI(NG),
1210  * J(NPNG2,NPN1),Y(NPNG2,NPN1),JR(NPNG2,NPN1),
1211  * JI(NPNG2,NPN1),DJ(NPNG2,NPN1),DY(NPNG2,NPN1),
1212  * DJR(NPNG2,NPN1),DJI(NPNG2,NPN1),
1213  * AJ(NPN1),AY(NPN1),AJR(NPN1),AJI(NPN1),
1214  * ADJ(NPN1),ADY(NPN1),ADJR(NPN1),
1215  * ADJI(NPN1)
1216  COMMON /CBESS/ J,Y,JR,JI,DJ,DY,DJR,DJI
1217 
1218  DO 10 I=1,NG
1219  XX=X(I)
1220  CALL RJB(XX,AJ,ADJ,NMAX,NNMAX1)
1221  CALL RYB(XX,AY,ADY,NMAX)
1222  YR=XR(I)
1223  YI=XI(I)
1224  CALL CJB(YR,YI,AJR,AJI,ADJR,ADJI,NMAX,NNMAX2)
1225  DO 10 N=1,NMAX
1226  J(I,N)=AJ(N)
1227  Y(I,N)=AY(N)
1228  JR(I,N)=AJR(N)
1229  JI(I,N)=AJI(N)
1230  DJ(I,N)=ADJ(N)
1231  DY(I,N)=ADY(N)
1232  DJR(I,N)=ADJR(N)
1233  DJI(I,N)=ADJI(N)
1234  10 CONTINUE
1235  RETURN
1236  END
1237 
1238 C**********************************************************************
1239 C *
1240 C Calculation of spherical Bessel functions of the first kind j *
1241 C of real-valued argument x of orders from 1 to NMAX by using *
1242 C backward recursion. Parametr NNMAX determines numerical accuracy. *
1243 C U - function (1/x)(d/dx)(x*j(x)) *
1244 C *
1245 C**********************************************************************
1246 
1247  SUBROUTINE RJB(X,Y,U,NMAX,NNMAX)
1248  IMPLICIT REAL*16 (A-H,O-Z)
1249  REAL*16 Y(NMAX),U(NMAX),Z(900)
1250  L=NMAX+NNMAX
1251  XX=1Q0/X
1252  Z(L)=1Q0/(QFLOAT(2*L+1)*XX)
1253  L1=L-1
1254  DO 5 I=1,L1
1255  I1=L-I
1256  Z(I1)=1Q0/(QFLOAT(2*I1+1)*XX-Z(I1+1))
1257  5 CONTINUE
1258  Z0=1Q0/(XX-Z(1))
1259  Y0=Z0*QCOS(X)*XX
1260  Y1=Y0*Z(1)
1261  U(1)=Y0-Y1*XX
1262  Y(1)=Y1
1263  DO 10 I=2,NMAX
1264  YI1=Y(I-1)
1265  YI=YI1*Z(I)
1266  U(I)=YI1-QFLOAT(I)*YI*XX
1267  Y(I)=YI
1268  10 CONTINUE
1269  RETURN
1270  END
1271 
1272 C**********************************************************************
1273 C *
1274 C Calculation of spherical Bessel functions of the second kind y *
1275 C of real-valued argument x of orders from 1 to NMAX by using upward*
1276 C recursion. V - function (1/x)(d/dx)(x*y(x)) *
1277 C *
1278 C**********************************************************************
1279 
1280  SUBROUTINE RYB(X,Y,V,NMAX)
1281  IMPLICIT REAL*16 (A-H,O-Z)
1282  REAL*16 Y(NMAX),V(NMAX)
1283  C=QCOS(X)
1284  S=QSIN(X)
1285  X1=1Q0/X
1286  X2=X1*X1
1287  X3=X2*X1
1288  Y1=-C*X2-S*X1
1289  Y(1)=Y1
1290  Y(2)=(-3Q0*X3+X1)*C-3Q0*X2*S
1291  NMAX1=NMAX-1
1292  DO 5 I=2,NMAX1
1293  5 Y(I+1)=QFLOAT(2*I+1)*X1*Y(I)-Y(I-1)
1294  V(1)=-X1*(C+Y1)
1295  DO 10 I=2,NMAX
1296  10 V(I)=Y(I-1)-QFLOAT(I)*X1*Y(I)
1297  RETURN
1298  END
1299 
1300 C**********************************************************************
1301 C *
1302 C Calculation of spherical Bessel functions of the first kind *
1303 C j=JR+I*JI of complex argument x=XR+I*XI of orders from 1 to NMAX *
1304 C by using backward recursion. Parametr NNMAX determines numerical *
1305 C accuracy. U=UR+I*UI - function (1/x)(d/dx)(x*j(x)) *
1306 C *
1307 C**********************************************************************
1308 
1309  SUBROUTINE CJB (XR,XI,YR,YI,UR,UI,NMAX,NNMAX)
1310  INCLUDE 'tmq.par.f'
1311  IMPLICIT REAL*16 (A-H,O-Z)
1312  REAL*16 YR(NMAX),YI(NMAX),UR(NMAX),UI(NMAX)
1313  REAL*16 CYR(NPN1),CYI(NPN1),CZR(2500),CZI(2500),
1314  * CUR(NPN1),CUI(NPN1)
1315  L=NMAX+NNMAX
1316  XRXI=1Q0/(XR*XR+XI*XI)
1317  CXXR=XR*XRXI
1318  CXXI=-XI*XRXI
1319  QF=1Q0/QFLOAT(2*L+1)
1320  CZR(L)=XR*QF
1321  CZI(L)=XI*QF
1322  L1=L-1
1323  DO 5 I=1,L1
1324  I1=L-I
1325  QF=QFLOAT(2*I1+1)
1326  AR=QF*CXXR-CZR(I1+1)
1327  AI=QF*CXXI-CZI(I1+1)
1328  ARI=1Q0/(AR*AR+AI*AI)
1329  CZR(I1)=AR*ARI
1330  CZI(I1)=-AI*ARI
1331  5 CONTINUE
1332  AR=CXXR-CZR(1)
1333  AI=CXXI-CZI(1)
1334  ARI=1Q0/(AR*AR+AI*AI)
1335  CZ0R=AR*ARI
1336  CZ0I=-AI*ARI
1337  CR=QCOS(XR)*QCOSH(XI)
1338  CI=-QSIN(XR)*QSINH(XI)
1339  AR=CZ0R*CR-CZ0I*CI
1340  AI=CZ0I*CR+CZ0R*CI
1341  CY0R=AR*CXXR-AI*CXXI
1342  CY0I=AI*CXXR+AR*CXXI
1343  CY1R=CY0R*CZR(1)-CY0I*CZI(1)
1344  CY1I=CY0I*CZR(1)+CY0R*CZI(1)
1345  AR=CY1R*CXXR-CY1I*CXXI
1346  AI=CY1I*CXXR+CY1R*CXXI
1347  CU1R=CY0R-AR
1348  CU1I=CY0I-AI
1349  CYR(1)=CY1R
1350  CYI(1)=CY1I
1351  CUR(1)=CU1R
1352  CUI(1)=CU1I
1353  YR(1)=CY1R
1354  YI(1)=CY1I
1355  UR(1)=CU1R
1356  UI(1)=CU1I
1357  DO 10 I=2,NMAX
1358  QI=QFLOAT(I)
1359  CYI1R=CYR(I-1)
1360  CYI1I=CYI(I-1)
1361  CYIR=CYI1R*CZR(I)-CYI1I*CZI(I)
1362  CYII=CYI1I*CZR(I)+CYI1R*CZI(I)
1363  AR=CYIR*CXXR-CYII*CXXI
1364  AI=CYII*CXXR+CYIR*CXXI
1365  CUIR=CYI1R-QI*AR
1366  CUII=CYI1I-QI*AI
1367  CYR(I)=CYIR
1368  CYI(I)=CYII
1369  CUR(I)=CUIR
1370  CUI(I)=CUII
1371  YR(I)=CYIR
1372  YI(I)=CYII
1373  UR(I)=CUIR
1374  UI(I)=CUII
1375  10 CONTINUE
1376  RETURN
1377  END
1378 
1379 C**********************************************************************
1380 C *
1381 C calculation of the T(0) matrix for an axially symmetric particle *
1382 C *
1383 C Output information: *
1384 C *
1385 C Arrays TR1 and TI1 (real and imaginary parts of the *
1386 C T(0) matrix) are in COMMON /CT/ *
1387 C *
1388 C**********************************************************************
1389 
1390  SUBROUTINE TMATR0 (NGAUSS,X,W,AN,ANN,S,SS,PPI,PIR,PII,R,DR,DDR,
1391  * DRR,DRI,NMAX,NCHECK)
1392  INCLUDE 'tmq.par.f'
1393  IMPLICIT REAL*16 (A-H,O-Z)
1394  REAL*16 X(NPNG2),W(NPNG2),AN(NPN1),S(NPNG2),SS(NPNG2),
1395  * R(NPNG2),DR(NPNG2),SIG(NPN2),
1396  * J(NPNG2,NPN1),Y(NPNG2,NPN1),
1397  * JR(NPNG2,NPN1),JI(NPNG2,NPN1),DJ(NPNG2,NPN1),
1398  * DY(NPNG2,NPN1),DJR(NPNG2,NPN1),
1399  * DJI(NPNG2,NPN1),DDR(NPNG2),DRR(NPNG2),
1400  * D1(NPNG2,NPN1),D2(NPNG2,NPN1),
1401  * DRI(NPNG2),DS(NPNG2),DSS(NPNG2),RR(NPNG2),
1402  * DV1(NPN1),DV2(NPN1)
1403 
1404  REAL*16 R11(NPN1,NPN1),R12(NPN1,NPN1),
1405  * R21(NPN1,NPN1),R22(NPN1,NPN1),
1406  * I11(NPN1,NPN1),I12(NPN1,NPN1),
1407  * I21(NPN1,NPN1),I22(NPN1,NPN1),
1408  * RG11(NPN1,NPN1),RG12(NPN1,NPN1),
1409  * RG21(NPN1,NPN1),RG22(NPN1,NPN1),
1410  * IG11(NPN1,NPN1),IG12(NPN1,NPN1),
1411  * IG21(NPN1,NPN1),IG22(NPN1,NPN1),
1412  * ANN(NPN1,NPN1),
1413  * QR(NPN2,NPN2),QI(NPN2,NPN2),
1414  * RGQR(NPN2,NPN2),RGQI(NPN2,NPN2),
1415  * TQR(NPN2,NPN2),TQI(NPN2,NPN2),
1416  * TRGQR(NPN2,NPN2),TRGQI(NPN2,NPN2)
1417  REAL*8 TR1(NPN2,NPN2),TI1(NPN2,NPN2)
1418  REAL*4 PLUS(NPN6*NPN4*NPN4*8)
1419  COMMON /TMAT/ PLUS,
1420  & R11,R12,R21,R22,I11,I12,I21,I22,RG11,RG12,RG21,RG22,
1421  & IG11,IG12,IG21,IG22
1422  COMMON /CBESS/ J,Y,JR,JI,DJ,DY,DJR,DJI
1423  COMMON /CT/ TR1,TI1
1424  COMMON /CTT/ QR,QI,RGQR,RGQI
1425  MM1=1
1426  NNMAX=NMAX+NMAX
1427  NG=2*NGAUSS
1428  NGSS=NG
1429  FACTOR=1Q0
1430 .EQ. IF (NCHECK1) THEN
1431  NGSS=NGAUSS
1432  FACTOR=2Q0
1433  ELSE
1434  CONTINUE
1435  ENDIF
1436  SI=1Q0
1437  DO 5 N=1,NNMAX
1438  SI=-SI
1439  SIG(N)=SI
1440  5 CONTINUE
1441  20 DO 25 I=1,NGAUSS
1442  I1=NGAUSS+I
1443  I2=NGAUSS-I+1
1444  CALL VIG (X(I1),NMAX,0,DV1,DV2)
1445  DO 25 N=1,NMAX
1446  SI=SIG(N)
1447  DD1=DV1(N)
1448  DD2=DV2(N)
1449  D1(I1,N)=DD1
1450  D2(I1,N)=DD2
1451  D1(I2,N)=DD1*SI
1452  D2(I2,N)=-DD2*SI
1453  25 CONTINUE
1454  30 DO 40 I=1,NGSS
1455  RR(I)=W(I)*R(I)
1456  40 CONTINUE
1457 
1458  DO 300 N1=MM1,NMAX
1459  AN1=AN(N1)
1460  DO 300 N2=MM1,NMAX
1461  AN2=AN(N2)
1462  AR12=0Q0
1463  AR21=0Q0
1464  AI12=0Q0
1465  AI21=0Q0
1466  GR12=0Q0
1467  GR21=0Q0
1468  GI12=0Q0
1469  GI21=0Q0
1470 .EQ..AND..LT. IF (NCHECK1SIG(N1+N2)0Q0) GO TO 205
1471  DO 200 I=1,NGSS
1472  D1N1=D1(I,N1)
1473  D2N1=D2(I,N1)
1474  D1N2=D1(I,N2)
1475  D2N2=D2(I,N2)
1476  A12=D1N1*D2N2
1477  A21=D2N1*D1N2
1478  A22=D2N1*D2N2
1479  AA1=A12+A21
1480 
1481  QJ1=J(I,N1)
1482  QY1=Y(I,N1)
1483  QJR2=JR(I,N2)
1484  QJI2=JI(I,N2)
1485  QDJR2=DJR(I,N2)
1486  QDJI2=DJI(I,N2)
1487  QDJ1=DJ(I,N1)
1488  QDY1=DY(I,N1)
1489 
1490  C1R=QJR2*QJ1
1491  C1I=QJI2*QJ1
1492  B1R=C1R-QJI2*QY1
1493  B1I=C1I+QJR2*QY1
1494 
1495  C2R=QJR2*QDJ1
1496  C2I=QJI2*QDJ1
1497  B2R=C2R-QJI2*QDY1
1498  B2I=C2I+QJR2*QDY1
1499 
1500  DDRI=DDR(I)
1501  C3R=DDRI*C1R
1502  C3I=DDRI*C1I
1503  B3R=DDRI*B1R
1504  B3I=DDRI*B1I
1505 
1506  C4R=QDJR2*QJ1
1507  C4I=QDJI2*QJ1
1508  B4R=C4R-QDJI2*QY1
1509  B4I=C4I+QDJR2*QY1
1510 
1511  DRRI=DRR(I)
1512  DRII=DRI(I)
1513  C5R=C1R*DRRI-C1I*DRII
1514  C5I=C1I*DRRI+C1R*DRII
1515  B5R=B1R*DRRI-B1I*DRII
1516  B5I=B1I*DRRI+B1R*DRII
1517 
1518  URI=DR(I)
1519  RRI=RR(I)
1520 
1521  F1=RRI*A22
1522  F2=RRI*URI*AN1*A12
1523  AR12=AR12+F1*B2R+F2*B3R
1524  AI12=AI12+F1*B2I+F2*B3I
1525  GR12=GR12+F1*C2R+F2*C3R
1526  GI12=GI12+F1*C2I+F2*C3I
1527 
1528  F2=RRI*URI*AN2*A21
1529  AR21=AR21+F1*B4R+F2*B5R
1530  AI21=AI21+F1*B4I+F2*B5I
1531  GR21=GR21+F1*C4R+F2*C5R
1532  GI21=GI21+F1*C4I+F2*C5I
1533  200 CONTINUE
1534 
1535  205 AN12=ANN(N1,N2)*FACTOR
1536  R12(N1,N2)=AR12*AN12
1537  R21(N1,N2)=AR21*AN12
1538  I12(N1,N2)=AI12*AN12
1539  I21(N1,N2)=AI21*AN12
1540  RG12(N1,N2)=GR12*AN12
1541  RG21(N1,N2)=GR21*AN12
1542  IG12(N1,N2)=GI12*AN12
1543  IG21(N1,N2)=GI21*AN12
1544  300 CONTINUE
1545 
1546  TPIR=PIR
1547  TPII=PII
1548  TPPI=PPI
1549 
1550  NM=NMAX
1551  DO 310 N1=MM1,NMAX
1552  K1=N1-MM1+1
1553  KK1=K1+NM
1554  DO 310 N2=MM1,NMAX
1555  K2=N2-MM1+1
1556  KK2=K2+NM
1557 
1558  TAR12= I12(N1,N2)
1559  TAI12=-R12(N1,N2)
1560  TGR12= IG12(N1,N2)
1561  TGI12=-RG12(N1,N2)
1562 
1563  TAR21=-I21(N1,N2)
1564  TAI21= R21(N1,N2)
1565  TGR21=-IG21(N1,N2)
1566  TGI21= RG21(N1,N2)
1567 
1568  TQR(K1,K2)=TPIR*TAR21-TPII*TAI21+TPPI*TAR12
1569  TQI(K1,K2)=TPIR*TAI21+TPII*TAR21+TPPI*TAI12
1570  TRGQR(K1,K2)=TPIR*TGR21-TPII*TGI21+TPPI*TGR12
1571  TRGQI(K1,K2)=TPIR*TGI21+TPII*TGR21+TPPI*TGI12
1572 
1573  TQR(K1,KK2)=0Q0
1574  TQI(K1,KK2)=0Q0
1575  TRGQR(K1,KK2)=0Q0
1576  TRGQI(K1,KK2)=0Q0
1577 
1578  TQR(KK1,K2)=0Q0
1579  TQI(KK1,K2)=0Q0
1580  TRGQR(KK1,K2)=0Q0
1581  TRGQI(KK1,K2)=0Q0
1582 
1583  TQR(KK1,KK2)=TPIR*TAR12-TPII*TAI12+TPPI*TAR21
1584  TQI(KK1,KK2)=TPIR*TAI12+TPII*TAR12+TPPI*TAI21
1585  TRGQR(KK1,KK2)=TPIR*TGR12-TPII*TGI12+TPPI*TGR21
1586  TRGQI(KK1,KK2)=TPIR*TGI12+TPII*TGR12+TPPI*TGI21
1587  310 CONTINUE
1588 
1589  NNMAX=2*NM
1590  DO 320 N1=1,NNMAX
1591  DO 320 N2=1,NNMAX
1592  QR(N1,N2)=TQR(N1,N2)
1593  QI(N1,N2)=TQI(N1,N2)
1594  RGQR(N1,N2)=TRGQR(N1,N2)
1595  RGQI(N1,N2)=TRGQI(N1,N2)
1596  320 CONTINUE
1597  CALL TT(NMAX,NCHECK)
1598  RETURN
1599  END
1600 
1601 C**********************************************************************
1602 C *
1603 .GE.C Calculation of the T(M) matrix, M1, for an axially symmetric *
1604 C particle *
1605 C *
1606 C Input parameters: *
1607 C *
1608 .GE.C M1 *
1609 C NG = NGAUSS*2 - number of gaussian division points on the *
1610 C interval (-1,1) *
1611 C W - quadrature weights *
1612 C AN,ANN - see subroutine CONST *
1613 C S,SS - see subroutine CONST *
1614 C ARRAYS DV1,DV2,DV3,DV4 are in COMMON /DV/ - *
1615 C see subroutine DVIG *
1616 C PPI,PIR,PII - see subroutine VARY *
1617 C R J DR - see subroutines RSP1 and RSP2 *
1618 C DDR,DRR,DRI - see subroutine VARY *
1619 C NMAX - dimension of the T(M) matrix *
1620 C Arrays J,Y,JR,JI,DJ,DY,DJR,DJI are in *
1621 C COMMON /CBESS/ - see subroutine BESS *
1622 C *
1623 C Output parameters: *
1624 C *
1625 C Arrays TR1,TI1 (real and imaginary parts of the T(M) matrix) *
1626 C are in COMMON /CT/ *
1627 C *
1628 C**********************************************************************
1629 
1630  SUBROUTINE TMATR (M,NGAUSS,X,W,AN,ANN,S,SS,PPI,PIR,PII,R,DR,DDR,
1631  * DRR,DRI,NMAX,NCHECK)
1632  INCLUDE 'tmq.par.f'
1633  IMPLICIT REAL*16 (A-H,O-Z)
1634  REAL*16 X(NPNG2),W(NPNG2),AN(NPN1),S(NPNG2),SS(NPNG2),
1635  * R(NPNG2),DR(NPNG2),SIG(NPN2),
1636  * J(NPNG2,NPN1),Y(NPNG2,NPN1),
1637  * JR(NPNG2,NPN1),JI(NPNG2,NPN1),DJ(NPNG2,NPN1),
1638  * DY(NPNG2,NPN1),DJR(NPNG2,NPN1),
1639  * DJI(NPNG2,NPN1),DDR(NPNG2),DRR(NPNG2),
1640  * D1(NPNG2,NPN1),D2(NPNG2,NPN1),
1641  * DRI(NPNG2),DS(NPNG2),DSS(NPNG2),RR(NPNG2),
1642  * DV1(NPN1),DV2(NPN1)
1643  REAL*16 R11(NPN1,NPN1),R12(NPN1,NPN1),
1644  * R21(NPN1,NPN1),R22(NPN1,NPN1),
1645  * I11(NPN1,NPN1),I12(NPN1,NPN1),
1646  * I21(NPN1,NPN1),I22(NPN1,NPN1),
1647  * RG11(NPN1,NPN1),RG12(NPN1,NPN1),
1648  * RG21(NPN1,NPN1),RG22(NPN1,NPN1),
1649  * IG11(NPN1,NPN1),IG12(NPN1,NPN1),
1650  * IG21(NPN1,NPN1),IG22(NPN1,NPN1),
1651  * ANN(NPN1,NPN1),
1652  * QR(NPN2,NPN2),QI(NPN2,NPN2),
1653  * RGQR(NPN2,NPN2),RGQI(NPN2,NPN2),
1654  * TQR(NPN2,NPN2),TQI(NPN2,NPN2),
1655  * TRGQR(NPN2,NPN2),TRGQI(NPN2,NPN2)
1656  REAL*8 TR1(NPN2,NPN2),TI1(NPN2,NPN2)
1657  REAL*4 PLUS(NPN6*NPN4*NPN4*8)
1658  COMMON /TMAT/ PLUS,
1659  & R11,R12,R21,R22,I11,I12,I21,I22,RG11,RG12,RG21,RG22,
1660  & IG11,IG12,IG21,IG22
1661  COMMON /CBESS/ J,Y,JR,JI,DJ,DY,DJR,DJI
1662  COMMON /CT/ TR1,TI1
1663  COMMON /CTT/ QR,QI,RGQR,RGQI
1664  MM1=M
1665  QM=QFLOAT(M)
1666  QMM=QM*QM
1667  NG=2*NGAUSS
1668  NGSS=NG
1669  FACTOR=1Q0
1670 .EQ. IF (NCHECK1) THEN
1671  NGSS=NGAUSS
1672  FACTOR=2Q0
1673  ELSE
1674  CONTINUE
1675  ENDIF
1676  SI=1Q0
1677  NM=NMAX+NMAX
1678  DO 5 N=1,NM
1679  SI=-SI
1680  SIG(N)=SI
1681  5 CONTINUE
1682  20 DO 25 I=1,NGAUSS
1683  I1=NGAUSS+I
1684  I2=NGAUSS-I+1
1685  CALL VIG (X(I1),NMAX,M,DV1,DV2)
1686  DO 25 N=1,NMAX
1687  SI=SIG(N+M)
1688  DD1=DV1(N)
1689  DD2=DV2(N)
1690  D1(I1,N)=DD1
1691  D2(I1,N)=DD2
1692  D1(I2,N)=DD1*SI
1693  D2(I2,N)=-DD2*SI
1694  25 CONTINUE
1695  30 DO 40 I=1,NGSS
1696  WR=W(I)*R(I)
1697  DS(I)=S(I)*QM*WR
1698  DSS(I)=SS(I)*QMM
1699  RR(I)=WR
1700  40 CONTINUE
1701 
1702  DO 300 N1=MM1,NMAX
1703  AN1=AN(N1)
1704  DO 300 N2=MM1,NMAX
1705  AN2=AN(N2)
1706  AR11=0Q0
1707  AR12=0Q0
1708  AR21=0Q0
1709  AR22=0Q0
1710  AI11=0Q0
1711  AI12=0Q0
1712  AI21=0Q0
1713  AI22=0Q0
1714  GR11=0Q0
1715  GR12=0Q0
1716  GR21=0Q0
1717  GR22=0Q0
1718  GI11=0Q0
1719  GI12=0Q0
1720  GI21=0Q0
1721  GI22=0Q0
1722  SI=SIG(N1+N2)
1723 
1724  DO 200 I=1,NGSS
1725  D1N1=D1(I,N1)
1726  D2N1=D2(I,N1)
1727  D1N2=D1(I,N2)
1728  D2N2=D2(I,N2)
1729  A11=D1N1*D1N2
1730  A12=D1N1*D2N2
1731  A21=D2N1*D1N2
1732  A22=D2N1*D2N2
1733  AA1=A12+A21
1734  AA2=A11*DSS(I)+A22
1735  QJ1=J(I,N1)
1736  QY1=Y(I,N1)
1737  QJR2=JR(I,N2)
1738  QJI2=JI(I,N2)
1739  QDJR2=DJR(I,N2)
1740  QDJI2=DJI(I,N2)
1741  QDJ1=DJ(I,N1)
1742  QDY1=DY(I,N1)
1743 
1744  C1R=QJR2*QJ1
1745  C1I=QJI2*QJ1
1746  B1R=C1R-QJI2*QY1
1747  B1I=C1I+QJR2*QY1
1748 
1749  C2R=QJR2*QDJ1
1750  C2I=QJI2*QDJ1
1751  B2R=C2R-QJI2*QDY1
1752  B2I=C2I+QJR2*QDY1
1753 
1754  DDRI=DDR(I)
1755  C3R=DDRI*C1R
1756  C3I=DDRI*C1I
1757  B3R=DDRI*B1R
1758  B3I=DDRI*B1I
1759 
1760  C4R=QDJR2*QJ1
1761  C4I=QDJI2*QJ1
1762  B4R=C4R-QDJI2*QY1
1763  B4I=C4I+QDJR2*QY1
1764 
1765  DRRI=DRR(I)
1766  DRII=DRI(I)
1767  C5R=C1R*DRRI-C1I*DRII
1768  C5I=C1I*DRRI+C1R*DRII
1769  B5R=B1R*DRRI-B1I*DRII
1770  B5I=B1I*DRRI+B1R*DRII
1771 
1772  C6R=QDJR2*QDJ1
1773  C6I=QDJI2*QDJ1
1774  B6R=C6R-QDJI2*QDY1
1775  B6I=C6I+QDJR2*QDY1
1776 
1777  C7R=C4R*DDRI
1778  C7I=C4I*DDRI
1779  B7R=B4R*DDRI
1780  B7I=B4I*DDRI
1781 
1782  C8R=C2R*DRRI-C2I*DRII
1783  C8I=C2I*DRRI+C2R*DRII
1784  B8R=B2R*DRRI-B2I*DRII
1785  B8I=B2I*DRRI+B2R*DRII
1786 
1787  URI=DR(I)
1788  DSI=DS(I)
1789  DSSI=DSS(I)
1790  RRI=RR(I)
1791 
1792 .EQ..AND..GT. IF (NCHECK1SI0Q0) GO TO 150
1793 
1794  E1=DSI*AA1
1795  AR11=AR11+E1*B1R
1796  AI11=AI11+E1*B1I
1797  GR11=GR11+E1*C1R
1798  GI11=GI11+E1*C1I
1799 .EQ. IF (NCHECK1) GO TO 160
1800 
1801  150 F1=RRI*AA2
1802  F2=RRI*URI*AN1*A12
1803  AR12=AR12+F1*B2R+F2*B3R
1804  AI12=AI12+F1*B2I+F2*B3I
1805  GR12=GR12+F1*C2R+F2*C3R
1806  GI12=GI12+F1*C2I+F2*C3I
1807 
1808  F2=RRI*URI*AN2*A21
1809  AR21=AR21+F1*B4R+F2*B5R
1810  AI21=AI21+F1*B4I+F2*B5I
1811  GR21=GR21+F1*C4R+F2*C5R
1812  GI21=GI21+F1*C4I+F2*C5I
1813 .EQ. IF (NCHECK1) GO TO 200
1814 
1815  160 E2=DSI*URI*A11
1816  E3=E2*AN2
1817  E2=E2*AN1
1818  AR22=AR22+E1*B6R+E2*B7R+E3*B8R
1819  AI22=AI22+E1*B6I+E2*B7I+E3*B8I
1820  GR22=GR22+E1*C6R+E2*C7R+E3*C8R
1821  GI22=GI22+E1*C6I+E2*C7I+E3*C8I
1822  200 CONTINUE
1823  AN12=ANN(N1,N2)*FACTOR
1824  R11(N1,N2)=AR11*AN12
1825  R12(N1,N2)=AR12*AN12
1826  R21(N1,N2)=AR21*AN12
1827  R22(N1,N2)=AR22*AN12
1828  I11(N1,N2)=AI11*AN12
1829  I12(N1,N2)=AI12*AN12
1830  I21(N1,N2)=AI21*AN12
1831  I22(N1,N2)=AI22*AN12
1832  RG11(N1,N2)=GR11*AN12
1833  RG12(N1,N2)=GR12*AN12
1834  RG21(N1,N2)=GR21*AN12
1835  RG22(N1,N2)=GR22*AN12
1836  IG11(N1,N2)=GI11*AN12
1837  IG12(N1,N2)=GI12*AN12
1838  IG21(N1,N2)=GI21*AN12
1839  IG22(N1,N2)=GI22*AN12
1840 
1841  300 CONTINUE
1842  TPIR=PIR
1843  TPII=PII
1844  TPPI=PPI
1845  NM=NMAX-MM1+1
1846  DO 310 N1=MM1,NMAX
1847  K1=N1-MM1+1
1848  KK1=K1+NM
1849  DO 310 N2=MM1,NMAX
1850  K2=N2-MM1+1
1851  KK2=K2+NM
1852 
1853  TAR11=-R11(N1,N2)
1854  TAI11=-I11(N1,N2)
1855  TGR11=-RG11(N1,N2)
1856  TGI11=-IG11(N1,N2)
1857 
1858  TAR12= I12(N1,N2)
1859  TAI12=-R12(N1,N2)
1860  TGR12= IG12(N1,N2)
1861  TGI12=-RG12(N1,N2)
1862 
1863  TAR21=-I21(N1,N2)
1864  TAI21= R21(N1,N2)
1865  TGR21=-IG21(N1,N2)
1866  TGI21= RG21(N1,N2)
1867 
1868  TAR22=-R22(N1,N2)
1869  TAI22=-I22(N1,N2)
1870  TGR22=-RG22(N1,N2)
1871  TGI22=-IG22(N1,N2)
1872 
1873  TQR(K1,K2)=TPIR*TAR21-TPII*TAI21+TPPI*TAR12
1874  TQI(K1,K2)=TPIR*TAI21+TPII*TAR21+TPPI*TAI12
1875  TRGQR(K1,K2)=TPIR*TGR21-TPII*TGI21+TPPI*TGR12
1876  TRGQI(K1,K2)=TPIR*TGI21+TPII*TGR21+TPPI*TGI12
1877 
1878  TQR(K1,KK2)=TPIR*TAR11-TPII*TAI11+TPPI*TAR22
1879  TQI(K1,KK2)=TPIR*TAI11+TPII*TAR11+TPPI*TAI22
1880  TRGQR(K1,KK2)=TPIR*TGR11-TPII*TGI11+TPPI*TGR22
1881  TRGQI(K1,KK2)=TPIR*TGI11+TPII*TGR11+TPPI*TGI22
1882 
1883  TQR(KK1,K2)=TPIR*TAR22-TPII*TAI22+TPPI*TAR11
1884  TQI(KK1,K2)=TPIR*TAI22+TPII*TAR22+TPPI*TAI11
1885  TRGQR(KK1,K2)=TPIR*TGR22-TPII*TGI22+TPPI*TGR11
1886  TRGQI(KK1,K2)=TPIR*TGI22+TPII*TGR22+TPPI*TGI11
1887 
1888  TQR(KK1,KK2)=TPIR*TAR12-TPII*TAI12+TPPI*TAR21
1889  TQI(KK1,KK2)=TPIR*TAI12+TPII*TAR12+TPPI*TAI21
1890  TRGQR(KK1,KK2)=TPIR*TGR12-TPII*TGI12+TPPI*TGR21
1891  TRGQI(KK1,KK2)=TPIR*TGI12+TPII*TGR12+TPPI*TGI21
1892  310 CONTINUE
1893 
1894  NNMAX=2*NM
1895  DO 320 N1=1,NNMAX
1896  DO 320 N2=1,NNMAX
1897  QR(N1,N2)=TQR(N1,N2)
1898  QI(N1,N2)=TQI(N1,N2)
1899  RGQR(N1,N2)=TRGQR(N1,N2)
1900  RGQI(N1,N2)=TRGQI(N1,N2)
1901  320 CONTINUE
1902  CALL TT(NM,NCHECK)
1903  RETURN
1904  END
1905 
1906 C*****************************************************************
1907 c
1908 c Calculation of the functiONS
1909 c DV1(n)=dvig(0,m,n,arccos x)
1910 c and
1911 c DV2(n)=[d/d(arccos x)] dvig(0,m,n,arccos x)
1912 .LE..LE.c 1NNMAX
1913 .LE..LE.c 0x1
1914 
1915  SUBROUTINE VIG (X,NMAX,M,DV1,DV2)
1916  INCLUDE 'tmq.par.f'
1917  IMPLICIT REAL*16 (A-H,O-Z)
1918  REAL*16 DV1(NPN1), DV2(NPN1)
1919  A=1Q0
1920  QS=QSQRT(1Q0-X*X)
1921  QS1=1Q0/QS
1922  DO 1 N=1,NMAX
1923  DV1(N)=0Q0
1924  DV2(N)=0Q0
1925  1 CONTINUE
1926 .NE. IF (M0) GO TO 20
1927  D1=1Q0
1928  D2=X
1929  DO 5 N=1,NMAX
1930  QN=QFLOAT(N)
1931  QN1=QFLOAT(N+1)
1932  QN2=QFLOAT(2*N+1)
1933  D3=(QN2*X*D2-QN*D1)/QN1
1934  DER=QS1*(QN1*QN/QN2)*(-D1+D3)
1935  DV1(N)=D2
1936  DV2(N)=DER
1937  D1=D2
1938  D2=D3
1939  5 CONTINUE
1940  RETURN
1941  20 QMM=QFLOAT(M*M)
1942  DO 25 I=1,M
1943  I2=I*2
1944  A=A*QSQRT(QFLOAT(I2-1)/QFLOAT(I2))*QS
1945  25 CONTINUE
1946  D1=0Q0
1947  D2=A
1948  DO 30 N=M,NMAX
1949  QN=QFLOAT(N)
1950  QN2=QFLOAT(2*N+1)
1951  QN1=QFLOAT(N+1)
1952  QNM=QSQRT(QN*QN-QMM)
1953  QNM1=QSQRT(QN1*QN1-QMM)
1954  D3=(QN2*X*D2-QNM*D1)/QNM1
1955  DER=QS1*(-QN1*QNM*D1+QN*QNM1*D3)/QN2
1956  DV1(N)=D2
1957  DV2(N)=DER
1958  D1=D2
1959  D2=D3
1960  30 CONTINUE
1961  RETURN
1962  END
1963 
1964 C**********************************************************************
1965 C *
1966 C Calculation of the matrix T = - RG(Q) * (Q**(-1)) *
1967 C *
1968 C Input infortmation is in COMMON /CTT/ *
1969 C Output information is in COMMON /CT/ *
1970 C *
1971 C**********************************************************************
1972 
1973  SUBROUTINE TT(NMAX,NCHECK)
1974  INCLUDE 'tmq.par.f'
1975  IMPLICIT REAL*8 (A-H,O-Z)
1976  REAL*16 F(NPN2,NPN2),B(NPN2),WORK(NPN2),COND,
1977  * QR(NPN2,NPN2),QI(NPN2,NPN2),
1978  * RGQR(NPN2,NPN2),RGQI(NPN2,NPN2),
1979  * A(NPN2,NPN2),C(NPN2,NPN2),D(NPN2,NPN2),E(NPN2,NPN2)
1980  REAL*8 TR1(NPN2,NPN2),TI1(NPN2,NPN2)
1981  COMPLEX*32 ZQ(NPN2,NPN2),ZW(NPN2)
1982  INTEGER IPIV(NPN2),IPVT(NPN2)
1983  COMMON /CT/ TR1,TI1
1984  COMMON /CTT/ QR,QI,RGQR,RGQI
1985  NDIM=NPN2
1986  NNMAX=2*NMAX
1987 
1988 C Inversion from LAPACK
1989 
1990  DO I=1,NNMAX
1991  DO J=1,NNMAX
1992  ZQ(I,J)=QCMPLX(QR(I,J),QI(I,J))
1993  ENDDO
1994  ENDDO
1995  INFO=0
1996  CALL ZGETRF(NNMAX,NNMAX,ZQ,NPN2,IPIV,INFO)
1997 .NE. IF (INFO0) WRITE (6,1100) INFO
1998  CALL ZGETRI(NNMAX,ZQ,NPN2,IPIV,ZW,NPN2,INFO)
1999 .NE. IF (INFO0) WRITE (6,1100) INFO
2000 
2001  1100 FORMAT ('warning: info=', I2)
2002  DO I=1,NNMAX
2003  DO J=1,NNMAX
2004  TR=0D0
2005  TI=0D0
2006  DO K=1,NNMAX
2007  ARR=RGQR(I,K)
2008  ARI=RGQI(I,K)
2009  AR=ZQ(K,J)
2010  AI=QIMAG(ZQ(K,J))
2011  TR=TR-ARR*AR+ARI*AI
2012  TI=TI-ARR*AI-ARI*AR
2013  ENDDO
2014  TR1(I,J)=TR
2015  TI1(I,J)=TI
2016  ENDDO
2017  ENDDO
2018  RETURN
2019  END
2020 
2021 C********************************************************************
2022 C *
2023 C Calculation of the expansion coefficients for the (I,Q,U,V) *
2024 C representation. *
2025 C *
2026 C Input parameters: *
2027 C *
2028 C LAM - wavelength of light *
2029 C CSCA - scattering cross section *
2030 C TR and TI - elements of the t-matrix. Transferred through *
2031 C COMMON /CTM/ *
2032 C NMAX - dimension of T(M) matrices *
2033 C *
2034 C Output infortmation: *
2035 C *
2036 C ALF1,...,ALF4,BET1,BET2 - expansion coefficients *
2037 C LMAX - number of coefficients minus 1 *
2038 C *
2039 C********************************************************************
2040 
2041  SUBROUTINE GSP(NMAX,CSCA,LAM,ALF1,ALF2,ALF3,ALF4,BET1,BET2,LMAX)
2042  INCLUDE 'tmq.par.f'
2043  IMPLICIT REAL*8 (A-B,D-H,O-Z),COMPLEX*16 (C)
2044  REAL*16 LAM
2045  REAL*8 SSIGN(900)
2046  REAL*8 CSCA,SSI(NPL),SSJ(NPN1),
2047  & ALF1(NPL),ALF2(NPL),ALF3(NPL),
2048  & ALF4(NPL),BET1(NPL),BET2(NPL),
2049  & TR1(NPL1,NPN4),TR2(NPL1,NPN4),
2050  & TI1(NPL1,NPN4),TI2(NPL1,NPN4),
2051  & G1(NPL1,NPN6),G2(NPL1,NPN6),
2052  & AR1(NPN4),AR2(NPN4),AI1(NPN4),AI2(NPN4),
2053  & FR(NPN4,NPN4),FI(NPN4,NPN4),FF(NPN4,NPN4)
2054  REAL*4 B1R(NPL1,NPL1,NPN4),B1I(NPL1,NPL1,NPN4),
2055  & B2R(NPL1,NPL1,NPN4),B2I(NPL1,NPL1,NPN4),
2056  & D1(NPL1,NPN4,NPN4),D2(NPL1,NPN4,NPN4),
2057  & D3(NPL1,NPN4,NPN4),D4(NPL1,NPN4,NPN4),
2058  & D5R(NPL1,NPN4,NPN4),D5I(NPL1,NPN4,NPN4),
2059  & PLUS1(NPN6*NPN4*NPN4*8)
2060  REAL*4
2061  & TR11(NPN6,NPN4,NPN4),TR12(NPN6,NPN4,NPN4),
2062  & TR21(NPN6,NPN4,NPN4),TR22(NPN6,NPN4,NPN4),
2063  & TI11(NPN6,NPN4,NPN4),TI12(NPN6,NPN4,NPN4),
2064  & TI21(NPN6,NPN4,NPN4),TI22(NPN6,NPN4,NPN4)
2065  COMPLEX*16 CIM(NPN1)
2066 
2067  COMMON /TMAT/ TR11,TR12,TR21,TR22,TI11,TI12,TI21,TI22
2068  COMMON /CBESS/ B1R,B1I,B2R,B2I
2069  COMMON /SS/ SSIGN
2070  EQUIVALENCE ( PLUS1(1),TR11(1,1,1) )
2071  EQUIVALENCE (D1(1,1,1),PLUS1(1)),
2072  & (D2(1,1,1),PLUS1(NPL1*NPN4*NPN4+1)),
2073  & (D3(1,1,1),PLUS1(NPL1*NPN4*NPN4*2+1)),
2074  & (D4(1,1,1),PLUS1(NPL1*NPN4*NPN4*3+1)),
2075  & (D5R(1,1,1),PLUS1(NPL1*NPN4*NPN4*4+1))
2076 
2077  CALL FACT
2078  CALL SIGNUM
2079  LMAX=2*NMAX
2080  L1MAX=LMAX+1
2081  CI=(0D0,1D0)
2082  CIM(1)=CI
2083  DO 2 I=2,NMAX
2084  CIM(I)=CIM(I-1)*CI
2085  2 CONTINUE
2086  SSI(1)=1D0
2087  DO 3 I=1,LMAX
2088  I1=I+1
2089  SI=DFLOAT(2*I+1)
2090  SSI(I1)=SI
2091 .LE. IF(INMAX) SSJ(I)=DSQRT(SI)
2092  3 CONTINUE
2093  CI=-CI
2094  DO 5 I=1,NMAX
2095  SI=SSJ(I)
2096  CCI=CIM(I)
2097  DO 4 J=1,NMAX
2098  SJ=1D0/SSJ(J)
2099  CCJ=CIM(J)*SJ/CCI
2100  FR(J,I)=CCJ
2101  FI(J,I)=CCJ*CI
2102  FF(J,I)=SI*SJ
2103  4 CONTINUE
2104  5 CONTINUE
2105  NMAX1=NMAX+1
2106 
2107 C ***** CALCULATION OF THE ARRAYS B1 AND B2 *****
2108 
2109  K1=1
2110  K2=0
2111  K3=0
2112  K4=1
2113  K5=1
2114  K6=2
2115 
2116 C PRINT 3300, B1,B2
2117  3300 FORMAT (' b1 and b2')
2118  DO 100 N=1,NMAX
2119 
2120 C ***** CALCULATION OF THE ARRAYS T1 AND T2 *****
2121 
2122 
2123  DO 10 NN=1,NMAX
2124  M1MAX=MIN0(N,NN)+1
2125  DO 6 M1=1,M1MAX
2126  M=M1-1
2127  L1=NPN6+M
2128  TT1=TR11(M1,N,NN)
2129  TT2=TR12(M1,N,NN)
2130  TT3=TR21(M1,N,NN)
2131  TT4=TR22(M1,N,NN)
2132  TT5=TI11(M1,N,NN)
2133  TT6=TI12(M1,N,NN)
2134  TT7=TI21(M1,N,NN)
2135  TT8=TI22(M1,N,NN)
2136  T1=TT1+TT2
2137  T2=TT3+TT4
2138  T3=TT5+TT6
2139  T4=TT7+TT8
2140  TR1(L1,NN)=T1+T2
2141  TR2(L1,NN)=T1-T2
2142  TI1(L1,NN)=T3+T4
2143  TI2(L1,NN)=T3-T4
2144 .EQ. IF(M0) GO TO 6
2145  L1=NPN6-M
2146  T1=TT1-TT2
2147  T2=TT3-TT4
2148  T3=TT5-TT6
2149  T4=TT7-TT8
2150  TR1(L1,NN)=T1-T2
2151  TR2(L1,NN)=T1+T2
2152  TI1(L1,NN)=T3-T4
2153  TI2(L1,NN)=T3+T4
2154  6 CONTINUE
2155  10 CONTINUE
2156 
2157 C ***** END OF THE CALCULATION OF THE ARRAYS T1 AND T2 *****
2158 
2159  NN1MAX=NMAX1+N
2160  DO 40 NN1=1,NN1MAX
2161  N1=NN1-1
2162 
2163 C ***** CALCULATION OF THE ARRAYS A1 AND A2 *****
2164 
2165  CALL CCG(N,N1,NMAX,K1,K2,G1)
2166  NNMAX=MIN0(NMAX,N1+N)
2167  NNMIN=MAX0(1,IABS(N-N1))
2168  KN=N+NN1
2169  DO 15 NN=NNMIN,NNMAX
2170  NNN=NN+1
2171  SIG=SSIGN(KN+NN)
2172  M1MAX=MIN0(N,NN)+NPN6
2173  AAR1=0D0
2174  AAR2=0D0
2175  AAI1=0D0
2176  AAI2=0D0
2177  DO 13 M1=NPN6,M1MAX
2178  M=M1-NPN6
2179  SSS=G1(M1,NNN)
2180  RR1=TR1(M1,NN)
2181  RI1=TI1(M1,NN)
2182  RR2=TR2(M1,NN)
2183  RI2=TI2(M1,NN)
2184 .EQ. IF(M0) GO TO 12
2185  M2=NPN6-M
2186  RR1=RR1+TR1(M2,NN)*SIG
2187  RI1=RI1+TI1(M2,NN)*SIG
2188  RR2=RR2+TR2(M2,NN)*SIG
2189  RI2=RI2+TI2(M2,NN)*SIG
2190  12 AAR1=AAR1+SSS*RR1
2191  AAI1=AAI1+SSS*RI1
2192  AAR2=AAR2+SSS*RR2
2193  AAI2=AAI2+SSS*RI2
2194  13 CONTINUE
2195  XR=FR(NN,N)
2196  XI=FI(NN,N)
2197  AR1(NN)=AAR1*XR-AAI1*XI
2198  AI1(NN)=AAR1*XI+AAI1*XR
2199  AR2(NN)=AAR2*XR-AAI2*XI
2200  AI2(NN)=AAR2*XI+AAI2*XR
2201  15 CONTINUE
2202 
2203 C ***** END OF THE CALCULATION OF THE ARRAYS A1 AND A2 ****
2204 
2205  CALL CCG(N,N1,NMAX,K3,K4,G2)
2206  M1=MAX0(-N1+1,-N)
2207  M2=MIN0(N1+1,N)
2208  M1MAX=M2+NPN6
2209  M1MIN=M1+NPN6
2210  DO 30 M1=M1MIN,M1MAX
2211  BBR1=0D0
2212  BBI1=0D0
2213  BBR2=0D0
2214  BBI2=0D0
2215  DO 25 NN=NNMIN,NNMAX
2216  NNN=NN+1
2217  SSS=G2(M1,NNN)
2218  BBR1=BBR1+SSS*AR1(NN)
2219  BBI1=BBI1+SSS*AI1(NN)
2220  BBR2=BBR2+SSS*AR2(NN)
2221  BBI2=BBI2+SSS*AI2(NN)
2222  25 CONTINUE
2223  B1R(NN1,M1,N)=BBR1
2224  B1I(NN1,M1,N)=BBI1
2225  B2R(NN1,M1,N)=BBR2
2226  B2I(NN1,M1,N)=BBI2
2227  30 CONTINUE
2228  40 CONTINUE
2229  100 CONTINUE
2230 
2231 C ***** END OF THE CALCULATION OF THE ARRAYS B1 AND B2 ****
2232 
2233 C ***** CALCULATION OF THE ARRAYS D1,D2,D3,D4, AND D5 *****
2234 
2235 c PRINT 3301
2236  3301 FORMAT(' d1, d2, ...')
2237  DO 200 N=1,NMAX
2238  DO 190 NN=1,NMAX
2239  M1=MIN0(N,NN)
2240  M1MAX=NPN6+M1
2241  M1MIN=NPN6-M1
2242  NN1MAX=NMAX1+MIN0(N,NN)
2243  DO 180 M1=M1MIN,M1MAX
2244  M=M1-NPN6
2245  NN1MIN=IABS(M-1)+1
2246  DD1=0D0
2247  DD2=0D0
2248  DO 150 NN1=NN1MIN,NN1MAX
2249  XX=SSI(NN1)
2250  X1=B1R(NN1,M1,N)
2251  X2=B1I(NN1,M1,N)
2252  X3=B1R(NN1,M1,NN)
2253  X4=B1I(NN1,M1,NN)
2254  X5=B2R(NN1,M1,N)
2255  X6=B2I(NN1,M1,N)
2256  X7=B2R(NN1,M1,NN)
2257  X8=B2I(NN1,M1,NN)
2258  DD1=DD1+XX*(X1*X3+X2*X4)
2259  DD2=DD2+XX*(X5*X7+X6*X8)
2260  150 CONTINUE
2261  D1(M1,NN,N)=DD1
2262  D2(M1,NN,N)=DD2
2263  180 CONTINUE
2264  MMAX=MIN0(N,NN+2)
2265  MMIN=MAX0(-N,-NN+2)
2266  M1MAX=NPN6+MMAX
2267  M1MIN=NPN6+MMIN
2268  DO 186 M1=M1MIN,M1MAX
2269  M=M1-NPN6
2270  NN1MIN=IABS(M-1)+1
2271  DD3=0D0
2272  DD4=0D0
2273  DD5R=0D0
2274  DD5I=0D0
2275  M2=-M+2+NPN6
2276  DO 183 NN1=NN1MIN,NN1MAX
2277  XX=SSI(NN1)
2278  X1=B1R(NN1,M1,N)
2279  X2=B1I(NN1,M1,N)
2280  X3=B2R(NN1,M1,N)
2281  X4=B2I(NN1,M1,N)
2282  X5=B1R(NN1,M2,NN)
2283  X6=B1I(NN1,M2,NN)
2284  X7=B2R(NN1,M2,NN)
2285  X8=B2I(NN1,M2,NN)
2286  DD3=DD3+XX*(X1*X5+X2*X6)
2287  DD4=DD4+XX*(X3*X7+X4*X8)
2288  DD5R=DD5R+XX*(X3*X5+X4*X6)
2289  DD5I=DD5I+XX*(X4*X5-X3*X6)
2290  183 CONTINUE
2291  D3(M1,NN,N)=DD3
2292  D4(M1,NN,N)=DD4
2293  D5R(M1,NN,N)=DD5R
2294  D5I(M1,NN,N)=DD5I
2295  186 CONTINUE
2296  190 CONTINUE
2297  200 CONTINUE
2298 
2299 C ***** END OF THE CALCULATION OF THE D-ARRAYS *****
2300 
2301 C ***** CALCULATION OF THE EXPANSION COEFFICIENTS *****
2302 
2303 C PRINT 3303
2304  3303 FORMAT (' g1, g2, ...')
2305 
2306  DK=LAM*LAM/(4D0*CSCA*DACOS(-1D0))
2307  DO 300 L1=1,L1MAX
2308  G1L=0D0
2309  G2L=0D0
2310  G3L=0D0
2311  G4L=0D0
2312  G5LR=0D0
2313  G5LI=0D0
2314  L=L1-1
2315  SL=SSI(L1)*DK
2316  DO 290 N=1,NMAX
2317  NNMIN=MAX0(1,IABS(N-L))
2318  NNMAX=MIN0(NMAX,N+L)
2319 .LT. IF(NNMAXNNMIN) GO TO 290
2320  CALL CCG(N,L,NMAX,K1,K2,G1)
2321 .GE. IF(L2) CALL CCG(N,L,NMAX,K5,K6,G2)
2322  NL=N+L
2323  DO 280 NN=NNMIN,NNMAX
2324  NNN=NN+1
2325  MMAX=MIN0(N,NN)
2326  M1MIN=NPN6-MMAX
2327  M1MAX=NPN6+MMAX
2328  SI=SSIGN(NL+NNN)
2329  DM1=0D0
2330  DM2=0D0
2331  DO 270 M1=M1MIN,M1MAX
2332  M=M1-NPN6
2333 .GE. IF(M0) SSS1=G1(M1,NNN)
2334 .LT. IF(M0) SSS1=G1(NPN6-M,NNN)*SI
2335  DM1=DM1+SSS1*D1(M1,NN,N)
2336  DM2=DM2+SSS1*D2(M1,NN,N)
2337  270 CONTINUE
2338  FFN=FF(NN,N)
2339  SSS=G1(NPN6+1,NNN)*FFN
2340  G1L=G1L+SSS*DM1
2341  G2L=G2L+SSS*DM2*SI
2342 .LT. IF(L2) GO TO 280
2343  DM3=0D0
2344  DM4=0D0
2345  DM5R=0D0
2346  DM5I=0D0
2347  MMAX=MIN0(N,NN+2)
2348  MMIN=MAX0(-N,-NN+2)
2349  M1MAX=NPN6+MMAX
2350  M1MIN=NPN6+MMIN
2351  DO 275 M1=M1MIN,M1MAX
2352  M=M1-NPN6
2353  SSS1=G2(NPN6-M,NNN)
2354  DM3=DM3+SSS1*D3(M1,NN,N)
2355  DM4=DM4+SSS1*D4(M1,NN,N)
2356  DM5R=DM5R+SSS1*D5R(M1,NN,N)
2357  DM5I=DM5I+SSS1*D5I(M1,NN,N)
2358  275 CONTINUE
2359  G5LR=G5LR-SSS*DM5R
2360  G5LI=G5LI-SSS*DM5I
2361  SSS=G2(NPN4,NNN)*FFN
2362  G3L=G3L+SSS*DM3
2363  G4L=G4L+SSS*DM4*SI
2364  280 CONTINUE
2365  290 CONTINUE
2366  G1L=G1L*SL
2367  G2L=G2L*SL
2368  G3L=G3L*SL
2369  G4L=G4L*SL
2370  G5LR=G5LR*SL
2371  G5LI=G5LI*SL
2372  ALF1(L1)=G1L+G2L
2373  ALF2(L1)=G3L+G4L
2374  ALF3(L1)=G3L-G4L
2375  ALF4(L1)=G1L-G2L
2376  BET1(L1)=G5LR*2D0
2377  BET2(L1)=G5LI*2D0
2378  LMAX=L
2379 .LT. IF(DABS(G1L)1D-6) GO TO 500
2380  300 CONTINUE
2381  500 CONTINUE
2382  RETURN
2383  END
2384 
2385 C****************************************************************
2386 
2387 C Calculation of the quantities F(N+1)=0.5*ln(n!)
2388 .LE..LE.C 0N899
2389 
2390  SUBROUTINE FACT
2391  REAL*8 F(900)
2392  COMMON /FAC/ F
2393  F(1)=0D0
2394  F(2)=0D0
2395  DO 2 I=3,900
2396  I1=I-1
2397  F(I)=F(I1)+0.5D0*DLOG(DFLOAT(I1))
2398  2 CONTINUE
2399  RETURN
2400  END
2401 
2402 C************************************************************
2403 
2404 C Calculation of the array SSIGN(N+1)=sign(n)
2405 .LE..LE.C 0N899
2406 
2407  SUBROUTINE SIGNUM
2408  REAL*8 SSIGN(900)
2409  COMMON /SS/ SSIGN
2410  SSIGN(1)=1D0
2411  DO 2 N=2,899
2412  SSIGN(N)=-SSIGN(N-1)
2413  2 CONTINUE
2414  RETURN
2415  END
2416 
2417 C******************************************************************
2418 C
2419 C Calculation of Clebsch-Gordan coefficients
2420 C (n,m:n1,m1/nn,mm)
2421 C for given n and n1. m1=mm-m, index mm is found from m as
2422 C mm=m*k1+k2
2423 C
2424 C Input parameters : N,N1,NMAX,K1,K2
2425 .LE.C NNMAX
2426 .GE.C N1
2427 .GE.C N10
2428 .LE.C N1N+NMAX
2429 C Output parameters : GG(M+NPN6,NN+1) - array of the corresponding
2430 C coefficients
2431 .LE.C /M/N
2432 .LE.C /M1/=/M*(K1-1)+K2/N1
2433 .LE.C NNMIN(N+N1,NMAX)
2434 .GE.C NNMAX(/MM/,/N-N1/)
2435 .LE..LE.C If K1=1 and K2=0, then 0MN
2436 
2437  SUBROUTINE CCG(N,N1,NMAX,K1,K2,GG)
2438  INCLUDE 'tmq.par.f'
2439  IMPLICIT REAL*8 (A-H,O-Z)
2440  REAL*8 GG(NPL1,NPN6),CD(0:NPN5),CU(0:NPN5)
2441 .LE. IF(NMAXNPN4.
2442 .LE. & AND.0N1.
2443 .LE. & AND.N1NMAX+N.
2444 .GE. & AND.N1.
2445 .LE. & AND.NNMAX) GO TO 1
2446  PRINT 5001
2447  STOP
2448  5001 FORMAT(' error in SUBROUTINE ccg')
2449  1 NNF=MIN0(N+N1,NMAX)
2450  MIN=NPN6-N
2451  MF=NPN6+N
2452 .EQ..AND..EQ. IF(K11K20) MIN=NPN6
2453  DO 100 MIND=MIN,MF
2454  M=MIND-NPN6
2455  MM=M*K1+K2
2456  M1=MM-M
2457 .GT. IF(IABS(M1)N1) GO TO 90
2458  NNL=MAX0(IABS(MM),IABS(N-N1))
2459 .GT. IF(NNLNNF) GO TO 90
2460  NNU=N+N1
2461  NNM=(NNU+NNL)*0.5D0
2462 .EQ. IF (NNLNNU) NNM=NNL
2463  CALL CCGIN(N,N1,M,MM,C)
2464  CU(NNL)=C
2465 .EQ. IF (NNLNNF) GO TO 50
2466  C2=0D0
2467  C1=C
2468  DO 7 NN=NNL+1,MIN0(NNM,NNF)
2469  A=DFLOAT((NN+MM)*(NN-MM)*(N1-N+NN))
2470  A=A*DFLOAT((N-N1+NN)*(N+N1-NN+1)*(N+N1+NN+1))
2471  A=DFLOAT(4*NN*NN)/A
2472  A=A*DFLOAT((2*NN+1)*(2*NN-1))
2473  A=DSQRT(A)
2474  B=0.5D0*DFLOAT(M-M1)
2475  D=0D0
2476 .EQ. IF(NN1) GO TO 5
2477  B=DFLOAT(2*NN*(NN-1))
2478  B=DFLOAT((2*M-MM)*NN*(NN-1)-MM*N*(N+1)+
2479  & MM*N1*(N1+1))/B
2480  D=DFLOAT(4*(NN-1)*(NN-1))
2481  D=D*DFLOAT((2*NN-3)*(2*NN-1))
2482  D=DFLOAT((NN-MM-1)*(NN+MM-1)*(N1-N+NN-1))/D
2483  D=D*DFLOAT((N-N1+NN-1)*(N+N1-NN+2)*(N+N1+NN))
2484  D=DSQRT(D)
2485  5 C=A*(B*C1-D*C2)
2486  C2=C1
2487  C1=C
2488  CU(NN)=C
2489  7 CONTINUE
2490 .LE. IF (NNFNNM) GO TO 50
2491  CALL DIRECT(N,M,N1,M1,NNU,MM,C)
2492  CD(NNU)=C
2493 .EQ. IF (NNUNNM+1) GO TO 50
2494  C2=0D0
2495  C1=C
2496  DO 12 NN=NNU-1,NNM+1,-1
2497  A=DFLOAT((NN-MM+1)*(NN+MM+1)*(N1-N+NN+1))
2498  A=A*DFLOAT((N-N1+NN+1)*(N+N1-NN)*(N+N1+NN+2))
2499  A=DFLOAT(4*(NN+1)*(NN+1))/A
2500  A=A*DFLOAT((2*NN+1)*(2*NN+3))
2501  A=DSQRT(A)
2502  B=DFLOAT(2*(NN+2)*(NN+1))
2503  B=DFLOAT((2*M-MM)*(NN+2)*(NN+1)-MM*N*(N+1)
2504  & +MM*N1*(N1+1))/B
2505  D=DFLOAT(4*(NN+2)*(NN+2))
2506  D=D*DFLOAT((2*NN+5)*(2*NN+3))
2507  D=DFLOAT((NN+MM+2)*(NN-MM+2)*(N1-N+NN+2))/D
2508  D=D*DFLOAT((N-N1+NN+2)*(N+N1-NN-1)*(N+N1+NN+3))
2509  D=DSQRT(D)
2510  C=A*(B*C1-D*C2)
2511  C2=C1
2512  C1=C
2513  CD(NN)=C
2514  12 CONTINUE
2515  50 DO 9 NN=NNL,NNF
2516 .LE. IF (NNNNM) GG(MIND,NN+1)=CU(NN)
2517 .GT. IF (NNNNM) GG(MIND,NN+1)=CD(NN)
2518 c WRITE (6,*) N,M,N1,M1,NN,MM,GG(MIND,NN+1)
2519  9 CONTINUE
2520  90 CONTINUE
2521  100 CONTINUE
2522  RETURN
2523  END
2524 
2525 C*********************************************************************
2526 
2527  SUBROUTINE DIRECT (N,M,N1,M1,NN,MM,C)
2528  IMPLICIT REAL*8 (A-H,O-Z)
2529  REAL*8 F(900)
2530  COMMON /FAC/ F
2531  C=F(2*N+1)+F(2*N1+1)+F(N+N1+M+M1+1)+F(N+N1-M-M1+1)
2532  C=C-F(2*(N+N1)+1)-F(N+M+1)-F(N-M+1)-F(N1+M1+1)-F(N1-M1+1)
2533  C=DEXP(C)
2534  RETURN
2535  END
2536 
2537 C*********************************************************************
2538 C
2539 C Calculation of the Clebcsh-Gordan coefficients
2540 C G=(n,m:n1,mm-m/nn,mm)
2541 C for given n,n1,m,mm, where NN=MAX(/MM/,/N-N1/)
2542 .LE.C /M/N
2543 .LE.C /MM-M/N1
2544 .LE.C /MM/N+N1
2545 
2546  SUBROUTINE CCGIN(N,N1,M,MM,G)
2547  IMPLICIT REAL*8 (A-H,O-Z)
2548  REAL*8 F(900),SSIGN(900)
2549  COMMON /SS/ SSIGN
2550  COMMON /FAC/ F
2551  M1=MM-M
2552 .GE. IF(NIABS(M).
2553 .GE. & AND.N1IABS(M1).
2554 .LE. & AND.IABS(MM)(N+N1)) GO TO 1
2555  PRINT 5001
2556  STOP
2557  5001 FORMAT(' error in subroutine ccgin')
2558 .GT. 1 IF (IABS(MM)IABS(N-N1)) GO TO 100
2559  L1=N
2560  L2=N1
2561  L3=M
2562 .LE. IF(N1N) GO TO 50
2563  K=N
2564  N=N1
2565  N1=K
2566  K=M
2567  M=M1
2568  M1=K
2569  50 N2=N*2
2570  M2=M*2
2571  N12=N1*2
2572  M12=M1*2
2573  G=SSIGN(N1+M1+1)
2574  & *DEXP(F(N+M+1)+F(N-M+1)+F(N12+1)+F(N2-N12+2)-F(N2+2)
2575  & -F(N1+M1+1)-F(N1-M1+1)-F(N-N1+MM+1)-F(N-N1-MM+1))
2576  N=L1
2577  N1=L2
2578  M=L3
2579  RETURN
2580  100 A=1D0
2581  L1=M
2582  L2=MM
2583 .GE. IF(MM0) GO TO 150
2584  MM=-MM
2585  M=-M
2586  M1=-M1
2587  A=SSIGN(MM+N+N1+1)
2588  150 G=A*SSIGN(N+M+1)
2589  & *DEXP(F(2*MM+2)+F(N+N1-MM+1)+F(N+M+1)+F(N1+M1+1)
2590  & -F(N+N1+MM+2)-F(N-N1+MM+1)-F(-N+N1+MM+1)-F(N-M+1)
2591  & -F(N1-M1+1))
2592  M=L1
2593  MM=L2
2594  RETURN
2595  END
2596 
2597 C*****************************************************************
2598 
2599  SUBROUTINE SAREA (D,RAT)
2600  IMPLICIT REAL*8 (A-H,O-Z)
2601 .GE. IF (D1) GO TO 10
2602  E=DSQRT(1D0-D*D)
2603  R=0.5D0*(D**(2D0/3D0) + D**(-1D0/3D0)*DASIN(E)/E)
2604  R=DSQRT(R)
2605  RAT=1D0/R
2606  RETURN
2607  10 E=DSQRT(1D0-1D0/(D*D))
2608  R=0.25D0*(2D0*D**(2D0/3D0) + D**(-4D0/3D0)*DLOG((1D0+E)/(1D0-E))
2609  & /E)
2610  R=DSQRT(R)
2611  RAT=1D0/R
2612  RETURN
2613  END
2614 
2615 c****************************************************************
2616 
2617  SUBROUTINE SURFCH (N,E,RAT)
2618  IMPLICIT REAL*8 (A-H,O-Z)
2619  REAL*8 X(60),W(60)
2620  DN=DFLOAT(N)
2621  E2=E*E
2622  EN=E*DN
2623  NG=60
2624  CALL GAUSS (NG,0,0,X,W)
2625  S=0D0
2626  V=0D0
2627  DO 10 I=1,NG
2628  XI=X(I)
2629  DX=DACOS(XI)
2630  DXN=DN*DX
2631  DS=DSIN(DX)
2632  DSN=DSIN(DXN)
2633  DCN=DCOS(DXN)
2634  A=1D0+E*DCN
2635  A2=A*A
2636  ENS=EN*DSN
2637  S=S+W(I)*A*DSQRT(A2+ENS*ENS)
2638  V=V+W(I)*(DS*A+XI*ENS)*DS*A2
2639  10 CONTINUE
2640  RS=DSQRT(S*0.5D0)
2641  RV=(V*3D0/4D0)**(1D0/3D0)
2642  RAT=RV/RS
2643  RETURN
2644  END
2645 
2646 C********************************************************************
2647 
2648  SUBROUTINE SAREAC (EPS,RAT)
2649  IMPLICIT REAL*8 (A-H,O-Z)
2650  RAT=(1.5D0/EPS)**(1D0/3D0)
2651  RAT=RAT/DSQRT( (EPS+2D0)/(2D0*EPS) )
2652  RETURN
2653  END
2654 
2655 C********************************************************************
2656 
2657 C Computation of R1 and R2 for a power law size distribution with
2658 C effective radius A and effective variance B
2659 
2660  SUBROUTINE POWER (A,B,R1,R2)
2661  IMPLICIT REAL*8 (A-H,O-Z)
2662  EXTERNAL F
2663  COMMON AA,BB
2664  AA=A
2665  BB=B
2666  AX=1D-5
2667  BX=A-1D-5
2668  R1=ZEROIN (AX,BX,F,0D0)
2669  R2=(1D0+B)*2D0*A-R1
2670  RETURN
2671  END
2672 
2673 C***********************************************************************
2674 
2675  DOUBLE PRECISION FUNCTION ZEROIN (AX,BX,F,TOL)
2676  IMPLICIT REAL*8 (A-H,O-Z)
2677  EPS=1D0
2678  10 EPS=0.5D0*EPS
2679  TOL1=1D0+EPS
2680 .GT. IF (TOL11D0) GO TO 10
2681  15 A=AX
2682  B=BX
2683  FA=F(A)
2684  FB=F(B)
2685  20 C=A
2686  FC=FA
2687  D=B-A
2688  E=D
2689 .GE. 30 IF (DABS(FC)DABS(FB)) GO TO 40
2690  35 A=B
2691  B=C
2692  C=A
2693  FA=FB
2694  FB=FC
2695  FC=FA
2696  40 TOL1=2D0*EPS*DABS(B)+0.5D0*TOL
2697  XM=0.5D0*(C-B)
2698 .LE. IF (DABS(XM)TOL1) GO TO 90
2699 .EQ. 44 IF (FB0D0) GO TO 90
2700 .LT. 45 IF (DABS(E)TOL1) GO TO 70
2701 .LE. 46 IF (DABS(FA)DABS(FB)) GO TO 70
2702 .NE. 47 IF (AC) GO TO 50
2703  48 S=FB/FA
2704  P=2D0*XM*S
2705  Q=1D0-S
2706  GO TO 60
2707  50 Q=FA/FC
2708  R=FB/FC
2709  S=FB/FA
2710  P=S*(2D0*XM*Q*(Q-R)-(B-A)*(R-1D0))
2711  Q=(Q-1D0)*(R-1D0)*(S-1D0)
2712 .GT. 60 IF (P0D0) Q=-Q
2713  P=DABS(P)
2714 .GE. IF ((2D0*P)(3D0*XM*Q-DABS(TOL1*Q))) GO TO 70
2715 .GE. 64 IF (PDABS(0.5D0*E*Q)) GO TO 70
2716  65 E=D
2717  D=P/Q
2718  GO TO 80
2719  70 D=XM
2720  E=D
2721  80 A=B
2722  FA=FB
2723 .GT. IF (DABS(D)TOL1) B=B+D
2724 .LE. IF (DABS(D)TOL1) B=B+DSIGN(TOL1,XM)
2725  FB=F(B)
2726 .GT. IF ((FB*(FC/DABS(FC)))0D0) GO TO 20
2727  85 GO TO 30
2728  90 ZEROIN=B
2729  RETURN
2730  END
2731 
2732 C***********************************************************************
2733 
2734  DOUBLE PRECISION FUNCTION F(R1)
2735  IMPLICIT REAL*8 (A-H,O-Z)
2736  COMMON A,B
2737  R2=(1D0+B)*2D0*A-R1
2738  F=(R2-R1)/DLOG(R2/R1)-A
2739  RETURN
2740  END
2741 
2742 C**********************************************************************
2743 C CALCULATION OF POINTS AND WEIGHTS OF GAUSSIAN QUADRATURE *
2744 C FORMULA. IF IND1 = 0 - ON INTERVAL (-1,1), IF IND1 = 1 - ON *
2745 C INTERVAL (0,1). IF IND2 = 1 RESULTS ARE PRINTED. *
2746 C N - NUMBER OF POINTS *
2747 C Z - DIVISION POINTS *
2748 C W - WEIGHTS *
2749 C**********************************************************************
2750 
2751  SUBROUTINE GAUSS ( N,IND1,IND2,Z,W )
2752  IMPLICIT REAL*8 (A-H,P-Z)
2753  REAL*8 Z(N),W(N)
2754  A=1D0
2755  B=2D0
2756  C=3D0
2757  IND=MOD(N,2)
2758  K=N/2+IND
2759  F=DFLOAT(N)
2760  DO 100 I=1,K
2761  M=N+1-I
2762 .EQ. IF(I1) X=A-B/((F+A)*F)
2763 .EQ. IF(I2) X=(Z(N)-A)*4D0+Z(N)
2764 .EQ. IF(I3) X=(Z(N-1)-Z(N))*1.6D0+Z(N-1)
2765 .GT. IF(I3) X=(Z(M+1)-Z(M+2))*C+Z(M+3)
2766 .EQ..AND..EQ. IF(IKIND1) X=0D0
2767  NITER=0
2768  CHECK=1D-16
2769  10 PB=1D0
2770  NITER=NITER+1
2771 .LE. IF (NITER100) GO TO 15
2772  CHECK=CHECK*10D0
2773  15 PC=X
2774  DJ=A
2775  DO 20 J=2,N
2776  DJ=DJ+A
2777  PA=PB
2778  PB=PC
2779  20 PC=X*PB+(X*PB-PA)*(DJ-A)/DJ
2780  PA=A/((PB-X*PC)*F)
2781  PB=PA*PC*(A-X*X)
2782  X=X-PB
2783 .GT. IF(DABS(PB)CHECK*DABS(X)) GO TO 10
2784  Z(M)=X
2785  W(M)=PA*PA*(A-X*X)
2786 .EQ. IF(IND10) W(M)=B*W(M)
2787 .EQ..AND..EQ. IF(IKIND1) GO TO 100
2788  Z(I)=-Z(M)
2789  W(I)=W(M)
2790  100 CONTINUE
2791 .NE. IF(IND21) GO TO 110
2792  PRINT 1100,N
2793  1100 FORMAT(' *** points and weights of gaussian quadrature formula',
2794  * ' of ',I4,'-th order')
2795  DO 105 I=1,K
2796  ZZ=-Z(I)
2797  105 PRINT 1200,I,ZZ,I,W(I)
2798  1200 FORMAT(' ',4X,'x(',I4,') = ',F17.14,5X,'w(',I4,') = ',F17.14)
2799  GO TO 115
2800  110 CONTINUE
2801 C PRINT 1300,N
2802  1300 FORMAT(' gaussian quadrature formula of ',I4,'-th order is used')
2803  115 CONTINUE
2804 .EQ. IF(IND10) GO TO 140
2805  DO 120 I=1,N
2806  120 Z(I)=(A+Z(I))/B
2807  140 CONTINUE
2808  RETURN
2809  END
2810 
2811 C****************************************************************
2812 
2813  SUBROUTINE DISTRB (NNK,YY,WY,NDISTR,AA,BB,GAM,R1,R2,REFF,
2814  & VEFF,PI)
2815  IMPLICIT REAL*8 (A-H,O-Z)
2816  REAL*8 YY(NNK),WY(NNK)
2817 .EQ. IF (NDISTR2) GO TO 100
2818 .EQ. IF (NDISTR3) GO TO 200
2819 .EQ. IF (NDISTR4) GO TO 300
2820 .EQ. IF (NDISTR5) GO TO 360
2821  PRINT 1001,AA,BB,GAM
2822  1001 FORMAT('modified gamma distribution, alpha=',F6.4,' r_c=',
2823  & F6.4,' gamma=',F6.4)
2824  A2=AA/GAM
2825  DB=1D0/BB
2826  DO 50 I=1,NNK
2827  X=YY(I)
2828  Y=X**AA
2829  X=X*DB
2830  Y=Y*DEXP(-A2*(X**GAM))
2831  WY(I)=WY(I)*Y
2832  50 CONTINUE
2833  GO TO 400
2834  100 PRINT 1002,AA,BB
2835  1002 FORMAT('log-normal distribution, r_g=',F8.4,
2836  & ' [ln(sigma_g)]**2=',F6.4)
2837  DA=1D0/AA
2838  DO 150 I=1,NNK
2839  X=YY(I)
2840  Y=DLOG(X*DA)
2841  Y=DEXP(-Y*Y*0.5D0/BB)/X
2842  WY(I)=WY(I)*Y
2843  150 CONTINUE
2844  GO TO 400
2845  200 PRINT 1003
2846  1003 FORMAT('power law distribution of hansen & travis 1974')
2847  DO 250 I=1,NNK
2848  X=YY(I)
2849  WY(I)=WY(I)/(X*X*X)
2850  250 CONTINUE
2851  GO TO 400
2852  300 PRINT 1004,AA,BB
2853  1004 FORMAT ('gamma distribution, a=',F8.4,' b=',F6.4)
2854  B2=(1D0-3D0*BB)/BB
2855  DAB=1D0/(AA*BB)
2856  DO 350 I=1,NNK
2857  X=YY(I)
2858  X=(X**B2)*DEXP(-X*DAB)
2859  WY(I)=WY(I)*X
2860  350 CONTINUE
2861  GO TO 400
2862  360 PRINT 1005,BB
2863  1005 FORMAT ('modified power law distribution, alpha=',D10.4)
2864  DO 370 I=1,NNK
2865  X=YY(I)
2866 .LE. IF (XR1) WY(I)=WY(I)
2867 .GT. IF (XR1) WY(I)=WY(I)*(X/R1)**BB
2868  370 CONTINUE
2869  400 CONTINUE
2870  SUM=0D0
2871  DO 450 I=1,NNK
2872  SUM=SUM+WY(I)
2873  450 CONTINUE
2874  SUM=1D0/SUM
2875  DO 500 I=1,NNK
2876  WY(I)=WY(I)*SUM
2877  500 CONTINUE
2878  G=0D0
2879  DO 550 I=1,NNK
2880  X=YY(I)
2881  G=G+X*X*WY(I)
2882  550 CONTINUE
2883  REFF=0D0
2884  DO 600 I=1,NNK
2885  X=YY(I)
2886  REFF=REFF+X*X*X*WY(I)
2887  600 CONTINUE
2888  REFF=REFF/G
2889  VEFF=0D0
2890  DO 650 I=1,NNK
2891  X=YY(I)
2892  XI=X-REFF
2893  VEFF=VEFF+XI*XI*X*X*WY(I)
2894  650 CONTINUE
2895  VEFF=VEFF/(G*REFF*REFF)
2896  RETURN
2897  END
2898 
2899 C*************************************************************
2900 
2901  SUBROUTINE HOVENR(L1,A1,A2,A3,A4,B1,B2)
2902  IMPLICIT REAL*8 (A-H,O-Z)
2903  REAL*8 A1(L1),A2(L1),A3(L1),A4(L1),B1(L1),B2(L1)
2904  DO 100 L=1,L1
2905  KONTR=1
2906  LL=L-1
2907  DL=DFLOAT(LL)*2D0+1D0
2908  DDL=DL*0.48D0
2909  AA1=A1(L)
2910  AA2=A2(L)
2911  AA3=A3(L)
2912  AA4=A4(L)
2913  BB1=B1(L)
2914  BB2=B2(L)
2915 .GE..AND..GE. IF(LL1DABS(AA1)DL) KONTR=2
2916 .GE. IF(DABS(AA2)DL) KONTR=2
2917 .GE. IF(DABS(AA3)DL) KONTR=2
2918 .GE. IF(DABS(AA4)DL) KONTR=2
2919 .GE. IF(DABS(BB1)DDL) KONTR=2
2920 .GE. IF(DABS(BB2)DDL) KONTR=2
2921 .EQ. IF(KONTR2) PRINT 3000,LL
2922  C=-0.1D0
2923  DO 50 I=1,11
2924  C=C+0.1D0
2925  CC=C*C
2926  C1=CC*BB2*BB2
2927  C2=C*AA4
2928  C3=C*AA3
2929 .LE. IF((DL-C*AA1)*(DL-C*AA2)-CC*BB1*BB1-1D-4) KONTR=2
2930 .LE. IF((DL-C2)*(DL-C3)+C1-1D-4) KONTR=2
2931 .LE. IF((DL+C2)*(DL-C3)-C1-1D-4) KONTR=2
2932 .LE. IF((DL-C2)*(DL+C3)-C1-1D-4) KONTR=2
2933 .EQ. IF(KONTR2) PRINT 4000,LL,C
2934  50 CONTINUE
2935  100 CONTINUE
2936 .EQ. IF(KONTR1) PRINT 2000
2937  2000 FORMAT('test of van der mee & hovenier is satisfied')
2938  3000 FORMAT('test of van der mee & hovenier is not satisfied, l=',I3)
2939  4000 FORMAT('test of van der mee & hovenier is not satisfied, l=',I3,
2940  & ' a=',D9.2)
2941  RETURN
2942  END
2943 
2944 C****************************************************************
2945 
2946 C CALCULATION OF THE SCATTERING MATRIX FOR GIVEN EXPANSION
2947 C COEFFICIENTS
2948 
2949 C A1,...,B2 - EXPANSION COEFFICIENTS
2950 C LMAX - NUMBER OF COEFFICIENTS MINUS 1
2951 C N - NUMBER OF SCATTERING ANGLES
2952 C THE CORRESPONDING SCATTERING ANGLES ARE GIVEN BY
2953 C 180*(I-1)/(N-1) (DEGREES), WHERE I NUMBERS THE ANGLES
2954 
2955  SUBROUTINE MATR(A1,A2,A3,A4,B1,B2,LMAX,NPNA)
2956  INCLUDE 'tmq.par.f'
2957  IMPLICIT REAL*8 (A-H,O-Z)
2958  REAL*8 A1(NPL),A2(NPL),A3(NPL),A4(NPL),B1(NPL),B2(NPL)
2959  N=NPNA
2960  DN=1D0/DFLOAT(N-1)
2961  DA=DACOS(-1D0)*DN
2962  DB=180D0*DN
2963  L1MAX=LMAX+1
2964  PRINT 1000
2965  1000 FORMAT(' ')
2966  PRINT 1001
2967  1001 FORMAT(' ',2X,'s',6X,'alpha1',6X,'alpha2',6X,'alpha3',
2968  & 6X,'alpha4',7X,'beta1',7X,'beta2')
2969  DO 10 L1=1,L1MAX
2970  L=L1-1
2971  PRINT 1002,L,A1(L1),A2(L1),A3(L1),A4(L1),B1(L1),B2(L1)
2972  10 CONTINUE
2973  1002 FORMAT(' ',I3,6F12.5)
2974  TB=-DB
2975  TAA=-DA
2976  PRINT 1000
2977  PRINT 1003
2978  1003 FORMAT(' ',5X,'<',8X,'f11',8X,'f22',8X,'f33',
2979  & 8X,'f44',8X,'f12',8X,'f34')
2980  D6=DSQRT(6D0)*0.25D0
2981  DO 500 I1=1,N
2982  TAA=TAA+DA
2983  TB=TB+DB
2984  U=DCOS(TAA)
2985  F11=0D0
2986  F2=0D0
2987  F3=0D0
2988  F44=0D0
2989  F12=0D0
2990  F34=0D0
2991  P1=0D0
2992  P2=0D0
2993  P3=0D0
2994  P4=0D0
2995  PP1=1D0
2996  PP2=0.25D0*(1D0+U)*(1D0+U)
2997  PP3=0.25D0*(1D0-U)*(1D0-U)
2998  PP4=D6*(U*U-1D0)
2999  DO 400 L1=1,L1MAX
3000  L=L1-1
3001  DL=DFLOAT(L)
3002  DL1=DFLOAT(L1)
3003  F11=F11+A1(L1)*PP1
3004  F44=F44+A4(L1)*PP1
3005 .EQ. IF(LLMAX) GO TO 350
3006  PL1=DFLOAT(2*L+1)
3007  P=(PL1*U*PP1-DL*P1)/DL1
3008  P1=PP1
3009  PP1=P
3010 .LT. 350 IF(L2) GO TO 400
3011  F2=F2+(A2(L1)+A3(L1))*PP2
3012  F3=F3+(A2(L1)-A3(L1))*PP3
3013  F12=F12+B1(L1)*PP4
3014  F34=F34+B2(L1)*PP4
3015 .EQ. IF(LLMAX) GO TO 400
3016  PL2=DFLOAT(L*L1)*U
3017  PL3=DFLOAT(L1*(L*L-4))
3018  PL4=1D0/DFLOAT(L*(L1*L1-4))
3019  P=(PL1*(PL2-4D0)*PP2-PL3*P2)*PL4
3020  P2=PP2
3021  PP2=P
3022  P=(PL1*(PL2+4D0)*PP3-PL3*P3)*PL4
3023  P3=PP3
3024  PP3=P
3025  P=(PL1*U*PP4-DSQRT(DFLOAT(L*L-4))*P4)/DSQRT(DFLOAT(L1*L1-4))
3026  P4=PP4
3027  PP4=P
3028  400 CONTINUE
3029  F22=(F2+F3)*0.5D0
3030  F33=(F2-F3)*0.5D0
3031 C F22=F22/F11
3032 C F33=F33/F11
3033 C F44=F44/F11
3034 C F12=-F12/F11
3035 C F34=F34/F11
3036  PRINT 1004,TB,F11,F22,F33,F44,F12,F34
3037  500 CONTINUE
3038  PRINT 1000
3039  1004 FORMAT(' ',F6.2,6F11.4)
3040  RETURN
3041  END
===========================================================================V4.1.3 12/18/2002============================================================================Changes which do not affect scientific output:1. The R *LUT was eliminated and the equivalent formulation for R *, i.e. 1/(m1 *e_sun_over_pi), was substituted for it in the only instance of its use, which is in the calculation of the RSB uncertainty index. This reduces the size of the Reflective LUT HDF file by approximately 1/4 to 1/3. The equivalent formulation of R *differed from the new by at most 0.056% in test granules and uncertainty differences of at most 1 count(out of a range of 0-15) were found in no more than 1 in 100, 000 pixels. 2. In Preprocess.c, a small error where the trailing dropped scan counter was incremented when the leading dropped scan counter should have been was fixed. This counter is internal only and is not yet used for any purpose. 3. NEW MYD02OBC Metadata Configuration Files. MCST wishes to have the OBC files archived even when the Orbit Number is recorded as "-1". Accordingly, ECS has delivered new MCF files for OBC output having all elements in the OrbitCalculatedSpatialDomain container set to "MANDATORY=FALSE". 4. pgs_in.version is now reset to "1" in Metadata.c before the call to look up the geolocation gringpoint information.============================================================================V4.1.1 CODE SPECIFIC TO MODIS/AQUA(FM1) 10/03/2002============================================================================Two changes were made to the code which do not affect scientific output:1. A bug which caused PGE02 to fail when scans were dropped between granules was fixed.(The length of the error message generated was shortened.) 2. Messages regarding an invalid MCST LUT Version or an invalid Write High Resolution Night Mode Output value in the PCF file were added.==============================================================================V4.1.0 CODE SPECIFIC TO MODIS/AQUA(FM1)(NEVER USED IN PRODUCTION) 07/30/2002==============================================================================Changes which impact scientific output of code:1. The LUT type of the RVS corrections was changed to piecewise linear. In addition the RVS LUTs were changed from listing the RVS corrections to listing the quadratic coefficients necessary to make the RVS corrections. The coefficients are now calculated by interpolating on the granule collection time and the RVS corrections are then generated using the interpolated coefficients. Previously used Emissive and Reflective RVS LUT tables were eliminated and new ones introduced. Several changes were made to the code which should not affect scientific output. They are:1. The ADC correction algorithm and related LUTs were stripped from the code.(The ADC correction has always been set to "0" so this has no scientific impact.) 2. Some small changes to the code, chiefly to casting of variables, were added to make it LINUX-compatible. Output of code run on LINUX machines displays differences of at most 1 scaled integer(SI) from output of code run on IRIX machines. The data type of the LUT "dn_sat_ev" was changed to float64 to avoid discrepancies seen between MOD_PR02 run on LINUX systems and IRIX systems where values were flagged under one operating system but not the other. 3. Checking for non-functioning detectors, sector rotation, incalculable values of the Emissive calibration factor "b1", and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal.c since none of these quantities are frame-dependent. 4. The code was altered so that if up to five scans are dropped between the leading/middle or middle/trailing granules, the leading or trailing granule will still be used in emissive calibration to form a cross-granule average. QA bits 25 and 26 are set for a gap between the leading/middle and middle/trailing granules respectively. This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule. 5.(MODIS/AQUA ONLY) The name of the seed(error message) file was changed from "MODIS_36100.h" to "MODIS_36110.h". 6. Metadata.c was changed so that the source of the geolocation metadata is the input geolocation file rather than the L1A granule. 7. To reduce to overall size of the reflective LUT HDF files, fill values were eliminated from all LUTs previously dimensioned "BDSM"([NUM_REFLECTIVE_BANDS] *[MAX_DETECTORS_PER_BAND] *[MAX_SAMPLES_PER_BAND] *[NUM_MIRROR_SIDES]) in the LUT HDF files. Each table piece is stored in the HDF file with dimensions NUM_REFLECTIVE_INDICES, where NUM_REFLECTIVE_INDICES=[NUM_250M_BANDS *DETECTORS_PER_250M_BAND *SAMPLES_PER_250M_BAND *NUM_MIRROR_SIDES]+[NUM_500M_BANDS *DETECTORS_PER_500M_BAND *SAMPLES_PER_500M_BAND *NUM_MIRROR_SIDES]+[NUM_1000M_BANDS *DETECTORS_PER_1KM_BAND *SAMPLES_PER_1KM_BAND *NUM_MIRROR_SIDES] with SAMPLES_PER_250M_BAND=4, SAMPLES_PER_500M_BAND=2, and SAMPLES_PER_1KM_BAND=1. Values within each table piece appear in the order listed above. The overall dimensions of time dependent BDSM LUTs are now[NUM_TIMES] *[NUM_REFLECTIVE_INDICES], where NUM_TIMES is the number of time dependent table pieces. 8. Checking for non-functioning detectors, sector rotation, incalculable values of the Emissive calibration factor "b1", and incalculable values of SV or BB averages was moved outside the loop over frames in Emissive_Cal.c since none of these quantities are frame-dependent. 9. The code was altered so that if up to five scans are dropped between the leading/middle or middle/trailing granules, the leading or trailing granule will still be used in emissive calibration to form a cross-granule average. QA bits 25 and 26 are set for a gap between the leading/middle and middle/trailing granules respectively. This may in rare instances lead to a change in emissive calibration coefficients for scans at the beginning or end of a granule. 10. The array of b1s in Preprocess.c was being initialized to -1 outside the loop over bands, which meant that if b1 could not be computed, the value of b1 from the previous band for that scan/detector combination was used. The initialization was moved inside the band loop.============================================================================V3.1.0(Original Aqua-specific code version) 02/06/2002============================================================================AQUA-Specific changes made:1. A correction to a problem with blackbody warmup on bands 33, 35, and 36 was inserted. PC Bands 33, 35, and 36 on MODIS Aqua saturate on BB warmup before 310K, which means current code will not provide correct b1 calibration coefficients when the BB temperatures are above the saturation threshold. A LUT with default b1s and band-dependent temperature thresholds will be inserted in code. If the BB temperature is over the saturation threshold for the band, the default b1 from the table is used. 2. The number of possible wavelengths in the Emissive LUT RSR file was changed to 67 in order to accommodate the Aqua RSR tables. 3. Several changes to the upper and lower bound limits on LUT values were inserted. Changes to both Aqua and Terra Code:1. A check was put into Emissive_Cal.c to see whether the value of b1 being used to calibrate a pixel is negative. If so, the pixel is flagged with the newly created flag TEB_B1_NOT_CALCULATED, value 65526, and the number of pixels for which this occurs is counted in the QA_common table. 2. The array of b1s in Preprocess.c was being initialized to -1 outside the loop over bands, which meant that if b1 could not be computed, the value of b1 from the previous band for that scan/detector combination was used. The initialization was moved inside the band loop. 3. Minor code changes were made to eliminate compiler warnings when the code is compiled in 64-bit mode. 4. Temperature equations were upgraded to be MODIS/Aqua or MODIS/Terra specific and temperature conversion coefficients for Aqua were inserted.========================================================================================================================================================ALL CHANGES BELOW ARE TO COMMON TERRA/AQUA CODE USED BEFORE 02/06/2002========================================================================================================================================================v3.0.1 11/26/2001============================================================================Several small changes to the code were made, none of which changes the scientific output:1. The code was changed so that production of 250m and 500m resolution data when all scans of a granule are in night mode may be turned off/on through the PCF file. 2. A check on the times of the leading and trailing granules was inserted. If a leading or trailing granule does not immediately precede or follow(respectively) the middle granule, it is treated as a missing granule and a warning message is printed. 3. The code now reads the "MCST Version Number"(e.g. "3.0.1.0_Terra") from the PCF file and checks it against the MCST Version number contained in the LUT HDF files. This was done to allow the user to make sure the code is being run using the correct LUT files.(The designators "0_Terra", "1_Terra", etc.) refer to the LUT versions.) 4. A small bug in Preprocess.c was corrected code
Definition: HISTORY.txt:661
subroutine ccg(N, N1, NMAX, K1, K2, GG)
Definition: tmd.lp.f:1209
float ** matrix(long nrl, long nrh, long ncl, long nch)
Definition: nrutil.c:60
subroutine tmatr(M, NGAUSS, X, W, AN, ANN, S, SS, PPI, PIR, PII, R, DR, DDR, DRR, DRI, NMAX, NCHECK)
Definition: ampld.lp.f:1514
===========================================================================V5.0.48(Terra) 03/20/2015 Changes shown below are differences from MOD_PR02 V5.0.46(Terra)============================================================================Changes noted for V6.1.20(Terra) below were also instituted for this version.============================================================================V6.1.20(Terra) 03/12/2015 Changes shown below are differences from MOD_PR02 V6.1.18(Terra)============================================================================Changes from v6.1.18 which may affect scientific output:A situation can occur in which a scan which contains sector rotated data has a telemetry value indicating the completeness of the sector rotation. This issue is caused by the timing of the instrument command to perform the sector rotation and the recording of the telemetry point that reports the status of sector rotation. In this case a scan is considered valid by L1B and pass through the calibration - reporting extremely high radiances. Operationally the TEB calibration uses a 40 scan average coefficient, so the 20 scans(one mirror side) after the sector rotation are contaminated with anomalously high radiance values. A similar timing issue appeared before the sector rotation was fixed in V6.1.2. Our analysis indicates the ‘SET_FR_ENC_DELTA’ telemetry correlates well with the sector rotation encoder position. The use of this telemetry point to determine scans that are sector rotated should fix the anomaly occured before and after the sector rotation(usually due to the lunar roll maneuver). The fix related to the sector rotation in V6.1.2 is removed in this version.============================================================================V6.1.18(Terra) 10/01/2014 Changes shown below are differences from MOD_PR02 V6.1.16(Terra)============================================================================Added doi attributes to NRT(Near-Real-Time) product.============================================================================V6.1.16(Terra) 01/27/2014 Changes shown below are differences from MOD_PR02 V6.1.14(Terra)============================================================================Migrate to SDP Toolkit 5.2.17============================================================================V6.1.14(Terra) 06/26/2012 Changes shown below are differences from MOD_PR02 V6.1.12(Terra)============================================================================Added the doi metadata to L1B product============================================================================V6.1.12(Terra) 04/25/2011 Changes shown below are differences from MOD_PR02 V6.1.8(Terra)============================================================================1. The algorithm to calculate uncertainties for reflective solar bands(RSB) is updated. The current uncertainty in L1B code includes 9 terms from prelaunch analysis. The new algorithm regroups them with the new added contributions into 5 terms:u1:the common term(AOI and time independent) and
Definition: HISTORY.txt:126
#define min(A, B)
Definition: main_biosmap.c:62
subroutine power(A, B, R1, R2)
Definition: tmd.lp.f:1380
subroutine ccgin(N, N1, M, MM, G)
Definition: tmd.lp.f:1318
#define f
Definition: l1_czcs_hdf.c:702
this program makes no use of any feature of the SDP Toolkit that could generate such a then geolocation is calculated at that and then aggregated up to Resolved feature request Bug by adding three new int8 SDSs for each high resolution offsets between the high resolution geolocation and a bi linear interpolation extrapolation of the positions This can be used to reconstruct the high resolution geolocation Resolved Bug by delaying cumulation of gflags until after validation of derived products Resolved Bug by setting Latitude and Longitude to the correct fill resolving to support Near Real Time because they may be unnecessary if use of entrained ephemeris and attitude data is turned on(as it will be in Near-Real-Time processing).
subroutine der(T, X, DX)
Definition: der.f:2