1 | subroutine ave_stelspec(STELLAR) |
---|
2 | |
---|
3 | !================================================================== |
---|
4 | ! |
---|
5 | ! Purpose |
---|
6 | ! ------- |
---|
7 | ! Average the chosen high resolution stellar spectrum over the |
---|
8 | ! visible bands in the model. |
---|
9 | ! |
---|
10 | ! Authors |
---|
11 | ! ------- |
---|
12 | ! Robin Wordsworth (2010). |
---|
13 | ! Generalized to very late spectral types (and Brown dwarfs) Jeremy Leconte (2012) |
---|
14 | ! |
---|
15 | ! Called by |
---|
16 | ! --------- |
---|
17 | ! setspv.F |
---|
18 | ! |
---|
19 | ! Calls |
---|
20 | ! ----- |
---|
21 | ! none |
---|
22 | ! |
---|
23 | !================================================================== |
---|
24 | |
---|
25 | use radinc_h, only: L_NSPECTV |
---|
26 | use radcommon_h, only: BWNV, DWNV, tstellar |
---|
27 | use datafile_mod, only: datadir |
---|
28 | |
---|
29 | implicit none |
---|
30 | |
---|
31 | #include "callkeys.h" |
---|
32 | |
---|
33 | real*8 STELLAR(L_NSPECTV) |
---|
34 | ! integer startype |
---|
35 | |
---|
36 | integer Nfine |
---|
37 | integer,parameter :: Nfineband=200 |
---|
38 | integer ifine |
---|
39 | |
---|
40 | real,allocatable :: lam(:),stel_f(:) |
---|
41 | real band,lamm,lamp |
---|
42 | real dl |
---|
43 | |
---|
44 | character(len=100) :: file_id,file_id_lam |
---|
45 | character(len=200) :: file_path,file_path_lam |
---|
46 | |
---|
47 | real lam_temp |
---|
48 | double precision stel_temp |
---|
49 | |
---|
50 | integer :: ios ! file opening/reading status |
---|
51 | |
---|
52 | STELLAR(:)=0.0 |
---|
53 | |
---|
54 | print*,'enter ave_stellspec' |
---|
55 | if(stelbbody)then |
---|
56 | tstellar=stelTbb |
---|
57 | Nfine=L_NSPECTV*Nfineband |
---|
58 | do band=1,L_NSPECTV |
---|
59 | lamm=10000.0/BWNV(band+1) |
---|
60 | lamp=10000.0/BWNV(band) |
---|
61 | dl=(lamp-lamm)/(Nfineband) |
---|
62 | do ifine=1,Nfineband |
---|
63 | lam_temp=lamm+(lamp-lamm)*(ifine-1.)/(Nfineband) |
---|
64 | call blackl(dble(lam_temp*1e-6),dble(tstellar),stel_temp) |
---|
65 | STELLAR(band)=STELLAR(band)+stel_temp*dl |
---|
66 | enddo |
---|
67 | end do |
---|
68 | STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV)) |
---|
69 | else |
---|
70 | ! load high resolution stellar data |
---|
71 | Select Case(startype) |
---|
72 | Case(1) |
---|
73 | file_id='/stellar_spectra/sol.txt' |
---|
74 | tstellar=5800. |
---|
75 | file_id_lam='/stellar_spectra/lam.txt' |
---|
76 | Nfine=5000 |
---|
77 | Case(2) |
---|
78 | file_id='/stellar_spectra/gl581.txt' |
---|
79 | tstellar=3200. |
---|
80 | file_id_lam='/stellar_spectra/lam.txt' |
---|
81 | Nfine=5000 |
---|
82 | Case(3) |
---|
83 | file_id='/stellar_spectra/adleo.txt' |
---|
84 | tstellar=3200. |
---|
85 | file_id_lam='/stellar_spectra/lam.txt' |
---|
86 | Nfine=5000 |
---|
87 | Case(4) |
---|
88 | file_id='/stellar_spectra/gj644.txt' |
---|
89 | print*,'Find out tstellar before using this star!' |
---|
90 | call abort |
---|
91 | file_id_lam='/stellar_spectra/lam.txt' |
---|
92 | Nfine=5000 |
---|
93 | Case(5) |
---|
94 | file_id='/stellar_spectra/hd128167.txt' |
---|
95 | tstellar=6700. ! Segura et al. (2003) |
---|
96 | file_id_lam='/stellar_spectra/lam.txt' |
---|
97 | Nfine=5000 |
---|
98 | Case(6) |
---|
99 | file_id='/stellar_spectra/BD_Teff-1600K.txt' |
---|
100 | tstellar=1600. |
---|
101 | file_id_lam='/stellar_spectra/lamBD.txt' |
---|
102 | Nfine=5000 |
---|
103 | Case(7) |
---|
104 | file_id='/stellar_spectra/BD_Teff-1000K.txt' |
---|
105 | tstellar=1000. |
---|
106 | file_id_lam='/stellar_spectra/lamBD.txt' |
---|
107 | Nfine=5000 |
---|
108 | Case(8) |
---|
109 | file_id='/stellar_spectra/Flux_K5_Teff4700_logg4.5_Met-0.5_BTsettle.dat' |
---|
110 | tstellar=4700. |
---|
111 | file_id_lam='/stellar_spectra/lambda_K5_Teff4700_logg4.5_Met-0.5_BTsettle.dat' |
---|
112 | Nfine=3986 |
---|
113 | Case Default |
---|
114 | print*,'Error: unknown star type chosen' |
---|
115 | call abort |
---|
116 | End Select |
---|
117 | |
---|
118 | allocate(lam(Nfine),stel_f(Nfine)) |
---|
119 | |
---|
120 | file_path_lam=TRIM(datadir)//TRIM(file_id_lam) |
---|
121 | open(110,file=file_path_lam,form='formatted',status='old',iostat=ios) |
---|
122 | if (ios.ne.0) then ! file not found |
---|
123 | write(*,*) 'Error from ave_stelspec' |
---|
124 | write(*,*) 'Data file ',trim(file_id_lam),' not found.' |
---|
125 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
126 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
127 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
128 | write(*,*)' Also check that there is a ',trim(file_id_lam),' there.' |
---|
129 | call abort |
---|
130 | else |
---|
131 | do ifine=1,Nfine |
---|
132 | read(110,*) lam(ifine) |
---|
133 | enddo |
---|
134 | close(110) |
---|
135 | endif |
---|
136 | |
---|
137 | |
---|
138 | ! load high resolution wavenumber data |
---|
139 | file_path=TRIM(datadir)//TRIM(file_id) |
---|
140 | open(111,file=file_path,form='formatted',status='old',iostat=ios) |
---|
141 | if (ios.ne.0) then ! file not found |
---|
142 | write(*,*) 'Error from ave_stelspec' |
---|
143 | write(*,*) 'Data file ',trim(file_id),' not found.' |
---|
144 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
145 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
146 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
147 | write(*,*)' Also check that there is a ',trim(file_id),' there.' |
---|
148 | call abort |
---|
149 | else |
---|
150 | do ifine=1,Nfine |
---|
151 | read(111,*) stel_f(ifine) |
---|
152 | enddo |
---|
153 | close(111) |
---|
154 | endif |
---|
155 | |
---|
156 | ! sum data by band |
---|
157 | band=1 |
---|
158 | Do while(lam(1).lt. real(10000.0/BWNV(band+1))) |
---|
159 | if (band.gt.L_NSPECTV-1) exit |
---|
160 | band=band+1 |
---|
161 | enddo |
---|
162 | dl=lam(2)-lam(1) |
---|
163 | STELLAR(band)=STELLAR(band)+stel_f(1)*dl |
---|
164 | do ifine = 2,Nfine |
---|
165 | if(lam(ifine) .gt. real(10000.0/BWNV(band)))then |
---|
166 | band=band-1 |
---|
167 | endif |
---|
168 | if(band .lt. 1) exit |
---|
169 | dl=lam(ifine)-lam(ifine-1) |
---|
170 | STELLAR(band)=STELLAR(band)+stel_f(ifine)*dl |
---|
171 | end do |
---|
172 | |
---|
173 | |
---|
174 | STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV)) |
---|
175 | deallocate(lam,stel_f) |
---|
176 | |
---|
177 | endif |
---|
178 | |
---|
179 | end subroutine ave_stelspec |
---|