-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmd.lp.f
2836 lines (2648 loc) · 105 KB
/
tmd.lp.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
! This test result was produced by the code in its
! current setting.
! NCHECK=1
! RANDOMLY ORIENTED OBLATE SPHEROIDS, A/B= 2.0000000
! LAM= .500000 MRR= .1530D+01 MRI= .8000D-02
! ACCURACY OF COMPUTATIONS DDELT = .10D-02
! POWER LAW DISTRIBUTION OF HANSEN & TRAVIS 1974
! R1= .546765 R2= 1.653235
! EQUAL-SURFACE-AREA-SPHERE REFF= 1.0000 VEFF= .1000
! NUMBER OF GAUSSIAN QUADRATURE POINTS IN SIZE AVERAGING = 7
! TEST OF VAN DER MEE & HOVENIER IS SATISFIED
! CEXT= .551130D+01 CSCA= .463115D+01 W= .840300D+00 <COS>= .704668D+00
! S ALPHA1 ALPHA2 ALPHA3 ALPHA4 BETA1 BETA2
! 0 1.00000 .00000 .00000 .86636 .00000 .00000
! 1 2.11400 .00000 .00000 2.16400 .00000 .00000
! 2 3.13065 3.94861 3.73632 3.15010 .00931 .21654
! 3 3.99715 4.12082 3.99065 3.95990 -.01603 -.12316
! 4 4.43363 4.91135 4.83199 4.37475 -.00691 -.07986
! 5 4.71452 4.86827 4.87865 4.73970 .05220 .03086
! 6 5.15129 5.30901 5.27054 5.15444 .00838 -.01179
! 7 5.51023 5.64027 5.58233 5.48176 .02996 -.14319
! 8 5.70011 5.84656 5.80601 5.67813 .05115 -.10754
! 9 5.81145 5.92277 5.92816 5.84438 .03241 -.09748
! 10 5.93903 6.05677 6.00716 5.92499 .00190 -.16506
! 11 5.91972 6.03305 6.00644 5.92478 .00548 -.19352
! 12 5.83268 5.94949 5.91679 5.83316 -.01030 -.20685
! 13 5.65812 5.76143 5.74482 5.67859 -.02545 -.23006
! 14 5.45787 5.56951 5.51960 5.44338 -.02494 -.26142
! 15 5.16956 5.25941 5.23960 5.18025 -.02456 -.24718
! 16 4.88831 4.98483 4.95151 4.88870 -.03269 -.25580
! 17 4.57158 4.64739 4.63271 4.58621 -.03669 -.25043
! 18 4.28119 4.36121 4.31846 4.26659 -.02736 -.26272
! 19 3.95365 4.01449 4.00017 3.96390 -.02652 -.22467
! 20 3.68160 3.74125 3.70996 3.67321 -.02841 -.22151
! 21 3.38915 3.43556 3.42933 3.40290 -.03453 -.20643
! 22 3.11315 3.16668 3.14183 3.11047 -.03502 -.21750
! 23 2.82184 2.86122 2.84914 2.82829 -.02878 -.20397
! 24 2.55926 2.60205 2.57295 2.54794 -.01920 -.19806
! 25 2.29505 2.32518 2.31607 2.30055 -.01439 -.16053
! 26 2.08359 2.11411 2.09304 2.07524 -.01726 -.14923
! 27 1.88162 1.90304 1.89536 1.88415 -.01561 -.12309
! 28 1.69977 1.72465 1.71430 1.70023 -.02783 -.11295
! 29 1.52061 1.53820 1.53472 1.52590 -.03569 -.10838
! 30 1.34785 1.37007 1.35437 1.34175 -.03503 -.11661
! 31 1.16036 1.17521 1.17269 1.16508 -.03158 -.09929
! 32 1.00968 1.02652 1.01066 1.00039 -.02326 -.10190
! 33 .85561 .86654 .86368 .85798 -.01545 -.07638
! 34 .73999 .75170 .74291 .73602 -.01446 -.07155
! 35 .62949 .63658 .63400 .63047 -.01459 -.05846
! 36 .53797 .54724 .53948 .53428 -.01344 -.05866
! 37 .43797 .44365 .44468 .44206 -.01651 -.04665
! 38 .36404 .37121 .36153 .35722 -.01113 -.05361
! 39 .27906 .28316 .28403 .28196 -.00869 -.03675
! 40 .22351 .22849 .22268 .21977 -.00544 -.03794
! 41 .16565 .16835 .16807 .16684 -.00425 -.02625
! 42 .12771 .13101 .12625 .12433 -.00244 -.02542
! 43 .08951 .09095 .09191 .09153 -.00373 -.01591
! 44 .06879 .07106 .06647 .06533 -.00161 -.01786
! 45 .04336 .04410 .04499 .04489 -.00214 -.00925
! 46 .03247 .03372 .03010 .02948 -.00070 -.01109
! 47 .01752 .01790 .01833 .01831 -.00102 -.00449
! 48 .01292 .01349 .01127 .01099 -.00011 -.00550
! 49 .00571 .00586 .00591 .00587 -.00015 -.00165
! 50 .00371 .00390 .00307 .00298 -.00010 -.00178
! 51 .00135 .00139 .00142 .00140 -.00007 -.00043
! 52 .00081 .00085 .00066 .00064 -.00002 -.00042
! 53 .00022 .00023 .00023 .00023 -.00001 -.00008
! 54 .00010 .00011 .00008 .00008 -.00001 -.00005
! 55 .00003 .00003 .00003 .00003 .00000 -.00002
! 56 .00001 .00001 .00001 .00001 .00000 -.00001
! 57 .00000 .00000 .00000 .00000 .00000 .00000
! 58 .00000 .00000 .00000 .00000 .00000 .00000
! 59 .00000 .00000 .00000 .00000 .00000 .00000
! 60 .00000 .00000 .00000 .00000 .00000 .00000
! < F11 F22 F33 F44 F12 F34
! .00 126.4358 126.3593 126.3593 126.2829 .0000 .0000
! 10.00 19.9147 19.8807 19.7843 19.7615 .0885 1.3957
! 20.00 3.2713 3.2536 3.1595 3.1548 -.1007 .1116
! 30.00 1.8477 1.8276 1.7628 1.7651 -.0390 -.0163
! 40.00 1.0114 .9923 .9330 .9364 .0166 .0159
! 50.00 .5769 .5582 .4966 .5013 .0083 -.0186
! 60.00 .3283 .3107 .2381 .2421 .0066 -.0334
! 70.00 .2204 .2032 .1246 .1284 .0053 -.0281
! 80.00 .2121 .1933 .0894 .0906 .0076 -.0911
! 90.00 .2800 .2559 .1164 .1157 .0034 -.1624
! 100.00 .3583 .3264 .1562 .1527 -.0220 -.2341
! 110.00 .3376 .2991 .1618 .1624 -.0411 -.1930
! 120.00 .2781 .2322 .1219 .1306 -.0161 -.1200
! 130.00 .2296 .1726 .0630 .0884 .0059 -.0765
! 140.00 .2114 .1326 .0112 .0596 .0153 -.0647
! 150.00 .1913 .0984 -.0261 .0396 .0175 -.0502
! 160.00 .1829 .1021 -.0345 .0248 .0210 -.0364
! 170.00 .1941 .1157 -.0497 .0086 .0078 .0135
! 180.00 .4076 .2343 -.2343 -.0609 .0000 .0000
! POWER LAW DISTRIBUTION OF HANSEN & TRAVIS 1974
! R1= .273383 R2= .826617
! EQUAL-SURFACE-AREA-SPHERE REFF= .5000 VEFF= .1000
! NUMBER OF GAUSSIAN QUADRATURE POINTS IN SIZE AVERAGING = 4
! TEST OF VAN DER MEE & HOVENIER IS SATISFIED
! CEXT= .178850D+01 CSCA= .166115D+01 W= .928793D+00 <COS>= .711510D+00
! S ALPHA1 ALPHA2 ALPHA3 ALPHA4 BETA1 BETA2
! 0 1.00000 .00000 .00000 .90379 .00000 .00000
! 1 2.13453 .00000 .00000 2.15472 .00000 .00000
! 2 2.87891 3.89769 3.76504 2.88912 -.03603 .17045
! 3 3.31141 3.64866 3.56472 3.30364 -.12718 -.08315
! 4 3.34005 3.87518 3.80119 3.30624 -.09511 -.12689
! 5 3.14764 3.42234 3.41522 3.16433 -.04799 -.10996
! 6 2.90725 3.19359 3.15908 2.91531 -.07907 -.13196
! 7 2.60182 2.78746 2.75457 2.61330 -.05008 -.17332
! 8 2.28500 2.47567 2.43219 2.28077 -.06222 -.17434
! 9 1.93788 2.04986 2.02004 1.93051 -.03176 -.16994
! 10 1.63217 1.74084 1.71696 1.62641 -.01822 -.13829
! 11 1.34299 1.40640 1.40588 1.35521 -.02153 -.10505
! 12 1.13893 1.20071 1.17446 1.12740 -.02856 -.11926
! 13 .92255 .96234 .95343 .92422 -.01335 -.08264
! 14 .78209 .82040 .80885 .78076 -.02368 -.07933
! 15 .62364 .64726 .64264 .62714 -.02292 -.06787
! 16 .50158 .52859 .51203 .49120 -.01582 -.07101
! 17 .36215 .37791 .37825 .36699 -.01229 -.04060
! 18 .27300 .28836 .27773 .26608 -.01081 -.04302
! 19 .18306 .18930 .19043 .18414 -.00561 -.02297
! 20 .12695 .13414 .12897 .12323 -.00758 -.02154
! 21 .07623 .08027 .08066 .07773 -.00810 -.01239
! 22 .05015 .05428 .04947 .04622 -.00575 -.01501
! 23 .02252 .02415 .02420 .02283 -.00100 -.00602
! 24 .01085 .01177 .01067 .00994 -.00028 -.00404
! 25 .00361 .00370 .00385 .00354 .00086 -.00107
! 26 .00106 .00115 .00102 .00086 .00041 -.00022
! 27 .00005 .00007 .00004 .00002 -.00001 .00013
! 28 .00018 .00019 .00017 .00015 -.00007 -.00005
! 29 .00003 .00004 .00004 .00003 .00000 -.00001
! 30 .00001 .00001 .00001 .00001 .00000 .00000
! 31 .00000 .00000 .00000 .00000 .00000 .00000
! 32 .00000 .00000 .00000 .00000 .00000 .00000
! < F11 F22 F33 F44 F12 F34
! .00 33.5983 33.5471 33.5471 33.4958 .0000 .0000
! 10.00 20.2059 20.1677 20.1565 20.1285 .1424 .4949
! 20.00 7.0078 6.9817 6.9317 6.9236 .1694 .4535
! 30.00 2.7091 2.6880 2.6265 2.6254 .1646 .1980
! 40.00 1.2202 1.1998 1.1367 1.1408 .1311 .0344
! 50.00 .7114 .6944 .6392 .6434 .0854 -.0322
! 60.00 .4294 .4090 .3598 .3639 .0740 -.0443
! 70.00 .3253 .3010 .2391 .2443 .0552 -.0763
! 80.00 .2917 .2662 .1799 .1848 .0291 -.1167
! 90.00 .2842 .2535 .1591 .1648 -.0060 -.1446
! 100.00 .2681 .2320 .1478 .1566 -.0241 -.1328
! 110.00 .2455 .1989 .1148 .1312 -.0259 -.1200
! 120.00 .2244 .1636 .0904 .1189 -.0408 -.0984
! 130.00 .1925 .1300 .0710 .1028 -.0276 -.0552
! 140.00 .1686 .1092 .0408 .0752 -.0037 -.0387
! 150.00 .1567 .0981 .0184 .0533 .0117 -.0334
! 160.00 .1354 .0946 -.0008 .0194 .0206 -.0173
! 170.00 .1504 .0734 -.0517 .0137 .0144 .0266
! 180.00 .2581 .1095 -.1095 .0391 .0000 .0000
! time = .33 min
C New release including the LAPACK matrix inversion procedure.
C We thank Cory Davis (University of Edinburgh) for pointing
C out the possibility of replacing the proprietary NAG matrix
C inversion routine by the public-domain LAPACK equivalent.
C CALCULATION OF LIGHT SCATTERING BY POLYDISPERSE, RANDOMLY
C ORIENTED PARTICLES OF IDENTICAL AXIALLY SYMMETRIC SHAPE
C This version of the code uses DOUBLE PRECISION variables
C and must be used along with the accompanying files tmd.par.f
C and lpd.f.
C Last update 08/06/2005
C The code has been developed by Michael Mishchenko at the NASA
C Goddard Institute for Space Studies, New York. This research
C was funded by the NASA Radiation Sciences Program.
C The code can be used without limitations in any not-for-
C profit scientific research. We only request that in any
C publication using the code the source of the code be acknowledged
C and relevant references (see below) be made.
C This version of the code is applicable to spheroids,
C Chebyshev particles, and finite circular cylinders.
C The computational method is based on the Watermsn's T-matrix
C approach and is described in detail in the following papers:
C
C 1. M. I. Mishchenko, Light scattering by randomly oriented
C axially symmetric particles, J. Opt. Soc. Am. A,
C vol. 8, 871-882 (1991).
C
C 2. M. I. Mishchenko, Light scattering by size-shape
C distributions of randomly oriented axially symmetric
C particles of a size comparable to a wavelength,
C Appl. Opt., vol. 32, 4652-4666 (1993).
C
C 3. M. I. Mishchenko and L. D. Travis, T-matrix computations
C of light scattering by large spheroidal particles,
C Opt. Commun., vol. 109, 16-21 (1994).
C
C 4. M. I. Mishchenko, L. D. Travis, and A. Macke, Scattering
C of light by polydisperse, randomly oriented, finite
C circular cylinders, Appl. Opt., vol. 35, 4927-4940 (1996).
C
C 5. D. J. Wielaard, M. I. Mishchenko, A. Macke, and B. E. Carlson,
C Improved T-matrix computations for large, nonabsorbing and
C weakly absorbing nonspherical particles and comparison
C with geometrical optics approximation, Appl. Opt., vol. 36,
C 4305-4313 (1997).
C
C A general review of the T-matrix approach can be found in
C
C 6. M. I. Mishchenko, L. D. Travis, and D. W. Mackowski,
C T-matrix computations of light scattering by nonspherical
C particles: a review, J. Quant. Spectrosc. Radiat.
C Transfer, vol. 55, 535-575 (1996).
C
C The following paper provides a detailed user guide to the
C T-matrix code:
C
C 7. M. I. Mishchenko and L. D. Travis, Capabilities and
C limitations of a current FORTRAN implementation of the
C T-matrix method for randomly oriented, rotationally
C symmetric scatterers, J. Quant. Spectrosc. Radiat. Transfer,
C vol. 60, 309-324 (1998).
C
C These papers are available in the .pdf format at the web site
C
C http://www.giss.nasa.gov/~crmim/publications/
C
C or in hardcopy upon request from Michael Mishchenko
C Please e-mail your request to [email protected].
C
C A comprehensive book "Scattering, Absorption, and Emission of
C Light by Small Particles" (Cambridge University Press, Cambridge,
C 2002) is also available in the .pdf format at the web site
C
C http://www.giss.nasa.gov/~crmim/books.html
C Analytical averaging over particle orientations (Ref. 1) makes
C this method the fastest exact technique currently available.
C The use of an automatic convergence procedure
C (Ref. 2) makes the code convenient in massive computations.
C Ref. 4 describes features specific for finite cylinders as
C particles with sharp rectangular edges. Ref. 5 describes further
C numerical improvements.
C The use of extended precision variables (Ref. 3) can
C significantly increase the maximal convergent equivalent-sphere
C size parameter and make it greater than 200 (depending on
C refractive index and aspect ratio). The extended-precision code
C is also available. However, the use of extended precision varibales
C results in a greater consumption of CPU time.
C On IBM RISC workstations, that code is approximately
C five times slower than this double-precision code. The
C CPU time difference between the double-precision and extended-
C precision codes can be larger on supercomputers.
C This is the first part of the full T-matrix code. The second part,
C lpd.f, is completely independent of the firsti part. It contains no
C T-matrix-specific subroutines and can be compiled separately.
C The second part of the code replaces the previously implemented
C standard matrix inversion scheme based on Gaussian elimination
C by a scheme based on the LU factorization technique.
C As described in Ref. 5 above, the use of the LU factorization is
C especially beneficial for nonabsorbing or weakly absorbing particles.
C In this code we use the LAPACK implementation of the LU factorization
C scheme. LAPACK stands for Linear Algebra PACKage. The latter is
C publicly available at the following internet site:
C
C http://www.netlib.org/lapack/
C INPUT PARAMETERS:
C
C RAT = 1 - particle size is specified in terms of the
C equal-volume-sphere radius
C RAT.NE.1 - particle size is specified in terms of the
C equal-surface-area-sphere radius
C NDISTR specifies the distribution of equivalent-sphere radii
C NDISTR = 1 - modified gamma distribution
C [Eq. (40) of Ref. 7]
C AXI=alpha
C B=r_c
C GAM=gamma
C NDISTR = 2 - log-normal distribution
C [Eq. 41) of Ref. 7]
C AXI=r_g
C B=[ln(sigma_g)]**2
C NDISTR = 3 - power law distribution
C [Eq. (42) of Ref. 7]
C AXI=r_eff (effective radius)
C B=v_eff (effective variance)
C Parameters R1 and R2 (see below) are calculated
C automatically for given AXI and B
C NDISTR = 4 - gamma distribution
C [Eq. (39) of Ref. 7]
C AXI=a
C B=b
C NDISTR = 5 - modified power law distribution
C [Eq. (24) in M. I. Mishchenko et al.,
C Bidirectional reflectance of flat,
C optically thick particulate laters: an efficient radiative
C transfer solution and applications to snow and soil surfaces,
C J. Quant. Spectrosc. Radiat. Transfer, Vol. 63, 409-432 (1999)].
C B=alpha
C
C The code computes NPNAX size distributions of the same type
C and with the same values of B and GAM in one run.
C The parameter AXI varies from AXMAX to AXMAX/NPNAX in steps of
C AXMAX/NPNAX. To compute a single size distribution, use
C NPNAX=1 and AXMAX equal to AXI of this size distribution.
C
C R1 and R2 - minimum and maximum equivalent-sphere radii
C in the size distribution. They are calculated automatically
C for the power law distribution with given AXI and B
C but must be specified for other distributions
C after the lines
C
C DO 600 IAX=1,NPNAX
C AXI=AXMAX-DAX*DFLOAT(IAX-1)
C
C in the main program.
C For the modified power law distribution (NDISTR=5), the
C minimum radius is 0, R2 is the maximum radius,
C and R1 is the intermediate radius at which the
C n(r)=const dependence is replaced by the power law
C dependence.
C
C NKMAX.LE.988 is such that NKMAX+2 is the
C number of Gaussian quadrature points used in
C integrating over the size distribution for particles with
C AXI=AXMAX. For particles with AXI=AXMAX-AXMAX/NPNAX,
C AXMAX-2*AXMAX/NPNAX, etc. the number of Gaussian points
C linearly decreases.
C For the modified power law distribution, the number
C of integration points on the interval [0,R1] is also
C equal to NKMAX.
C
C LAM - wavelength of light
C MRR and MRI - real and imaginary parts of the refractive
C index (MRI.GE.0)
C EPS and NP - specify the shape of the particles.
C For spheroids NP=-1 and EPS is the ratio of the
C horizontal to rotational axes. EPS is larger than
C 1 for oblate spheroids and smaller than 1 for
C prolate spheroids.
C For cylinders NP=-2 and EPS is the ratio of the
C diameter to the length.
C For Chebyshev particles NP must be positive and
C is the degree of the Chebyshev polynomial, while
C EPS is the deformation parameter
C [Eq. (33) of Ref. 7].
C DDELT - accuracy of the computations
C NPNA - number of equidistant scattering angles (from 0
C to 180 deg) for which the scattering matrix is
C calculated.
C NDGS - parameter controlling the number of division points
C in computing integrals over the particle surface.
C For compact particles, the recommended value is 2.
C For highly aspherical particles larger values (3, 4,...)
C may be necessary to obtain convergence.
C The code does not check convergence over this parameter.
C Therefore, control comparisons of results obtained with
C different NDGS-values are recommended.
C OUTPUT PARAMETERS:
C
C REFF and VEFF - effective radius and effective variance of
C the size distribution as defined by Eqs. (43)-(45) of
C Ref. 7.
C CEXT - extinction cross section per particle
C CSCA - scattering cross section per particle
C W - single scattering albedo
C <cos> - asymmetry parameter of the phase function
C ALPHA1,...,BETA2 - coefficients appearing in the expansions
C of the elements of the scattering matrix in
C generalized spherical functions
C [Eqs. (11)-(16) of Ref. 7].
C F11,...,F44 - elements of the normalized scattering matrix [as
C defined by Eqs. (1)-(3) of Ref. 7] versus scattering angle
C Note that LAM, r_c, r_g, r_eff, a, R1, and R2 must
C be given in the same units of length, and that
C the dimension of CEXT and CSCA is that of LAM squared (e.g., if
C LAM and AXI are given in microns, then CEXT and CSCA are
C calculated in square microns).
C The physical correctness of the computed results is tested using
C the general inequalities derived by van der Mee and Hovenier,
C Astron. Astrophys., vol. 228, 559-568 (1990). Although
C the message that the test of van der Mee and Hovenier is satisfied
C does not guarantee that the results are absolutely correct,
C the message that the test is not satisfied can mean that something
C is wrong.
C The convergence of the T-matrix method for particles with
C different sizes, refractive indices, and aspect ratios can be
C dramatically different. Usually, large sizes and large aspect
C ratios cause problems. The user of this code
C should first experiment with different input parameters in
C order to get an idea of the range of applicability of this
C technique. Sometimes decreasing the aspect ratio
C from 3 to 2 can increase the maximum convergent equivalent-
C sphere size parameter by a factor of several (Ref. 7).
C The CPU time required rapidly increases with increasing ratio
C radius/wavelength and/or with increasing particle asphericity.
C This should be taken into account in planning massive computations.
C Using an optimizing compiler on IBM RISC workstations saves
C about 70% of CPU time.
C Execution can be automatically terminated if dimensions of certain
C arrays are not big enough or if the convergence procedure decides
C that the accuracy of double precision variables is insufficient
C to obtain a converged T-matrix solution for given particles.
C In all cases, a message appears explaining the cause of termination.
C The message
C "WARNING: W IS GREATER THAN 1"
C means that the single-scattering albedo exceeds the maximum
C possible value 1. If W is greater than 1 by more than
C DDELT, this message can be an indication of numerical
C instability caused by extreme values of particle parameters.
C The message "WARNING: NGAUSS=NPNG1" means that convergence over
C the parameter NG (see Ref. 2) cannot be obtained for the NPNG1
C value specified in the PARAMETER statement in the file tmd.par.f.
C Often this is not a serious problem, especially for compact
C particles.
C Larger and/or more aspherical particles may require larger
C values of the parameters NPN1, NPN4, and NPNG1 in the file
C tmd.par.f. It is recommended to keep NPN1=NPN4+25 and
C NPNG1=3*NPN1. Note that the memory requirement increases
C as the third power of NPN4. If the memory of
C a computer is too small to accomodate the code in its current
C setting, the parameters NPN1, NPN4, and NPNG1 should be
C decreased. However, this will decrease the maximum size parameter
C that can be handled by the code.
C In some cases any increases of NPN1 will not make the T-matrix
C computations convergent. This means that the particle is just
C too "bad" (extreme size parameter and/or extreme aspect ratio
C and/or extreme refractive index; see Ref. 7).
C The main program contains several PRINT statements which are
C currently commentd out. If uncommented, these statements will
C produce numbers which show the convergence rate and can be
C used to determine whether T-matrix computations for given particle
C parameters will converge at all.
C Some of the common blocks are used to save memory rather than
C to transfer data. Therefore, if a compiler produces a warning
C message that the lengths of a common block are different in
C different subroutines, this is not a real problem.
C The recommended value of DDELT is 0.001. For bigger values,
C false convergence can be obtained.
C In computations for spheres use EPS=1.000001 instead of EPS=1.
C The use of EPS=1 can cause overflows in some rare cases.
C To calculate a monodisperse particle, use the options
C NPNAX=1
C AXMAX=R
C B=1D-1
C NKMAX=-1
C NDISTR=4
C ...
C DO 600 IAX=1,NPNAX
C AXI=AXMAX-DAX*DFLOAT(IAX-1)
C R1=0.9999999*AXI
C R2=1.0000001*AXI
C ...
C where R is the equivalent-sphere radius.
C It is recommended to use the power law rather than the
C gamma size distribution, because in this case convergent solution
C can be obtained for larger REFF and VEFF assuming the same
C maximal R2 (Mishchenko and Travis, Appl. Opt., vol. 33, 7206-7225,
C 1994).
C For some compilers, DACOS must be raplaced by DARCOS and DASIN
C by DARSIN.
C If many different size distributions are computed and the
C refractive index is fixed, then another approach can be more
C efficient than running this code many times. Specifically,
C scattering results should be computed for monodisperse particles
C with sizes ranging from essentially zero to some maximum value
C with a small step size (say, 0.02 microns). These results
C should be stored on disk and can be used along with spline
C interpolation to compute scattering by particles with intermediate
C sizes. Scattering patterns for monodisperse nonspherical
C particles in random orientation are (much) smoother than for
C monodisperse spheres, and spline interpolation usually gives good
C results. In this way, averaging over any size distribution is a
C matter of seconds. For more on size averaging, see Refs. 2 and 4.
C We would highly appreciate informing me of any problems encountered
C with this code. Please send your message to the following
C e-mail address: [email protected].
C WHILE THE COMPUTER PROGRAM HAS BEEN TESTED FOR A VARIETY OF CASES,
C IT IS NOT INCONCEIVABLE THAT IT CONTAINS UNDETECTED ERRORS. ALSO,
C INPUT PARAMETERS CAN BE USED WHICH ARE OUTSIDE THE ENVELOPE OF
C VALUES FOR WHICH RESULTS ARE COMPUTED ACCURATELY. FOR THIS REASON,
C THE AUTHORS AND THEIR ORGANIZATION DISCLAIM ALL LIABILITY FOR
C ANY DAMAGES THAT MAY RESULT FROM THE USE OF THE PROGRAM.
IMPLICIT REAL*8 (A-H,O-Z)
INCLUDE 'tmd.par.f'
REAL*8 LAM,MRR,MRI,X(NPNG2),W(NPNG2),S(NPNG2),SS(NPNG2),
* AN(NPN1),R(NPNG2),DR(NPNG2),
* DDR(NPNG2),DRR(NPNG2),DRI(NPNG2),ANN(NPN1,NPN1)
REAL*8 XG(1000),WG(1000),TR1(NPN2,NPN2),TI1(NPN2,NPN2),
& ALPH1(NPL),ALPH2(NPL),ALPH3(NPL),ALPH4(NPL),BET1(NPL),
& BET2(NPL),XG1(2000),WG1(2000),
& AL1(NPL),AL2(NPL),AL3(NPL),AL4(NPL),BE1(NPL),BE2(NPL)
REAL*4
& RT11(NPN6,NPN4,NPN4),RT12(NPN6,NPN4,NPN4),
& RT21(NPN6,NPN4,NPN4),RT22(NPN6,NPN4,NPN4),
& IT11(NPN6,NPN4,NPN4),IT12(NPN6,NPN4,NPN4),
& IT21(NPN6,NPN4,NPN4),IT22(NPN6,NPN4,NPN4)
COMMON /CT/ TR1,TI1
COMMON /TMAT/ RT11,RT12,RT21,RT22,IT11,IT12,IT21,IT22
P=DACOS(-1D0)
C OPEN FILES *******************************************************
OPEN (6,FILE='test')
OPEN (10,FILE='tmatr.write')
C INPUT DATA ********************************************************
RAT=0.5 D0
NDISTR=3
AXMAX=1D0
NPNAX=2
B=0.1D0
GAM=0.5D0
NKMAX=5
EPS=2D0
NP=-1
LAM=0.5D0
MRR=1.53 d0
MRI=0.008D0
DDELT=0.001D0
NPNA=19
NDGS=2
NCHECK=0
IF (NP.EQ.-1.OR.NP.EQ.-2) NCHECK=1
IF (NP.GT.0.AND.(-1)**NP.EQ.1) NCHECK=1
WRITE (6,5454) NCHECK
5454 FORMAT ('NCHECK=',I1)
DAX=AXMAX/NPNAX
IF (DABS(RAT-1D0).GT.1D-8.AND.NP.EQ.-1) CALL SAREA (EPS,RAT)
if (DABS(RAT-1D0).GT.1D-8.AND.NP.GE.0) CALL SURFCH(NP,EPS,RAT)
IF (DABS(RAT-1D0).GT.1D-8.AND.NP.EQ.-2) CALL SAREAC (EPS,RAT)
C PRINT 8000, RAT
8000 FORMAT ('RAT=',F8.6)
IF(NP.EQ.-1.AND.EPS.GE.1D0) PRINT 7000,EPS
IF(NP.EQ.-1.AND.EPS.LT.1D0) PRINT 7001,EPS
IF(NP.GE.0) PRINT 7100,NP,EPS
IF(NP.EQ.-2.AND.EPS.GE.1D0) PRINT 7150,EPS
IF(NP.EQ.-2.AND.EPS.LT.1D0) PRINT 7151,EPS
PRINT 7400, LAM,MRR,MRI
PRINT 7200, DDELT
7000 FORMAT('RANDOMLY ORIENTED OBLATE SPHEROIDS, A/B=',F11.7)
7001 FORMAT('RANDOMLY ORIENTED PROLATE SPHEROIDS, A/B=',F11.7)
7100 FORMAT('RANDOMLY ORIENTED CHEBYSHEV PARTICLES, T',
& I1,'(',F5.2,')')
7150 FORMAT('RANDOMLY ORIENTED OBLATE CYLINDERS, D/L=',F11.7)
7151 FORMAT('RANDOMLY ORIENTED PROLATE CYLINDERS, D/L=',F11.7)
7200 FORMAT ('ACCURACY OF COMPUTATIONS DDELT = ',D8.2)
7400 FORMAT('LAM=',F10.6,3X,'MRR=',D10.4,3X,'MRI=',D10.4)
DDELT=0.1D0*DDELT
DO 600 IAX=1,NPNAX
AXI=AXMAX-DAX*DFLOAT(IAX-1)
R1=0.89031D0*AXI
R2=1.56538D0*AXI
NK=IDINT(AXI*NKMAX/AXMAX+2)
IF (NK.GT.1000) PRINT 8001,NK
IF (NK.GT.1000) STOP
IF (NDISTR.EQ.3) CALL POWER (AXI,B,R1,R2)
8001 FORMAT ('NK=',I4,' I.E., IS GREATER THAN 1000. ',
& 'EXECUTION TERMINATED.')
CALL GAUSS (NK,0,0,XG,WG)
Z1=(R2-R1)*0.5D0
Z2=(R1+R2)*0.5D0
Z3=R1*0.5D0
IF (NDISTR.EQ.5) GO TO 3
DO I=1,NK
XG1(I)=Z1*XG(I)+Z2
WG1(I)=WG(I)*Z1
ENDDO
GO TO 4
3 DO I=1,NK
XG1(I)=Z3*XG(I)+Z3
WG1(I)=WG(I)*Z3
ENDDO
DO I=NK+1,2*NK
II=I-NK
XG1(I)=Z1*XG(II)+Z2
WG1(I)=WG(II)*Z1
ENDDO
NK=NK*2
4 CALL DISTRB (NK,XG1,WG1,NDISTR,AXI,B,GAM,R1,R2,
& REFF,VEFF,P)
PRINT 8002,R1,R2
8002 FORMAT('R1=',F10.6,' R2=',F10.6)
IF (DABS(RAT-1D0).LE.1D-6) PRINT 8003, REFF,VEFF
IF (DABS(RAT-1D0).GT.1D-6) PRINT 8004, REFF,VEFF
8003 FORMAT('EQUAL-VOLUME-SPHERE REFF=',F8.4,' VEFF=',F7.4)
8004 FORMAT('EQUAL-SURFACE-AREA-SPHERE REFF=',F8.4,
& ' VEFF=',F7.4)
PRINT 7250,NK
7250 FORMAT('NUMBER OF GAUSSIAN QUADRATURE POINTS ',
& 'IN SIZE AVERAGING =',I4)
DO I=1,NPL
ALPH1(I)=0D0
ALPH2(I)=0D0
ALPH3(I)=0D0
ALPH4(I)=0D0
BET1(I)=0D0
BET2(I)=0D0
ENDDO
CSCAT=0D0
CEXTIN=0D0
L1MAX=0
DO 500 INK=1,NK
I=NK-INK+1
A=RAT*XG1(I)
XEV=2D0*P*A/LAM
IXXX=XEV+4.05D0*XEV**0.333333D0
INM1=MAX0(4,IXXX)
IF (INM1.GE.NPN1) PRINT 7333, NPN1
IF (INM1.GE.NPN1) STOP
7333 FORMAT('CONVERGENCE IS NOT OBTAINED FOR NPN1=',I3,
& '. EXECUTION TERMINATED')
QEXT1=0D0
QSCA1=0D0
DO 50 NMA=INM1,NPN1
NMAX=NMA
MMAX=1
NGAUSS=NMAX*NDGS
IF (NGAUSS.GT.NPNG1) PRINT 7340, NGAUSS
IF (NGAUSS.GT.NPNG1) STOP
7340 FORMAT('NGAUSS =',I3,' I.E. IS GREATER THAN NPNG1.',
& ' EXECUTION TERMINATED')
7334 FORMAT(' NMAX =', I3,' DC2=',D8.2,' DC1=',D8.2)
7335 FORMAT(' NMAX1 =', I3,' DC2=',D8.2,
& ' DC1=',D8.2)
CALL CONST(NGAUSS,NMAX,MMAX,P,X,W,AN,ANN,S,SS,NP,EPS)
CALL VARY(LAM,MRR,MRI,A,EPS,NP,NGAUSS,X,P,PPI,PIR,PII,R,
& DR,DDR,DRR,DRI,NMAX)
CALL TMATR0 (NGAUSS,X,W,AN,ANN,S,SS,PPI,PIR,PII,R,DR,
& DDR,DRR,DRI,NMAX,NCHECK)
QEXT=0D0
QSCA=0D0
DO N=1,NMAX
N1=N+NMAX
TR1NN=TR1(N,N)
TI1NN=TI1(N,N)
TR1NN1=TR1(N1,N1)
TI1NN1=TI1(N1,N1)
DN1=DFLOAT(2*N+1)
QSCA=QSCA+DN1*(TR1NN*TR1NN+TI1NN*TI1NN
& +TR1NN1*TR1NN1+TI1NN1*TI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I)
WGI=WGII*CSCA
DO 250 L1=1,L1M
ALPH1(L1)=ALPH1(L1)+AL1(L1)*WGI
ALPH2(L1)=ALPH2(L1)+AL2(L1)*WGI
ALPH3(L1)=ALPH3(L1)+AL3(L1)*WGI
ALPH4(L1)=ALPH4(L1)+AL4(L1)*WGI
BET1(L1)=BET1(L1)+BE1(L1)*WGI
BET2(L1)=BET2(L1)+BE2(L1)*WGI
250 CONTINUE
CSCAT=CSCAT+WGI
CEXTIN=CEXTIN+CEXT*WGII
C PRINT 6070, I,NMAX,NMAX1,NGAUSS
6070 FORMAT(4I6)
500 CONTINUE
DO 510 L1=1,L1MAX
ALPH1(L1)=ALPH1(L1)/CSCAT
ALPH2(L1)=ALPH2(L1)/CSCAT
ALPH3(L1)=ALPH3(L1)/CSCAT
ALPH4(L1)=ALPH4(L1)/CSCAT
BET1(L1)=BET1(L1)/CSCAT
BET2(L1)=BET2(L1)/CSCAT
510 CONTINUE
WALB=CSCAT/CEXTIN
CALL HOVENR(L1MAX,ALPH1,ALPH2,ALPH3,ALPH4,BET1,BET2)
ASYMM=ALPH1(2)/3D0
PRINT 9100,CEXTIN,CSCAT,WALB,ASYMM
9100 FORMAT('CEXT=',D12.6,2X,'CSCA=',D12.6,2X,
& 2X,'W=',D12.6,2X,'<COS>=',D12.6)
IF (WALB.GT.1D0) PRINT 9111
9111 FORMAT ('WARNING: W IS GREATER THAN 1')
WRITE (10,580) WALB,L1MAX
DO L=1,L1MAX
WRITE (10,575) ALPH1(L),ALPH2(L),ALPH3(L),ALPH4(L),
& BET1(L),BET2(L)
ENDDO
575 FORMAT(6D14.7)
580 FORMAT(D14.8,I8)
LMAX=L1MAX-1
CALL MATR (ALPH1,ALPH2,ALPH3,ALPH4,BET1,BET2,LMAX,NPNA)
600 CONTINUE
ITIME=MCLOCK()
TIME=DFLOAT(ITIME)/6000D0
PRINT 1001,TIME
1001 FORMAT (' time =',F8.2,' min')
STOP
END
C**********************************************************************
SUBROUTINE CONST (NGAUSS,NMAX,MMAX,P,X,W,AN,ANN,S,SS,NP,EPS)
IMPLICIT REAL*8 (A-H,O-Z)
INCLUDE 'tmd.par.f'
REAL*8 X(NPNG2),W(NPNG2),X1(NPNG1),W1(NPNG1),
* X2(NPNG1),W2(NPNG1),
* S(NPNG2),SS(NPNG2),
* AN(NPN1),ANN(NPN1,NPN1),DD(NPN1)
DO 10 N=1,NMAX
NN=N*(N+1)
AN(N)=DFLOAT(NN)
D=DSQRT(DFLOAT(2*N+1)/DFLOAT(NN))
DD(N)=D
DO 10 N1=1,N
DDD=D*DD(N1)*0.5D0
ANN(N,N1)=DDD
ANN(N1,N)=DDD
10 CONTINUE
NG=2*NGAUSS
IF (NP.EQ.-2) GO TO 11
CALL GAUSS(NG,0,0,X,W)
GO TO 19
11 NG1=DFLOAT(NGAUSS)/2D0
NG2=NGAUSS-NG1
XX=-DCOS(DATAN(EPS))
CALL GAUSS(NG1,0,0,X1,W1)
CALL GAUSS(NG2,0,0,X2,W2)
DO 12 I=1,NG1
W(I)=0.5D0*(XX+1D0)*W1(I)
X(I)=0.5D0*(XX+1D0)*X1(I)+0.5D0*(XX-1D0)
12 CONTINUE
DO 14 I=1,NG2
W(I+NG1)=-0.5D0*XX*W2(I)
X(I+NG1)=-0.5D0*XX*X2(I)+0.5D0*XX
14 CONTINUE
DO 16 I=1,NGAUSS
W(NG-I+1)=W(I)
X(NG-I+1)=-X(I)
16 CONTINUE
19 DO 20 I=1,NGAUSS
Y=X(I)
Y=1D0/(1D0-Y*Y)
SS(I)=Y
SS(NG-I+1)=Y
Y=DSQRT(Y)
S(I)=Y
S(NG-I+1)=Y
20 CONTINUE
RETURN
END
C**********************************************************************
SUBROUTINE VARY (LAM,MRR,MRI,A,EPS,NP,NGAUSS,X,P,PPI,PIR,PII,
* R,DR,DDR,DRR,DRI,NMAX)
INCLUDE 'tmd.par.f'
IMPLICIT REAL*8 (A-H,O-Z)
REAL*8 X(NPNG2),R(NPNG2),DR(NPNG2),MRR,MRI,LAM,
* Z(NPNG2),ZR(NPNG2),ZI(NPNG2),
* J(NPNG2,NPN1),Y(NPNG2,NPN1),JR(NPNG2,NPN1),
* JI(NPNG2,NPN1),DJ(NPNG2,NPN1),
* DJR(NPNG2,NPN1),DJI(NPNG2,NPN1),DDR(NPNG2),
* DRR(NPNG2),DRI(NPNG2),
* DY(NPNG2,NPN1)
COMMON /CBESS/ J,Y,JR,JI,DJ,DY,DJR,DJI
NG=NGAUSS*2
IF (NP.EQ.-1) CALL RSP1(X,NG,NGAUSS,A,EPS,NP,R,DR)
IF (NP.GE.0) CALL RSP2(X,NG,A,EPS,NP,R,DR)
IF (NP.EQ.-2) CALL RSP3(X,NG,NGAUSS,A,EPS,R,DR)
PI=P*2D0/LAM
PPI=PI*PI
PIR=PPI*MRR
PII=PPI*MRI
V=1D0/(MRR*MRR+MRI*MRI)
PRR=MRR*V
PRI=-MRI*V
TA=0D0
DO 10 I=1,NG
VV=DSQRT(R(I))
V=VV*PI
TA=MAX(TA,V)
VV=1D0/V
DDR(I)=VV
DRR(I)=PRR*VV
DRI(I)=PRI*VV
V1=V*MRR
V2=V*MRI
Z(I)=V
ZR(I)=V1
ZI(I)=V2
10 CONTINUE
IF (NMAX.GT.NPN1) PRINT 9000,NMAX,NPN1
IF (NMAX.GT.NPN1) STOP
9000 FORMAT(' NMAX = ',I2,', i.e., greater than ',I3)
TB=TA*DSQRT(MRR*MRR+MRI*MRI)
TB=DMAX1(TB,DFLOAT(NMAX))
NNMAX1=1.2D0*DSQRT(DMAX1(TA,DFLOAT(NMAX)))+3D0
NNMAX2=(TB+4D0*(TB**0.33333D0)+1.2D0*DSQRT(TB))
NNMAX2=NNMAX2-NMAX+5
CALL BESS(Z,ZR,ZI,NG,NMAX,NNMAX1,NNMAX2)
RETURN
END
C**********************************************************************
SUBROUTINE RSP1 (X,NG,NGAUSS,REV,EPS,NP,R,DR)
IMPLICIT REAL*8 (A-H,O-Z)
REAL*8 X(NG),R(NG),DR(NG)
A=REV*EPS**(1D0/3D0)
AA=A*A
EE=EPS*EPS
EE1=EE-1D0
DO 50 I=1,NGAUSS
C=X(I)
CC=C*C
SS=1D0-CC
S=DSQRT(SS)
RR=1D0/(SS+EE*CC)
R(I)=AA*RR
R(NG-I+1)=R(I)
DR(I)=RR*C*S*EE1
DR(NG-I+1)=-DR(I)
50 CONTINUE
RETURN
END