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 | use callkeys_mod, only: stelbbody,stelTbb,startype |
---|
29 | |
---|
30 | implicit none |
---|
31 | |
---|
32 | real*8 STELLAR(L_NSPECTV) |
---|
33 | ! integer startype |
---|
34 | |
---|
35 | integer Nfine |
---|
36 | integer,parameter :: Nfineband=200 |
---|
37 | integer ifine,band |
---|
38 | |
---|
39 | real,allocatable,save :: lam(:),stel_f(:) !read by master |
---|
40 | real lamm,lamp |
---|
41 | real dl |
---|
42 | |
---|
43 | character(len=100) :: file_id,file_id_lam |
---|
44 | character(len=200) :: file_path,file_path_lam |
---|
45 | |
---|
46 | real lam_temp |
---|
47 | double precision stel_temp |
---|
48 | |
---|
49 | integer :: ios ! file opening/reading status |
---|
50 | |
---|
51 | STELLAR(:)=0.0 |
---|
52 | |
---|
53 | print*,'enter ave_stellspec' |
---|
54 | if(stelbbody)then |
---|
55 | tstellar=stelTbb |
---|
56 | Nfine=L_NSPECTV*Nfineband |
---|
57 | do band=1,L_NSPECTV |
---|
58 | lamm=10000.0/BWNV(band+1) |
---|
59 | lamp=10000.0/BWNV(band) |
---|
60 | dl=(lamp-lamm)/(Nfineband) |
---|
61 | do ifine=1,Nfineband |
---|
62 | lam_temp=lamm+(lamp-lamm)*(ifine-1.)/(Nfineband) |
---|
63 | call blackl(dble(lam_temp*1e-6),dble(tstellar),stel_temp) |
---|
64 | STELLAR(band)=STELLAR(band)+stel_temp*dl |
---|
65 | enddo |
---|
66 | end do |
---|
67 | STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV)) |
---|
68 | else |
---|
69 | ! load high resolution stellar data |
---|
70 | Select Case(startype) |
---|
71 | Case(1) |
---|
72 | file_id='/stellar_spectra/sol.txt' |
---|
73 | tstellar=5800. |
---|
74 | file_id_lam='/stellar_spectra/lam.txt' |
---|
75 | Nfine=5000 |
---|
76 | Case(2) |
---|
77 | file_id='/stellar_spectra/gl581.txt' |
---|
78 | tstellar=3200. |
---|
79 | file_id_lam='/stellar_spectra/lam.txt' |
---|
80 | Nfine=5000 |
---|
81 | Case(3) |
---|
82 | file_id='/stellar_spectra/adleo.txt' |
---|
83 | tstellar=3200. |
---|
84 | file_id_lam='/stellar_spectra/lam.txt' |
---|
85 | Nfine=5000 |
---|
86 | Case(4) |
---|
87 | file_id='/stellar_spectra/gj644.txt' |
---|
88 | print*,'Find out tstellar before using this star!' |
---|
89 | call abort |
---|
90 | file_id_lam='/stellar_spectra/lam.txt' |
---|
91 | Nfine=5000 |
---|
92 | Case(5) |
---|
93 | file_id='/stellar_spectra/hd128167.txt' |
---|
94 | tstellar=6700. ! Segura et al. (2003) |
---|
95 | file_id_lam='/stellar_spectra/lam.txt' |
---|
96 | Nfine=5000 |
---|
97 | Case(6) |
---|
98 | file_id='/stellar_spectra/BD_Teff-1600K.txt' |
---|
99 | tstellar=1600. |
---|
100 | file_id_lam='/stellar_spectra/lamBD.txt' |
---|
101 | Nfine=5000 |
---|
102 | Case(7) |
---|
103 | file_id='/stellar_spectra/BD_Teff-1000K.txt' |
---|
104 | tstellar=1000. |
---|
105 | file_id_lam='/stellar_spectra/lamBD.txt' |
---|
106 | Nfine=5000 |
---|
107 | Case(8) |
---|
108 | file_id='/stellar_spectra/Flux_K5_Teff4700_logg4.5_Met-0.5_BTsettle.dat' |
---|
109 | tstellar=4700. |
---|
110 | file_id_lam='/stellar_spectra/lambda_K5_Teff4700_logg4.5_Met-0.5_BTsettle.dat' |
---|
111 | Nfine=3986 |
---|
112 | Case(9) |
---|
113 | file_id='/stellar_spectra/Flux_M7_Teff2550_logg3.0_Met-0.0.dat' |
---|
114 | tstellar=2550. |
---|
115 | file_id_lam='/stellar_spectra/lambda_M7_Teff2550_logg3.0_Met-0.0.dat' |
---|
116 | Nfine=5000 |
---|
117 | Case Default |
---|
118 | print*,'Error: unknown star type chosen' |
---|
119 | call abort |
---|
120 | End Select |
---|
121 | |
---|
122 | !$OMP MASTER |
---|
123 | allocate(lam(Nfine),stel_f(Nfine)) |
---|
124 | |
---|
125 | file_path_lam=TRIM(datadir)//TRIM(file_id_lam) |
---|
126 | open(110,file=file_path_lam,form='formatted',status='old',iostat=ios) |
---|
127 | if (ios.ne.0) then ! file not found |
---|
128 | write(*,*) 'Error from ave_stelspec' |
---|
129 | write(*,*) 'Data file ',trim(file_id_lam),' not found.' |
---|
130 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
131 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
132 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
133 | write(*,*)' Also check that there is a ',trim(file_id_lam),' there.' |
---|
134 | call abort |
---|
135 | else |
---|
136 | do ifine=1,Nfine |
---|
137 | read(110,*) lam(ifine) |
---|
138 | enddo |
---|
139 | close(110) |
---|
140 | endif |
---|
141 | |
---|
142 | |
---|
143 | ! load high resolution wavenumber data |
---|
144 | file_path=TRIM(datadir)//TRIM(file_id) |
---|
145 | open(111,file=file_path,form='formatted',status='old',iostat=ios) |
---|
146 | if (ios.ne.0) then ! file not found |
---|
147 | write(*,*) 'Error from ave_stelspec' |
---|
148 | write(*,*) 'Data file ',trim(file_id),' not found.' |
---|
149 | write(*,*)'Check that your path to datagcm:',trim(datadir) |
---|
150 | write(*,*)' is correct. You can change it in callphys.def with:' |
---|
151 | write(*,*)' datadir = /absolute/path/to/datagcm' |
---|
152 | write(*,*)' Also check that there is a ',trim(file_id),' there.' |
---|
153 | call abort |
---|
154 | else |
---|
155 | do ifine=1,Nfine |
---|
156 | read(111,*) stel_f(ifine) |
---|
157 | enddo |
---|
158 | close(111) |
---|
159 | endif |
---|
160 | !$OMP END MASTER |
---|
161 | !$OMP BARRIER |
---|
162 | |
---|
163 | ! sum data by band |
---|
164 | band=1 |
---|
165 | Do while(lam(1).lt. real(10000.0/BWNV(band+1))) |
---|
166 | if (band.gt.L_NSPECTV-1) exit |
---|
167 | band=band+1 |
---|
168 | enddo |
---|
169 | dl=lam(2)-lam(1) |
---|
170 | STELLAR(band)=STELLAR(band)+stel_f(1)*dl |
---|
171 | do ifine = 2,Nfine |
---|
172 | if(lam(ifine) .gt. real(10000.0/BWNV(band)))then |
---|
173 | band=band-1 |
---|
174 | endif |
---|
175 | if(band .lt. 1) exit |
---|
176 | dl=lam(ifine)-lam(ifine-1) |
---|
177 | STELLAR(band)=STELLAR(band)+stel_f(ifine)*dl |
---|
178 | end do |
---|
179 | |
---|
180 | |
---|
181 | STELLAR(1:L_NSPECTV)=STELLAR(1:L_NSPECTV)/sum(STELLAR(1:L_NSPECTV)) |
---|
182 | !$OMP BARRIER |
---|
183 | !$OMP MASTER |
---|
184 | if (allocated(lam)) deallocate(lam) |
---|
185 | if (allocated(stel_f)) deallocate(stel_f) |
---|
186 | !$OMP END MASTER |
---|
187 | !$OMP BARRIER |
---|
188 | endif |
---|
189 | |
---|
190 | end subroutine ave_stelspec |
---|