-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIGMA.f90
2161 lines (1908 loc) · 70.5 KB
/
SIGMA.f90
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
module Tools
IMPLICIT NONE
! "kind PARAMETER" for DOuble precision
INTEGER, PUBLIC, PARAMETER :: dp = SELECTED_REAL_KIND(P=15)
REAL (KIND=dp), PUBLIC, PARAMETER :: pi = 3.1415926535897932384_dp
REAL (KIND=dp), PUBLIC, PARAMETER :: clight = 2.99792458e14_dp ! Celerity of light c (micron s-1)
REAL (KIND=dp), PUBLIC, PARAMETER :: N_Avo = 6.0221e23_dp ! Avogadro constant
LOGICAL, PUBLIC :: verbose
LOGICAL, PUBLIC :: geom
REAL (KIND=dp) :: a0 ! monomer size
REAL (KIND=dp) :: Df ! monomer size
LOGICAL, PUBLIC :: crt
LOGICAL, PUBLIC :: hyperion
REAL (KIND=dp), ALLOCATABLE :: lam(:) ! wavelength
INTEGER :: nlam ! nr of wavelengths
CHARACTER (len=500) :: data_path='/Users/lefevre/DUST/SIGMA/DATA/'!!!!! TO_BE_CHANGED
! ------------------------------------------------------------------------
! Mueller matrix to be filled, others are equal to zero
! ------------------------------------------------------------------------
TYPE MUELLER
REAL (KIND=dp) :: F11(180) ! Mueller coefficients related to phase function
REAL (KIND=dp) :: F12(180) ! Mueller coefficients
REAL (KIND=dp) :: F22(180) ! Mueller coefficients
REAL (KIND=dp) :: F33(180) ! Mueller coefficients
REAL (KIND=dp) :: F44(180) ! Mueller coefficients
REAL (KIND=dp) :: F34(180) ! Mueller coefficients
end type MUELLER
! ------------------------------------------------------------------------
! Output variables
! ------------------------------------------------------------------------
TYPE PARTICLE
REAL (KIND=dp) :: rv ! radius
REAL (KIND=dp) :: rvmin ! minimum radius
REAL (KIND=dp) :: rvmax ! maximal radius
REAL (KIND=dp) :: rho ! mass density in g.cm^-3
REAL (KIND=dp) :: mass ! mass density in g
REAL (KIND=dp), ALLOCATABLE :: Kabs(:) ! absorption coefficient
REAL (KIND=dp), ALLOCATABLE :: Ksca(:) ! scattering coefficient
REAL (KIND=dp), ALLOCATABLE :: Kext(:) ! extinction coefficient
REAL (KIND=dp), ALLOCATABLE :: qabs_size(:,:) ! individual qabs by size
REAL (KIND=dp), ALLOCATABLE :: qsca_size(:,:) ! individual qsca by size
REAL (KIND=dp), ALLOCATABLE :: r_size(:) ! individual sizes
REAL (KIND=dp), ALLOCATABLE :: g(:) ! asymmetry parameter Henyey Greenstein
REAL (KIND=dp), ALLOCATABLE :: pol(:) ! average polarisation
TYPE(MUELLER), ALLOCATABLE :: F(:)
END TYPE PARTICLE
end module Tools
program SIGMA
use Tools
IMPLICIT NONE
REAL (KIND=dp) :: lam1 ! minimum wavelength
REAL (KIND=dp) :: lam2 ! maximum wavelength
CHARACTER (len=500) :: particlefile ! name of output
CHARACTER (len=500) :: inputfile ! name of output
INTEGER :: na ! nr of sizes for size distribution
REAL (KIND=dp) :: apow ! power law index
REAL (KIND=dp) :: fmax ! maximum fraction of vaccum for DHS
REAL (KIND=dp) :: porosity ! porosity = 1 - filling_factor
INTEGER :: nm ! nr of grain material in a composite grain
INTEGER :: n_add ! nr of grain material to be added
INTEGER :: n_mix ! nr of grain material to be mixed
REAL (KIND=dp) :: V_ices ! volume fraction of ices
TYPE(PARTICLE) :: p
INTEGER :: i, j
INTEGER :: ilam
INTEGER :: nlines
INTEGER :: count_mix
INTEGER :: count_add
CHARACTER (len=100) :: tmp
CHARACTER (len=100) :: value
INTEGER, ALLOCATABLE :: number(:) ! number associated to a component
CHARACTER*500, ALLOCATABLE :: dust_type(:) ! type of component
CHARACTER*500, ALLOCATABLE :: ref_index(:)
CHARACTER*3, ALLOCATABLE :: rule(:)
CHARACTER*500, ALLOCATABLE :: sizedis(:)
REAL (KIND=dp), ALLOCATABLE :: vfrac(:) ! volume fraction of each component
REAL (KIND=dp), ALLOCATABLE :: m_dust(:)
REAL (KIND=dp), ALLOCATABLE :: a_min(:) ! minimum size
REAL (KIND=dp), ALLOCATABLE :: a_max(:) ! maximum size
CHARACTER (len=500), ALLOCATABLE :: dust_type_mix(:)
CHARACTER (len=500), ALLOCATABLE :: ref_index_mix(:)
CHARACTER (len=500), ALLOCATABLE :: sizedistrib_mix(:)
REAL (KIND=dp), ALLOCATABLE :: vfrac_mix(:)
REAL (KIND=dp), ALLOCATABLE :: a_min_mix(:) ! minimum size
REAL (KIND=dp), ALLOCATABLE :: a_max_mix(:) ! maximum size
CHARACTER (len=500), ALLOCATABLE :: dust_type_add(:)
CHARACTER (len=500), ALLOCATABLE :: ref_index_add(:)
CHARACTER (len=500), ALLOCATABLE :: sizedistrib_add(:)
REAL (KIND=dp), ALLOCATABLE :: vfrac_add(:)
REAL (KIND=dp), ALLOCATABLE :: a_min_add(:) ! minimum size
REAL (KIND=dp), ALLOCATABLE :: a_max_add(:) ! maximum size
REAL (KIND=dp), ALLOCATABLE :: Kabs_tot(:) ! absorption coefficient
REAL (KIND=dp), ALLOCATABLE :: Ksca_tot(:) ! scattering coefficient
REAL (KIND=dp), ALLOCATABLE :: Kext_tot(:) ! extinction coefficient
REAL (KIND=dp), ALLOCATABLE :: g_tot(:)
REAL (KIND=dp) :: Mtot
REAL (KIND=dp) :: lambda_ref ! reference wavelength for extinction normalisation
! ------------------------------------------------------------------------
! Default parameters - may be updated by users - to be moved to an external file?
! ------------------------------------------------------------------------
verbose = .false.
geom = .false.
a0 = 0.2_dp !default value for Min et al.2016
Df = 3.0_dp !default value for Min et al.2016
crt = .true.
hyperion = .true.
apow = 3.50_dp
fmax = 0.0_dp
porosity = 0.0_dp
V_ices = 0.0_dp !by default no ice mantles
na = 50
nlam = 1000
lam1 = 0.05_dp
lam2 = 1000.0_dp
nm = 3 !by default mixture of silicates, carbonaceous and iron sulfide
n_add = 0
n_mix = 0
particlefile = "opacities"
inputfile = ""
lambda_ref = 2.20 !by default K band is used
! ------------------------------------------------------------------------
! Input parameters
! ------------------------------------------------------------------------
CALL getarg(1,tmp)
i = 1
DO while(tmp.ne.' ')
select CASE(tmp)
CASE('-apow')
i = i+1
CALL getarg(i,value)
READ(value,*) apow
CASE('-nm')
i = i+1
CALL getarg(i,value)
READ(value,*) nm
CASE('-na')
i = i+1
CALL getarg(i,value)
READ(value,*) na
CASE('-lmin')
i = i+1
CALL getarg(i,value)
READ(value,*) lam1
CASE('-lmax')
i = i+1
CALL getarg(i,value)
READ(value,*) lam2
CASE('-nlam')
i = i+1
CALL getarg(i,value)
READ(value,*) nlam
CASE('-porosity')
i = i+1
CALL getarg(i,value)
READ(value,*) porosity
CASE('-fmax')
i = i+1
CALL getarg(i,value)
READ(value,*) fmax
CASE('-lambda_ref')
i = i+1
CALL getarg(i,value)
READ(value,*) lambda_ref
CASE('-file','-ofile')
i = i+1
CALL getarg(i,particlefile)
CASE('-ifile')
i = i+1
CALL getarg(i,inputfile)
CASE('-lref')
i = i+1
CALL getarg(i,value)
READ(value,*) lambda_ref
CASE('-df')
i = i+1
CALL getarg(i,value)
READ(value,*) Df
CASE('-a0')
i = i+1
CALL getarg(i,value)
READ(value,*) a0
CASE('-v','-verbose')
verbose = .true.
CASE('-geom')
geom = .true.
CASE('--help','-help','help')
WRITE(*,'(" ")')
WRITE(*,'(" SIGMA FEB-19 HELP ")')
WRITE(*,'(" AVAILABLE OPTIONS ARE THE FOLLOWING: ")')
WRITE(*,'(" ")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" Dust Composition:")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" -nm = number of dust components apart from vacuum")')
WRITE(*,'("")')
WRITE(*,'(" Set according to DATA/input/COMPO.dat")')
WRITE(*,'(" or DATA/input/COMPO_ifile.dat if -ifile is defined")')
WRITE(*,'(" Examples of composition are provided in DATA/input folder")')
WRITE(*,'("")')
WRITE(*,'(" The different components could be mixed or added")')
WRITE(*,'(" Individual components refractive index tables are located in DATA in the following subdirectories:")')
WRITE(*,'(" * carbonaceous")')
WRITE(*,'(" * silicates")')
WRITE(*,'(" * iron")')
WRITE(*,'(" * iron_sulfides")')
WRITE(*,'(" * iron")')
WRITE(*,'(" * ices")')
WRITE(*,'("")')
WRITE(*,'(" !!!! WARNING: FOR THE TIME BEING ICES MUST BE DEFINED AS THE LAST COMPONENT in DATA/input/COMPO.dat !!!!")')
WRITE(*,'("")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" Size distribution:")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" Set individually for each component according to DATA/input/COMPO.dat")')
WRITE(*,'(" Should be identical for mixture (mix) while it could be different for added opacities (add)")')
WRITE(*,'(" Either power law (plaw) or custom size distribution can be used:")')
WRITE(*,'(" Custom size distribution are taken from DATA/sizedistrib folder")')
WRITE(*,'(" Filename without extension should be provided in DATA/input/COMPO.dat")')
WRITE(*,'(" File content is a(microns), n(a)*a, porosity(see below)")')
WRITE(*,'("")')
WRITE(*,'(" Other parameters:")')
WRITE(*,'(" -apow = will be used only if power law")')
WRITE(*,'(" -na = number of bin sizes")')
WRITE(*,'("")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" Dust Shape:")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" -fmax = volume fraction of vacuum for hollow spheres (DHS)")')
WRITE(*,'(" -porosity = constant porosity if plaw or if -1 is set in size distribution file")')
WRITE(*,'(" Otherwise porosity can be defined as a function of size in size distribution file.")')
WRITE(*,'("")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" Other parameters:")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" -lmin = lambda min")')
WRITE(*,'(" -lmax = lambda max")')
WRITE(*,'(" -nlam = number of wavelength bins")')
WRITE(*,'(" -lambda_ref = wavelength in micron to normalize extinction, by default 2.2")')
WRITE(*,'(" -file or -ofile = output filename, by default opacities")')
WRITE(*,'(" -ifile = input filename: DATA/input/COMPO_ifile.dat will be used as composition file")')
WRITE(*,'(" -v = verbose")')
WRITE(*,'("")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" Default parameters :")')
WRITE(*,'(" ========================================================")')
WRITE(*,'("")')
WRITE(*,'(" You may find default parameters inside the code itself (in SIGMA.f90).")')
WRITE(*,'(" You can update them to your needs in particular the following ones:")')
WRITE(*,'("")')
WRITE(*,'(" verbose = .false.")')
WRITE(*,'(" crt = .true.")')
WRITE(*,'(" hyperion = .true.")')
WRITE(*,'("")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" Outputs:")')
WRITE(*,'(" ========================================================")')
WRITE(*,'(" By default output files are written in output folder.")')
WRITE(*,'(" They will be overwritten if a different filename is not given as an argument.")')
WRITE(*,'("")')
WRITE(*,'(" SIGMA provides the following outputs:")')
WRITE(*,'("")')
WRITE(*,'(" * filename.dat = ASCII file that contains main outputs:")')
WRITE(*,'(" lambda[micron] Kabs[cm^2/g] Ksca[cm^2/g] Kext[cm^2/g] albedo asymmetry_parameter linear_pol")')
WRITE(*,'("")')
WRITE(*,'(" * Kext_opacities.dat = extinction normalized by default by K band")')
WRITE(*,'("")')
WRITE(*,'(" OUTPUT RELATED TO SPECIFIC RADIATIVE TRANSFER CODES:")')
WRITE(*,'("")')
WRITE(*,'(" 1) CRT (Juvela et al.):")')
WRITE(*,'(" * CRT_opacities.nH2.dust")')
WRITE(*,'(" * CRT_DSC_opacities.dat")')
WRITE(*,'("")')
WRITE(*,'(" 2) HYPERION (Robitaille et al.):")')
WRITE(*,'(" * HYPERION_set_filename.py")')
WRITE(*,'(" Contains the full parameters needed to build hdf5 dust model that can be directly used by HYPERION")')
WRITE(*,'(" It includes computation of Rosseland and Planck mean extinctions")')
STOP
CASE default
WRITE(*,'("Option not recognized! SIGMA -help to list all available options.")')
STOP
end select
i = i+1
CALL getarg(i,tmp)
ENDDO
IF (verbose) THEN
WRITE(*,'("========================================================")')
WRITE(*,'("Running SIGMA to compute dust opacities")')
WRITE(*,'("Copyright (c) 2018, C. Lefèvre, IRAM")')
WRITE(*,'("E-mail: lefevre@iram.fr")')
WRITE(*,'("License: one can freely use, modify, or redistribute all parts of the code")')
WRITE(*,'("SIGMA is a commented and modified version of the DIANA Opacity code (P. Woitke, St Andrews)")')
WRITE(*,'("========================================================")')
WRITE(*,'(" Parameters:")')
WRITE(*,'(" apow = ",f14.4)') apow
WRITE(*,'(" na = ",i14)') na
WRITE(*,'("========================================================")')
ENDIF
ALLOCATE (lam(nlam))
ALLOCATE (p%Kabs(nlam))
ALLOCATE (p%Kext(nlam))
ALLOCATE (p%Ksca(nlam))
ALLOCATE (p%qsca_size(nlam,na))
ALLOCATE (p%qabs_size(nlam,na))
ALLOCATE (p%r_size(na))
ALLOCATE (p%g(nlam))
ALLOCATE (p%F(nlam))
ALLOCATE (p%pol(nlam))
ALLOCATE (Kabs_tot(nlam))
ALLOCATE (Kext_tot(nlam))
ALLOCATE (Ksca_tot(nlam))
ALLOCATE (g_tot(nlam))
DO i = 1,nlam
lam(i)=10.0_dp**(log10(lam1)+log10(lam2/lam1)*(i-1)/(nlam-1))
ENDDO
IF(verbose) WRITE(*,'("========================================================")')
ALLOCATE (number(nm))
ALLOCATE (dust_type(nm))
ALLOCATE (ref_index(nm))
ALLOCATE (sizedis(nm))
ALLOCATE (vfrac(nm))
ALLOCATE (m_dust(nm))
ALLOCATE (rule(nm))
ALLOCATE (a_min(nm))
ALLOCATE (a_max(nm))
CALL READ_COMPO(nm,number,dust_type,ref_index,vfrac,rule,sizedis,m_dust,a_min,a_max,inputfile)
!Check number of bin sizes:
nlines = 0
IF (trim(sizedis(1)).NE."plaw") THEN
OPEN (1, file = "DATA/sizedistrib/"//trim(sizedis(1))//".dat")
DO
READ (1,*, END=119)
nlines = nlines + 1
END DO
119 CLOSE (1)
IF (na.NE.nlines) THEN
write(*,'("ERROR: ",i4," size bins found in DATA/sizedistrib/",a,".dat")') nlines, trim(sizedis(1))
write(*,'("You should run SIGMA with -na ",i4)') nlines
stop
ENDIF
ENDIF
DO i=1,nm
IF (trim(rule(i)).EQ."add") THEN
n_add = n_add+1
ELSE IF (trim(rule(i)).EQ."mix") THEN
n_mix = n_mix+1
ENDIF
END DO
ALLOCATE (dust_type_mix(n_mix))
ALLOCATE (ref_index_mix(n_mix))
ALLOCATE (vfrac_mix(n_mix))
ALLOCATE (sizedistrib_mix(n_mix))
ALLOCATE (a_min_mix(n_mix))
ALLOCATE (a_max_mix(n_mix))
ALLOCATE (dust_type_add(n_add))
ALLOCATE (ref_index_add(n_add))
ALLOCATE (vfrac_add(n_add))
ALLOCATE (sizedistrib_add(n_add))
ALLOCATE (a_min_add(n_add))
ALLOCATE (a_max_add(n_add))
count_mix = 0
count_add = 0
DO i = 1, (n_add+n_mix)
IF (trim(rule(i)).EQ."mix") THEN
count_mix = count_mix+1
dust_type_mix(count_mix) = trim(dust_type(i))
ref_index_mix(count_mix) = trim(ref_index(i))
vfrac_mix(count_mix) = vfrac(i)
sizedistrib_mix(count_mix) = trim(sizedis(i))
a_min_mix(count_mix) = a_min(i)
a_max_mix(count_mix) = a_max(i)
ELSE
count_add = count_add+1
dust_type_add(count_add) = trim(dust_type(i))
ref_index_add(count_add) = trim(ref_index(i))
vfrac_add(count_add) = vfrac(i)
sizedistrib_add(count_add) = trim(sizedis(i))
a_min_add(count_add) = a_min(i)
a_max_add(count_add) = a_max(i)
ENDIF
ENDDO
!Safety check - for mixture the same size distribution need to be used
DO i=1,n_mix
IF (trim(sizedistrib_mix(i)).NE.trim(sizedistrib_mix(1))) THEN
write(*,*) "ERROR The same size distribution needs to be defined for mixture (mix option, sizedistrib in DATA/input/COMPO.dat)."
stop
ENDIF
IF (a_min_mix(i).NE.a_min_mix(1)) THEN
write(*,*) "ERROR The same minimum size needs to be defined for mixture (mix option, amin in DATA/input/COMPO.dat)."
stop
ENDIF
IF (a_max_mix(i).NE.a_max_mix(1)) THEN
write(*,*) "ERROR The same maximum size needs to be defined for mixture (mix option, amax in DATA/input/COMPO.dat)."
stop
ENDIF
IF (m_dust(i).NE.m_dust(1).AND.trim(rule(1)).EQ."mix") THEN
write(*,*) "ERROR The same Mdust/(100*MH) needs to be defined for mixture in DATA/input/COMPO.dat (mix option)"
stop
ENDIF
END DO
Kabs_tot = 0.0_dp
Ksca_tot = 0.0_dp
Kext_tot = 0.0_dp
g_tot = 0.0_dp
IF (n_mix.GT.0) THEN
nm = n_mix
CALL ComputePart(p,a_min_mix(1),a_max_mix(1),apow,fmax,vfrac_mix, porosity,na,&
& nm,dust_type_mix,ref_index_mix,sizedistrib_mix(1))
Kabs_tot = 0.0_dp
Ksca_tot = 0.0_dp
Kext_tot = 0.0_dp
g_tot = 0.0_dp
DO ilam = 1,nlam
Kabs_tot(ilam) = Kabs_tot(ilam)+p%Kabs(ilam)*m_dust(1)
Ksca_tot(ilam) = Ksca_tot(ilam)+p%Ksca(ilam)*m_dust(1)
Kext_tot(ilam) = Kext_tot(ilam)+p%Kext(ilam)*m_dust(1)
g_tot(ilam) = g_tot(ilam)+p%g(ilam)*p%Ksca(ilam)*m_dust(1)
ENDDO
ENDIF
IF (n_add.GT.0) THEN
! commented on 27-may-2020 to give the possibility to have both mix and add
! in one single composition file
! Kabs_tot = 0.0_dp
! Ksca_tot = 0.0_dp
! Kext_tot = 0.0_dp
! g_tot = 0.0_dp
nm = 1
DO i = 1,n_add
CALL ComputePart(p,a_min_add(i),a_max_add(i),apow,fmax,vfrac_add(i), porosity,na,&
& nm,dust_type_add(i),ref_index_add(i),sizedistrib_add(i))
DO ilam = 1,nlam
Kabs_tot(ilam) = Kabs_tot(ilam)+p%Kabs(ilam)*vfrac_add(i)*m_dust(i)
Ksca_tot(ilam) = Ksca_tot(ilam)+p%Ksca(ilam)*vfrac_add(i)*m_dust(i)
Kext_tot(ilam) = Kext_tot(ilam)+p%Kext(ilam)*vfrac_add(i)*m_dust(i)
g_tot(ilam) = g_tot(ilam)+p%g(ilam)*p%Ksca(ilam)*vfrac_add(i)*m_dust(i)
ENDDO
ENDDO
ENDIF
DO ilam = 1,nlam
g_tot(ilam) = g_tot(ilam)/Ksca_tot(ilam)
ENDDO
CALL WriteOutput(particlefile,nlam,na,Kabs_tot,Ksca_tot,Kext_tot,g_tot,p, lambda_ref)
IF (verbose) WRITE(*,'("========================================================")')
IF (verbose) WRITE(*,'("Done! Have a nice day.")')
IF (verbose) WRITE(*,'("========================================================")')
end
SUBROUTINE WriteOutput (particlefile,nwav,ns,Kabs_tot,Ksca_tot,Kext_tot,g_tot,p,aref)
use Tools
IMPLICIT NONE
TYPE(PARTICLE) :: p
CHARACTER (len=500) :: particlefile ! name of output
CHARACTER (len=500) :: tablefile ! name of output
CHARACTER (len=500) :: ddsfile ! name of output for debris disks simulator (dds)
CHARACTER (len=500) :: crtfile ! name of output for CRT
CHARACTER (len=500) :: dscfile ! name of output for DSC file for CRT
CHARACTER (len=500) :: extinctfile ! name of output for normalized extinction
CHARACTER (len=500) :: phasefunctionfile ! name of output
CHARACTER (len=500) :: lineardegpolfile ! name of output
CHARACTER (len=500) :: hyperionfile ! name of output for hyperion python file
CHARACTER (len=500) :: dust_hyperionfile ! name of output for hyperion dust file
INTEGER :: nwav
INTEGER :: ns
INTEGER :: i, ilam, k
REAL (KIND=dp) :: Kabs_tot(nwav)
REAL (KIND=dp) :: Ksca_tot(nwav)
REAL (KIND=dp) :: Kext_tot(nwav)
REAL (KIND=dp) :: g_tot(nwav)
LOGICAL :: truefalse
REAL (KIND=dp) :: aref
REAL (KIND=dp) :: Kext_ref
tablefile = "output/" // trim(particlefile) // ".dat"
ddsfile = "output/dds_"// trim(particlefile) // ".dat"
crtfile = "output/CRT_" // trim(particlefile) // ".nH2.dust"
dscfile = "output/CRT_DSC_"// trim(particlefile) // ".dat"
hyperionfile = "output/HYPERION_set_"//trim(particlefile)//".py"
extinctfile = "output/Kext_"// trim(particlefile) // ".dat"
phasefunctionfile = "output/PF_"// trim(particlefile) // ".dat"
lineardegpolfile = "output/LDP_"// trim(particlefile) // ".dat"
dust_hyperionfile = "output/" // trim(particlefile)
IF(verbose) THEN
WRITE(*,'("Cross sections output to ascii table: ",a)') trim(tablefile)
IF(crt) WRITE(*,'("Optical properties output to ascii file for CRT: ",a)') trim(crtfile)
IF(crt) WRITE(*,'("Full scattring matrix output to ascii file for CRT: ",a)') trim(dscfile)
IF(hyperion) WRITE(*,'("Python program to set dust properties for HYPERION: ",a)') trim(hyperionfile)
ENDIF
! Output file as ascii file
inquire(file=tablefile,exist=truefalse)
if(truefalse) then
OPEN(unit=20,file=tablefile)
IF(verbose) write(*,'("Output file ",a," already exists, overwriting")') trim(tablefile)
CLOSE(unit=20,status='delete')
endif
OPEN(unit=20,file=tablefile,RECL=100000)
write(20,'("#====================================================================#")')
write(20,'("# Cross sections computed using SIGMA")')
write(20,'("#=====================================================================================#")')
write(20,'("# lambda[micron] Kabs[cm^2/g] Ksca[cm^2/g] Kext[cm^2/g] albedo asymmetry_parameter linear_pol")')
write(20,'("#=====================================================================================#")')
do ilam=1,nwav
write(20,*) lam(ilam),Kabs_tot(ilam),Ksca_tot(ilam), Kext_tot(ilam), Ksca_tot(ilam)/Kext_tot(ilam), g_tot(ilam), p%pol(ilam)
enddo
CLOSE(unit=20)
inquire(file=ddsfile,exist=truefalse)
if(truefalse) then
OPEN(unit=25,file=ddsfile)
IF(verbose) write(*,'("Output file ",a," already exists, overwriting")') trim(ddsfile)
CLOSE(unit=25,status='delete')
endif
OPEN(unit=25,file=ddsfile,RECL=100000)
write(25,FMT='(a)') "#-------------------------------------------------------------------/"
write(25,FMT='(a)') "# Tabulated dust properties: Q_abs, Q_sca, Q_ext, Albedo"
write(25,FMT='(a)') "# as a function of wavelength for different dust grain radii"
write(25,FMT='(a)') "#"
write(25,FMT='(a)') "# ===> Please respect file formatting. Insert *no* comment lines!"
write(25,FMT='(a)') "#-------------------------------------------------------------------/"
write(25,FMT='(a,i4,a)') " ", ns, " # Number of different dust grain radii"
write(25,FMT='(a,i4,a)') " ", nwav, " # Number of wavelengths tabulated for each grain radius"
write(25,FMT='(a)') "#List of dust grain radii [micron], sorted monotonically"
do k=1,ns
write(25,FMT='(D15.3)') p%r_size(k)
enddo
write(25,FMT='(a)') "# List of wavelengths [micron], sorted monotonically"
do ilam=1,nwav
write(25,FMT='(D15.3)') lam(ilam)
enddo
do k=1,ns
write(25,FMT='(a,D15.3,a)') "# Dust grain radius = ",p%r_size(k)," micron"
write(25,FMT='(a)') "# Q_abs Q_sca Q_ext albedo"
write(25,FMT='(a)') "#"
do ilam=1,nwav
write(25,*) p%qabs_size(ilam,k),p%qsca_size(ilam,k), p%qabs_size(ilam,k)+p%qsca_size(ilam,k), &
& p%qsca_size(ilam,k)/(p%qabs_size(ilam,k)+p%qsca_size(ilam,k))
enddo
enddo
CLOSE(unit=25)
! Output files needed to set CRT dust model (Juvela et al.)
inquire(file=crtfile,exist=truefalse)
if(truefalse.and.crt) then
OPEN(unit=30,file=crtfile)
IF(verbose) write(*,'("Output file ",a," already exists, overwriting")') trim(crtfile)
CLOSE(unit=30,status='delete')
endif
IF(crt) THEN
OPEN(unit=30,file=crtfile,RECL=100000)
!*****Header's*****
WRITE(UNIT=30,FMT='(a)') "eqdust" ! keyword in CRT dust file could be eqdust or simple
WRITE(UNIT=30,FMT='(E10.3)') 2.0e-7_dp ! N(H2) weighted by respective abundance of each type of grain compare to other types
WRITE(UNIT=30,FMT='(E10.3)') 1.0e-4_dp !CRT file need an arbitrary local size (a)
WRITE(UNIT=30,FMT='(i4)') nwav ! number of frequencies
WRITE(UNIT=30,FMT='(a)') "#"
!*****Header's end*****
do ilam=nwav,1,-1
write(UNIT=30,FMT='(E15.3)',advance='no') clight/lam(ilam)
write(UNIT=30,FMT='(E15.3)',advance='no') g_tot(ilam)
write(UNIT=30,FMT='(E15.3)',advance='no') Kabs_tot(ilam)/(pi*1e-15_dp*N_Avo*100)
write(UNIT=30,FMT='(E15.3)') Ksca_tot(ilam)/(pi*1e-15_dp*N_Avo*100)
enddo
CLOSE(unit=30)
ENDIF
IF(crt) THEN
inquire(file=dscfile,exist=truefalse)
if(truefalse.and.crt) then
OPEN(unit=40,file=dscfile)
IF(verbose) write(*,'("Output file ",a," already exists, overwriting")') trim(dscfile)
CLOSE(unit=40,status='delete')
endif
OPEN(unit=40,file=dscfile,RECL=100000)
!*****Header's*****
write(40,'(I4)') nwav+1 !first colum is dedicated to angle number
!*****Header's end*****
write(40,'(I4)',advance='no') -999
DO ilam = 1,nwav-1
write(40,'(E15.7)',advance="no") clight/lam(ilam)
END DO
write(40,'(E15.7)') clight/lam(nwav)
write(40,'(I4)',advance='no') -999
DO ilam = 1,nwav-1
write(40,'(E15.7)',advance="no") g_tot(ilam) !dummy values not used by CRT
END DO
write(40,'(E15.7)') g_tot(nwav)
! DO ilam = 1,nwav
! write(40,'(E15.7)',advance="no") 0.0_dp
! END DO
DO i = 1, 180
write(40,'(I3)',advance="no") i
DO ilam = 1,nwav-1
write(40,'(E15.7)',advance="no") p%F(ilam)%F11(i)
END DO
write(40,'(E15.7)') p%F(nwav)%F11(i)
END DO
CLOSE(unit=40)
ENDIF
IF (hyperion) then
! Output files needed to set hyperion dust model (Robitaille et al.)
inquire(file=hyperionfile,exist=truefalse)
if(truefalse.and.hyperion) then
OPEN(unit=45,file=hyperionfile)
IF(verbose) write(*,'("Output file ",a," already exists, overwriting")') trim(hyperionfile)
CLOSE(unit=45,status='delete')
endif
OPEN(unit=45,file=hyperionfile,RECL=10000000)
WRITE(UNIT=45,FMT='(a)') "import os"
WRITE(UNIT=45,FMT='(a)') "from hyperion.dust import SphericalDust"
WRITE(UNIT=45,FMT='(a)') "from numpy import *"
WRITE(UNIT=45,FMT='(a)') "d = SphericalDust()"
!***** frequencies *****
write(45,FMT='(a)',advance="no") "d.optical_properties.nu = ["
DO ilam = nwav,2,-1
write(45,'(E15.7)',advance="no") clight/lam(ilam)
write(45,FMT='(a)',advance="no") ","
END DO
write(45,'(E15.7)',advance="no") clight/lam(1)
write(45,'(a)') "]"
!***** albedo *****
write(45,FMT='(a)',advance="no") "d.optical_properties.albedo = ["
DO ilam = nwav,2,-1
write(45,'(E15.7)',advance="no") Ksca_tot(ilam)/Kext_tot(ilam)
write(45,FMT='(a)',advance="no") ","
END DO
write(45,'(E15.7)',advance="no") Ksca_tot(ilam)/Kext_tot(1)
write(45,'(a)') "]"
!***** extinction *****
write(45,FMT='(a)',advance="no") "d.optical_properties.chi = ["
DO ilam = nwav,2,-1
write(45,'(E15.7)',advance="no") Kext_tot(ilam)
write(45,FMT='(a)',advance="no") ","
END DO
write(45,'(E15.7)',advance="no") Kext_tot(1)
write(45,'(a)') "]"
!***** scattering angle *****
write(45,FMT='(a)',advance="no") "d.optical_properties.mu = ["
DO i = 180, 2, -1
write(45,FMT='(a)',advance="no") "cos("
write(45,'(I3)',advance="no") i
write(45,FMT='(a)',advance="no") "*pi/180.)"
write(45,FMT='(a)',advance="no") ","
END DO
write(45,FMT='(a)',advance="no") "cos(1*pi/180.)"
write(45,'(a)') "]"
!***** scattering matrix *****
!convention of Code & Whitney (1995):
! P1 (equivalent to S11), P2 (equivalent to S12), P3 (equivalent to S44), and P4 (equivalent to -S34).
!Each of these variables should be specified as a 2-d array with dimensions (n_nu, n_mu),
!where n_nu is the number of frequencies, and n_mu is the number of values of the cosine of the scattering angle
write(45,FMT='(a)') "d.optical_properties.initialize_scattering_matrix()"
DO i = 180, 2, -1
write(45,FMT='(a)',advance="no") "d.optical_properties.P1[:,"
write(45,'(I3)',advance="no") i-1
write(45,FMT='(a)',advance="no") "] = ["
DO ilam = nwav,2,-1
write(45,'(E15.7)',advance="no") p%F(ilam)%F11(i)
write(45,FMT='(a)',advance="no") ","
END DO
write(45,'(E15.7)') p%F(1)%F11(i)
write(45,'(a)') "]"
END DO
DO i = 180, 2, -1
write(45,FMT='(a)',advance="no") "d.optical_properties.P2[:,"
write(45,'(I3)',advance="no") i-1
write(45,FMT='(a)',advance="no") "] = ["
DO ilam = nwav,2,-1
write(45,'(E15.7)',advance="no") p%F(ilam)%F12(i)
write(45,FMT='(a)',advance="no") ","
END DO
write(45,'(E15.7)') p%F(1)%F12(i)
write(45,'(a)') "]"
END DO
DO i = 180, 2, -1
write(45,FMT='(a)',advance="no") "d.optical_properties.P3[:,"
write(45,'(I3)',advance="no") i-1
write(45,FMT='(a)',advance="no") "] = ["
DO ilam = nwav,2,-1
write(45,'(E15.7)',advance="no") p%F(ilam)%F44(i)
write(45,FMT='(a)',advance="no") ","
END DO
write(45,'(E15.7)') p%F(1)%F44(i)
write(45,'(a)') "]"
END DO
DO i = 180, 2, -1
write(45,FMT='(a)',advance="no") "d.optical_properties.P4[:,"
write(45,'(I3)',advance="no") i-1
write(45,FMT='(a)',advance="no") "] = ["
DO ilam = nwav,2,-1
write(45,'(E15.7)',advance="no") -p%F(ilam)%F34(i)
write(45,FMT='(a)',advance="no") ","
END DO
write(45,'(E15.7)') p%F(1)%F34(i)
write(45,'(a)') "]"
END DO
!***** set emissivities to compute Rosseland and Planck *****
! extrapolation needed:
! the frequency range should extend almost three orders of magnitude above the peak frequency for the coldest temperature
! and one order of magnitude below the peak frequency for the hottest temperature.
write(45,'(a)') "d.optical_properties.extrapolate_nu(1.e1, 1.e20)"
write(45,'(a)') "d.set_lte_emissivities(n_temp=1000,temp_min=10,temp_max=100000.)"
!***** set hdf5 dust model *****
write(45,'(a)') "d.write('"//trim(dust_hyperionfile)//".hdf5')"
!***** plot dust model *****
write(45,'(a)') "d.plot('"//trim(dust_hyperionfile)//".png')"
write(45,'(a)') "os.system('csh make_rosseland.csh "//trim(dust_hyperionfile)//"')"
CLOSE(unit=45)
ENDIF
inquire(file=extinctfile,exist=truefalse)
if(truefalse) then
OPEN(unit=50,file=extinctfile)
IF(verbose) write(*,'("Output file ",a," already exists, overwriting")') trim(extinctfile)
CLOSE(unit=50,status='delete')
endif
DO i=1,nwav
IF (lam(i)>aref-0.05_dp.and.lam(i)<aref+0.05_dp) then
Kext_ref = Kext_tot(i)
exit
ENDIF
ENDDO
Kext_tot = Kext_tot/Kext_ref
OPEN(unit=50,file=extinctfile,RECL=100000)
do ilam=1,nwav
write(50,*) lam(ilam),Kext_tot(ilam)
enddo
CLOSE(unit=50)
OPEN(unit=60,file=phasefunctionfile,RECL=100000)
IF(verbose) write(*,'("Output file ",a," already exists, overwriting")') trim(phasefunctionfile)
DO ilam = 1,nwav-1
write(60,'(E15.7)',advance="no") lam(ilam)
ENDDO
write(60,'(E15.7)') lam(nwav)
DO i = 1, 180
write(60,'(I3)',advance="no") i
DO ilam = 1,nwav-1
write(60,'(E15.7)',advance="no") p%F(ilam)%F11(i)
END DO
write(60,'(E15.7)') p%F(nwav)%F11(i)
END DO
CLOSE(unit=60)
END
!-----------------------------------------------------------------------
!-----------------------------------------------------------------------
SUBROUTINE READ_COMPO(ndust,number,type,refr_index,vtype,rule,sizedis,mdust,amin,amax,ifile)
use Tools
IMPLICIT NONE
INTEGER :: ndust
INTEGER :: nlines
INTEGER :: i
INTEGER :: number(ndust) ! number associated to a component
CHARACTER*500 :: type(ndust) ! type of component
CHARACTER*500 :: refr_index(ndust)
INTEGER :: sd_type(ndust)
CHARACTER*3 :: rule(ndust)
REAL (KIND=dp) :: vtype(ndust) ! volume fraction of each component
REAL (KIND=dp) :: mdust(ndust)
CHARACTER*500 :: sizedis(ndust)
CHARACTER*500 :: ifile
CHARACTER(len = :), allocatable :: ifile_trim
REAL (KIND=dp) :: amin(ndust)
REAL (KIND=dp) :: amax(ndust)
ifile_trim = trim(ifile)
!Check that nm is correct:
nlines = 0
if(ifile_trim.NE."") THEN
OPEN (1, file = "DATA/input/COMPO_"//trim(ifile)//".dat")
ELSE
OPEN (1, file = "DATA/input/COMPO.dat")
endif
DO
READ (1,*, END=109)
nlines = nlines + 1
END DO
109 CLOSE (1)
nlines = nlines - 2 !subtraction of command lines
IF (ndust.NE.nlines) THEN
write(*,'("ERROR: ",i2," components found in file = DATA/input/COMPO_",a,".dat")') nlines,ifile_trim
write(*,'("You should run SIGMA with -nm ",i2)') nlines
stop
ENDIF
if(ifile_trim.NE."") THEN
OPEN (99, file = "DATA/input/COMPO_"//trim(ifile)//".dat")
if(verbose) write(*,*) "Composition taken from: DATA/input/COMPO_"//trim(ifile)//".dat"
ELSE
OPEN (99, file = "DATA/input/COMPO.dat")
if(verbose) write(*,*) "Composition taken from: DATA/input/COMPO.dat"
endif
read (99, fmt=* )
read (99, fmt=* )
do i=3, ndust+2
read (99, fmt=* ) number(i-2), type(i-2), refr_index(i-2), vtype(i-2), rule(i-2), sizedis(i-2), mdust(i-2), amin(i-2), amax(i-2)
end do
CLOSE(99)
END
SUBROUTINE tellertje(i,n)
use Tools
IMPLICIT NONE
INTEGER :: i,n,f
IF(i.EQ.1.AND.verbose) WRITE(*,'("....................")')
f=int(20.0_dp*dble(i)/dble(n))
IF(20.0_dp*real(i-1)/real(n).LT.real(f) &
& .and.20.0_dp*real(i+1)/real(n).GT.real(f).and.verbose) then
WRITE(*,'(".",$)')
CALL flush(6)
ENDIF
IF(i.EQ.n.and.verbose) WRITE(*,*)
return
end
SUBROUTINE ComputePart(p,amin,amax,apow,fmax,vfrac,porosity,nsubgrains,nm,d_type,ref_ind,sizedistrib)
use Tools
IMPLICIT NONE
INTEGER :: na ! nr of sizes for size distribution
REAL (KIND=dp) :: amin ! minimum size
REAL (KIND=dp) :: amax ! maximum size
REAL (KIND=dp) :: apow ! power law index
CHARACTER*500 :: sizedistrib ! IF 0 power law - ELSE READ from file(s)
REAL (KIND=dp) :: fmax ! maximum fraction of vaccum for DHS
REAL (KIND=dp) :: porosity ! porosity = 1 - filling_factor
INTEGER :: nm ! nr of grain material in a composite grain
REAL (KIND=dp) :: vfrac(nm)
CHARACTER*500 :: d_type(nm) ! type of component
CHARACTER*500 :: ref_ind(nm)
REAL (KIND=dp) :: V_ices ! volume fraction of ices
TYPE (PARTICLE) :: p
INTEGER :: ii, i, j, k, l
INTEGER :: MAXMAT ! maximum number of grain material
INTEGER, PARAMETER :: n_ang = 180 ! number of angles
INTEGER :: iopac
INTEGER :: nsubgrains
INTEGER :: nlines
INTEGER :: nf
INTEGER :: ns
INTEGER :: nmono
INTEGER :: ilam
INTEGER :: i_ice
INTEGER :: Err
INTEGER :: spheres
INTEGER :: toolarge
INTEGER :: READ_option
REAL (KIND=dp) :: cext
REAL (KIND=dp) :: csca
REAL (KIND=dp) :: cabs
REAL (KIND=dp) :: ksca_bis
REAL (KIND=dp) :: kabs_bis
REAL (KIND=dp) :: kabs_G
REAL (KIND=dp) :: G
REAL (KIND=dp) :: cabs_RGD
REAL (KIND=dp) :: cabs_mono
REAL (KIND=dp) :: cemie_mono
REAL (KIND=dp) :: csmie_mono
REAL (KIND=dp) :: QEXT
REAL (KIND=dp) :: QSCA
REAL (KIND=dp) :: QABS
REAL (KIND=dp) :: GQSC
REAL (KIND=dp) :: totA
REAL (KIND=dp), ALLOCATABLE :: f11(:,:)
REAL (KIND=dp), ALLOCATABLE :: f12(:,:)
REAL (KIND=dp), ALLOCATABLE :: f22(:,:)
REAL (KIND=dp), ALLOCATABLE :: f33(:,:)
REAL (KIND=dp), ALLOCATABLE :: f34(:,:)
REAL (KIND=dp), ALLOCATABLE :: f44(:,:)
REAL (KIND=dp), ALLOCATABLE :: Mief11(:)
REAL (KIND=dp), ALLOCATABLE :: Mief12(:)
REAL (KIND=dp), ALLOCATABLE :: Mief22(:)
REAL (KIND=dp), ALLOCATABLE :: Mief33(:)
REAL (KIND=dp), ALLOCATABLE :: Mief34(:)
REAL (KIND=dp), ALLOCATABLE :: Mief44(:)
REAL (KIND=dp), ALLOCATABLE :: mu(:)
REAL (KIND=dp), ALLOCATABLE :: M1(:,:)
REAL (KIND=dp), ALLOCATABLE :: M2(:,:)
REAL (KIND=dp), ALLOCATABLE :: S21(:,:)
REAL (KIND=dp), ALLOCATABLE :: D21(:,:)
REAL (KIND=dp), ALLOCATABLE :: r(:)
REAL (KIND=dp), ALLOCATABLE :: nr(:,:)
REAL (KIND=dp), ALLOCATABLE :: pr(:)
REAL (KIND=dp), ALLOCATABLE :: f(:)
REAL (KIND=dp), ALLOCATABLE :: wf(:)
REAL (KIND=dp), ALLOCATABLE :: rho(:)
REAL (KIND=dp), ALLOCATABLE :: rho_k(:)
REAL (KIND=dp), ALLOCATABLE :: rho_k_no_ice(:)
REAL (KIND=dp) :: rmie
REAL (KIND=dp) :: lmie
REAL (KIND=dp) :: e1mie
REAL (KIND=dp) :: e2mie
REAL (KIND=dp) :: csmie
REAL (KIND=dp) :: cemie
REAL (KIND=dp) :: KR
REAL (KIND=dp) :: theta
REAL (KIND=dp) :: dummy
REAL (KIND=dp) :: maxf
REAL (KIND=dp) :: lambda
REAL (KIND=dp) :: lmin
REAL (KIND=dp) :: lmax
REAL (KIND=dp) :: minlog
REAL (KIND=dp) :: maxlog
REAL (KIND=dp) :: rad
REAL (KIND=dp) :: r1
REAL (KIND=dp) :: r2
REAL (KIND=dp) :: tot, tot2
REAL (KIND=dp) :: pow
REAL (KIND=dp) :: Mass
REAL (KIND=dp) :: Mass_noice
REAL (KIND=dp) :: Mass2
REAL (KIND=dp) :: Vol
REAL (KIND=dp) :: rho_av
REAL (KIND=dp) :: rho_av_no_ice
REAL (KIND=dp) :: rho_av_no_por
REAL (KIND=dp) :: rho_av_no_por_no_ice
REAL (KIND=dp) :: rho_ice
REAL (KIND=dp) :: rcore
REAL (KIND=dp) :: wvno
REAL (KIND=dp) :: scale
!Effective refractive index
REAL (KIND=dp) :: e1blend
REAL (KIND=dp) :: e2blend
REAL (KIND=dp) :: e1blend_ice
REAL (KIND=dp) :: e2blend_ice
REAL (KIND=dp) :: e1av