MPI-AMRVAC 3.2
The MPI - Adaptive Mesh Refinement - Versatile Advection Code (development version)
Loading...
Searching...
No Matches
mod_thermal_emission.t
Go to the documentation of this file.
1! module mod_thermal_emission -- synthesize emission flux of some
2! thermal lines
3! EUV lines database:
4! 'He_II_304' 'Fe_IX_171' 'Fe_XXIV_193' 'Fe_XIV_211' 'Fe_XVI_335'
5! 'Fe_XVIII_94' 'Fe_XXI_131'
6! subroutines:
7! get_EUV: get local EUV emission intensity (for 1d, 2d and 3d)
8! get_SXR: get local Soft X-ray emission intensity (for 1d, 2d and 3d)
9
12 use mod_geometry
13 use mod_physics
14 use mod_comm_lib, only: mpistop
15
16 implicit none
17
18 integer :: n_aia
19 double precision :: t_aia(1:101)
20 double precision :: f_94(1:101),f_131(1:101),f_171(1:101)
21 double precision :: f_193(1:101),f_211(1:101),f_304(1:101)
22 double precision :: f_335(1:101)
23 integer :: n_iris
24 double precision :: t_iris(1:41)
25 double precision :: f_1354(1:41)
26 integer :: n_eis
27 double precision :: t_eis1(1:60),t_eis2(1:60)
28 double precision :: f_263(1:60),f_264(1:60),f_192(1:60),f_255(1:60)
29
30
31 double precision :: vec_xi1(1:3),vec_xi2(1:3),vec_los(1:3)
32
33 data n_aia / 101 /
34
35 data t_aia / 4. , 4.05, 4.1, 4.15, 4.2, 4.25, 4.3, 4.35, &
36 4.4, 4.45, 4.5, 4.55, 4.6, 4.65, 4.7, 4.75, &
37 4.8, 4.85, 4.9, 4.95, 5. , 5.05, 5.1, 5.15, &
38 5.2, 5.25, 5.3, 5.35, 5.4, 5.45, 5.5, 5.55, &
39 5.6, 5.65, 5.7, 5.75, 5.8, 5.85, 5.9, 5.95, &
40 6. , 6.05, 6.1, 6.15, 6.2, 6.25, 6.3, 6.35, &
41 6.4, 6.45, 6.5, 6.55, 6.6, 6.65, 6.7, 6.75, &
42 6.8, 6.85, 6.9, 6.95, 7. , 7.05, 7.1, 7.15, &
43 7.2, 7.25, 7.3, 7.35, 7.4, 7.45, 7.5, 7.55, &
44 7.6, 7.65, 7.7, 7.75, 7.8, 7.85, 7.9, 7.95, &
45 8. , 8.05, 8.1, 8.15, 8.2, 8.25, 8.3, 8.35, &
46 8.4, 8.45, 8.5, 8.55, 8.6, 8.65, 8.7, 8.75, &
47 8.8, 8.85, 8.9, 8.95, 9. /
48
49 data f_94 / 4.25022959d-37, 4.35880298d-36, 3.57054296d-35, 2.18175426d-34, &
50 8.97592571d-34, 2.68512961d-33, 7.49559346d-33, 2.11603751d-32, &
51 5.39752853d-32, 1.02935904d-31, 1.33822307d-31, 1.40884290d-31, &
52 1.54933156d-31, 2.07543102d-31, 3.42026227d-31, 6.31171444d-31, &
53 1.16559416d-30, 1.95360497d-30, 2.77818735d-30, 3.43552578d-30, &
54 4.04061803d-30, 4.75470982d-30, 5.65553769d-30, 6.70595782d-30, &
55 7.80680354d-30, 8.93247715d-30, 1.02618156d-29, 1.25979030d-29, &
56 1.88526483d-29, 3.62448572d-29, 7.50553279d-29, 1.42337571d-28, &
57 2.37912813d-28, 3.55232305d-28, 4.84985757d-28, 6.20662827d-28, &
58 7.66193687d-28, 9.30403645d-28, 1.10519802d-27, 1.25786927d-27, &
59 1.34362634d-27, 1.33185242d-27, 1.22302081d-27, 1.05677973d-27, &
60 9.23064720d-28, 8.78570994d-28, 8.02397416d-28, 5.87681142d-28, &
61 3.82272695d-28, 3.11492649d-28, 3.85736090d-28, 5.98893519d-28, &
62 9.57553548d-28, 1.46650267d-27, 2.10365847d-27, 2.79406671d-27, &
63 3.39420087d-27, 3.71077520d-27, 3.57296767d-27, 2.95114380d-27, &
64 2.02913103d-27, 1.13361825d-27, 5.13405629d-28, 2.01305089d-28, &
65 8.15781482d-29, 4.28366817d-29, 3.08701543d-29, 2.68693906d-29, &
66 2.51764203d-29, 2.41773103d-29, 2.33996083d-29, 2.26997246d-29, &
67 2.20316143d-29, 2.13810001d-29, 2.07424438d-29, 2.01149189d-29, &
68 1.94980213d-29, 1.88917920d-29, 1.82963583d-29, 1.77116920d-29, &
69 1.71374392d-29, 1.65740593d-29, 1.60214447d-29, 1.54803205d-29, &
70 1.49510777d-29, 1.44346818d-29, 1.39322305d-29, 1.34441897d-29, &
71 1.29713709d-29, 1.25132618d-29, 1.20686068d-29, 1.14226584d-29, &
72 1.09866413d-29, 1.05635524d-29, 1.01532444d-29, 9.75577134d-30, &
73 9.37102736d-30, 8.99873335d-30, 8.63860172d-30, 8.29051944d-30, &
74 7.95414793d-30 /
75
76 data f_131 / 3.18403601d-37, 3.22254703d-36, 2.61657920d-35, &
77 1.59575286d-34, 6.65779556d-34, 2.07015132d-33, &
78 6.05768615d-33, 1.76074833d-32, 4.52633001d-32, &
79 8.57121883d-32, 1.09184271d-31, 1.10207963d-31, &
80 1.11371658d-31, 1.29105226d-31, 1.80385897d-31, &
81 3.27295431d-31, 8.92002136d-31, 3.15214579d-30, &
82 9.73440787d-30, 2.22709702d-29, 4.01788984d-29, &
83 6.27471832d-29, 8.91764995d-29, 1.18725647d-28, &
84 1.52888040d-28, 2.05082946d-28, 3.47651873d-28, &
85 8.80482184d-28, 2.66533063d-27, 7.05805149d-27, &
86 1.46072515d-26, 2.45282476d-26, 3.55303726d-26, &
87 4.59075911d-26, 5.36503515d-26, 5.68444094d-26, &
88 5.47222296d-26, 4.81119761d-26, 3.85959059d-26, &
89 2.80383406d-26, 1.83977650d-26, 1.11182849d-26, &
90 6.50748885d-27, 3.96843481d-27, 2.61876319d-27, &
91 1.85525324d-27, 1.39717024d-27, 1.11504283d-27, &
92 9.38169611d-28, 8.24801234d-28, 7.43331919d-28, &
93 6.74537063d-28, 6.14495760d-28, 5.70805277d-28, &
94 5.61219786d-28, 6.31981777d-28, 9.19747307d-28, &
95 1.76795732d-27, 3.77985446d-27, 7.43166191d-27, &
96 1.19785603d-26, 1.48234676d-26, 1.36673114d-26, &
97 9.61047146d-27, 5.61209353d-27, 3.04779780d-27, &
98 1.69378976d-27, 1.02113491d-27, 6.82223774d-28, &
99 5.02099099d-28, 3.99377760d-28, 3.36279037d-28, &
100 2.94767378d-28, 2.65740865d-28, 2.44396277d-28, &
101 2.28003967d-28, 2.14941419d-28, 2.04178995d-28, &
102 1.95031045d-28, 1.87011994d-28, 1.79777869d-28, &
103 1.73093957d-28, 1.66795789d-28, 1.60785455d-28, &
104 1.55002399d-28, 1.49418229d-28, 1.44022426d-28, &
105 1.38807103d-28, 1.33772767d-28, 1.28908404d-28, &
106 1.24196208d-28, 1.17437501d-28, 1.12854330d-28, &
107 1.08410498d-28, 1.04112003d-28, 9.99529904d-29, &
108 9.59358806d-29, 9.20512291d-29, 8.83009123d-29, &
109 8.46817043d-29, 8.11921928d-29 /
110
111 data f_171 / 2.98015581d-42, 1.24696230d-40, 3.37614652d-39, 5.64103034d-38, &
112 5.20550266d-37, 2.77785939d-36, 1.16283616d-35, 6.50007689d-35, &
113 9.96177399d-34, 1.89586076d-32, 2.10982799d-31, 1.36946479d-30, &
114 6.27396553d-30, 2.29955134d-29, 7.13430211d-29, 1.91024282d-28, &
115 4.35358848d-28, 7.94807808d-28, 1.07431875d-27, 1.08399488d-27, &
116 9.16212938d-28, 7.34715770d-28, 6.59246382d-28, 9.13541375d-28, &
117 2.05939035d-27, 5.08206555d-27, 1.10148083d-26, 2.01884662d-26, &
118 3.13578384d-26, 4.14367719d-26, 5.36067711d-26, 8.74170213d-26, &
119 1.64161233d-25, 2.94587860d-25, 4.76298332d-25, 6.91765639d-25, &
120 9.08825111d-25, 1.08496183d-24, 1.17440114d-24, 1.13943939d-24, &
121 9.71696981d-25, 7.09593688d-25, 4.31376399d-25, 2.12708486d-25, &
122 8.47429567d-26, 3.17608104d-26, 1.95898842d-26, 1.98064242d-26, &
123 1.67706555d-26, 8.99126003d-27, 3.29773878d-27, 1.28896127d-27, &
124 8.51169698d-28, 7.53520167d-28, 6.18268143d-28, 4.30034650d-28, &
125 2.78152409d-28, 1.95437088d-28, 1.65896278d-28, 1.68740181d-28, &
126 1.76054383d-28, 1.63978419d-28, 1.32880591d-28, 1.00833205d-28, &
127 7.82252806d-29, 6.36181741d-29, 5.34633869d-29, 4.58013864d-29, &
128 3.97833422d-29, 3.49414760d-29, 3.09790940d-29, 2.76786227d-29, &
129 2.48806269d-29, 2.24823367d-29, 2.04016653d-29, 1.85977413d-29, &
130 1.70367499d-29, 1.56966125d-29, 1.45570643d-29, 1.35964565d-29, &
131 1.27879263d-29, 1.21016980d-29, 1.15132499d-29, 1.09959628d-29, &
132 1.05307482d-29, 1.01040261d-29, 9.70657096d-30, 9.33214234d-30, &
133 8.97689427d-30, 8.63761192d-30, 8.31149879d-30, 7.85162401d-30, &
134 7.53828281d-30, 7.23559452d-30, 6.94341530d-30, 6.66137038d-30, &
135 6.38929156d-30, 6.12669083d-30, 5.87346434d-30, 5.62943622d-30, &
136 5.39435202d-30 /
137
138 data f_193 / 6.40066486d-32, 4.92737300d-31, 2.95342934d-30, 1.28061594d-29, &
139 3.47747667d-29, 5.88554792d-29, 7.72171179d-29, 9.75609282d-29, &
140 1.34318963d-28, 1.96252638d-28, 2.70163878d-28, 3.63192965d-28, &
141 5.28087341d-28, 8.37821446d-28, 1.39089159d-27, 2.31749718d-27, &
142 3.77510689d-27, 5.85198594d-27, 8.26021568d-27, 1.04870405d-26, &
143 1.25209374d-26, 1.47406787d-26, 1.77174067d-26, 2.24098537d-26, &
144 3.05926105d-26, 4.50018853d-26, 6.84720216d-26, 1.00595861d-25, &
145 1.30759222d-25, 1.36481773d-25, 1.15943558d-25, 1.01467304d-25, &
146 1.04092532d-25, 1.15071251d-25, 1.27416033d-25, 1.38463476d-25, &
147 1.47882726d-25, 1.57041238d-25, 1.69786224d-25, 1.94970397d-25, &
148 2.50332918d-25, 3.58321431d-25, 5.18061550d-25, 6.60405549d-25, &
149 6.64085365d-25, 4.83825816d-25, 2.40545020d-25, 8.59534098d-26, &
150 2.90920638d-26, 1.33204845d-26, 9.03933926d-27, 7.78910836d-27, &
151 7.29342321d-27, 7.40267022d-27, 8.05279981d-27, 8.13829291d-27, &
152 6.92634262d-27, 5.12521880d-27, 3.59527615d-27, 2.69617560d-27, &
153 2.84432713d-27, 5.06697306d-27, 1.01281903d-26, 1.63526978d-26, &
154 2.06759342d-26, 2.19482312d-26, 2.10050611d-26, 1.89837248d-26, &
155 1.66347131d-26, 1.43071097d-26, 1.21518419d-26, 1.02078343d-26, &
156 8.46936184d-27, 6.93015742d-27, 5.56973237d-27, 4.38951754d-27, &
157 3.38456457d-27, 2.55309556d-27, 1.88904224d-27, 1.38057546d-27, &
158 1.00718330d-27, 7.43581116d-28, 5.63562931d-28, 4.43359435d-28, &
159 3.63923535d-28, 3.11248143d-28, 2.75586846d-28, 2.50672237d-28, &
160 2.32419348d-28, 2.18325682d-28, 2.06834486d-28, 1.93497044d-28, &
161 1.84540751d-28, 1.76356504d-28, 1.68741425d-28, 1.61566157d-28, &
162 1.54754523d-28, 1.48249410d-28, 1.42020176d-28, 1.36045230d-28, &
163 1.30307965d-28 /
164
165 data f_211 / 4.74439912d-42, 1.95251522d-40, 5.19700194d-39, 8.53120166d-38, &
166 7.72745727d-37, 4.04158559d-36, 1.64853511d-35, 8.56295439d-35, &
167 1.17529722d-33, 2.16867729d-32, 2.40472264d-31, 1.56418133d-30, &
168 7.20032889d-30, 2.65838271d-29, 8.33196904d-29, 2.26128236d-28, &
169 5.24295811d-28, 9.77791121d-28, 1.35913489d-27, 1.43957785d-27, &
170 1.37591544d-27, 1.49029886d-27, 2.06183401d-27, 3.31440622d-27, &
171 5.42497318d-27, 8.41100374d-27, 1.17941366d-26, 1.49269794d-26, &
172 1.71506074d-26, 1.71266353d-26, 1.51434781d-26, 1.36766622d-26, &
173 1.33483562d-26, 1.36834518d-26, 1.45829002d-26, 1.62575306d-26, &
174 1.88773347d-26, 2.22026986d-26, 2.54930499d-26, 2.80758138d-26, &
175 3.06176409d-26, 3.62799792d-26, 5.13226109d-26, 8.46260744d-26, &
176 1.38486586d-25, 1.86192535d-25, 1.78007934d-25, 1.16548409d-25, &
177 5.89293257d-26, 2.69952884d-26, 1.24891081d-26, 6.41273176d-27, &
178 4.08282914d-27, 3.26463328d-27, 2.76230280d-27, 2.08986882d-27, &
179 1.37658470d-27, 8.48489381d-28, 5.19304217d-28, 3.19312514d-28, &
180 2.02968197d-28, 1.50171666d-28, 1.39164218d-28, 1.42448821d-28, &
181 1.41714519d-28, 1.33341059d-28, 1.20759270d-28, 1.07259692d-28, &
182 9.44895400d-29, 8.29030041d-29, 7.25440631d-29, 6.33479483d-29, &
183 5.51563757d-29, 4.79002469d-29, 4.14990482d-29, 3.59384972d-29, &
184 3.12010860d-29, 2.72624742d-29, 2.40734791d-29, 2.15543565d-29, &
185 1.95921688d-29, 1.80682882d-29, 1.68695662d-29, 1.59020936d-29, &
186 1.50940886d-29, 1.43956179d-29, 1.37731622d-29, 1.32049043d-29, &
187 1.26771875d-29, 1.21803879d-29, 1.17074716d-29, 1.10507836d-29, &
188 1.06022834d-29, 1.01703080d-29, 9.75436986d-30, 9.35349257d-30, &
189 8.96744546d-30, 8.59527489d-30, 8.23678940d-30, 7.89144480d-30, &
190 7.55891138d-30 /
191
192 data f_304 / 3.62695850d-32, 2.79969087d-31, 1.68340584d-30, 7.32681440d-30, &
193 1.99967770d-29, 3.41296785d-29, 4.55409104d-29, 5.94994635d-29, &
194 8.59864963d-29, 1.39787633d-28, 3.17701965d-28, 1.14474920d-27, &
195 4.44845958d-27, 1.54785841d-26, 4.70265345d-26, 1.24524365d-25, &
196 2.81535352d-25, 5.10093666d-25, 6.83545307d-25, 6.82110329d-25, &
197 5.66886188d-25, 4.36205513d-25, 3.29265688d-25, 2.49802368d-25, &
198 1.92527113d-25, 1.51058572d-25, 1.20596047d-25, 9.76884267d-26, &
199 7.89979266d-26, 6.18224289d-26, 4.67298332d-26, 3.57934505d-26, &
200 2.84535785d-26, 2.32853022d-26, 1.95228514d-26, 1.67880071d-26, &
201 1.47608785d-26, 1.32199691d-26, 1.20070960d-26, 1.09378177d-26, &
202 1.00031730d-26, 9.62434001d-27, 1.05063954d-26, 1.27267143d-26, &
203 1.45923057d-26, 1.36746707d-26, 1.03466970d-26, 6.97647829d-27, &
204 4.63141039d-27, 3.19031994d-27, 2.33373613d-27, 1.81589079d-27, &
205 1.48446917d-27, 1.26611478d-27, 1.12617468d-27, 1.03625148d-27, &
206 9.61400595d-28, 8.79016231d-28, 7.82612130d-28, 6.73762960d-28, &
207 5.59717956d-28, 4.53010243d-28, 3.65712196d-28, 3.00958686d-28, &
208 2.54011502d-28, 2.18102277d-28, 1.88736437d-28, 1.63817539d-28, &
209 1.42283147d-28, 1.23631916d-28, 1.07526003d-28, 9.36797928d-29, &
210 8.18565660d-29, 7.18152734d-29, 6.32523238d-29, 5.59513985d-29, &
211 4.96614048d-29, 4.42518826d-29, 3.95487628d-29, 3.54690294d-29, &
212 3.18953930d-29, 2.87720933d-29, 2.60186750d-29, 2.36011522d-29, &
213 2.14717806d-29, 1.95905217d-29, 1.79287981d-29, 1.64562262d-29, &
214 1.51489425d-29, 1.39876064d-29, 1.29496850d-29, 1.18665438d-29, &
215 1.10240474d-29, 1.02643099d-29, 9.57780996d-30, 8.95465151d-30, &
216 8.38950190d-30, 7.87283711d-30, 7.40136507d-30, 6.96804279d-30, &
217 6.56945323d-30 /
218
219 data f_335 / 2.46882661d-32, 1.89476632d-31, 1.13216502d-30, 4.89532008d-30, &
220 1.32745970d-29, 2.25390335d-29, 3.00511672d-29, 3.96035934d-29, &
221 5.77977656d-29, 8.58600736d-29, 1.14083000d-28, 1.48644411d-28, &
222 2.15788823d-28, 3.51628877d-28, 6.12200698d-28, 1.08184987d-27, &
223 1.85590697d-27, 2.91679107d-27, 3.94405396d-27, 4.63610680d-27, &
224 5.13824456d-27, 5.66602209d-27, 6.30009232d-27, 7.03422868d-27, &
225 7.77973918d-27, 8.32371831d-27, 8.56724316d-27, 8.62601374d-27, &
226 8.13308844d-27, 6.53188216d-27, 4.55197029d-27, 3.57590087d-27, &
227 3.59571707d-27, 4.03502770d-27, 4.54366411d-27, 4.96914990d-27, &
228 5.24601170d-27, 5.39979250d-27, 5.43023669d-27, 5.26235042d-27, &
229 4.91585495d-27, 4.52628362d-27, 4.13385020d-27, 3.67538967d-27, &
230 3.39939742d-27, 3.81284533d-27, 5.02332701d-27, 6.19438602d-27, &
231 6.49613071d-27, 6.04010475d-27, 5.24664275d-27, 4.37225997d-27, &
232 3.52957182d-27, 2.76212276d-27, 2.08473158d-27, 1.50850518d-27, &
233 1.04602472d-27, 7.13091243d-28, 5.34289645d-28, 5.21079581d-28, &
234 6.22246365d-28, 6.99555864d-28, 6.29665489d-28, 4.45077026d-28, &
235 2.67046793d-28, 1.52774686d-28, 9.18061770d-29, 6.09116074d-29, &
236 4.48562572d-29, 3.59463696d-29, 3.05820218d-29, 2.70766652d-29, &
237 2.46144034d-29, 2.27758450d-29, 2.13331183d-29, 2.01537836d-29, &
238 1.91566180d-29, 1.82893912d-29, 1.75167748d-29, 1.68136168d-29, &
239 1.61615595d-29, 1.55481846d-29, 1.49643236d-29, 1.44046656d-29, &
240 1.38657085d-29, 1.33459068d-29, 1.28447380d-29, 1.23615682d-29, &
241 1.18963296d-29, 1.14478976d-29, 1.10146637d-29, 1.04039479d-29, &
242 9.98611410d-30, 9.58205147d-30, 9.19202009d-30, 8.81551313d-30, &
243 8.45252127d-30, 8.10224764d-30, 7.76469090d-30, 7.43954323d-30, &
244 7.12653873d-30 /
245
246
247 data n_iris / 41 /
248
249 data t_iris / 4. , 4.1 , 4.2 , 4.3 , 4.40000001, &
250 4.50000001, 4.60000001, 4.70000001, 4.80000001, 4.90000001, &
251 5.00000001, 5.10000002, 5.20000002, 5.30000002, 5.40000002, &
252 5.50000002, 5.60000002, 5.70000003, 5.80000003, 5.90000003, &
253 6.00000003, 6.10000003, 6.20000003, 6.30000003, 6.40000004, &
254 6.50000004, 6.60000004, 6.70000004, 6.80000004, 6.90000004, &
255 7.00000004, 7.10000005, 7.20000005, 7.30000005, 7.40000005, &
256 7.50000005, 7.60000005, 7.70000006, 7.80000006, 7.90000006, &
257 8.00000006 /
258
259 data f_1354 / 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, &
260 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, &
261 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, &
262 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, &
263 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, &
264 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 1.09503647d-39, &
265 5.47214550d-36, 2.42433983d-33, 2.75295034d-31, 1.21929718d-29, &
266 2.48392125d-28, 2.33268145d-27, 8.68623633d-27, 1.00166284d-26, &
267 3.63126633d-27, 7.45174807d-28, 1.38224064d-28, 2.69270994d-29, &
268 5.53314977d-30, 1.15313092d-30, 2.34195788d-31, 4.48242942d-32, &
269 7.94976380d-33 /
270
271
272 data n_eis / 60 /
273
274 data t_eis1 / 1.99526231d+05, 2.23872114d+05, 2.51188643d+05, 2.81838293d+05, &
275 3.16227766d+05, 3.54813389d+05, 3.98107171d+05, 4.46683592d+05, &
276 5.01187234d+05, 5.62341325d+05, 6.30957344d+05, 7.07945784d+05, &
277 7.94328235d+05, 8.91250938d+05, 1.00000000d+06, 1.12201845d+06, &
278 1.25892541d+06, 1.41253754d+06, 1.58489319d+06, 1.77827941d+06, &
279 1.99526231d+06, 2.23872114d+06, 2.51188643d+06, 2.81838293d+06, &
280 3.16227766d+06, 3.54813389d+06, 3.98107171d+06, 4.46683592d+06, &
281 5.01187234d+06, 5.62341325d+06, 6.30957344d+06, 7.07945784d+06, &
282 7.94328235d+06, 8.91250938d+06, 1.00000000d+07, 1.12201845d+07, &
283 1.25892541d+07, 1.41253754d+07, 1.58489319d+07, 1.77827941d+07, &
284 1.99526231d+07, 2.23872114d+07, 2.51188643d+07, 2.81838293d+07, &
285 3.16227766d+07, 3.54813389d+07, 3.98107171d+07, 4.46683592d+07, &
286 5.01187234d+07, 5.62341325d+07, 6.30957344d+07, 7.07945784d+07, &
287 7.94328235d+07, 8.91250938d+07, 1.00000000d+08, 1.12201845d+08, &
288 1.25892541d+08, 1.41253754d+08, 1.58489319d+08, 1.77827941d+08 /
289
290 data t_eis2 / 1.99526231d+06, 2.23872114d+06, 2.51188643d+06, 2.81838293d+06, &
291 3.16227766d+06, 3.54813389d+06, 3.98107171d+06, 4.46683592d+06, &
292 5.01187234d+06, 5.62341325d+06, 6.30957344d+06, 7.07945784d+06, &
293 7.94328235d+06, 8.91250938d+06, 1.00000000d+07, 1.12201845d+07, &
294 1.25892541d+07, 1.41253754d+07, 1.58489319d+07, 1.77827941d+07, &
295 1.99526231d+07, 2.23872114d+07, 2.51188643d+07, 2.81838293d+07, &
296 3.16227766d+07, 3.54813389d+07, 3.98107171d+07, 4.46683592d+07, &
297 5.01187234d+07, 5.62341325d+07, 6.30957344d+07, 7.07945784d+07, &
298 7.94328235d+07, 8.91250938d+07, 1.00000000d+08, 1.12201845d+08, &
299 1.25892541d+08, 1.41253754d+08, 1.58489319d+08, 1.77827941d+08, &
300 1.99526231d+08, 2.23872114d+08, 2.51188643d+08, 2.81838293d+08, &
301 3.16227766d+08, 3.54813389d+08, 3.98107171d+08, 4.46683592d+08, &
302 5.01187234d+08, 5.62341325d+08, 6.30957344d+08, 7.07945784d+08, &
303 7.94328235d+08, 8.91250938d+08, 1.00000000d+09, 1.12201845d+09, &
304 1.25892541d+09, 1.41253754d+09, 1.58489319d+09, 1.77827941d+09 /
305
306 data f_263 / 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, &
307 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, &
308 0.00000000d+00, 4.46454917d-45, 3.26774829d-42, 1.25292566d-39, &
309 2.66922338d-37, 3.28497742d-35, 2.38677554d-33, 1.03937729d-31, &
310 2.75075687d-30, 4.47961733d-29, 4.46729177d-28, 2.64862689d-27, &
311 8.90863800d-27, 1.72437548d-26, 2.22217752d-26, 2.27999477d-26, &
312 2.08264363d-26, 1.78226687d-26, 1.45821699d-26, 1.14675379d-26, &
313 8.63082492d-27, 6.15925429d-27, 4.11252514d-27, 2.51530564d-27, &
314 1.37090986d-27, 6.42443134d-28, 2.48392636d-28, 7.59187874d-29, &
315 1.77852938d-29, 3.23945221d-30, 4.90533903d-31, 6.75458158d-32, &
316 9.06878868d-33, 1.23927474d-33, 1.75769395d-34, 2.60710914d-35, &
317 4.04318030d-36, 6.53500581d-37, 1.09365022d-37, 1.88383322d-38, &
318 3.31425233d-39, 5.90964084d-40, 1.06147549d-40, 1.90706170d-41, &
319 3.41331584d-42, 6.07310718d-43, 1.07364738d-43, 1.89085498d-44, &
320 3.32598922d-45, 5.87125640d-46, 0.00000000d+00, 0.00000000d+00 /
321
322 data f_264 / 0.00000000d+00, 2.81670057d-46, 1.28007268d-43, 2.54586603d-41, &
323 2.67887256d-39, 1.68413285d-37, 6.85702304d-36, 1.91797284d-34, &
324 3.84675839d-33, 5.69939170d-32, 6.36224608d-31, 5.39176489d-30, &
325 3.45478458d-29, 1.64848693d-28, 5.71476364d-28, 1.39909997d-27, &
326 2.37743056d-27, 2.86712530d-27, 2.65206348d-27, 2.07175767d-27, &
327 1.47866767d-27, 1.01087374d-27, 6.79605811d-28, 4.54746770d-28, &
328 3.04351751d-28, 2.03639149d-28, 1.35940991d-28, 9.01451939d-29, &
329 5.91289972d-29, 3.81821178d-29, 2.41434696d-29, 1.48871220d-29, &
330 8.93362094d-30, 5.21097445d-30, 2.95964719d-30, 1.64278748d-30, &
331 8.95571660d-31, 4.82096011d-31, 2.57390991d-31, 1.36821781d-31, &
332 7.27136350d-32, 3.87019426d-32, 2.06883430d-32, 1.11228884d-32, &
333 6.01883313d-33, 3.27790676d-33, 1.79805012d-33, 9.93085346d-34, &
334 5.52139556d-34, 3.08881387d-34, 1.73890315d-34, 9.84434964d-35, &
335 5.60603378d-35, 3.20626492d-35, 1.84111068d-35, 0.00000000d+00, &
336 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00 /
337
338 data f_192 / 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 4.35772105d-44, &
339 1.26162319d-41, 1.97471205d-39, 1.83409019d-37, 1.08206288d-35, &
340 4.27914363d-34, 1.17943846d-32, 2.32565755d-31, 3.33087991d-30, &
341 3.47013260d-29, 2.60375866d-28, 1.37737127d-27, 5.01053913d-27, &
342 1.23479810d-26, 2.11310542d-26, 2.71831513d-26, 2.89851163d-26, &
343 2.77312376d-26, 2.50025229d-26, 2.18323661d-26, 1.86980322d-26, &
344 1.58035034d-26, 1.31985651d-26, 1.08733133d-26, 8.81804906d-27, &
345 7.00417973d-27, 5.43356567d-27, 4.09857884d-27, 2.99651764d-27, &
346 2.11902962d-27, 1.45014127d-27, 9.62291023d-28, 6.21548647d-28, &
347 3.92807578d-28, 2.44230375d-28, 1.50167782d-28, 9.17611405d-29, &
348 5.58707641d-29, 3.40570915d-29, 2.08030862d-29, 1.27588676d-29, &
349 7.86535588d-30, 4.87646151d-30, 3.03888897d-30, 1.90578649d-30, &
350 1.20195947d-30, 7.61955060d-31, 4.85602199d-31, 3.11049969d-31, &
351 2.00087065d-31, 1.29223740d-31, 8.37422008d-32, 0.00000000d+00, &
352 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00 /
353
354 data f_255 / 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 1.76014287d-44, &
355 5.07057938d-42, 7.90473970d-40, 7.31852999d-38, 4.30709255d-36, &
356 1.70009061d-34, 4.67925160d-33, 9.21703546d-32, 1.31918676d-30, &
357 1.37393161d-29, 1.03102379d-28, 5.45694018d-28, 1.98699648d-27, &
358 4.90346776d-27, 8.40524725d-27, 1.08321456d-26, 1.15714525d-26, &
359 1.10905152d-26, 1.00155023d-26, 8.75799161d-27, 7.50935839d-27, &
360 6.35253533d-27, 5.30919268d-27, 4.37669455d-27, 3.55185164d-27, &
361 2.82347055d-27, 2.19257595d-27, 1.65589541d-27, 1.21224987d-27, &
362 8.58395132d-28, 5.88163935d-28, 3.90721447d-28, 2.52593407d-28, &
363 1.59739995d-28, 9.93802874d-29, 6.11343388d-29, 3.73711135d-29, &
364 2.27618743d-29, 1.38793199d-29, 8.48060787d-30, 5.20305940d-30, &
365 3.20867365d-30, 1.99011277d-30, 1.24064551d-30, 7.78310544d-31, &
366 4.91013681d-31, 3.11338381d-31, 1.98451675d-31, 1.27135460d-31, &
367 8.17917486d-32, 5.28280497d-32, 3.42357159d-32, 0.00000000d+00, &
368 0.00000000d+00, 0.00000000d+00, 0.00000000d+00, 0.00000000d+00 /
369
370 abstract interface
371 subroutine get_subr1(w,x,ixI^L,ixO^L,res)
373 integer, intent(in) :: ixI^L, ixO^L
374 double precision, intent(in) :: w(ixI^S,nw)
375 double precision, intent(in) :: x(ixI^S,1:ndim)
376 double precision, intent(out):: res(ixI^S)
377 end subroutine get_subr1
378
379 end interface
380
382
383 procedure(get_subr1), pointer, nopass :: get_rho => null()
384 procedure(get_subr1), pointer, nopass :: get_temperature => null()
385
386 end type te_fluid
387
388
389 contains
390
391 subroutine get_line_info(wl,ion,mass,logTe,line_center,spatial_px,spectral_px,sigma_PSF,width_slit)
392 ! get information of the spectral line
393 ! wl: wavelength
394 ! mass: ion mass, unit -- proton mass
395 ! logTe: peak temperature of emission line in logarithm
396 ! line_center: center wavelength of emission line, unit -- Angstrom (0.1 nm)
397 ! spatial_px: pixel size in space of instrument (for image), unit -- arcsec
398 ! spectral_px: pixel size in wagelength of instrument (for spectrum), unit -- Angstrom
399 ! sigma_PSF: width of point spread function core (for instrument), unit -- pixel
400 ! width_slit: width of slit for spectrograph, unit -- arcsec
402
403 integer, intent(in) :: wl
404 integer, intent(out) :: mass
405 character(len=30), intent(out) :: ion
406 double precision, intent(out) :: logTe,line_center,spatial_px,spectral_px
407 double precision, intent(out) :: sigma_PSF,width_slit
408
409 select case(wl)
410 case(304)
411 ion='He II'
412 mass=4
413 logte=4.7d0
414 line_center=303.8d0
415 spatial_px=0.6d0
416 spectral_px=0.02d0
417 sigma_psf=0.895d0
418 width_slit=0.6d0
419 case(171)
420 ion='Fe IX'
421 mass=56
422 logte=5.8d0
423 line_center=171.1d0
424 spatial_px=0.6d0
425 spectral_px=0.02d0
426 sigma_psf=1.019d0
427 width_slit=0.6d0
428 case(193)
429 ion='Fe XXIV'
430 mass=56
431 logte=7.3d0
432 line_center=193.5d0
433 spatial_px=0.6d0
434 spectral_px=0.02d0
435 sigma_psf=0.813d0
436 width_slit=0.6d0
437 case(211)
438 ion='Fe XIV'
439 mass=56
440 logte=6.3d0
441 line_center=211.3d0
442 spatial_px=0.6d0
443 spectral_px=0.02d0
444 sigma_psf=0.913d0
445 width_slit=0.6d0
446 case(335)
447 ion='Fe XVI'
448 mass=56
449 logte=6.4d0
450 line_center=335.4d0
451 spatial_px=0.6d0
452 spectral_px=0.02d0
453 sigma_psf=1.019d0
454 width_slit=0.6d0
455 case(94)
456 ion='Fe XVIII'
457 mass=56
458 logte=6.8d0
459 line_center=93.9d0
460 spatial_px=0.6d0
461 spectral_px=0.02d0
462 sigma_psf=1.025d0
463 width_slit=0.6d0
464 case(131)
465 ion='Fe XXI'
466 mass=56
467 logte=7.0d0
468 line_center=131.0d0
469 spatial_px=0.6d0
470 spectral_px=0.02d0
471 sigma_psf=0.984d0
472 width_slit=0.6d0
473 case(1354)
474 ion='Fe XXI'
475 mass=56
476 logte=7.0d0
477 line_center=1354.1d0
478 spatial_px=0.1663d0
479 spectral_px=12.98d-3
480 sigma_psf=1.d0
481 width_slit=0.33d0
482 case(263)
483 ion='Fe XVI'
484 mass=56
485 logte=6.4d0
486 line_center=262.976d0
487 spatial_px=1.d0
488 spectral_px=22.d-3
489 sigma_psf=1.d0
490 width_slit=2.d0
491 case(264)
492 ion='Fe XXIII'
493 mass=56
494 logte=7.1d0
495 line_center=263.765d0
496 spatial_px=1.d0
497 spectral_px=22.d-3
498 sigma_psf=1.d0
499 width_slit=2.d0
500 case(192)
501 ion='Fe XXIV'
502 mass=56
503 logte=7.2d0
504 line_center=192.028d0
505 spatial_px=1.d0
506 spectral_px=22.d-3
507 sigma_psf=1.d0
508 width_slit=2.d0
509 case(255)
510 ion='Fe XXIV'
511 mass=56
512 logte=7.2d0
513 line_center=255.113d0
514 spatial_px=1.d0
515 spectral_px=22.d-3
516 sigma_psf=1.d0
517 width_slit=2.d0
518 case default
519 call mpistop("No information about this line")
520 end select
521
522 spatial_px=spatial_px/instrument_resolution_factor
523 end subroutine get_line_info
524
525 subroutine get_euv(wl,ixI^L,ixO^L,w,x,fl,flux)
526 ! calculate the local emission intensity of given EUV line (optically thin)
527 ! wavelength is the wave length of the emission line
528 ! unit [DN cm^-1 s^-1 pixel^-1]
529 ! ingrate flux along line of sight: DN s^-1 pixel^-1
531
532 integer, intent(in) :: wl
533 integer, intent(in) :: ixI^L, ixO^L
534 double precision, intent(in) :: x(ixI^S,1:ndim)
535 double precision, intent(in) :: w(ixI^S,1:nw)
536 type(te_fluid), intent(in) :: fl
537 double precision, intent(out) :: flux(ixI^S)
538
539 integer :: n_table
540 double precision, allocatable :: t_table(:),f_table(:)
541 integer :: ix^D,iTt,i
542 double precision :: Te(ixI^S),Ne(ixI^S)
543 double precision :: logT,logGT,GT
544
545 ! selecting emission table
546 select case(wl)
547 case(94)
548 n_table=n_aia
549 allocate(t_table(1:n_table))
550 allocate(f_table(1:n_table))
551 t_table(1:n_table)=t_aia(1:n_aia)
552 f_table(1:n_table)=f_94(1:n_aia)
553 case(131)
554 n_table=n_aia
555 allocate(t_table(1:n_table))
556 allocate(f_table(1:n_table))
557 t_table(1:n_table)=t_aia(1:n_aia)
558 f_table(1:n_table)=f_131(1:n_aia)
559 case(171)
560 n_table=n_aia
561 allocate(t_table(1:n_table))
562 allocate(f_table(1:n_table))
563 t_table(1:n_table)=t_aia(1:n_aia)
564 f_table(1:n_table)=f_171(1:n_aia)
565 case(193)
566 n_table=n_aia
567 allocate(t_table(1:n_table))
568 allocate(f_table(1:n_table))
569 t_table(1:n_table)=t_aia(1:n_aia)
570 f_table(1:n_table)=f_193(1:n_aia)
571 case(211)
572 n_table=n_aia
573 allocate(t_table(1:n_table))
574 allocate(f_table(1:n_table))
575 t_table(1:n_table)=t_aia(1:n_aia)
576 f_table(1:n_table)=f_211(1:n_aia)
577 case(304)
578 n_table=n_aia
579 allocate(t_table(1:n_table))
580 allocate(f_table(1:n_table))
581 t_table(1:n_table)=t_aia(1:n_aia)
582 f_table(1:n_table)=f_304(1:n_aia)
583 case(335)
584 n_table=n_aia
585 allocate(t_table(1:n_table))
586 allocate(f_table(1:n_table))
587 t_table(1:n_table)=t_aia(1:n_aia)
588 f_table(1:n_table)=f_335(1:n_aia)
589 case(1354)
590 n_table=n_iris
591 allocate(t_table(1:n_table))
592 allocate(f_table(1:n_table))
593 t_table(1:n_table)=t_iris(1:n_iris)
594 f_table(1:n_table)=f_1354(1:n_iris)
595 case(263)
596 n_table=n_eis
597 allocate(t_table(1:n_table))
598 allocate(f_table(1:n_table))
599 t_table(1:n_table)=t_eis1(1:n_eis)
600 f_table(1:n_table)=f_263(1:n_eis)
601 case(264)
602 n_table=n_eis
603 allocate(t_table(1:n_table))
604 allocate(f_table(1:n_table))
605 t_table(1:n_table)=t_eis2(1:n_eis)
606 f_table(1:n_table)=f_264(1:n_eis)
607 case(192)
608 n_table=n_eis
609 allocate(t_table(1:n_table))
610 allocate(f_table(1:n_table))
611 t_table(1:n_table)=t_eis2(1:n_eis)
612 f_table(1:n_table)=f_192(1:n_eis)
613 case(255)
614 n_table=n_eis
615 allocate(t_table(1:n_table))
616 allocate(f_table(1:n_table))
617 t_table(1:n_table)=t_eis2(1:n_eis)
618 f_table(1:n_table)=f_255(1:n_eis)
619 case default
620 allocate(t_table(1))
621 allocate(f_table(1))
622 call mpistop("Unknown wavelength")
623 end select
624 call fl%get_rho(w,x,ixi^l,ixo^l,ne)
625 call fl%get_temperature(w,x,ixi^l,ixo^l,te)
626 te(ixo^s)=te(ixo^s)*unit_temperature
627 if (si_unit) then
628 ne(ixo^s)=ne(ixo^s)*unit_numberdensity/1.d6 ! m^-3 -> cm-3
629 flux(ixo^s)=ne(ixo^s)**2
630 else
631 ne(ixo^s)=ne(ixo^s)*unit_numberdensity
632 flux(ixo^s)=ne(ixo^s)**2
633 endif
634
635 select case(wl)
636 case(94,131,171,193,211,304,335,1354)
637 ! temperature table in log
638 do i=1,n_table
639 if(f_table(i) .gt. 1.d-99) then
640 f_table(i)=log10(f_table(i))
641 else
642 f_table(i)=-99.d0
643 endif
644 enddo
645 {do ix^db=ixomin^db,ixomax^db\}
646 loggt=zero
647 logt=log10(te(ix^d))
648 if (logt>=t_table(1) .and. logt<=t_table(n_table)) then
649 if (logt>=t_table(n_table)) then
650 loggt=f_table(n_table)
651 else
652 do itt=1,n_table-1
653 if (logt>=t_table(itt) .and. logt<t_table(itt+1)) then
654 loggt=f_table(itt)*(logt-t_table(itt+1))/(t_table(itt)-t_table(itt+1))+&
655 f_table(itt+1)*(logt-t_table(itt))/(t_table(itt+1)-t_table(itt))
656 exit
657 endif
658 enddo
659 endif
660 flux(ix^d)=flux(ix^d)*(10**(loggt))
661 if(flux(ix^d)<smalldouble) flux(ix^d)=0.d0
662 else
663 flux(ix^d)=zero
664 endif
665 {enddo\}
666 case default
667 ! temperature table linear
668 {do ix^db=ixomin^db,ixomax^db\}
669 gt=zero
670 if (te(ix^d)>=t_table(1) .and. te(ix^d)<=t_table(n_table)) then
671 if (te(ix^d)>=t_table(n_table)) then
672 gt=f_table(n_table)
673 else
674 do itt=1,n_table-1
675 if (te(ix^d)>=t_table(itt) .and. te(ix^d)<t_table(itt+1)) then
676 gt=f_table(itt)*(te(ix^d)-t_table(itt+1))/(t_table(itt)-t_table(itt+1))+&
677 f_table(itt+1)*(te(ix^d)-t_table(itt))/(t_table(itt+1)-t_table(itt))
678 exit
679 endif
680 enddo
681 endif
682 flux(ix^d)=flux(ix^d)*gt
683 if(flux(ix^d)<smalldouble) flux(ix^d)=0.d0
684 else
685 flux(ix^d)=zero
686 endif
687 {enddo\}
688 end select
689
690 deallocate(t_table,f_table)
691 end subroutine get_euv
692
693 subroutine get_sxr(ixI^L,ixO^L,w,x,fl,flux,El,Eu)
694 !synthesize thermal SXR from El keV to Eu keV released by cm^-3/m^-3
695 ! volume of plasma in 1 s
696 !flux (cgs): photons cm^-3 s^-1
697 !flux (SI): photons m^-3 s^-1
699
700 integer, intent(in) :: ixI^L,ixO^L
701 integer, intent(in) :: El,Eu
702 double precision, intent(in) :: x(ixI^S,1:ndim)
703 double precision, intent(in) :: w(ixI^S,nw)
704 type(te_fluid), intent(in) :: fl
705 double precision, intent(out) :: flux(ixI^S)
706
707 integer :: ix^D,ixO^D
708 integer :: iE,numE
709 double precision :: I0,kb,keV,dE,Ei
710 double precision :: Te(ixI^S),kbT(ixI^S)
711 double precision :: Ne(ixI^S),gff(ixI^S),fi(ixI^S)
712 double precision :: EM(ixI^S)
713
714 i0=3.01d-15 ! I0*4*pi*AU**2, I0 from Pinto (2015)
715 kb=const_kb
716 kev=1.0d3*const_ev
717 de=0.1
718 nume=floor((eu-el)/de)
719 call fl%get_rho(w,x,ixi^l,ixo^l,ne)
720 call fl%get_temperature(w,x,ixi^l,ixo^l,te)
721 te(ixo^s)=te(ixo^s)*unit_temperature
722 if (si_unit) then
723 ne(ixo^s)=ne(ixo^s)*unit_numberdensity/1.d6 ! m^-3 -> cm-3
724 em(ixo^s)=(ne(ixo^s))**2*1.d6 ! cm^-3 m^-3
725 else
726 ne(ixo^s)=ne(ixo^s)*unit_numberdensity
727 em(ixo^s)=(ne(ixo^s))**2
728 endif
729 kbt(ixo^s)=kb*te(ixo^s)/kev
730 flux(ixo^s)=0.0d0
731 do ie=0,nume-1
732 ei=de*ie+el*1.d0
733 gff(ixo^s)=1.d0
734 {do ix^db=ixomin^db,ixomax^db\}
735 if (kbt(ix^d)>0.01*ei) then
736 if(kbt(ix^d)<ei) gff(ix^d)=(kbt(ix^d)/ei)**0.4
737 fi(ix^d)=(em(ix^d)*gff(ix^d))*dexp(-ei/(kbt(ix^d)))/(ei*dsqrt(kbt(ix^d)))
738 else
739 fi(ix^d)=zero
740 endif
741 {enddo\}
742 flux(ixo^s)=flux(ixo^s)+fi(ixo^s)*de
743 enddo
744 flux(ixo^s)=flux(ixo^s)*i0
745 end subroutine get_sxr
746
747 subroutine get_goes_sxr_flux(xbox^L,fl,eflux)
748 !get GOES SXR 1-8A flux observing at 1AU from given box [w/m^2]
750
751 double precision, intent(in) :: xbox^L
752 type(te_fluid), intent(in) :: fl
753 double precision, intent(out) :: eflux
754
755 double precision :: dxb^D,xb^L
756 integer :: iigrid,igrid
757 integer :: ixO^L,ixI^L,ix^D
758 double precision :: eflux_grid,eflux_pe
759
760 ^d&iximin^d=ixglo^d;
761 ^d&iximax^d=ixghi^d;
762 ^d&ixomin^d=ixmlo^d;
763 ^d&ixomax^d=ixmhi^d;
764 eflux_pe=zero
765 do iigrid=1,igridstail; igrid=igrids(iigrid);
766 ^d&dxlevel(^d)=rnode(rpdx^d_,igrid);
767 ^d&xbmin^d=rnode(rpxmin^d_,igrid);
768 ^d&xbmax^d=rnode(rpxmax^d_,igrid);
769 call get_goes_flux_grid(ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,ps(igrid)%dvolume(ixi^s),xbox^l,xb^l,fl,eflux_grid)
770 eflux_pe=eflux_pe+eflux_grid
771 enddo
772 call mpi_allreduce(eflux_pe,eflux,1,mpi_double_precision,mpi_sum,icomm,ierrmpi)
773 end subroutine get_goes_sxr_flux
774
775 subroutine get_goes_flux_grid(ixI^L,ixO^L,w,x,dV,xbox^L,xb^L,fl,eflux_grid)
777
778 integer, intent(in) :: ixI^L,ixO^L
779 double precision, intent(in) :: x(ixI^S,1:ndim),dV(ixI^S)
780 double precision, intent(in) :: w(ixI^S,nw)
781 double precision, intent(in) :: xbox^L,xb^L
782 type(te_fluid), intent(in) :: fl
783 double precision, intent(out) :: eflux_grid
784
785 integer :: ix^D,ixO^D,ixb^L
786 integer :: iE,numE,inbox
787 double precision :: I0,kb,keV,dE,Ei,El,Eu,A_cgs
788 double precision :: Te(ixI^S),kbT(ixI^S)
789 double precision :: Ne(ixI^S),EM(ixI^S)
790 double precision :: gff,fi,erg_SI
791
792 ! check whether the grid is inside given box
793 inbox=0
794 {if (xbmin^d<xboxmax^d .and. xbmax^d>xboxmin^d) inbox=inbox+1\}
795
796 if (inbox==ndim) then
797 ! indexes for cells inside given box
798 ^d&ixbmin^d=ixomin^d;
799 ^d&ixbmax^d=ixomax^d;
800 {if (xbmax^d>xboxmax^d) ixbmax^d=ixomax^d-ceiling((xbmax^d-xboxmax^d)/dxlevel(^d))\}
801 {if (xbmin^d<xboxmin^d) ixbmin^d=ceiling((xboxmin^d-xbmin^d)/dxlevel(^d))+ixomin^d\}
802
803 i0=1.07d-38 ! photon flux index for observed at 1AU [photon cm^3 m^-2 s^-1 keV^-1]
804 kb=const_kb
805 kev=1.0d3*const_ev
806 erg_si=1.d-7
807 a_cgs=1.d-8 ! Angstrom
808 el=const_h*const_c/(8.d0*a_cgs)/kev ! 8 A
809 eu=const_h*const_c/(1.d0*a_cgs)/kev ! 1 A
810 de=0.1 ! keV
811 nume=floor((eu-el)/de)
812 call fl%get_rho(w,x,ixi^l,ixb^l,ne)
813 call fl%get_temperature(w,x,ixi^l,ixb^l,te)
814 te(ixb^s)=te(ixb^s)*unit_temperature
815 if (si_unit) then
816 ne(ixb^s)=ne(ixb^s)*unit_numberdensity/1.d6
817 em(ixb^s)=(i0*(ne(ixb^s))**2)*dv(ixb^s) * &
818 (unit_length*1.d2)**3
819 else
820 ne(ixb^s)=ne(ixb^s)*unit_numberdensity
821 em(ixb^s)=(i0*(ne(ixb^s))**2)*dv(ixb^s) * &
822 unit_length**3
823 endif
824 kbt(ixb^s)=kb*te(ixb^s)/kev
825 eflux_grid=0.0d0
826
827 do ie=0,nume-1
828 ei=de*ie+el
829 {do ix^db=ixbmin^db,ixbmax^db\}
830 if (kbt(ix^d)>1.d-2*ei) then
831 if(kbt(ix^d)<ei) then
832 gff=(kbt(ix^d)/ei)**0.4
833 else
834 gff=1.d0
835 endif
836 fi=(em(ix^d)*gff)*dexp(-ei/(kbt(ix^d)))/(ei*dsqrt(kbt(ix^d)))
837 eflux_grid=eflux_grid+fi*de*ei
838 endif
839 {enddo\}
840 enddo
841 eflux_grid=eflux_grid*kev*erg_si
842 endif
843
844 end subroutine get_goes_flux_grid
845
846 {^ifthreed
847 subroutine get_euv_spectrum(qunit,fl)
849
850 integer, intent(in) :: qunit
851 type(te_fluid), intent(in) :: fl
852 character(20) :: datatype
853
854 integer :: mass
855 character (30) :: ion
856 double precision :: logTe,lineCent,sigma_PSF,spaceRsl,wlRsl,wslit
857 double precision :: xslit,arcsec
858
859 datatype='spectrum_euv'
860 arcsec=7.25d7/unit_length
861 call get_line_info(spectrum_wl,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
862
863 if (mype==0) print *, '###################################################'
864 select case(spectrum_wl)
865 case (1354)
866 if (mype==0) print *, 'Systhesizing EUV spectrum (observed by IRIS).'
867 case (263,264,192,255)
868 if (mype==0) print *, 'Systhesizing EUV spectrum (observed by Hinode/EIS).'
869 case default
870 call mpistop('Wrong wavelength!')
871 end select
872
874 call mpistop('Wrong spectrum window!')
875 endif
876
877 if (mype==0) write(*,'(a,f8.3,a)') ' Wavelength: ',linecent,' Angstrom'
878 if (mype==0) print *, 'Unit of EUV flux: DN s^-1 pixel^-1'
879
880 if (dat_resolution) then
881 if (mype==0) then
882 write(*,'(a,f5.3,a,f5.1,a)') ' Supposed pixel: ',wlrsl,' Angstrom x ',spacersl*725.0, ' km'
883 print *, 'Unit of wavelength: Angstrom (0.1 nm) '
884 if (si_unit) then
885 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d6,' Mm'
886 else
887 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d8,' Mm'
888 endif
889 write(*,'(a,f8.1,a)') ' Supposed width of slit: ',wslit*725.0,' km'
890 endif
891 call get_spectrum_datresol(qunit,datatype,fl)
892 else
893 if (mype==0) then
894 print *, 'Unit of wavelength: Angstrom (0.1 nm) '
895 if (activate_unit_arcsec) then
896 write(*,'(a,f5.3,a,f5.1,a)') ' Pixel: ',wlrsl,' Angstrom x ',spacersl*725.0, ' km'
897 print *, 'Unit of length: arcsec (~725 km)'
898 write(*,'(a,f8.1,a)') ' Location of slit: xI1 = ',location_slit,' arcsec'
899 write(*,'(a,f8.1,a)') ' Width of slit: ',wslit,' arcsec'
900 else
901 if (si_unit) then
902 if (mype==0) write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d6,' Mm'
903 else
904 if (mype==0) write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d8,' Mm'
905 endif
906 write(*,'(a,f8.1,a)') ' Location of slit: xI1 = ',location_slit,' Unit_length'
907 write(*,'(a,f8.1,a)') ' Width of slit: ',wslit*725.d0,' km'
908 endif
909 endif
910 if (mype==0) print *, 'Direction of the slit: parallel to xI2 vector'
912 call get_spectrum(qunit,datatype,fl)
913 else
914 call mpistop("EUV spectrum synthesis: support for sperical coordinates is to be added!")
915 endif
916 endif
917
918 if (mype==0) print *, '###################################################'
919
920 end subroutine get_euv_spectrum
921
922 subroutine get_spectrum_datresol(qunit,datatype,fl)
923
924 integer, intent(in) :: qunit
925 character(20), intent(in) :: datatype
926 type(te_fluid), intent(in) :: fl
927
928 integer :: numWL,numXS,iwL,ixS,numWI,numS
929 double precision :: dwLg,xSmin,xSmax,wLmin,wLmax
930 double precision, allocatable :: wL(:),xS(:),dwL(:),dxS(:)
931 double precision, allocatable :: wI(:,:,:),spectra(:,:),spectra_rc(:,:)
932 integer :: strtype,nstrb,nbb,nuni,nstr,bnx
933 double precision :: qs,dxfirst,dxmid,lenstr
934
935 integer :: iigrid,igrid,j,dir_loc
936 double precision :: xbmin(1:ndim),xbmax(1:ndim)
937
938 dwlg=1.d-3
939 numwl=4*int((spectrum_window_max-spectrum_window_min)/(4.d0*dwlg))
940 wlmin=(spectrum_window_max+spectrum_window_min)/2.d0-dwlg*numwl/2
941 wlmax=(spectrum_window_max+spectrum_window_min)/2.d0+dwlg*numwl/2
942 allocate(wl(numwl),dwl(numwl))
943 dwl(:)=dwlg
944 do iwl=1,numwl
945 wl(iwl)=wlmin+iwl*dwlg-half*dwlg
946 enddo
947
948 select case(direction_slit)
949 case (1)
950 numxs=domain_nx1*2**(refine_max_level-1)
951 xsmin=xprobmin1
952 xsmax=xprobmax1
953 bnx=block_nx1
954 nbb=domain_nx1
955 strtype=stretch_type(1)
956 nstrb=nstretchedblocks_baselevel(1)
957 qs=qstretch_baselevel(1)
958 if (mype==0) print *, 'Direction of the slit: x'
959 case (2)
960 numxs=domain_nx2*2**(refine_max_level-1)
961 xsmin=xprobmin2
962 xsmax=xprobmax2
963 bnx=block_nx2
964 nbb=domain_nx2
965 strtype=stretch_type(2)
966 nstrb=nstretchedblocks_baselevel(2)
967 qs=qstretch_baselevel(2)
968 if (mype==0) print *, 'Direction of the slit: y'
969 case (3)
970 numxs=domain_nx3*2**(refine_max_level-1)
971 xsmin=xprobmin3
972 xsmax=xprobmax3
973 bnx=block_nx3
974 nbb=domain_nx3
975 strtype=stretch_type(3)
976 nstrb=nstretchedblocks_baselevel(3)
977 qs=qstretch_baselevel(3)
978 if (mype==0) print *, 'Direction of the slit: z'
979 case default
980 call mpistop('Wrong direction_slit')
981 end select
982
983 allocate(xs(numxs),dxs(numxs),spectra(numwl,numxs),spectra_rc(numwl,numxs))
984 numwi=1
985 allocate(wi(numwl,numxs,numwi))
986
987 select case(strtype)
988 case(0) ! uniform
989 dxs(:)=(xsmax-xsmin)/numxs
990 do ixs=1,numxs
991 xs(ixs)=xsmin+dxs(ixs)*(ixs-half)
992 enddo
993 case(1) ! uni stretch
994 qs=qs**(one/2**(refine_max_level-1))
995 dxfirst=(xsmax-xsmin)*(one-qs)/(one-qs**numxs)
996 dxs(1)=dxfirst
997 do ixs=2,numxs
998 dxs(ixs)=dxfirst*qs**(ixs-1)
999 xs(ixs)=dxs(1)/(one-qs)*(one-qs**(ixs-1))+half*dxs(ixs)
1000 enddo
1001 case(2) ! symm stretch
1002 ! base level, nbb = nstr + nuni + nstr
1003 nstr=nstrb*bnx/2
1004 nuni=nbb-nstrb*bnx
1005 lenstr=(xsmax-xsmin)/(2.d0+nuni*(one-qs)/(one-qs**nstr))
1006 dxfirst=(xsmax-xsmin)/(dble(nuni)+2.d0/(one-qs)*(one-qs**nstr))
1007 dxmid=dxfirst
1008 ! refine_max level, numXI = nstr + nuni + nstr
1009 nstr=nstr*2**(refine_max_level-1)
1010 nuni=nuni*2**(refine_max_level-1)
1011 qs=qs**(one/2**(refine_max_level-1))
1012 dxfirst=lenstr*(one-qs)/(one-qs**nstr)
1013 dxmid=dxmid/2**(refine_max_level-1)
1014 ! uniform center
1015 if(nuni .gt. 0) then
1016 do ixs=nstr+1,nstr+nuni
1017 dxs(ixs)=dxmid
1018 xs(ixs)=lenstr+(dble(ixs)-0.5d0-nstr)*dxs(ixs)+xsmin
1019 enddo
1020 endif
1021 ! left half
1022 do ixs=nstr,1,-1
1023 dxs(ixs)=dxfirst*qs**(nstr-ixs)
1024 xs(ixs)=xsmin+lenstr-dxs(ixs)*half-dxfirst*(one-qs**(nstr-ixs))/(one-qs)
1025 enddo
1026 ! right half
1027 do ixs=nstr+nuni+1,numxs
1028 dxs(ixs)=dxfirst*qs**(ixs-nstr-nuni-1)
1029 xs(ixs)=xsmax-lenstr+dxs(ixs)*half+dxfirst*(one-qs**(ixs-nstr-nuni-1))/(one-qs)
1030 enddo
1031 case default
1032 call mpistop("unknown stretch type")
1033 end select
1034
1035 if (los_phi==0 .and. los_theta==90 .and. direction_slit==2) then
1036 ! LOS->x slit->y
1037 dir_loc=3
1038 else if (los_phi==0 .and. los_theta==90 .and. direction_slit==3) then
1039 ! LOS->x slit->z
1040 dir_loc=2
1041 else if (los_phi==90 .and. los_theta==90 .and. direction_slit==1) then
1042 ! LOS->y slit->x
1043 dir_loc=3
1044 else if (los_phi==90 .and. los_theta==90 .and. direction_slit==3) then
1045 ! LOS->y slit->z
1046 dir_loc=1
1047 else if (los_theta==0 .and. direction_slit==1) then
1048 ! LOS->z slit->x
1049 dir_loc=2
1050 else if (los_theta==0 .and. direction_slit==2) then
1051 ! LOS->z slit->y
1052 dir_loc=1
1053 else
1054 call mpistop('Wrong combination of LOS and slit direction!')
1055 endif
1056
1057 if (dir_loc==1) then
1058 if (location_slit>xprobmax1 .or. location_slit<xprobmin1) then
1059 call mpistop('Wrong value for location_slit!')
1060 endif
1061 if(mype==0) write(*,'(a,f8.1,a)') ' Location of slit: x = ',location_slit,' Unit_length'
1062 else if (dir_loc==2) then
1063 if (location_slit>xprobmax2 .or. location_slit<xprobmin2) then
1064 call mpistop('Wrong value for location_slit!')
1065 endif
1066 if(mype==0) write(*,'(a,f8.1,a)') ' Location of slit: y = ',location_slit,' Unit_length'
1067 else
1068 if (location_slit>xprobmax3 .or. location_slit<xprobmin3) then
1069 call mpistop('Wrong value for location_slit!')
1070 endif
1071 if(mype==0) write(*,'(a,f8.1,a)') ' Location of slit: z = ',location_slit,' Unit_length'
1072 endif
1073
1074 ! find slit and do integration
1075 spectra=zero
1076 do iigrid=1,igridstail; igrid=igrids(iigrid);
1077 ^d&xbmin(^d)=rnode(rpxmin^d_,igrid);
1078 ^d&xbmax(^d)=rnode(rpxmax^d_,igrid);
1079 if (location_slit>=xbmin(dir_loc) .and. location_slit<xbmax(dir_loc)) then
1080 call integrate_spectra_datresol(igrid,wl,dwl,spectra,numwl,numxs,dir_loc,fl)
1081 endif
1082 enddo
1083
1084 nums=numwl*numxs
1085 call mpi_allreduce(spectra,spectra_rc,nums,mpi_double_precision, &
1086 mpi_sum,icomm,ierrmpi)
1087 do iwl=1,numwl
1088 do ixs=1,numxs
1089 if (spectra_rc(iwl,ixs)>smalldouble) then
1090 wi(iwl,ixs,1)=spectra_rc(iwl,ixs)
1091 else
1092 wi(iwl,ixs,1)=zero
1093 endif
1094 enddo
1095 enddo
1096
1097 call output_data(qunit,wl,xs,dwl,dxs,wi,numwl,numxs,numwi,datatype)
1098
1099 deallocate(wl,xs,dwl,dxs,spectra,spectra_rc,wi)
1100
1101 end subroutine get_spectrum_datresol
1102
1103 subroutine integrate_spectra_datresol(igrid,wL,dwL,spectra,numWL,numXS,dir_loc,fl)
1104 use mod_constants
1105
1106 integer, intent(in) :: igrid,numWL,numXS,dir_loc
1107 type(te_fluid), intent(in) :: fl
1108 double precision, intent(in) :: wL(numWL),dwL(numWL)
1109 double precision, intent(inout) :: spectra(numWL,numXS)
1110
1111 integer :: direction_LOS
1112 integer :: ixO^L,ixI^L,ix^D,ixOnew
1113 double precision, allocatable :: flux(:^D&),v(:^D&),Te(:^D&),rho(:^D&)
1114 double precision :: wlc,wlwd
1115
1116 integer :: mass
1117 double precision :: logTe,lineCent
1118 character (30) :: ion
1119 double precision :: spaceRsl,wlRsl,sigma_PSF,wslit
1120
1121 integer :: levelg,rft,ixSmin,ixSmax,iwL
1122 double precision :: flux_pix,dL
1123
1124 call get_line_info(spectrum_wl,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
1125
1126 if (los_phi==0 .and. los_theta==90) then
1127 direction_los=1
1128 else if (los_phi==90 .and. los_theta==90) then
1129 direction_los=2
1130 else
1131 direction_los=3
1132 endif
1133
1134 ^d&ixomin^d=ixmlo^d\
1135 ^d&ixomax^d=ixmhi^d\
1136 ^d&iximin^d=ixglo^d\
1137 ^d&iximax^d=ixghi^d\
1138 allocate(flux(ixi^s),v(ixi^s),te(ixi^s),rho(ixi^s))
1139
1140 ^d&ix^d=ixomin^d;
1141 if (dir_loc==1) then
1142 do ix1=ixomin1,ixomax1
1143 if (location_slit>=(ps(igrid)%x(ix^d,1)-half*ps(igrid)%dx(ix^d,1)) .and. &
1144 location_slit<(ps(igrid)%x(ix^d,1)+half*ps(igrid)%dx(ix^d,1))) then
1145 ixonew=ix1
1146 endif
1147 enddo
1148 ixomin1=ixonew
1149 ixomax1=ixonew
1150 else if (dir_loc==2) then
1151 do ix2=ixomin2,ixomax2
1152 if (location_slit>=(ps(igrid)%x(ix^d,2)-half*ps(igrid)%dx(ix^d,2)) .and. &
1153 location_slit<(ps(igrid)%x(ix^d,2)+half*ps(igrid)%dx(ix^d,2))) then
1154 ixonew=ix2
1155 endif
1156 enddo
1157 ixomin2=ixonew
1158 ixomax2=ixonew
1159 else
1160 do ix3=ixomin3,ixomax3
1161 if (location_slit>=(ps(igrid)%x(ix^d,3)-half*ps(igrid)%dx(ix^d,3)) .and. &
1162 location_slit<(ps(igrid)%x(ix^d,3)+half*ps(igrid)%dx(ix^d,3))) then
1163 ixonew=ix3
1164 endif
1165 enddo
1166 ixomin3=ixonew
1167 ixomax3=ixonew
1168 endif
1169
1170 call get_euv(spectrum_wl,ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux)
1171 flux(ixo^s)=flux(ixo^s)/instrument_resolution_factor**2 ! adjust flux due to artifical change of resolution
1172 call fl%get_rho(ps(igrid)%w,ps(igrid)%x,ixi^l,ixo^l,rho)
1173 v(ixo^s)=-ps(igrid)%w(ixo^s,iw_mom(direction_los))/rho(ixo^s)
1174 call fl%get_temperature(ps(igrid)%w,ps(igrid)%x,ixi^l,ixo^l,te)
1175
1176 ! grid parameters
1177 levelg=ps(igrid)%level
1178 rft=2**(refine_max_level-levelg)
1179
1180 {do ix^d=ixomin^d,ixomax^d\}
1181 if (flux(ix^d)>smalldouble) then
1182 if (si_unit) then
1183 wlc=linecent*(1.d0+v(ix^d)*unit_velocity*1.d2/const_c)
1184 else
1185 wlc=linecent*(1.d0+v(ix^d)*unit_velocity/const_c)
1186 endif
1187 wlwd=sqrt(kb_cgs*te(ix^d)*unit_temperature/(mass*mp_cgs))
1188 wlwd=wlwd*linecent/const_c
1189 ! involved pixel
1190 select case(direction_slit)
1191 case(1)
1192 ixsmin=(block_nx1*(node(pig1_,igrid)-1)+(ix1-ixomin1))*rft+1
1193 ixsmax=(block_nx1*(node(pig1_,igrid)-1)+(ix1-ixomin1+1))*rft
1194 case(2)
1195 ixsmin=(block_nx2*(node(pig2_,igrid)-1)+(ix2-ixomin2))*rft+1
1196 ixsmax=(block_nx2*(node(pig2_,igrid)-1)+(ix2-ixomin2+1))*rft
1197 case(3)
1198 ixsmin=(block_nx3*(node(pig3_,igrid)-1)+(ix3-ixomin3))*rft+1
1199 ixsmax=(block_nx3*(node(pig3_,igrid)-1)+(ix3-ixomin3+1))*rft
1200 end select
1201 ! LOS depth
1202 select case(direction_los)
1203 case(1)
1204 dl=ps(igrid)%dx(ix^d,1)*unit_length
1205 case(2)
1206 dl=ps(igrid)%dx(ix^d,2)*unit_length
1207 case default
1208 dl=ps(igrid)%dx(ix^d,3)*unit_length
1209 end select
1210 if (si_unit) dl=dl*1.d2
1211 ! integral pixel flux
1212 do iwl=1,numwl
1213 flux_pix=flux(ix^d)*wlrsl*dl*exp(-(wl(iwl)-wlc)**2/(2*wlwd**2))/(sqrt(2*dpi)*wlwd)
1214 if (flux_pix>smalldouble) then
1215 flux_pix=flux_pix*wslit/spacersl
1216 spectra(iwl,ixsmin:ixsmax)=spectra(iwl,ixsmin:ixsmax)+flux_pix
1217 endif
1218 enddo
1219 endif
1220 {enddo\}
1221
1222 deallocate(flux,v,te,rho)
1223
1224 end subroutine integrate_spectra_datresol
1225
1226 subroutine get_spectrum(qunit,datatype,fl)
1227
1228 integer, intent(in) :: qunit
1229 character(20), intent(in) :: datatype
1230 type(te_fluid), intent(in) :: fl
1231
1232 integer :: numWL,numXS,iwL,ixS,numWI,ix^D
1233 double precision :: dwLg,dxSg,xSmin,xSmax,xScent,wLmin,wLmax
1234 double precision, allocatable :: wL(:),xS(:),dwL(:),dxS(:)
1235 double precision, allocatable :: wI(:,:,:),spectra(:,:),spectra_rc(:,:)
1236 double precision :: vec_cor(1:3),xI_cor(1:2)
1237 double precision :: res,r_loc,r_max
1238
1239 integer :: mass
1240 character (30) :: ion
1241 double precision :: logTe,lineCent,sigma_PSF,spaceRsl,wlRsl,wslit
1242 double precision :: unitv,arcsec,RHESSI_rsl,pixel
1243 integer :: iigrid,igrid,i,j,numS
1244 double precision :: xLmin,xLmax,xslit
1245
1246 if (coordinate==spherical) then
1248 else
1249 ! cartesian
1251 endif
1252
1253 ! calculate domain in space
1254 if (coordinate==spherical) then
1255 xsmin=-abs(xprobmax1)
1256 xsmax=abs(xprobmax1)
1257 else
1258 do ix1=1,2
1259 if (ix1==1) vec_cor(1)=xprobmin1
1260 if (ix1==2) vec_cor(1)=xprobmax1
1261 do ix2=1,2
1262 if (ix2==1) vec_cor(2)=xprobmin2
1263 if (ix2==2) vec_cor(2)=xprobmax2
1264 do ix3=1,2
1265 if (ix3==1) vec_cor(3)=xprobmin3
1266 if (ix3==2) vec_cor(3)=xprobmax3
1267 if (big_image) then
1268 r_loc=(vec_cor(1)-x_origin(1))**2
1269 r_loc=r_loc+(vec_cor(2)-x_origin(2))**2
1270 r_loc=r_loc+(vec_cor(3)-x_origin(3))**2
1271 r_loc=sqrt(r_loc)
1272 if (ix1==1 .and. ix2==1 .and. ix3==1) then
1273 r_max=r_loc
1274 else
1275 r_max=max(r_max,r_loc)
1276 endif
1277 else
1278 call get_cor_image(vec_cor,xi_cor)
1279 if (ix1==1 .and. ix2==1 .and. ix3==1) then
1280 xsmin=xi_cor(2)
1281 xsmax=xi_cor(2)
1282 else
1283 xsmin=min(xsmin,xi_cor(2))
1284 xsmax=max(xsmax,xi_cor(2))
1285 endif
1286 endif
1287 enddo
1288 enddo
1289 enddo
1290 if (big_image) then
1291 xsmin=-r_max
1292 xsmax=r_max
1293 endif
1294 endif
1295 xscent=(xsmin+xsmax)/2.d0
1296
1297 ! tables for storing spectra data
1298 if (si_unit) then
1299 arcsec=7.25d5/unit_length
1300 else
1301 arcsec=7.25d7/unit_length
1302 endif
1303 call get_line_info(spectrum_wl,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
1304 dxsg=spacersl*arcsec
1305 numxs=ceiling((xsmax-xscent)/dxsg)
1306 xsmin=xscent-numxs*dxsg
1307 xsmax=xscent+numxs*dxsg
1308 numxs=numxs*2
1309 dwlg=wlrsl
1310 numwl=2*int((spectrum_window_max-spectrum_window_min)/(2.d0*dwlg))
1311 wlmin=(spectrum_window_max+spectrum_window_min)/2.d0-dwlg*numwl/2
1312 wlmax=(spectrum_window_max+spectrum_window_min)/2.d0+dwlg*numwl/2
1313 allocate(wl(numwl),dwl(numwl),xs(numxs),dxs(numxs))
1314 numwi=1
1315 allocate(wi(numwl,numxs,numwi),spectra(numwl,numxs),spectra_rc(numwl,numxs))
1316 do iwl=1,numwl
1317 wl(iwl)=wlmin+iwl*dwlg-half*dwlg
1318 dwl=dwlg
1319 enddo
1320 do ixs=1,numxs
1321 xs(ixs)=xsmin+dxsg*(ixs-half)
1322 dxs(ixs)=dxsg
1323 enddo
1324
1325 ! find slit and do integration
1326 spectra=zero
1327 do iigrid=1,igridstail; igrid=igrids(iigrid);
1328 do ix1=1,2
1329 if (ix1==1) vec_cor(1)=rnode(rpxmin1_,igrid)
1330 if (ix1==2) vec_cor(1)=rnode(rpxmax1_,igrid)
1331 do ix2=1,2
1332 if (ix2==1) vec_cor(2)=rnode(rpxmin2_,igrid)
1333 if (ix2==2) vec_cor(2)=rnode(rpxmax2_,igrid)
1334 do ix3=1,2
1335 if (ix3==1) vec_cor(3)=rnode(rpxmin3_,igrid)
1336 if (ix3==2) vec_cor(3)=rnode(rpxmax3_,igrid)
1337 call get_cor_image(vec_cor,xi_cor)
1338 if (ix1==1 .and. ix2==1 .and. ix3==1) then
1339 xlmin=xi_cor(1)
1340 xlmax=xi_cor(1)
1341 else
1342 xlmin=min(xlmin,xi_cor(1))
1343 xlmax=max(xlmax,xi_cor(1))
1344 endif
1345 enddo
1346 enddo
1347 enddo
1348
1349 if (activate_unit_arcsec) then
1350 xslit=location_slit*arcsec
1351 else
1352 xslit=location_slit
1353 endif
1354 if (xslit>=xlmin-wslit*arcsec .and. xslit<=xlmax+wslit*arcsec) then
1355 call integrate_spectra_cartesian(igrid,wl,dwlg,xs,dxsg,spectra,numwl,numxs,fl)
1356 endif
1357 enddo
1358
1359 nums=numwl*numxs
1360 call mpi_allreduce(spectra,spectra_rc,nums,mpi_double_precision, &
1361 mpi_sum,icomm,ierrmpi)
1362 do iwl=1,numwl
1363 do ixs=1,numxs
1364 if (spectra_rc(iwl,ixs)>smalldouble) then
1365 wi(iwl,ixs,1)=spectra_rc(iwl,ixs)
1366 else
1367 wi(iwl,ixs,1)=zero
1368 endif
1369 enddo
1370 enddo
1371
1372 if (activate_unit_arcsec) then
1373 xs=xs/arcsec
1374 dxs=dxs/arcsec
1375 endif
1376
1377 call output_data(qunit,wl,xs,dwl,dxs,wi,numwl,numxs,numwi,datatype)
1378
1379 deallocate(wl,xs,dwl,dxs,spectra,spectra_rc,wi)
1380
1381 end subroutine get_spectrum
1382
1383 subroutine integrate_spectra_cartesian(igrid,wL,dwLg,xS,dxSg,spectra,numWL,numXS,fl)
1384
1385 integer, intent(in) :: igrid,numWL,numXS
1386 double precision, intent(in) :: wL(numWL),xS(numXS)
1387 double precision, intent(in) :: dwLg,dxSg
1388 double precision, intent(inout) :: spectra(numWL,numXS)
1389 type(te_fluid), intent(in) :: fl
1390
1391 integer :: ixO^L,ixI^L,ix^D,ixOnew,j
1392 double precision, allocatable :: flux(:^D&),v(:^D&),Te(:^D&),rho(:^D&)
1393 double precision :: wlc,wlwd,res,dst_slit,xslit,arcsec
1394 double precision :: vloc(1:3),xloc(1:3),dxloc(1:3),xIloc(1:2),dxIloc(1:2)
1395 integer :: nSubC^D,iSubC^D,iwL,ixS,ixSmin,ixSmax,iwLmin,iwLmax,nwL
1396 double precision :: slit_width,dxSubC^D,xerf^L,fluxSubC
1397 double precision :: xSubC(1:3),xCent(1:2)
1398
1399 integer :: mass
1400 double precision :: logTe,lineCent
1401 character (30) :: ion
1402 double precision :: spaceRsl,wlRsl,sigma_PSF,wslit
1403 double precision :: sigma_wl,sigma_xs,factor
1404
1405 if (si_unit) then
1406 arcsec=7.25d5/unit_length
1407 else
1408 arcsec=7.25d7/unit_length
1409 endif
1410 if (activate_unit_arcsec) then
1411 xslit=location_slit*arcsec
1412 else
1413 xslit=location_slit
1414 endif
1415
1416 call get_line_info(spectrum_wl,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
1417
1418 ^d&ixomin^d=ixmlo^d\
1419 ^d&ixomax^d=ixmhi^d\
1420 ^d&iximin^d=ixglo^d\
1421 ^d&iximax^d=ixghi^d\
1422 allocate(flux(ixi^s),v(ixi^s),te(ixi^s),rho(ixi^s))
1423 ! get local EUV flux and velocity
1424 call get_euv(spectrum_wl,ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux)
1425 flux(ixo^s)=flux(ixo^s)/instrument_resolution_factor**2 ! adjust flux due to artifical change of resolution
1426 call fl%get_rho(ps(igrid)%w,ps(igrid)%x,ixi^l,ixo^l,rho)
1427 call fl%get_temperature(ps(igrid)%w,ps(igrid)%x,ixi^l,ixo^l,te)
1428 {do ix^d=ixomin^d,ixomax^d\}
1429 do j=1,3
1430 vloc(j)=ps(igrid)%w(ix^d,iw_mom(j))/rho(ix^d)
1431 enddo
1432 call dot_product_loc(vloc,vec_los,res)
1433 v(ix^d)=res
1434 {enddo\}
1435
1436 deallocate(rho)
1437
1438 slit_width=wslit*arcsec
1439 sigma_wl=sigma_psf*dwlg
1440 sigma_xs=sigma_psf*dxsg
1441 {do ix^d=ixomin^d,ixomax^d\}
1442 if (flux(ix^d)>smalldouble) then
1443 xloc(1:3)=ps(igrid)%x(ix^d,1:3)
1444 dxloc(1:3)=ps(igrid)%dx(ix^d,1:3)
1445 call get_cor_image(xloc,xiloc)
1446 call dot_product_loc(dxloc,vec_xi1,res)
1447 dxiloc(1)=abs(res)
1448 if (xiloc(1)>=xslit-half*(slit_width+dxiloc(1)) .and. &
1449 xiloc(1)<=xslit+half*(slit_width+dxiloc(1))) then
1450 ^d&nsubc^d=1;
1451 ^d&nsubc^d=max(nsubc^d,ceiling(ps(igrid)%dx(ix^dd,^d)*abs(vec_xi1(^d))/(slit_width/16.d0)));
1452 ^d&nsubc^d=max(nsubc^d,ceiling(ps(igrid)%dx(ix^dd,^d)*abs(vec_xi2(^d))/(dxsg/4.d0)));
1453 ^d&dxsubc^d=ps(igrid)%dx(ix^dd,^d)/nsubc^d;
1454 ! local line center and line width
1455 if (si_unit) then
1456 fluxsubc=flux(ix^d)*dxsubc1*dxsubc2*dxsubc3*unit_length*1.d2/dxsg/dxsg ! DN s^-1
1457 wlc=linecent*(1.d0+v(ix^d)*unit_velocity*1.d2/const_c)
1458 else
1459 fluxsubc=flux(ix^d)*dxsubc1*dxsubc2*dxsubc3*unit_length/dxsg/dxsg ! DN s^-1
1460 wlc=linecent*(1.d0+v(ix^d)*unit_velocity/const_c)
1461 endif
1462 wlwd=sqrt(kb_cgs*te(ix^d)*unit_temperature/(mass*mp_cgs))
1463 wlwd=wlwd*linecent/const_c
1464 ! dividing a cell to several parts to get more accurate integrating values
1465 {do isubc^d=1,nsubc^d\}
1466 ^d&xsubc(^d)=xloc(^d)-half*dxloc(^d)+(isubc^d-half)*dxsubc^d;
1467 call get_cor_image(xsubc,xcent)
1468 dst_slit=abs(xcent(1)-xslit) ! space distance to slit center
1469 if (dst_slit<=half*slit_width) then
1470 ixs=floor((xcent(2)-(xs(1)-half*dxsg))/dxsg)+1
1471 ixsmin=max(1,ixs-3)
1472 ixsmax=min(ixs+3,numxs)
1473 iwl=floor((wlc-(wl(1)-half*dwlg))/dwlg)+1
1474 nwl=3*ceiling(wlwd/dwlg+1)
1475 iwlmin=max(1,iwl-nwl)
1476 iwlmax=min(iwl+nwl,numwl)
1477 ! calculate the contribution to nearby pixels
1478 do iwl=iwlmin,iwlmax
1479 do ixs=ixsmin,ixsmax
1480 xerfmin1=(wl(iwl)-half*dwlg-wlc)/sqrt(2.d0*(sigma_wl**2+wlwd**2))
1481 xerfmax1=(wl(iwl)+half*dwlg-wlc)/sqrt(2.d0*(sigma_wl**2+wlwd**2))
1482 xerfmin2=(xs(ixs)-half*dxsg-xcent(2))/(sqrt(2.d0)*sigma_xs)
1483 xerfmax2=(xs(ixs)+half*dxsg-xcent(2))/(sqrt(2.d0)*sigma_xs)
1484 factor=(erfc(xerfmin1)-erfc(xerfmax1))*(erfc(xerfmin2)-erfc(xerfmax2))/4.d0
1485 spectra(iwl,ixs)=spectra(iwl,ixs)+fluxsubc*factor
1486 enddo
1487 enddo
1488 ! nearby pixels
1489 endif
1490 {enddo\}
1491 endif
1492 endif
1493 {enddo\}
1494
1495 deallocate(flux,v,te)
1496 end subroutine integrate_spectra_cartesian
1497 }
1498
1499 {^ifthreed
1500 subroutine get_euv_image(qunit,fl)
1502
1503 integer, intent(in) :: qunit
1504 type(te_fluid), intent(in) :: fl
1505 character(20) :: datatype
1506
1507 integer :: mass
1508 character (30) :: ion
1509 double precision :: logTe,lineCent,sigma_PSF,spaceRsl,wlRsl,wslit
1510 double precision :: t0,t1
1511
1512 t0=mpi_wtime()
1513 datatype='image_euv'
1514 call get_line_info(wavelength,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
1515
1516 if (mype==0) then
1517 print *, '###################################################'
1518 print *, 'Systhesizing EUV image'
1519 write(*,'(a,f8.3,a)') ' Wavelength: ',linecent,' Angstrom'
1520 print *, 'Unit of EUV flux: DN s^-1 pixel^-1'
1521 endif
1522
1523 if (dat_resolution) then
1524 if (coordinate/=cartesian) call mpistop('EUV synthesis: only cartesian is supported for .dat resolution!')
1525 if (mype==0) then
1526 write(*,'(a,f7.1,a,f7.1,a,f5.1,a,f5.1,a)') ' Supposed Pixel: ',spacersl*725.0,' km x ',spacersl*725.0, &
1527 ' km (', spacersl, ' arcsec x ', spacersl, ' arcsec)'
1528 if (si_unit) then
1529 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d6,' Mm'
1530 else
1531 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d8,' Mm'
1532 endif
1533 endif
1534 if (los_phi==0 .and. los_theta==90) then
1535 call get_image_datresol(qunit,datatype,fl)
1536 else if (los_phi==90 .and. los_theta==90) then
1537 call get_image_datresol(qunit,datatype,fl)
1538 else if (los_theta==0) then
1539 call get_image_datresol(qunit,datatype,fl)
1540 else
1541 call mpistop('ERROR: Wrong LOS for synthesizing emission!')
1542 endif
1543 else
1544 if (mype==0) then
1545 write(*,'(a,f7.1,a,f7.1,a,f5.1,a,f5.1,a)') ' Pixel: ',spacersl*725.0,' km x ',spacersl*725.0, ' km (', &
1546 spacersl, ' arcsec x ', spacersl, ' arcsec)'
1547 if (activate_unit_arcsec) then
1548 print *, 'Unit of length: arcsec (~725 km)'
1549 else
1550 if (si_unit) then
1551 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d6,' Mm'
1552 else
1553 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d8,' Mm'
1554 endif
1555 endif
1556 endif
1557 if (coordinate==cartesian) then
1558 if (mype==0) write(*,'(a,f8.3,f8.3,f8.3,a)') ' Mapping: [',x_origin(1),x_origin(2),x_origin(3), &
1559 '] of the simulation box is located at [X=0,Y=0] of the image'
1560 call get_image(qunit,datatype,fl)
1561 else if (coordinate==spherical) then
1562 if (mype==0) write(*,'(a,f6.3,f8.3,f8.3,a)') ' Mapping: R=0 of the simulation box is located at [X=0,Y=0] of the image'
1563 call get_image(qunit,datatype,fl)
1564 else
1565 call mpistop("EUV synthesis: this coordinate is not supported!")
1566 endif
1567 endif
1568
1569 t1=mpi_wtime()
1570 if (mype==0) print *, 'time comsuming: ',t1-t0,' s'
1571 if (mype==0) print *, '###################################################'
1572
1573 end subroutine get_euv_image
1574
1575 subroutine get_sxr_image(qunit,fl)
1577
1578 integer, intent(in) :: qunit
1579 type(te_fluid), intent(in) :: fl
1580 character(20) :: datatype
1581 double precision :: RHESSI_rsl
1582 double precision :: t0,t1
1583
1584 t0=mpi_wtime()
1585 datatype='image_sxr'
1586 rhessi_rsl=2.3/instrument_resolution_factor
1587
1588 if (mype==0) then
1589 print *, '###################################################'
1590 print *, 'Systhesizing SXR image (observed at 1 AU).'
1591 write(*,'(a,i2,a,i2,a)') ' Passband: ',emin_sxr,' - ',emax_sxr,' keV'
1592 endif
1593
1594 if (dat_resolution) then
1595 if (coordinate/=cartesian) call mpistop('SXR synthesis: only cartesian is supported for .dat resolution!')
1596 if (mype==0) then
1597 print *, 'Unit of SXR flux: photons cm^-2 s^-1 pixel^-1'
1598 write(*,'(a,f5.1,a,f5.1,a,f5.1,a,f5.1,a)') ' Supposed Pixel: ',rhessi_rsl*0.725, ' Mm x ',rhessi_rsl*0.725, &
1599 ' Mm (', rhessi_rsl, ' arcsec x ', rhessi_rsl, ' arcsec)'
1600 if (si_unit) then
1601 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d6,' Mm'
1602 else
1603 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d8,' Mm'
1604 endif
1605 endif
1606 if (los_phi==0 .and. los_theta==90) then
1607 call get_image_datresol(qunit,datatype,fl)
1608 else if (los_phi==90 .and. los_theta==90) then
1609 call get_image_datresol(qunit,datatype,fl)
1610 else if (los_theta==0) then
1611 call get_image_datresol(qunit,datatype,fl)
1612 else
1613 call mpistop('ERROR: Wrong LOS for synthesizing emission!')
1614 endif
1615 else
1616 if (mype==0) then
1617 print *, 'Unit of SXR flux: photons cm^-2 s^-1 pixel^-1'
1618 write(*,'(a,f5.1,a,f5.1,a,f5.1,a,f5.1,a)') ' Pixel: ',rhessi_rsl*0.725, ' Mm x ',rhessi_rsl*0.725, &
1619 ' Mm (', rhessi_rsl, ' arcsec x ', rhessi_rsl, ' arcsec)'
1620 if (activate_unit_arcsec) then
1621 print *, 'Unit of length: arcsec (~725 km)'
1622 else
1623 if (si_unit) then
1624 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d6,' Mm'
1625 else
1626 write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d8,' Mm'
1627 endif
1628 endif
1629 endif
1630 if (coordinate==cartesian) then
1631 if (mype==0) write(*,'(a,f8.3,f8.3,f8.3,a)') ' Mapping: [',x_origin(1),x_origin(2),x_origin(3), &
1632 '] of the simulation box is located at [X=0,Y=0] of the image'
1633 call get_image(qunit,datatype,fl)
1634 else if (coordinate==spherical) then
1635 if (mype==0) write(*,'(a,f6.3,f8.3,f8.3,a)') ' Mapping: R=0 of the simulation box is located at [X=0,Y=0] of the image'
1636 call get_image(qunit,datatype,fl)
1637 else
1638 call mpistop("SXR synthesis: this coordinate is not supported!")
1639 endif
1640 endif
1641
1642 t1=mpi_wtime()
1643 if (mype==0) print *, 'time comsuming:',t1-t0
1644 if (mype==0) print *, '###################################################'
1645
1646 end subroutine get_sxr_image
1647
1648 subroutine get_whitelight_image(qunit,fl)
1650
1651 integer, intent(in) :: qunit
1652 type(te_fluid), intent(in) :: fl
1653 character(20) :: datatype
1654 double precision :: LASCO_rsl
1655
1656 if (mype==0) print *, '###################################################'
1657
1658 if (whitelight_instrument=='LASCO/C1') then
1659 lasco_rsl=5.6d0/instrument_resolution_factor
1660 if (mype==0) print *, 'Systhesizing white light image (observed by LASCO/C1).'
1661 else if (whitelight_instrument=='LASCO/C2') then
1662 lasco_rsl=11.4d0/instrument_resolution_factor
1663 if (mype==0) print *, 'Systhesizing white light image (observed by LASCO/C2).'
1664 else if (whitelight_instrument=='LASCO/C3') then
1665 lasco_rsl=56.d0/instrument_resolution_factor
1666 if (mype==0) print *, 'Systhesizing white light image (observed by LASCO/C3).'
1667 else
1668 call mpistop('Whitelight synthesis: instrument is not supported!')
1669 endif
1670
1671 if (mype==0) write(*,'(a,f5.1,a,f5.1,a,f5.1,a,f5.1,a)') ' Pixel: ',lasco_rsl*0.725,' Mm x ',lasco_rsl*0.725, ' Mm (', &
1672 lasco_rsl, ' arcsec x ', lasco_rsl, ' arcsec) '
1673 if (mype==0) print *, 'Unit of white light flux: average Sun brightness'
1674
1675 datatype='image_whitelight'
1676
1677 if (mype==0) then
1678 if (activate_unit_arcsec) then
1679 print *, 'Unit of length: arcsec (~725 km)'
1680 else
1681 if (si_unit) then
1682 if (mype==0) write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d6,' Mm'
1683 else
1684 if (mype==0) write(*,'(a,f8.1,a)') ' Unit of length: ',unit_length/1.d8,' Mm'
1685 endif
1686 endif
1687 endif
1688
1689 if (coordinate==spherical) then
1690 if (mype==0) write(*,'(a,f6.3,f8.3,f8.3,a)') ' Mapping: R=0 of the simulation box is located at [X=0,Y=0] of the image'
1691 call get_image(qunit,datatype,fl)
1692 else
1693 call mpistop("Whitelight synthesis: this coordinate is not supported!")
1694 endif
1695
1696 if (mype==0) print *, '###################################################'
1697
1698 end subroutine get_whitelight_image
1699
1700 subroutine get_image_datresol(qunit,datatype,fl)
1701 ! integrate emission flux along line of sight (LOS)
1702 ! in a 3D simulation box and get a 2D EUV image
1704 use mod_constants
1705
1706 integer, intent(in) :: qunit
1707 character(20), intent(in) :: datatype
1708 type(te_fluid), intent(in) :: fl
1709
1710 double precision :: dx^D
1711 integer :: numX^D,ix^D
1712 double precision, allocatable :: EUV(:,:),EUVs(:,:),Dpl(:,:),Dpls(:,:)
1713 double precision, allocatable :: SXR(:,:),SXRs(:,:),wI(:,:,:)
1714 double precision, allocatable :: xI1(:),xI2(:),dxI1(:),dxI2(:),dxIi
1715 integer :: numXI1,numXI2,numSI,numWI
1716 double precision :: xI^L
1717 integer :: iigrid,igrid,i,j
1718 double precision, allocatable :: xIF1(:),xIF2(:),dxIF1(:),dxIF2(:)
1719 integer :: nXIF1,nXIF2
1720 double precision :: xIF^L
1721
1722 double precision :: unitv,arcsec,RHESSI_rsl
1723 integer :: strtype^D,nstrb^D,nbb^D,nuni^D,nstr^D,bnx^D
1724 double precision :: qs^D,dxfirst^D,dxmid^D,lenstr^D
1725
1726 numx1=domain_nx1*2**(refine_max_level-1)
1727 numx2=domain_nx2*2**(refine_max_level-1)
1728 numx3=domain_nx3*2**(refine_max_level-1)
1729
1730 ! parameters for creating table
1731 if (los_phi==0 .and. los_theta==90) then
1732 nxif1=domain_nx2*2**(refine_max_level-1)
1733 nxif2=domain_nx3*2**(refine_max_level-1)
1734 xifmin1=xprobmin2
1735 xifmax1=xprobmax2
1736 xifmin2=xprobmin3
1737 xifmax2=xprobmax3
1738 bnx1=block_nx2
1739 bnx2=block_nx3
1740 nbb1=domain_nx2
1741 nbb2=domain_nx3
1742 strtype1=stretch_type(2)
1743 strtype2=stretch_type(3)
1746 qs1=qstretch_baselevel(2)
1747 qs2=qstretch_baselevel(3)
1748 if (mype==0) write(*,'(a)') ' LOS vector: [-1.00 0.00 0.00]'
1749 if (mype==0) write(*,'(a)') ' xI1 vector: [ 0.00 1.00 0.00]'
1750 if (mype==0) write(*,'(a)') ' xI2 vector: [ 0.00 0.00 1.00]'
1751 else if (los_phi==90 .and. los_theta==90) then
1752 nxif1=domain_nx3*2**(refine_max_level-1)
1753 nxif2=domain_nx1*2**(refine_max_level-1)
1754 xifmin1=xprobmin3
1755 xifmax1=xprobmax3
1756 xifmin2=xprobmin1
1757 xifmax2=xprobmax1
1758 bnx1=block_nx3
1759 bnx2=block_nx1
1760 nbb1=domain_nx3
1761 nbb2=domain_nx1
1762 strtype1=stretch_type(3)
1763 strtype2=stretch_type(1)
1766 qs1=qstretch_baselevel(3)
1767 qs2=qstretch_baselevel(1)
1768 if (mype==0) write(*,'(a)') ' LOS vector: [ 0.00 -1.00 0.00]'
1769 if (mype==0) write(*,'(a)') ' xI1 vector: [-1.00 0.00 0.00]'
1770 if (mype==0) write(*,'(a)') ' xI2 vector: [ 0.00 0.00 1.00]'
1771 else
1772 nxif1=domain_nx1*2**(refine_max_level-1)
1773 nxif2=domain_nx2*2**(refine_max_level-1)
1774 xifmin1=xprobmin1
1775 xifmax1=xprobmax1
1776 xifmin2=xprobmin2
1777 xifmax2=xprobmax2
1778 bnx1=block_nx1
1779 bnx2=block_nx2
1780 nbb1=domain_nx1
1781 nbb2=domain_nx2
1782 strtype1=stretch_type(1)
1783 strtype2=stretch_type(2)
1786 qs1=qstretch_baselevel(1)
1787 qs2=qstretch_baselevel(2)
1788 if (mype==0) write(*,'(a)') ' LOS vector: [ 0.00 0.00 -1.00]'
1789 if (mype==0) write(*,'(a)') ' xI1 vector: [ 1.00 0.00 0.00]'
1790 if (mype==0) write(*,'(a)') ' xI2 vector: [ 0.00 1.00 0.00]'
1791 endif
1792 allocate(xif1(nxif1),xif2(nxif2),dxif1(nxif1),dxif2(nxif2))
1793
1794 ! initialize image coordinate
1795 select case(strtype1)
1796 case(0) ! uniform
1797 dxif1(:)=(xifmax1-xifmin1)/nxif1
1798 do ix1=1,nxif1
1799 xif1(ix1)=xifmin1+dxif1(ix1)*(ix1-half)
1800 enddo
1801 case(1) ! uni stretch
1802 qs1=qs1**(one/2**(refine_max_level-1))
1803 dxfirst1=(xifmax1-xifmin1)*(one-qs1)/(one-qs1**nxif1)
1804 dxif1(1)=dxfirst1
1805 do ix1=2,nxif1
1806 dxif1(ix1)=dxfirst1*qs1**(ix1-1)
1807 xif1(ix1)=dxif1(1)/(one-qs1)*(one-qs1**(ix1-1))+half*dxif1(ix1)
1808 enddo
1809 case(2) ! symm stretch
1810 ! base level, nbb = nstr + nuni + nstr
1811 nstr1=nstrb1*bnx1/2
1812 nuni1=nbb1-nstrb1*bnx1
1813 lenstr1=(xifmax1-xifmin1)/(2.d0+nuni1*(one-qs1)/(one-qs1**nstr1))
1814 dxfirst1=(xifmax1-xifmin1)/(dble(nuni1)+2.d0/(one-qs1)*(one-qs1**nstr1))
1815 dxmid1=dxfirst1
1816 ! refine_max level, numXI = nstr + nuni + nstr
1817 nstr1=nstr1*2**(refine_max_level-1)
1818 nuni1=nuni1*2**(refine_max_level-1)
1819 qs1=qs1**(one/2**(refine_max_level-1))
1820 dxfirst1=lenstr1*(one-qs1)/(one-qs1**nstr1)
1821 dxmid1=dxmid1/2**(refine_max_level-1)
1822 ! uniform center
1823 if(nuni1 .gt. 0) then
1824 do ix1=nstr1+1,nstr1+nuni1
1825 dxif1(ix1)=dxmid1
1826 xif1(ix1)=lenstr1+(dble(ix1)-0.5d0-nstr1)*dxif1(ix1)+xifmin1
1827 enddo
1828 endif
1829 ! left half
1830 do ix1=nstr1,1,-1
1831 dxif1(ix1)=dxfirst1*qs1**(nstr1-ix1)
1832 xif1(ix1)=xifmin1+lenstr1-dxif1(ix1)*half-dxfirst1*(one-qs1**(nstr1-ix1))/(one-qs1)
1833 enddo
1834 ! right half
1835 do ix1=nstr1+nuni1+1,nxif1
1836 dxif1(ix1)=dxfirst1*qs1**(ix1-nstr1-nuni1-1)
1837 xif1(ix1)=xifmax1-lenstr1+dxif1(ix1)*half+dxfirst1*(one-qs1**(ix1-nstr1-nuni1-1))/(one-qs1)
1838 enddo
1839 case default
1840 call mpistop("unknown stretch type")
1841 end select
1842
1843 select case(strtype2)
1844 case(0) ! uniform
1845 dxif2(:)=(xifmax2-xifmin2)/nxif2
1846 do ix2=1,nxif2
1847 xif2(ix2)=xifmin2+dxif2(ix2)*(ix2-half)
1848 enddo
1849 case(1) ! uni stretch
1850 qs2=qs2**(one/2**(refine_max_level-1))
1851 dxfirst2=(xifmax2-xifmin2)*(one-qs2)/(one-qs2**nxif2)
1852 dxif2(1)=dxfirst2
1853 do ix2=2,nxif1
1854 dxif2(ix2)=dxfirst2*qs2**(ix2-1)
1855 xif2(ix2)=dxif2(1)/(one-qs2)*(one-qs2**(ix2-1))+half*dxif2(ix2)
1856 enddo
1857 case(2) ! symm stretch
1858 ! base level, nbb = nstr + nuni + nstr
1859 nstr2=nstrb2*bnx2/2
1860 nuni2=nbb2-nstrb2*bnx2
1861 lenstr2=(xifmax2-xifmin2)/(2.d0+nuni2*(one-qs2)/(one-qs2**nstr2))
1862 dxfirst2=(xifmax2-xifmin2)/(dble(nuni2)+2.d0/(one-qs2)*(one-qs2**nstr2))
1863 dxmid2=dxfirst2
1864 ! refine_max level, numXI = nstr + nuni + nstr
1865 nstr2=nstr2*2**(refine_max_level-1)
1866 nuni2=nuni2*2**(refine_max_level-1)
1867 qs2=qs2**(one/2**(refine_max_level-1))
1868 dxfirst2=lenstr2*(one-qs2)/(one-qs2**nstr2)
1869 dxmid2=dxmid2/2**(refine_max_level-1)
1870 ! uniform center
1871 if(nuni2 .gt. 0) then
1872 do ix2=nstr2+1,nstr2+nuni2
1873 dxif2(ix2)=dxmid2
1874 xif2(ix2)=lenstr2+(dble(ix2)-0.5d0-nstr2)*dxif2(ix2)+xifmin2
1875 enddo
1876 endif
1877 ! left half
1878 do ix2=nstr2,1,-1
1879 dxif2(ix2)=dxfirst2*qs2**(nstr2-ix2)
1880 xif2(ix2)=xifmin2+lenstr2-dxif2(ix2)*half-dxfirst2*(one-qs2**(nstr2-ix2))/(one-qs2)
1881 enddo
1882 ! right half
1883 do ix2=nstr2+nuni2+1,nxif2
1884 dxif2(ix2)=dxfirst2*qs2**(ix2-nstr2-nuni2-1)
1885 xif2(ix2)=xifmax2-lenstr2+dxif2(ix2)*half+dxfirst2*(one-qs2**(ix2-nstr2-nuni2-1))/(one-qs2)
1886 enddo
1887 case default
1888 call mpistop("unknown stretch type")
1889 end select
1890
1891 ! integrate EUV flux and get cell average flux for image
1892 if (datatype=='image_euv') then
1893 if (si_unit) then
1894 unitv=unit_velocity/1.0e3 ! km/s
1895 else
1896 unitv=unit_velocity/1.0e5 ! km/s
1897 endif
1898 numwi=2
1899 allocate(wi(nxif1,nxif2,numwi))
1900 allocate(euvs(nxif1,nxif2),euv(nxif1,nxif2))
1901 allocate(dpl(nxif1,nxif2),dpls(nxif1,nxif2))
1902 euvs=0.0d0
1903 euv=0.0d0
1904 dpl=0.d0
1905 dpls=0.d0
1906 do iigrid=1,igridstail; igrid=igrids(iigrid);
1907 call integrate_euv_datresol(igrid,nxif1,nxif2,xif1,xif2,dxif1,dxif2,fl,euvs,dpls)
1908 enddo
1909 numsi=nxif1*nxif2
1910 call mpi_allreduce(euvs,euv,numsi,mpi_double_precision, &
1911 mpi_sum,icomm,ierrmpi)
1912 call mpi_allreduce(dpls,dpl,numsi,mpi_double_precision, &
1913 mpi_sum,icomm,ierrmpi)
1914 do ix1=1,nxif1
1915 do ix2=1,nxif2
1916 if (euv(ix1,ix2)<smalldouble) euv(ix1,ix2)=zero
1917 if(euv(ix1,ix2)/=0) then
1918 dpl(ix1,ix2)=(dpl(ix1,ix2)/euv(ix1,ix2))*unitv
1919 else
1920 dpl(ix1,ix2)=0.d0
1921 endif
1922 if (abs(dpl(ix1,ix2))<smalldouble) dpl(ix1,ix2)=zero
1923 enddo
1924 enddo
1925 wi(:,:,1)=euv(:,:)
1926 wi(:,:,2)=dpl(:,:)
1927
1928 call output_data(qunit,xif1,xif2,dxif1,dxif2,wi,nxif1,nxif2,numwi,datatype)
1929 deallocate(wi,euv,euvs,dpl,dpls)
1930 endif
1931
1932 ! integrate SXR flux and get cell average flux for image
1933 if (datatype=='image_sxr') then
1934 if (si_unit) then
1935 arcsec=7.25d5
1936 else
1937 arcsec=7.25d7
1938 endif
1939 rhessi_rsl=2.3d0/instrument_resolution_factor
1940 numwi=1
1941 allocate(wi(nxif1,nxif2,numwi))
1942 allocate(sxrs(nxif1,nxif2),sxr(nxif1,nxif2))
1943 sxrs=0.0d0
1944 sxr=0.0d0
1945 do iigrid=1,igridstail; igrid=igrids(iigrid);
1946 call integrate_sxr_datresol(igrid,nxif1,nxif2,xif1,xif2,dxif1,dxif2,fl,sxrs)
1947 enddo
1948 numsi=nxif1*nxif2
1949 call mpi_allreduce(sxrs,sxr,numsi,mpi_double_precision, &
1950 mpi_sum,icomm,ierrmpi)
1951
1952 sxr=sxr*(rhessi_rsl*arcsec)**2 ! photons cm^-2 s^-1 pixel^-1
1953 do ix1=1,nxif1
1954 do ix2=1,nxif2
1955 if (sxr(ix1,ix2)<smalldouble) sxr(ix1,ix2)=zero
1956 enddo
1957 enddo
1958 wi(:,:,1)=sxr(:,:)
1959
1960 call output_data(qunit,xif1,xif2,dxif1,dxif2,wi,nxif1,nxif2,numwi,datatype)
1961 deallocate(wi,sxr,sxrs)
1962 endif
1963
1964 deallocate(xif1,xif2,dxif1,dxif2)
1965
1966 end subroutine get_image_datresol
1967
1968 subroutine integrate_sxr_datresol(igrid,nXIF1,nXIF2,xIF1,xIF2,dxIF1,dxIF2,fl,SXR)
1970
1971 integer, intent(in) :: igrid,nXIF1,nXIF2
1972 double precision, intent(in) :: xIF1(nXIF1),xIF2(nXIF2)
1973 double precision, intent(in) :: dxIF1(nXIF1),dxIF2(nXIF2)
1974 type(te_fluid), intent(in) :: fl
1975 double precision, intent(out) :: SXR(nXIF1,nXIF2)
1976
1977 integer :: ixO^L,ixO^D,ixI^L,ix^D,i,j
1978 double precision :: xb^L,xd^D
1979 double precision, allocatable :: flux(:^D&)
1980 double precision, allocatable :: dxb1(:^D&),dxb2(:^D&),dxb3(:^D&)
1981 double precision, allocatable :: SXRg(:,:),xg1(:),xg2(:),dxg1(:),dxg2(:)
1982 integer :: levelg,nXg1,nXg2,iXgmin1,iXgmax1,iXgmin2,iXgmax2,rft,iXg^D
1983 double precision :: SXRt,xc^L,xg^L,r2,area_1AU
1984 integer :: ixP^L,ixP^D
1985 integer :: direction_LOS
1986
1987 if (los_phi==0 .and. los_theta==90) then
1988 direction_los=1
1989 else if (los_phi==90 .and. los_theta==90) then
1990 direction_los=2
1991 else
1992 direction_los=3
1993 endif
1994
1995 ^d&ixomin^d=ixmlo^d\
1996 ^d&ixomax^d=ixmhi^d\
1997 ^d&iximin^d=ixglo^d\
1998 ^d&iximax^d=ixghi^d\
1999 ^d&xbmin^d=rnode(rpxmin^d_,igrid)\
2000 ^d&xbmax^d=rnode(rpxmax^d_,igrid)\
2001
2002 allocate(flux(ixi^s))
2003 allocate(dxb1(ixi^s),dxb2(ixi^s),dxb3(ixi^s))
2004 dxb1(ixo^s)=ps(igrid)%dx(ixo^s,1)
2005 dxb2(ixo^s)=ps(igrid)%dx(ixo^s,2)
2006 dxb3(ixo^s)=ps(igrid)%dx(ixo^s,3)
2007 ! get local SXR flux
2008 call get_sxr(ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux,emin_sxr,emax_sxr)
2009
2010 ! grid parameters
2011 levelg=ps(igrid)%level
2012 rft=2**(refine_max_level-levelg)
2013
2014 ! fine table for storing EUV flux of current grid
2015 select case(direction_los)
2016 case(1)
2017 nxg1=iximax2*rft
2018 nxg2=iximax3*rft
2019 case(2)
2020 nxg1=iximax3*rft
2021 nxg2=iximax1*rft
2022 case(3)
2023 nxg1=iximax1*rft
2024 nxg2=iximax2*rft
2025 end select
2026 allocate(sxrg(nxg1,nxg2),xg1(nxg1),xg2(nxg2),dxg1(nxg1),dxg2(nxg2))
2027 sxrg=zero
2028 xg1=zero
2029 xg2=zero
2030
2031 ! integrate for different direction
2032 select case(direction_los)
2033 case(1)
2034 do ix2=ixomin2,ixomax2
2035 ixgmin1=(ix2-1)*rft+1
2036 ixgmax1=ix2*rft
2037 do ix3=ixomin3,ixomax3
2038 ixgmin2=(ix3-1)*rft+1
2039 ixgmax2=ix3*rft
2040 sxrt=0.d0
2041 do ix1=ixomin1,ixomax1
2042 sxrt=sxrt+flux(ix^d)*dxb1(ix^d)*unit_length
2043 enddo
2044 sxrg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=sxrt
2045 enddo
2046 enddo
2047 case(2)
2048 do ix3=ixomin3,ixomax3
2049 ixgmin1=(ix3-1)*rft+1
2050 ixgmax1=ix3*rft
2051 do ix1=ixomin1,ixomax1
2052 ixgmin2=(ix1-1)*rft+1
2053 ixgmax2=ix1*rft
2054 sxrt=0.d0
2055 do ix2=ixomin2,ixomax2
2056 sxrt=sxrt+flux(ix^d)*dxb2(ix^d)*unit_length
2057 enddo
2058 sxrg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=sxrt
2059 enddo
2060 enddo
2061 case(3)
2062 do ix1=ixomin1,ixomax1
2063 ixgmin1=(ix1-1)*rft+1
2064 ixgmax1=ix1*rft
2065 do ix2=ixomin2,ixomax2
2066 ixgmin2=(ix2-1)*rft+1
2067 ixgmax2=ix2*rft
2068 sxrt=0.d0
2069 do ix3=ixomin3,ixomax3
2070 sxrt=sxrt+flux(ix^d)*dxb3(ix^d)*unit_length
2071 enddo
2072 sxrg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=sxrt
2073 enddo
2074 enddo
2075 end select
2076
2077 area_1au=2.81d27
2078 sxrg=sxrg/area_1au
2079
2080 ! mapping grid data to global table
2081 ! index ranges in local table
2082 select case(direction_los)
2083 case(1)
2084 ixgmin1=(ixomin2-1)*rft+1
2085 ixgmax1=ixomax2*rft
2086 ixgmin2=(ixomin3-1)*rft+1
2087 ixgmax2=ixomax3*rft
2088 case(2)
2089 ixgmin1=(ixomin3-1)*rft+1
2090 ixgmax1=ixomax3*rft
2091 ixgmin2=(ixomin1-1)*rft+1
2092 ixgmax2=ixomax1*rft
2093 case(3)
2094 ixgmin1=(ixomin1-1)*rft+1
2095 ixgmax1=ixomax1*rft
2096 ixgmin2=(ixomin2-1)*rft+1
2097 ixgmax2=ixomax2*rft
2098 end select
2099 ! index ranges in global table & mapping
2100 select case(direction_los)
2101 case(1)
2102 ixpmin1=(node(pig2_,igrid)-1)*rft*block_nx2+1
2103 ixpmax1=node(pig2_,igrid)*rft*block_nx2
2104 ixpmin2=(node(pig3_,igrid)-1)*rft*block_nx3+1
2105 ixpmax2=node(pig3_,igrid)*rft*block_nx3
2106 case(2)
2107 ixpmin1=(node(pig3_,igrid)-1)*rft*block_nx3+1
2108 ixpmax1=node(pig3_,igrid)*rft*block_nx3
2109 ixpmin2=(node(pig1_,igrid)-1)*rft*block_nx1+1
2110 ixpmax2=node(pig1_,igrid)*rft*block_nx1
2111 case(3)
2112 ixpmin1=(node(pig1_,igrid)-1)*rft*block_nx1+1
2113 ixpmax1=node(pig1_,igrid)*rft*block_nx1
2114 ixpmin2=(node(pig2_,igrid)-1)*rft*block_nx2+1
2115 ixpmax2=node(pig2_,igrid)*rft*block_nx2
2116 end select
2117 xg1(ixgmin1:ixgmax1)=xif1(ixpmin1:ixpmax1)
2118 xg2(ixgmin2:ixgmax2)=xif2(ixpmin2:ixpmax2)
2119 dxg1(ixgmin1:ixgmax1)=dxif1(ixpmin1:ixpmax1)
2120 dxg2(ixgmin2:ixgmax2)=dxif2(ixpmin2:ixpmax2)
2121 sxr(ixpmin1:ixpmax1,ixpmin2:ixpmax2)=sxr(ixpmin1:ixpmax1,ixpmin2:ixpmax2)+&
2122 sxrg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)
2123
2124 deallocate(flux,dxb1,dxb2,dxb3,sxrg,xg1,xg2,dxg1,dxg2)
2125
2126 end subroutine integrate_sxr_datresol
2127
2128 subroutine integrate_euv_datresol(igrid,nXIF1,nXIF2,xIF1,xIF2,dxIF1,dxIF2,fl,EUV,Dpl)
2130
2131 integer, intent(in) :: igrid,nXIF1,nXIF2
2132 double precision, intent(in) :: xIF1(nXIF1),xIF2(nXIF2)
2133 double precision, intent(in) :: dxIF1(nXIF1),dxIF2(nXIF2)
2134 type(te_fluid), intent(in) :: fl
2135 double precision, intent(out) :: EUV(nXIF1,nXIF2),Dpl(nXIF1,nXIF2)
2136
2137 integer :: ixO^L,ixO^D,ixI^L,ix^D,i,j
2138 double precision :: xb^L,xd^D
2139 double precision, allocatable :: flux(:^D&),v(:^D&),rho(:^D&)
2140 double precision, allocatable :: dxb1(:^D&),dxb2(:^D&),dxb3(:^D&)
2141 double precision, allocatable :: EUVg(:,:),Fvg(:,:),xg1(:),xg2(:),dxg1(:),dxg2(:)
2142 integer :: levelg,nXg1,nXg2,iXgmin1,iXgmax1,iXgmin2,iXgmax2,rft,iXg^D
2143 double precision :: EUVt,Fvt,xc^L,xg^L,r2
2144 integer :: ixP^L,ixP^D
2145 integer :: direction_LOS
2146
2147 if (los_phi==0 .and. los_theta==90) then
2148 direction_los=1
2149 else if (los_phi==90 .and. los_theta==90) then
2150 direction_los=2
2151 else
2152 direction_los=3
2153 endif
2154
2155 ^d&ixomin^d=ixmlo^d\
2156 ^d&ixomax^d=ixmhi^d\
2157 ^d&iximin^d=ixglo^d\
2158 ^d&iximax^d=ixghi^d\
2159 ^d&xbmin^d=rnode(rpxmin^d_,igrid)\
2160 ^d&xbmax^d=rnode(rpxmax^d_,igrid)\
2161
2162 allocate(flux(ixi^s),v(ixi^s),rho(ixi^s))
2163 allocate(dxb1(ixi^s),dxb2(ixi^s),dxb3(ixi^s))
2164 dxb1(ixo^s)=ps(igrid)%dx(ixo^s,1)
2165 dxb2(ixo^s)=ps(igrid)%dx(ixo^s,2)
2166 dxb3(ixo^s)=ps(igrid)%dx(ixo^s,3)
2167 ! get local EUV flux and velocity
2168 call get_euv(wavelength,ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux)
2169 flux(ixo^s)=flux(ixo^s)/instrument_resolution_factor**2 ! adjust flux due to artifical change of resolution
2170 call fl%get_rho(ps(igrid)%w,ps(igrid)%x,ixi^l,ixo^l,rho)
2171 v(ixo^s)=-ps(igrid)%w(ixo^s,iw_mom(direction_los))/rho(ixo^s)
2172 deallocate(rho)
2173
2174 ! grid parameters
2175 levelg=ps(igrid)%level
2176 rft=2**(refine_max_level-levelg)
2177
2178 ! fine table for storing EUV flux of current grid
2179 select case(direction_los)
2180 case(1)
2181 nxg1=iximax2*rft
2182 nxg2=iximax3*rft
2183 case(2)
2184 nxg1=iximax3*rft
2185 nxg2=iximax1*rft
2186 case(3)
2187 nxg1=iximax1*rft
2188 nxg2=iximax2*rft
2189 end select
2190 allocate(euvg(nxg1,nxg2),fvg(nxg1,nxg2),xg1(nxg1),xg2(nxg2),dxg1(nxg1),dxg2(nxg2))
2191 euvg=zero
2192 fvg=zero
2193 xg1=zero
2194 xg2=zero
2195
2196 ! integrate for different direction
2197 select case(direction_los)
2198 case(1)
2199 do ix2=ixomin2,ixomax2
2200 ixgmin1=(ix2-1)*rft+1
2201 ixgmax1=ix2*rft
2202 do ix3=ixomin3,ixomax3
2203 ixgmin2=(ix3-1)*rft+1
2204 ixgmax2=ix3*rft
2205 euvt=0.d0
2206 fvt=0.d0
2207 do ix1=ixomin1,ixomax1
2208 euvt=euvt+flux(ix^d)*dxb1(ix^d)*unit_length
2209 fvt=fvt+flux(ix^d)*dxb1(ix^d)*unit_length*v(ix^d)
2210 enddo
2211 euvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=euvt
2212 fvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=fvt
2213 enddo
2214 enddo
2215 case(2)
2216 do ix3=ixomin3,ixomax3
2217 ixgmin1=(ix3-1)*rft+1
2218 ixgmax1=ix3*rft
2219 do ix1=ixomin1,ixomax1
2220 ixgmin2=(ix1-1)*rft+1
2221 ixgmax2=ix1*rft
2222 euvt=0.d0
2223 fvt=0.d0
2224 do ix2=ixomin2,ixomax2
2225 euvt=euvt+flux(ix^d)*dxb2(ix^d)*unit_length
2226 fvt=fvt+flux(ix^d)*dxb2(ix^d)*unit_length*v(ix^d)
2227 enddo
2228 euvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=euvt
2229 fvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=fvt
2230 enddo
2231 enddo
2232 case(3)
2233 do ix1=ixomin1,ixomax1
2234 ixgmin1=(ix1-1)*rft+1
2235 ixgmax1=ix1*rft
2236 do ix2=ixomin2,ixomax2
2237 ixgmin2=(ix2-1)*rft+1
2238 ixgmax2=ix2*rft
2239 euvt=0.d0
2240 fvt=0.d0
2241 do ix3=ixomin3,ixomax3
2242 euvt=euvt+flux(ix^d)*dxb3(ix^d)*unit_length
2243 fvt=fvt+flux(ix^d)*dxb3(ix^d)*unit_length*v(ix^d)
2244 enddo
2245 euvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=euvt
2246 fvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)=fvt
2247 enddo
2248 enddo
2249 end select
2250 if (si_unit) then
2251 euvg=euvg*1.d2
2252 fvg=fvg*1.d2
2253 endif
2254
2255 ! mapping grid data to global table
2256 ! index ranges in local table
2257 select case(direction_los)
2258 case(1)
2259 ixgmin1=(ixomin2-1)*rft+1
2260 ixgmax1=ixomax2*rft
2261 ixgmin2=(ixomin3-1)*rft+1
2262 ixgmax2=ixomax3*rft
2263 case(2)
2264 ixgmin1=(ixomin3-1)*rft+1
2265 ixgmax1=ixomax3*rft
2266 ixgmin2=(ixomin1-1)*rft+1
2267 ixgmax2=ixomax1*rft
2268 case(3)
2269 ixgmin1=(ixomin1-1)*rft+1
2270 ixgmax1=ixomax1*rft
2271 ixgmin2=(ixomin2-1)*rft+1
2272 ixgmax2=ixomax2*rft
2273 end select
2274 ! index ranges in global table & mapping
2275 select case(direction_los)
2276 case(1)
2277 ixpmin1=(node(pig2_,igrid)-1)*rft*block_nx2+1
2278 ixpmax1=node(pig2_,igrid)*rft*block_nx2
2279 ixpmin2=(node(pig3_,igrid)-1)*rft*block_nx3+1
2280 ixpmax2=node(pig3_,igrid)*rft*block_nx3
2281 case(2)
2282 ixpmin1=(node(pig3_,igrid)-1)*rft*block_nx3+1
2283 ixpmax1=node(pig3_,igrid)*rft*block_nx3
2284 ixpmin2=(node(pig1_,igrid)-1)*rft*block_nx1+1
2285 ixpmax2=node(pig1_,igrid)*rft*block_nx1
2286 case(3)
2287 ixpmin1=(node(pig1_,igrid)-1)*rft*block_nx1+1
2288 ixpmax1=node(pig1_,igrid)*rft*block_nx1
2289 ixpmin2=(node(pig2_,igrid)-1)*rft*block_nx2+1
2290 ixpmax2=node(pig2_,igrid)*rft*block_nx2
2291 end select
2292 xg1(ixgmin1:ixgmax1)=xif1(ixpmin1:ixpmax1)
2293 xg2(ixgmin2:ixgmax2)=xif2(ixpmin2:ixpmax2)
2294 dxg1(ixgmin1:ixgmax1)=dxif1(ixpmin1:ixpmax1)
2295 dxg2(ixgmin2:ixgmax2)=dxif2(ixpmin2:ixpmax2)
2296 euv(ixpmin1:ixpmax1,ixpmin2:ixpmax2)=euv(ixpmin1:ixpmax1,ixpmin2:ixpmax2)+&
2297 euvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)
2298 dpl(ixpmin1:ixpmax1,ixpmin2:ixpmax2)=dpl(ixpmin1:ixpmax1,ixpmin2:ixpmax2)+&
2299 fvg(ixgmin1:ixgmax1,ixgmin2:ixgmax2)
2300
2301 deallocate(flux,v,dxb1,dxb2,dxb3,euvg,fvg,xg1,xg2,dxg1,dxg2)
2302
2303 end subroutine integrate_euv_datresol
2304
2305 subroutine get_image(qunit,datatype,fl)
2306 ! integrate emission flux along line of sight (LOS)
2307 ! in a 3D simulation box and get a 2D EUV image
2309 use mod_constants
2310
2311 integer, intent(in) :: qunit
2312 type(te_fluid), intent(in) :: fl
2313 character(20), intent(in) :: datatype
2314
2315 integer :: ix^D,numXI1,numXI2,numWI
2316 double precision :: xImin1,xImax1,xImin2,xImax2,xIcent1,xIcent2,dxI
2317 double precision, allocatable :: xI1(:),xI2(:),dxI1(:),dxI2(:)
2318 double precision, allocatable :: wI(:,:,:),wIs(:,:,:),EM(:,:),WLB(:,:,:)
2319 double precision :: vec_temp1(1:3),vec_temp2(1:3)
2320 double precision :: vec_z(1:3),vec_cor(1:3),xI_cor(1:2)
2321 double precision :: res,LOS_psi,r_max,r_loc
2322
2323 integer :: mass
2324 character (30) :: ion
2325 double precision :: logTe,lineCent,sigma_PSF,spaceRsl,wlRsl,wslit
2326 double precision :: arcsec,RHESSI_rsl,LASCO_rsl,pixel,R_occult,smallflux
2327 integer :: iigrid,igrid,i,j,numSI,iw
2328 logical :: emit
2329
2330 if (coordinate==spherical) then
2332 else
2333 ! cartesian
2335 endif
2336
2337 ! calculate domain of the image
2338 if (coordinate==spherical) then
2339 ximin1=-abs(xprobmax1)
2340 ximin2=-abs(xprobmax1)
2341 ximax1=abs(xprobmax1)
2342 ximax2=abs(xprobmax1)
2343 else
2344 ! calculate domain of the image
2345 do ix1=1,2
2346 if (ix1==1) vec_cor(1)=xprobmin1
2347 if (ix1==2) vec_cor(1)=xprobmax1
2348 do ix2=1,2
2349 if (ix2==1) vec_cor(2)=xprobmin2
2350 if (ix2==2) vec_cor(2)=xprobmax2
2351 do ix3=1,2
2352 if (ix3==1) vec_cor(3)=xprobmin3
2353 if (ix3==2) vec_cor(3)=xprobmax3
2354 if (big_image) then
2355 r_loc=(vec_cor(1)-x_origin(1))**2
2356 r_loc=r_loc+(vec_cor(2)-x_origin(2))**2
2357 r_loc=r_loc+(vec_cor(3)-x_origin(3))**2
2358 r_loc=sqrt(r_loc)
2359 if (ix1==1 .and. ix2==1 .and. ix3==1) then
2360 r_max=r_loc
2361 else
2362 r_max=max(r_max,r_loc)
2363 endif
2364 else
2365 call get_cor_image(vec_cor,xi_cor)
2366 if (ix1==1 .and. ix2==1 .and. ix3==1) then
2367 ximin1=xi_cor(1)
2368 ximax1=xi_cor(1)
2369 ximin2=xi_cor(2)
2370 ximax2=xi_cor(2)
2371 else
2372 ximin1=min(ximin1,xi_cor(1))
2373 ximax1=max(ximax1,xi_cor(1))
2374 ximin2=min(ximin2,xi_cor(2))
2375 ximax2=max(ximax2,xi_cor(2))
2376 endif
2377 endif
2378 enddo
2379 enddo
2380 enddo
2381 if (big_image) then
2382 ximin1=-r_max
2383 ximin2=-r_max
2384 ximax1=r_max
2385 ximax2=r_max
2386 endif
2387 endif
2388 xicent1=(ximin1+ximax1)/2.d0
2389 xicent2=(ximin2+ximax2)/2.d0
2390
2391 ! tables for image
2392 if (si_unit) then
2393 arcsec=7.25d5/unit_length
2394 else
2395 arcsec=7.25d7/unit_length
2396 endif
2397 if (datatype=='image_euv') then
2398 call get_line_info(wavelength,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
2399 dxi=spacersl*arcsec ! intrument resolution of image
2400 smallflux=smalldouble
2401 else if (datatype=='image_sxr') then
2402 rhessi_rsl=2.3d0/instrument_resolution_factor
2403 dxi=rhessi_rsl*arcsec
2404 smallflux=1.d-40
2405 else if (datatype=='image_whitelight') then
2406 if (whitelight_instrument=='LASCO/C1') then
2407 lasco_rsl=5.6d0/instrument_resolution_factor
2408 r_occult=1.1d0
2409 else if (whitelight_instrument=='LASCO/C2') then
2410 lasco_rsl=11.4d0/instrument_resolution_factor
2411 r_occult=2.d0
2412 else if (whitelight_instrument=='LASCO/C3') then
2413 lasco_rsl=56.d0/instrument_resolution_factor
2414 r_occult=3.7d0
2415 else
2416 call mpistop('Whitelight synthesis: instrument is not supported!')
2417 endif
2418 dxi=lasco_rsl*arcsec
2419 if (r_occultor>1.d0) r_occult=r_occultor
2420 r_occult=r_occult*const_rsun/unit_length
2421 smallflux=1.d-20
2422 endif
2423 numxi1=8*ceiling((ximax1-xicent1)/dxi/8.d0)
2424 ximin1=xicent1-numxi1*dxi
2425 ximax1=xicent1+numxi1*dxi
2426 numxi1=numxi1*2
2427 numxi2=8*ceiling((ximax2-xicent2)/dxi/8.d0)
2428 ximin2=xicent2-numxi2*dxi
2429 ximax2=xicent2+numxi2*dxi
2430 numxi2=numxi2*2
2431 allocate(xi1(numxi1),xi2(numxi2),dxi1(numxi1),dxi2(numxi2))
2432 do ix1=1,numxi1
2433 xi1(ix1)=ximin1+dxi*(ix1-half)
2434 dxi1(ix1)=dxi
2435 enddo
2436 do ix2=1,numxi2
2437 xi2(ix2)=ximin2+dxi*(ix2-half)
2438 dxi2(ix2)=dxi
2439 enddo
2440
2441 ! calculate emission
2442 if (datatype=='image_euv' .or. datatype=='image_sxr') then
2443 numwi=1
2444 allocate(wi(numxi1,numxi2,numwi),wis(numxi1,numxi2,numwi),em(numxi1,numxi2))
2445 wi=zero
2446 wis=zero
2447 em=zero
2448 if (coordinate==cartesian) then
2449 do iigrid=1,igridstail; igrid=igrids(iigrid);
2450 call integrate_emission_cartesian(igrid,numxi1,numxi2,xi1,xi2,dxi,fl,datatype,em)
2451 enddo
2452 else
2453 do iigrid=1,igridstail; igrid=igrids(iigrid);
2454 call integrate_emission_spherical(igrid,numxi1,numxi2,xi1,xi2,dxi,fl,datatype,em)
2455 enddo
2456 endif
2457 do ix1=1,numxi1
2458 do ix2=1,numxi2
2459 if (em(ix1,ix2)>smallflux) wis(ix1,ix2,1)=em(ix1,ix2)
2460 enddo
2461 enddo
2462 numsi=numxi1*numxi2*numwi
2463 call mpi_allreduce(wis,wi,numsi,mpi_double_precision,mpi_sum,icomm,ierrmpi)
2464 if (activate_unit_arcsec) then
2465 xi1=xi1/arcsec
2466 dxi1=dxi1/arcsec
2467 xi2=xi2/arcsec
2468 dxi2=dxi2/arcsec
2469 endif
2470 call output_data(qunit,xi1,xi2,dxi1,dxi2,wi,numxi1,numxi2,numwi,datatype)
2471 deallocate(wi,wis,em)
2472 else if (datatype=='image_whitelight') then
2473 numwi=2
2474 allocate(wi(numxi1,numxi2,numwi),wis(numxi1,numxi2,numwi),wlb(numxi1,numxi2,numwi))
2475 wi=zero
2476 wis=zero
2477 wlb=zero
2478 if (coordinate==spherical) then
2479 do iigrid=1,igridstail; igrid=igrids(iigrid);
2480 call integrate_whitelight_spherical(igrid,numxi1,numxi2,numwi,xi1,xi2,dxi,fl,datatype,wlb)
2481 enddo
2482 endif
2483 do ix1=1,numxi1
2484 do ix2=1,numxi2
2485 if (wlb(ix1,ix2,1)>smallflux) then
2486 wis(ix1,ix2,1)=wlb(ix1,ix2,1)
2487 wis(ix1,ix2,2)=wlb(ix1,ix2,2)
2488 endif
2489 enddo
2490 enddo
2491 numsi=numxi1*numxi2*numwi
2492 call mpi_allreduce(wis,wi,numsi,mpi_double_precision,mpi_sum,icomm,ierrmpi)
2493 if (activate_unit_arcsec) then
2494 xi1=xi1/arcsec
2495 dxi1=dxi1/arcsec
2496 xi2=xi2/arcsec
2497 dxi2=dxi2/arcsec
2498 endif
2499 call output_data(qunit,xi1,xi2,dxi1,dxi2,wi,numxi1,numxi2,numwi,datatype)
2500 deallocate(wi,wis,wlb)
2501 endif
2502
2503 deallocate(xi1,xi2,dxi1,dxi2)
2504
2505 end subroutine get_image
2506
2507 subroutine integrate_emission_cartesian(igrid,numXI1,numXI2,xI1,xI2,dxI,fl,datatype,EM)
2508 integer, intent(in) :: igrid,numXI1,numXI2
2509 double precision, intent(in) :: xI1(numXI1),xI2(numXI2)
2510 double precision, intent(in) :: dxI
2511 type(te_fluid), intent(in) :: fl
2512 character(20), intent(in) :: datatype
2513 double precision, intent(inout) :: EM(numXI1,numXI2)
2514
2515 integer :: ixO^L,ixO^D,ixI^L,ix^D,i,j
2516 double precision :: xb^L,xd^D
2517 double precision, allocatable :: flux(:^D&)
2518 double precision :: res
2519 integer :: ixP^L,ixP^D,nSubC^D,iSubC^D
2520 double precision :: xSubP1,xSubP2,dxSubP,xerf^L,fluxsubC
2521 double precision :: xSubC(1:3),dxSubC^D,xCent(1:2)
2522
2523 integer :: mass
2524 double precision :: logTe
2525 character (30) :: ion
2526 double precision :: lineCent
2527 double precision :: sigma_PSF,spaceRsl,wlRsl,sigma0,factor,wslit
2528 double precision :: arcsec,pixel,RHESSI_rsl,area_1AU
2529 double precision :: aa,bb
2530
2531 ^d&ixomin^d=ixmlo^d\
2532 ^d&ixomax^d=ixmhi^d\
2533 ^d&iximin^d=ixglo^d\
2534 ^d&iximax^d=ixghi^d\
2535 ^d&xbmin^d=rnode(rpxmin^d_,igrid)\
2536 ^d&xbmax^d=rnode(rpxmax^d_,igrid)\
2537
2538 if (si_unit) then
2539 arcsec=7.25d5/unit_length
2540 else
2541 arcsec=7.25d7/unit_length
2542 endif
2543
2544 allocate(flux(ixi^s))
2545 if (datatype=='image_euv') then
2546 ! get local EUV flux and velocity
2547 call get_euv(wavelength,ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux)
2548 flux(ixo^s)=flux(ixo^s)/instrument_resolution_factor**2 ! adjust flux due to artifical change of resolution
2549 call get_line_info(wavelength,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
2550 pixel=spacersl*arcsec
2551 sigma0=sigma_psf*pixel
2552 else if (datatype=='image_sxr') then
2553 ! get local SXR flux photons cm^-3 s^-1 (cgs) or photons m^-3 s^-1 (SI)
2554 call get_sxr(ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux,emin_sxr,emax_sxr)
2555 rhessi_rsl=2.3d0/instrument_resolution_factor
2556 sigma_psf=1.d0
2557 pixel=rhessi_rsl*arcsec
2558 sigma0=sigma_psf*pixel
2559 area_1au=2.81d27
2560 endif
2561
2562 ! integrate emission
2563 {do ix^d=ixomin^d,ixomax^d\}
2564 ^d&nsubc^d=1;
2565 ^d&nsubc^d=max(nsubc^d,ceiling(ps(igrid)%dx(ix^dd,^d)*abs(vec_xi1(^d))/(dxi/2.d0)));
2566 ^d&nsubc^d=max(nsubc^d,ceiling(ps(igrid)%dx(ix^dd,^d)*abs(vec_xi2(^d))/(dxi/2.d0)));
2567 ^d&dxsubc^d=ps(igrid)%dx(ix^dd,^d)/nsubc^d;
2568 if (datatype=='image_euv') then
2569 if (si_unit) then
2570 fluxsubc=flux(ix^d)*dxsubc1*dxsubc2*dxsubc3*unit_length*1.d2/dxi/dxi ! DN s^-1
2571 else
2572 fluxsubc=flux(ix^d)*dxsubc1*dxsubc2*dxsubc3*unit_length/dxi/dxi ! DN s^-1
2573 endif
2574 else if (datatype=='image_sxr') then
2575 ! sub-cell SXR flux at 1 AU [photons s^-1 cm^-2]
2576 fluxsubc=flux(ix^d)*dxsubc1*dxsubc2*dxsubc3*unit_length**3/area_1au
2577 endif
2578 if (fluxsubc>smalldouble) then
2579 ! dividing a cell to several parts to get more accurate integrating values
2580 {do isubc^d=1,nsubc^d\}
2581 ^d&xsubc(^d)=ps(igrid)%x(ix^dd,^d)-half*ps(igrid)%dx(ix^dd,^d)+(isubc^d-half)*dxsubc^d;
2582 ! mapping the 3D coordinate to location at the image
2583 call get_cor_image(xsubc,xcent)
2584 ! distribution at nearby pixels
2585 ixp1=floor((xcent(1)-(xi1(1)-half*dxi))/dxi)+1
2586 ixp2=floor((xcent(2)-(xi2(1)-half*dxi))/dxi)+1
2587 ixpmin1=max(1,ixp1-3)
2588 ixpmax1=min(ixp1+3,numxi1)
2589 ixpmin2=max(1,ixp2-3)
2590 ixpmax2=min(ixp2+3,numxi2)
2591 do ixp1=ixpmin1,ixpmax1
2592 do ixp2=ixpmin2,ixpmax2
2593 xerfmin1=((xi1(ixp1)-half*dxi)-xcent(1))/(sqrt(2.d0)*sigma0)
2594 xerfmax1=((xi1(ixp1)+half*dxi)-xcent(1))/(sqrt(2.d0)*sigma0)
2595 xerfmin2=((xi2(ixp2)-half*dxi)-xcent(2))/(sqrt(2.d0)*sigma0)
2596 xerfmax2=((xi2(ixp2)+half*dxi)-xcent(2))/(sqrt(2.d0)*sigma0)
2597 factor=(erfc(xerfmin1)-erfc(xerfmax1))*(erfc(xerfmin2)-erfc(xerfmax2))/4.d0
2598 em(ixp1,ixp2)=em(ixp1,ixp2)+fluxsubc*factor
2599 enddo !ixP2
2600 enddo !ixP1
2601 {enddo\} !iSubC
2602 endif
2603 {enddo\} !ix
2604
2605 deallocate(flux)
2606 end subroutine integrate_emission_cartesian
2607
2608 subroutine integrate_emission_spherical(igrid,numXI1,numXI2,xI1,xI2,dxI,fl,datatype,EM)
2609 integer, intent(in) :: igrid,numXI1,numXI2
2610 double precision, intent(in) :: xI1(numXI1),xI2(numXI2)
2611 double precision, intent(in) :: dxI
2612 type(te_fluid), intent(in) :: fl
2613 character(20), intent(in) :: datatype
2614 double precision, intent(inout) :: EM(numXI1,numXI2)
2615
2616 integer :: ixO^L,ixO^D,ixI^L,ix^D,i,j
2617 double precision, allocatable :: flux(:^D&),Ne(:^D&)
2618 integer :: ixP^L,ixP^D,nSubC^D,iSubC^D
2619 double precision :: xSubP1,xSubP2,dxSubP,xerf^L,fluxsubC,RsubC
2620 double precision :: TBsubC,PBsubC
2621 double precision :: xSubC(1:3),dxSubC^D,xCent(1:2),xSubC_car(1:3)
2622 double precision :: R_thick,dotp,dvolume,R_occult,Rc
2623 double precision :: dxl(1:3),x_sph(1:3),dx_sph(1:3)
2624 double precision :: unitv_r(1:3),unitv_theta(1:3),unitv_phi(1:3)
2625 logical :: sun_back_side,emit
2626
2627 integer :: mass
2628 double precision :: logTe
2629 character (30) :: ion
2630 double precision :: lineCent
2631 double precision :: sigma_PSF,spaceRsl,wlRsl,sigma0,factor,wslit
2632 double precision :: RHESSI_rsl,area_1AU,arcsec,pixel
2633
2634 ^d&ixomin^d=ixmlo^d;
2635 ^d&ixomax^d=ixmhi^d;
2636 ^d&iximin^d=ixglo^d;
2637 ^d&iximax^d=ixghi^d;
2638
2639 if (si_unit) then
2640 arcsec=7.25d5/unit_length
2641 else
2642 arcsec=7.25d7/unit_length
2643 endif
2644
2645 allocate(flux(ixi^s))
2646 if (datatype=='image_euv') then
2647 ! get local EUV flux and velocity
2648 call get_euv(wavelength,ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux)
2649 flux(ixo^s)=flux(ixo^s)/instrument_resolution_factor**2 ! adjust flux due to artifical change of resolution
2650 call get_line_info(wavelength,ion,mass,logte,linecent,spacersl,wlrsl,sigma_psf,wslit)
2651 pixel=spacersl*arcsec
2652 sigma0=sigma_psf*pixel
2653 else if (datatype=='image_sxr') then
2654 ! get local SXR flux photons cm^-3 s^-1 (cgs) or photons m^-3 s^-1 (SI)
2655 call get_sxr(ixi^l,ixo^l,ps(igrid)%w,ps(igrid)%x,fl,flux,emin_sxr,emax_sxr)
2656 rhessi_rsl=2.3d0/instrument_resolution_factor
2657 sigma_psf=1.d0
2658 pixel=rhessi_rsl*arcsec
2659 sigma0=sigma_psf*pixel
2660 area_1au=2.81d27
2661 endif
2662
2663 ! integrate emission
2664 r_thick=r_opt_thick*const_rsun/unit_length
2665 {do ix^d=ixomin^d,ixomax^d\}
2666 x_sph(1:3)=ps(igrid)%x(ix^d,1:3)
2667 dx_sph(1:3)=ps(igrid)%dx(ix^d,1:3)
2668 dxl(1)=dx_sph(1) ! cell size in length
2669 dxl(2)=x_sph(1)*dx_sph(2) ! cell size in length
2670 dxl(3)=x_sph(1)*dsin(x_sph(2))*dx_sph(3) ! cell size in length
2671 ! dividing a cell to several sub-cells to get more accurate integrating values
2672 ^d&nsubc^d=1;
2673 call get_unit_vector_spherical(x_sph,unitv_r,unitv_theta,unitv_phi)
2674 call dot_product_loc(unitv_r,vec_xi1,dotp)
2675 nsubc1=max(nsubc1,ceiling(dxl(1)*abs(dotp)/(dxi/2.d0)))
2676 call dot_product_loc(unitv_r,vec_xi2,dotp)
2677 nsubc1=max(nsubc1,ceiling(dxl(1)*abs(dotp)/(dxi/2.d0)))
2678 call dot_product_loc(unitv_theta,vec_xi1,dotp)
2679 nsubc2=max(nsubc2,ceiling(dxl(2)*abs(dotp)/(dxi/2.d0)))
2680 call dot_product_loc(unitv_theta,vec_xi2,dotp)
2681 nsubc2=max(nsubc2,ceiling(dxl(2)*abs(dotp)/(dxi/2.d0)))
2682 call dot_product_loc(unitv_phi,vec_xi1,dotp)
2683 nsubc3=max(nsubc3,ceiling(dxl(3)*abs(dotp)/(dxi/2.d0)))
2684 call dot_product_loc(unitv_phi,vec_xi2,dotp)
2685 nsubc3=max(nsubc3,ceiling(dxl(3)*abs(dotp)/(dxi/2.d0)))
2686
2687 ! integrate sub-cells
2688 do isubc1=1,nsubc1
2689 ! sub-cell center coordinate in spherical
2690 xsubc(1)=x_sph(1)-half*dx_sph(1)+(isubc1-half)*dx_sph(1)/nsubc1
2691 rsubc=xsubc(1)
2692 dxsubc1=dx_sph(1)/nsubc1 ! sub-cell size in length
2693 do isubc2=1,nsubc2
2694 ! sub-cell center coordinate in spherical
2695 xsubc(2)=x_sph(2)-half*dx_sph(2)+(isubc2-half)*dx_sph(2)/nsubc2
2696 dxsubc2=xsubc(1)*dx_sph(2)/nsubc2 ! sub-cell size in length
2697 dxsubc3=xsubc(1)*dsin(xsubc(2))*dx_sph(3)/nsubc3 ! sub-cell size in length
2698 dvolume=dxsubc1*dxsubc2*dxsubc3
2699 if (datatype=='image_euv') then
2700 if (si_unit) then
2701 fluxsubc=flux(ix^d)*dvolume*unit_length*1.d2/dxi/dxi ! DN s^-1
2702 else
2703 fluxsubc=flux(ix^d)*dvolume*unit_length/dxi/dxi ! DN s^-1
2704 endif
2705 else if (datatype=='image_sxr') then
2706 ! sub-cell SXR flux at 1 AU [photons s^-1 cm^-2]
2707 fluxsubc=flux(ix^d)*dvolume*unit_length**3/area_1au
2708 endif
2709 ! enter integration if flux large enough
2710 if (fluxsubc>smalldouble) then
2711 do isubc3=1,nsubc3
2712 ! sub-cell center coordinate in spherical
2713 xsubc(3)=x_sph(3)-half*dx_sph(3)+(isubc3-half)*dx_sph(3)/nsubc3
2714 call get_cor_image_spherical(xsubc,xcent)
2715 rc=dsqrt(xcent(1)**2+xcent(2)**2) ! distance to sun center (on the image plane)
2716 !
2717 ! whether the local emitted photons can arrive the telescope
2718 call spherical_to_cartesian(xsubc,xsubc_car)
2719 call dot_product_loc(vec_los,xsubc_car,dotp)
2720 sun_back_side=.true.
2721 if (dotp<0.d0) sun_back_side=.false.
2722 ! whether the local emission can reach the telescope
2723 if (sun_back_side) then
2724 emit=.false.
2725 if (rc>r_thick) emit=.true.
2726 else
2727 emit=.true.
2728 if (xsubc(1)<=r_thick) emit=.false.
2729 endif
2730 !
2731 if (emit) then
2732 ! mapping the 3D coordinate to location at the image
2733 ! distribution at nearby pixels
2734 ixp1=floor((xcent(1)-(xi1(1)-half*dxi))/dxi)+1
2735 ixp2=floor((xcent(2)-(xi2(1)-half*dxi))/dxi)+1
2736 ixpmin1=max(1,ixp1-3)
2737 ixpmax1=min(ixp1+3,numxi1)
2738 ixpmin2=max(1,ixp2-3)
2739 ixpmax2=min(ixp2+3,numxi2)
2740 do ixp1=ixpmin1,ixpmax1
2741 do ixp2=ixpmin2,ixpmax2
2742 xerfmin1=((xi1(ixp1)-half*dxi)-xcent(1))/(sqrt(2.d0)*sigma0)
2743 xerfmax1=((xi1(ixp1)+half*dxi)-xcent(1))/(sqrt(2.d0)*sigma0)
2744 xerfmin2=((xi2(ixp2)-half*dxi)-xcent(2))/(sqrt(2.d0)*sigma0)
2745 xerfmax2=((xi2(ixp2)+half*dxi)-xcent(2))/(sqrt(2.d0)*sigma0)
2746 factor=(erfc(xerfmin1)-erfc(xerfmax1))*(erfc(xerfmin2)-erfc(xerfmax2))/4.d0
2747 em(ixp1,ixp2)=em(ixp1,ixp2)+fluxsubc*factor
2748 enddo !ixP2
2749 enddo !ixP1
2750 endif !emit
2751 enddo !iSubC3
2752 endif !smallflux
2753 enddo !iSubC2
2754 enddo !iSubC1
2755 {enddo\} !ix
2756
2757 deallocate(flux)
2758
2759 end subroutine integrate_emission_spherical
2760
2761 subroutine integrate_whitelight_spherical(igrid,numXI1,numXI2,numWI,xI1,xI2,dxI,fl,datatype,WLB)
2762 integer, intent(in) :: igrid,numXI1,numXI2,numWI
2763 double precision, intent(in) :: xI1(numXI1),xI2(numXI2)
2764 double precision, intent(in) :: dxI
2765 type(te_fluid), intent(in) :: fl
2766 character(20), intent(in) :: datatype
2767 double precision, intent(inout) :: WLB(numXI1,numXI2,numWI)
2768
2769 integer :: ixO^L,ixO^D,ixI^L,ix^D,i,j
2770 double precision, allocatable :: flux(:^D&),Ne(:^D&)
2771 integer :: ixP^L,ixP^D,nSubC^D,iSubC^D
2772 double precision :: xSubP1,xSubP2,dxSubP,xerf^L,fluxsubC,RsubC
2773 double precision :: sigma_PSF,sigma0,arcsec,pixel,LASCO_rsl
2774 double precision :: A,B,C,D,Rc,Ne0,TBsubC,PBsubC,factor
2775 double precision :: R_thick,dotp,dvolume,R_occult
2776 double precision :: xSubC(1:3),dxSubC^D,xCent(1:2),xSubC_car(1:3)
2777 double precision :: dxl(1:3),x_sph(1:3),dx_sph(1:3)
2778 double precision :: unitv_r(1:3),unitv_theta(1:3),unitv_phi(1:3)
2779 logical :: emit
2780
2781 ^d&ixomin^d=ixmlo^d;
2782 ^d&ixomax^d=ixmhi^d;
2783 ^d&iximin^d=ixglo^d;
2784 ^d&iximax^d=ixghi^d;
2785
2786 if (si_unit) then
2787 arcsec=7.25d5/unit_length
2788 else
2789 arcsec=7.25d7/unit_length
2790 endif
2791
2792 allocate(ne(ixi^s))
2793 if (whitelight_instrument=='LASCO/C1') then
2794 lasco_rsl=5.6d0/instrument_resolution_factor
2795 r_occult=1.1d0
2796 else if (whitelight_instrument=='LASCO/C2') then
2797 lasco_rsl=11.4d0/instrument_resolution_factor
2798 r_occult=2.d0
2799 else if (whitelight_instrument=='LASCO/C3') then
2800 lasco_rsl=56.d0/instrument_resolution_factor
2801 r_occult=3.7d0
2802 endif
2803 if (r_occultor>1.d0) r_occult=r_occultor
2804 r_occult=r_occult*const_rsun/unit_length
2805 call fl%get_rho(ps(igrid)%w,ps(igrid)%x,ixi^l,ixo^l,ne)
2806 sigma_psf=1.d0
2807 pixel=lasco_rsl*arcsec
2808 sigma0=sigma_psf*pixel
2809
2810 ! integrate emission
2811 r_thick=r_opt_thick*const_rsun/unit_length
2812 {do ix^d=ixomin^d,ixomax^d\}
2813 x_sph(1:3)=ps(igrid)%x(ix^d,1:3)
2814 dx_sph(1:3)=ps(igrid)%dx(ix^d,1:3)
2815 dxl(1)=dx_sph(1) ! cell size in length
2816 dxl(2)=x_sph(1)*dx_sph(2) ! cell size in length
2817 dxl(3)=x_sph(1)*dsin(x_sph(2))*dx_sph(3) ! cell size in length
2818 ne0=ne(ix^d)*unit_numberdensity
2819 ! dividing a cell to several sub-cells to get more accurate integrating values
2820 ^d&nsubc^d=1;
2821 call get_unit_vector_spherical(x_sph,unitv_r,unitv_theta,unitv_phi)
2822 call dot_product_loc(unitv_r,vec_xi1,dotp)
2823 nsubc1=max(nsubc1,ceiling(dxl(1)*abs(dotp)/(dxi/2.d0)))
2824 call dot_product_loc(unitv_r,vec_xi2,dotp)
2825 nsubc1=max(nsubc1,ceiling(dxl(1)*abs(dotp)/(dxi/2.d0)))
2826 call dot_product_loc(unitv_theta,vec_xi1,dotp)
2827 nsubc2=max(nsubc2,ceiling(dxl(2)*abs(dotp)/(dxi/2.d0)))
2828 call dot_product_loc(unitv_theta,vec_xi2,dotp)
2829 nsubc2=max(nsubc2,ceiling(dxl(2)*abs(dotp)/(dxi/2.d0)))
2830 call dot_product_loc(unitv_phi,vec_xi1,dotp)
2831 nsubc3=max(nsubc3,ceiling(dxl(3)*abs(dotp)/(dxi/2.d0)))
2832 call dot_product_loc(unitv_phi,vec_xi2,dotp)
2833 nsubc3=max(nsubc3,ceiling(dxl(3)*abs(dotp)/(dxi/2.d0)))
2834
2835 ! integrate sub-cells
2836 do isubc1=1,nsubc1
2837 ! sub-cell center coordinate in spherical
2838 xsubc(1)=x_sph(1)-half*dx_sph(1)+(isubc1-half)*dx_sph(1)/nsubc1
2839 rsubc=xsubc(1)
2840 dxsubc1=dx_sph(1)/nsubc1 ! sub-cell size in length
2841 call get_thomson_parameters(rsubc,a,b,c,d)
2842 do isubc2=1,nsubc2
2843 ! sub-cell center coordinate in spherical
2844 xsubc(2)=x_sph(2)-half*dx_sph(2)+(isubc2-half)*dx_sph(2)/nsubc2
2845 dxsubc2=xsubc(1)*dx_sph(2)/nsubc2 ! sub-cell size in length
2846 dxsubc3=xsubc(1)*dsin(xsubc(2))*dx_sph(3)/nsubc3 ! sub-cell size in length
2847 dvolume=dxsubc1*dxsubc2*dxsubc3
2848 do isubc3=1,nsubc3
2849 ! sub-cell center coordinate in spherical
2850 xsubc(3)=x_sph(3)-half*dx_sph(3)+(isubc3-half)*dx_sph(3)/nsubc3
2851 call get_cor_image_spherical(xsubc,xcent)
2852 rc=dsqrt(xcent(1)**2+xcent(2)**2) ! distance to sun center (on the image plane)
2853 ! whether the local emitted photons can arrive the telescope
2854 emit=.false.
2855 if (rc>r_occult) then
2856 emit=.true.
2857 ! scaterring flux from cm^-3 of plasma
2858 call get_whitelight_thomson(rsubc,rc,ne0,a,b,c,d,tbsubc,pbsubc)
2859 tbsubc=tbsubc*dvolume*unit_length/dxi/dxi
2860 pbsubc=pbsubc*dvolume*unit_length/dxi/dxi
2861 if (tbsubc<1.d-20) emit=.false.
2862 endif
2863 if (emit) then
2864 ! mapping the 3D coordinate to location at the image
2865 ! distribution at nearby pixels
2866 ixp1=floor((xcent(1)-(xi1(1)-half*dxi))/dxi)+1
2867 ixp2=floor((xcent(2)-(xi2(1)-half*dxi))/dxi)+1
2868 ixpmin1=max(1,ixp1-3)
2869 ixpmax1=min(ixp1+3,numxi1)
2870 ixpmin2=max(1,ixp2-3)
2871 ixpmax2=min(ixp2+3,numxi2)
2872 do ixp1=ixpmin1,ixpmax1
2873 do ixp2=ixpmin2,ixpmax2
2874 xerfmin1=((xi1(ixp1)-half*dxi)-xcent(1))/(sqrt(2.d0)*sigma0)
2875 xerfmax1=((xi1(ixp1)+half*dxi)-xcent(1))/(sqrt(2.d0)*sigma0)
2876 xerfmin2=((xi2(ixp2)-half*dxi)-xcent(2))/(sqrt(2.d0)*sigma0)
2877 xerfmax2=((xi2(ixp2)+half*dxi)-xcent(2))/(sqrt(2.d0)*sigma0)
2878 factor=(erfc(xerfmin1)-erfc(xerfmax1))*(erfc(xerfmin2)-erfc(xerfmax2))/4.d0
2879 wlb(ixp1,ixp2,1)=wlb(ixp1,ixp2,1)+tbsubc*factor
2880 wlb(ixp1,ixp2,2)=wlb(ixp1,ixp2,2)+pbsubc*factor
2881 enddo !ixP2
2882 enddo !ixP1
2883 endif
2884 enddo !iSubC3
2885 enddo !iSubC2
2886 enddo !iSubC1
2887 {enddo\} !ix
2888
2889 deallocate(ne)
2890
2891 end subroutine integrate_whitelight_spherical
2892
2893 subroutine get_thomson_parameters(Rl,A,B,C,D)
2894 ! parameters given in Billings 1968
2895 use mod_constants
2896 double precision, intent(in) :: Rl
2897 double precision, intent(inout) :: A,B,C,D
2898
2899 double precision :: sinO,cosO,sinO2,cosO2,tmp
2900
2901 sino=const_rsun/(rl*unit_length)
2902 sino2=sino**2
2903 coso2=1.d0-sino2
2904 coso=abs(dsqrt(coso2))
2905 tmp=log((1.d0+sino)/coso)
2906 a=coso*sino2
2907 b=-(1.d0-3.d0*sino2-(coso2/sino)*(1.d0+3.d0*sino2)*tmp)/8.d0
2908 c=4.d0/3.d0-coso-coso*coso2/3.d0
2909 d=(5.d0+sino2-(coso2/sino)*(5.d0-sino2)*tmp)/8.d0
2910
2911 end subroutine get_thomson_parameters
2912
2913 subroutine get_whitelight_thomson(Rl,Rin,Ne,A,B,C,D,fluxTB,fluxPB)
2914 ! use the method in SSW/eltheory
2915 double precision, intent(in) :: Rl,Rin,Ne,A,B,C,D
2916 double precision, intent(inout) :: fluxTB,fluxPB
2917
2918 double precision :: const,u,Bt,Br,PB,TB,sinchi2
2919
2920 u=0.63d0
2921 const=1.24878d-25/(1.d0-u/3.d0)
2922 sinchi2=(rin/rl)**2
2923 bt=const*(c+u*(d-c))
2924 pb=const*sinchi2*((a+u*(b-a)))
2925 br=bt-pb
2926 tb=bt+br
2927 fluxtb=tb*ne
2928 fluxpb=pb*ne
2929
2930 end subroutine get_whitelight_thomson
2931
2932 subroutine get_unit_vector_spherical(x_sph,unitv_r,unitv_theta,unitv_phi)
2933 double precision, intent(in) :: x_sph(1:3)
2934 double precision, intent(inout) :: unitv_r(1:3),unitv_theta(1:3),unitv_phi(1:3)
2935
2936 unitv_r(1)=dsin(x_sph(2))*dcos(x_sph(3))
2937 unitv_r(2)=dsin(x_sph(2))*dsin(x_sph(3))
2938 unitv_r(3)=dcos(x_sph(2))
2939 unitv_theta(1)=dcos(x_sph(2))*dcos(x_sph(3))
2940 unitv_theta(2)=dcos(x_sph(2))*dsin(x_sph(3))
2941 unitv_theta(3)=-dsin(x_sph(2))
2942 unitv_phi(1)=-dsin(x_sph(3))
2943 unitv_phi(2)=dcos(x_sph(3))
2944 unitv_phi(3)=zero
2945
2946 end subroutine get_unit_vector_spherical
2947
2948 subroutine output_data(qunit,xO1,xO2,dxO1,dxO2,wO,nXO1,nXO2,nWO,datatype)
2949 ! change the format of data and write data
2951
2952 integer, intent(in) :: qunit,nXO1,nXO2,nWO
2953 double precision, intent(in) :: dxO1(nxO1),dxO2(nxO2)
2954 double precision, intent(in) :: xO1(nXO1),xO2(nxO2)
2955 double precision, intent(inout) :: wO(nXO1,nXO2,nWO)
2956 character(20), intent(in) :: datatype
2957
2958 integer :: nPiece,nP1,nP2,nC1,nC2,nWC
2959 integer :: piece_nmax1,piece_nmax2,ix1,ix2,j,ipc,ixc1,ixc2
2960 double precision, allocatable :: xC(:,:,:,:),wC(:,:,:,:),dxC(:,:,:,:)
2961
2962 ! clean small values
2963 do ix1=1,nxo1
2964 do ix2=1,nxo2
2965 do j=1,nwo
2966 if (abs(wo(ix1,ix2,j))<smalldouble) wo(ix1,ix2,j)=zero
2967 enddo
2968 enddo
2969 enddo
2970
2971 ! how many cells in each grid
2972 if (dat_resolution) then
2973 if (datatype=='image_euv' .or. datatype=='image_sxr') then
2974 if (los_phi==0 .and. los_theta==90) then
2975 piece_nmax1=block_nx2
2976 piece_nmax2=block_nx3
2977 else if (los_phi==90 .and. los_theta==90) then
2978 piece_nmax1=block_nx3
2979 piece_nmax2=block_nx1
2980 else
2981 piece_nmax1=block_nx1
2982 piece_nmax2=block_nx2
2983 endif
2984 else if (datatype=='spectrum_euv') then
2985 piece_nmax1=16
2986 if (direction_slit==1) then
2987 piece_nmax2=block_nx1
2988 else if (direction_slit==2) then
2989 piece_nmax2=block_nx2
2990 else
2991 piece_nmax2=block_nx3
2992 endif
2993 endif
2994 else
2995 piece_nmax1=20
2996 piece_nmax2=20
2997 endif
2998 loopn1: do j=piece_nmax1,1,-1
2999 if(mod(nxo1,j)==0) then
3000 nc1=j
3001 exit loopn1
3002 endif
3003 enddo loopn1
3004 loopn2: do j=piece_nmax2,1,-1
3005 if(mod(nxo2,j)==0) then
3006 nc2=j
3007 exit loopn2
3008 endif
3009 enddo loopn2
3010 ! how many grids
3011 np1=nxo1/nc1
3012 np2=nxo2/nc2
3013 npiece=np1*np2
3014 nwc=nwo
3015
3016 ! output images
3017 select case(convert_type)
3018 case('EIvtuCCmpi','ESvtuCCmpi','SIvtuCCmpi','WIvtuCCmpi')
3019 ! put data into grids
3020 allocate(xc(npiece,nc1,nc2,2))
3021 allocate(dxc(npiece,nc1,nc2,2))
3022 allocate(wc(npiece,nc1,nc2,nwo))
3023 do ipc=1,npiece
3024 do ixc1=1,nc1
3025 do ixc2=1,nc2
3026 ix1=mod(ipc-1,np1)*nc1+ixc1
3027 ix2=floor(1.0*(ipc-1)/np1)*nc2+ixc2
3028 xc(ipc,ixc1,ixc2,1)=xo1(ix1)
3029 xc(ipc,ixc1,ixc2,2)=xo2(ix2)
3030 dxc(ipc,ixc1,ixc2,1)=dxo1(ix1)
3031 dxc(ipc,ixc1,ixc2,2)=dxo2(ix2)
3032 do j=1,nwc
3033 wc(ipc,ixc1,ixc2,j)=wo(ix1,ix2,j)
3034 enddo
3035 enddo
3036 enddo
3037 enddo
3038 ! write data into vtu file
3039 call write_image_vtucc(qunit,xc,wc,dxc,npiece,nc1,nc2,nwc,datatype)
3040 deallocate(xc,dxc,wc)
3041 case('EIvtiCCmpi','ESvtiCCmpi','SIvtiCCmpi','WIvtiCCmpi')
3042 if (sum(stretch_type(:))>0 .and. dat_resolution) then
3043 call mpistop("Error in synthesize emission: vti is not supported for dat resolution")
3044 else
3045 call write_image_vticc(qunit,xo1,xo2,dxo1,dxo2,wo,nxo1,nxo2,nwo,nc1,nc2)
3046 endif
3047 case default
3048 call mpistop("Error in synthesize emission: Unknown convert_type")
3049 end select
3050
3051 end subroutine output_data
3052 }
3053
3054 subroutine write_image_vticc(qunit,xO1,xO2,dxO1,dxO2,wO,nXO1,nXO2,nWO,nC1,nC2)
3055 ! write image data to vti
3057
3058 integer, intent(in) :: qunit,nXO1,nXO2,nWO,nC1,nC2
3059 double precision, intent(in) :: xO1(nXO1),xO2(nxO2)
3060 double precision, intent(in) :: dxO1(nxO1),dxO2(nxO2)
3061 double precision, intent(in) :: wO(nXO1,nXO2,nWO)
3062
3063 double precision :: origin(1:3), spacing(1:3)
3064 integer :: wholeExtent(1:6),extent(1:6)
3065 integer :: nP1,nP2,iP1,iP2,iw
3066 integer :: ixC1,ixC2,ixCmin1,ixCmax1,ixCmin2,ixCmax2
3067
3068 integer :: filenr
3069 logical :: fileopen
3070 character (70) :: subname,wname,vname,nameL,nameS
3071 character (len=std_len) :: filename
3072 integer :: mass
3073 double precision :: logTe
3074 character (30) :: ion
3075 double precision :: line_center
3076 double precision :: spatial_rsl,spectral_rsl,sigma_PSF,wslit
3077
3078
3079 origin(1)=xo1(1)-0.5d0*dxo1(1)
3080 origin(2)=xo2(1)-0.5d0*dxo2(1)
3081 origin(3)=zero
3082 spacing(1)=dxo1(1)
3083 spacing(2)=dxo2(1)
3084 spacing(3)=zero
3085 wholeextent=0
3086 wholeextent(2)=nxo1
3087 wholeextent(4)=nxo2
3088 np1=nxo1/nc1
3089 np2=nxo2/nc2
3090
3091 ! get information of emission line
3092 if (convert_type=='EIvtiCCmpi') then
3093 call get_line_info(wavelength,ion,mass,logte,line_center,spatial_rsl,spectral_rsl,sigma_psf,wslit)
3094 else if (convert_type=='ESvtiCCmpi') then
3095 call get_line_info(spectrum_wl,ion,mass,logte,line_center,spatial_rsl,spectral_rsl,sigma_psf,wslit)
3096 endif
3097
3098 if (mype==0) then
3099 inquire(qunit,opened=fileopen)
3100 if(.not.fileopen)then
3101 ! generate filename
3102 filenr=snapshotini
3103 if (autoconvert) filenr=snapshotnext
3104 if (convert_type=='EIvtiCCmpi') then
3105 write(filename,'(a,i4.4,a)') trim(filename_euv),filenr,".vti"
3106 else if (convert_type=='SIvtiCCmpi') then
3107 write(filename,'(a,i4.4,a)') trim(filename_sxr),filenr,".vti"
3108 else if (convert_type=='WIvtiCCmpi') then
3109 write(filename,'(a,i4.4,a)') trim(filename_whitelight),filenr,".vti"
3110 else if (convert_type=='ESvtiCCmpi') then
3111 write(filename,'(a,i4.4,a)') trim(filename_spectrum),filenr,".vti"
3112 endif
3113 open(qunit,file=filename,status='unknown',form='formatted')
3114 endif
3115
3116 ! generate xml header
3117 write(qunit,'(a)')'<?xml version="1.0"?>'
3118 write(qunit,'(a)',advance='no') '<VTKFile type="ImageData"'
3119 write(qunit,'(a)')' version="0.1" byte_order="LittleEndian">'
3120 write(qunit,'(a,3(1pe14.6),a,6(i10),a,3(1pe14.6),a)')' <ImageData Origin="',&
3121 origin,'" WholeExtent="',wholeextent,'" Spacing="',spacing,'">'
3122 ! file info
3123 write(qunit,'(a)')'<FieldData>'
3124 write(qunit,'(2a)')'<DataArray type="Float32" Name="TIME" ',&
3125 'NumberOfTuples="1" format="ascii">'
3126 write(qunit,*) real(global_time*time_convert_factor)
3127 write(qunit,'(a)')'</DataArray>'
3128 if (convert_type=='EIvtiCCmpi' .or. convert_type=='ESvtiCCmpi') then
3129 write(qunit,'(2a)')'<DataArray type="Float32" Name="logT" ',&
3130 'NumberOfTuples="1" format="ascii">'
3131 write(qunit,*) real(logte)
3132 write(qunit,'(a)')'</DataArray>'
3133 endif
3134 write(qunit,'(a)')'</FieldData>'
3135 ! pixel/cell data
3136 do ip1=1,np1
3137 do ip2=1,np2
3138 extent=0
3139 extent(1)=(ip1-1)*nc1
3140 extent(2)=ip1*nc1
3141 extent(3)=(ip2-1)*nc2
3142 extent(4)=ip2*nc2
3143 ixcmin1=extent(1)+1
3144 ixcmax1=extent(2)
3145 ixcmin2=extent(3)+1
3146 ixcmax2=extent(4)
3147 write(qunit,'(a,6(i10),a)') &
3148 '<Piece Extent="',extent,'">'
3149 write(qunit,'(a)')'<CellData>'
3150 do iw=1,nwo
3151 ! variable name
3152 if (convert_type=='EIvtiCCmpi') then
3153 if (wavelength<100) then
3154 write(vname,'(a,i2)') "AIA",wavelength
3155 else if (wavelength<1000) then
3156 write(vname,'(a,i3)') "AIA",wavelength
3157 else
3158 write(vname,'(a,i4)') "IRIS",wavelength
3159 endif
3160 if (iw==2 .and. dat_resolution) vname='Doppler_velocity'
3161 else if (convert_type=='SIvtiCCmpi') then
3162 if (emin_sxr<10 .and. emax_sxr<10) then
3163 write(vname,'(a,i1,a,i1,a)') "SXR",emin_sxr,"-",emax_sxr,"keV"
3164 else if (emin_sxr<10 .and. emax_sxr>=10) then
3165 write(vname,'(a,i1,a,i2,a)') "SXR",emin_sxr,"-",emax_sxr,"keV"
3166 else
3167 write(vname,'(a,i2,a,i2,a)') "SXR",emin_sxr,"-",emax_sxr,"keV"
3168 endif
3169 else if (convert_type=='WIvtiCCmpi') then
3170 if (iw==1) write(vname,'(a)')'B'
3171 if (iw==2) write(vname,'(a)')'pB'
3172 else if (convert_type=='ESvtiCCmpi') then
3173 if (spectrum_wl==1354) then
3174 write(vname,'(a,i4)') "SG",spectrum_wl
3175 else
3176 write(vname,'(a,i3)') "EIS",spectrum_wl
3177 endif
3178 endif
3179 write(qunit,'(a,a,a)')&
3180 '<DataArray type="Float64" Name="',trim(vname),'" format="ascii">'
3181 write(qunit,'(200(1pe14.6))') ((wo(ixc1,ixc2,iw),ixc1=ixcmin1,ixcmax1),ixc2=ixcmin2,ixcmax2)
3182 write(qunit,'(a)')'</DataArray>'
3183 enddo
3184 write(qunit,'(a)')'</CellData>'
3185 write(qunit,'(a)')'</Piece>'
3186 enddo
3187 enddo
3188 ! end
3189 write(qunit,'(a)')'</ImageData>'
3190 write(qunit,'(a)')'</VTKFile>'
3191 close(qunit)
3192 endif
3193
3194 end subroutine write_image_vticc
3195
3196 subroutine write_image_vtucc(qunit,xC,wC,dxC,nPiece,nC1,nC2,nWC,datatype)
3197 ! write image data to vtu
3199
3200 integer, intent(in) :: qunit
3201 integer, intent(in) :: nPiece,nC1,nC2,nWC
3202 double precision, intent(in) :: xC(nPiece,nC1,nC2,2),dxC(nPiece,nc1,nc2,2)
3203 double precision, intent(in) :: wC(nPiece,nC1,nC2,nWC)
3204 character(20), intent(in) :: datatype
3205
3206 integer :: nP1,nP2
3207 double precision :: xP(nPiece,nC1+1,nC2+1,2)
3208 integer :: filenr
3209 logical :: fileopen
3210 character (70) :: subname,wname,vname,nameL,nameS
3211 character (len=std_len) :: filename
3212 integer :: ixC1,ixC2,ixP,ix1,ix2,j
3213 integer :: nc,np,icel,VTK_type
3214 integer :: mass
3215 double precision :: logTe
3216 character (30) :: ion
3217 double precision :: line_center
3218 double precision :: spatial_rsl,spectral_rsl,sigma_PSF,wslit
3219
3220 np1=nc1+1
3221 np2=nc2+1
3222 np=np1*np2
3223 nc=nc1*nc2
3224 ! cell corner location
3225 do ixp=1,npiece
3226 do ix1=1,np1
3227 do ix2=1,np2
3228 if (ix1<np1) xp(ixp,ix1,ix2,1)=xc(ixp,ix1,1,1)-0.5d0*dxc(ixp,ix1,1,1)
3229 if (ix1==np1) xp(ixp,ix1,ix2,1)=xc(ixp,ix1-1,1,1)+0.5d0*dxc(ixp,ix1-1,1,1)
3230 if (ix2<np2) xp(ixp,ix1,ix2,2)=xc(ixp,1,ix2,2)-0.5d0*dxc(ixp,1,ix2,2)
3231 if (ix2==np2) xp(ixp,ix1,ix2,2)=xc(ixp,1,ix2-1,2)+0.5d0*dxc(ixp,1,ix2-1,2)
3232 enddo
3233 enddo
3234 enddo
3235 ! get information of emission line
3236 if (datatype=='image_euv') then
3237 call get_line_info(wavelength,ion,mass,logte,line_center,spatial_rsl,spectral_rsl,sigma_psf,wslit)
3238 else if (datatype=='spectrum_euv') then
3239 call get_line_info(spectrum_wl,ion,mass,logte,line_center,spatial_rsl,spectral_rsl,sigma_psf,wslit)
3240 endif
3241
3242 if (mype==0) then
3243 inquire(qunit,opened=fileopen)
3244 if(.not.fileopen)then
3245 ! generate filename
3246 filenr=snapshotini
3247 if (autoconvert) filenr=snapshotnext
3248 if (datatype=='image_euv') then
3249 write(filename,'(a,i4.4,a)') trim(filename_euv),filenr,".vtu"
3250 else if (datatype=='image_sxr') then
3251 write(filename,'(a,i4.4,a)') trim(filename_sxr),filenr,".vtu"
3252 else if (datatype=='image_whitelight') then
3253 write(filename,'(a,i4.4,a)') trim(filename_whitelight),filenr,".vtu"
3254 else if (datatype=='spectrum_euv') then
3255 write(filename,'(a,i4.4,a)') trim(filename_spectrum),filenr,".vtu"
3256 endif
3257 open(qunit,file=filename,status='unknown',form='formatted')
3258 endif
3259 ! generate xml header
3260 write(qunit,'(a)')'<?xml version="1.0"?>'
3261 write(qunit,'(a)',advance='no') '<VTKFile type="UnstructuredGrid"'
3262 write(qunit,'(a)')' version="0.1" byte_order="LittleEndian">'
3263 write(qunit,'(a)')'<UnstructuredGrid>'
3264 write(qunit,'(a)')'<FieldData>'
3265 write(qunit,'(2a)')'<DataArray type="Float32" Name="TIME" ',&
3266 'NumberOfTuples="1" format="ascii">'
3267 write(qunit,*) real(global_time*time_convert_factor)
3268 write(qunit,'(a)')'</DataArray>'
3269 if (datatype=='image_euv' .or. datatype=='spectrum_euv') then
3270 write(qunit,'(2a)')'<DataArray type="Float32" Name="logT" ',&
3271 'NumberOfTuples="1" format="ascii">'
3272 write(qunit,*) real(logte)
3273 write(qunit,'(a)')'</DataArray>'
3274 endif
3275 write(qunit,'(a)')'</FieldData>'
3276 do ixp=1,npiece
3277 write(qunit,'(a,i7,a,i7,a)') &
3278 '<Piece NumberOfPoints="',np,'" NumberOfCells="',nc,'">'
3279 write(qunit,'(a)')'<CellData>'
3280 do j=1,nwc
3281 if (datatype=='image_euv') then
3282 if (j==1) then
3283 if (wavelength<100) then
3284 write(vname,'(a,i2)') "AIA",wavelength
3285 else if (wavelength<1000) then
3286 write(vname,'(a,i3)') "AIA",wavelength
3287 else
3288 write(vname,'(a,i4)') "IRIS",wavelength
3289 endif
3290 endif
3291 if (j==2 .and. dat_resolution) vname='Doppler_velocity'
3292 else if (datatype=='image_sxr') then
3293 if (emin_sxr<10 .and. emax_sxr<10) then
3294 write(vname,'(a,i1,a,i1,a)') "SXR",emin_sxr,"-",emax_sxr,"keV"
3295 else if (emin_sxr<10 .and. emax_sxr>=10) then
3296 write(vname,'(a,i1,a,i2,a)') "SXR",emin_sxr,"-",emax_sxr,"keV"
3297 else
3298 write(vname,'(a,i2,a,i2,a)') "SXR",emin_sxr,"-",emax_sxr,"keV"
3299 endif
3300 else if (datatype=='image_whitelight') then
3301 write(vname,'(a)')'whitelight'
3302 else if (datatype=='spectrum_euv') then
3303 if (spectrum_wl==1354) then
3304 write(vname,'(a,i4)') "SG",spectrum_wl
3305 else
3306 write(vname,'(a,i3)') "EIS",spectrum_wl
3307 endif
3308 endif
3309 write(qunit,'(a,a,a)')&
3310 '<DataArray type="Float64" Name="',trim(vname),'" format="ascii">'
3311 write(qunit,'(200(1pe14.6))') ((wc(ixp,ixc1,ixc2,j),ixc1=1,nc1),ixc2=1,nc2)
3312 write(qunit,'(a)')'</DataArray>'
3313 enddo
3314 write(qunit,'(a)')'</CellData>'
3315 write(qunit,'(a)')'<Points>'
3316 write(qunit,'(a)')'<DataArray type="Float32" NumberOfComponents="3" format="ascii">'
3317 do ix2=1,np2
3318 do ix1=1,np1
3319 if (datatype=='image_euv' .and. dat_resolution) then
3320 if (los_phi==0 .and. los_theta==90) then
3321 write(qunit,'(3(1pe14.6))') 0.d0,xp(ixp,ix1,ix2,1),xp(ixp,ix1,ix2,2)
3322 else if (los_phi==90 .and. los_theta==90) then
3323 write(qunit,'(3(1pe14.6))') xp(ixp,ix1,ix2,2),0.d0,xp(ixp,ix1,ix2,1)
3324 else
3325 write(qunit,'(3(1pe14.6))') xp(ixp,ix1,ix2,1),xp(ixp,ix1,ix2,2),0.d0
3326 endif
3327 else if (datatype=='image_sxr' .and. dat_resolution) then
3328 if (los_phi==0 .and. los_theta==90) then
3329 write(qunit,'(3(1pe14.6))') 0.d0,xp(ixp,ix1,ix2,1),xp(ixp,ix1,ix2,2)
3330 else if (los_phi==90 .and. los_theta==90) then
3331 write(qunit,'(3(1pe14.6))') xp(ixp,ix1,ix2,2),0.d0,xp(ixp,ix1,ix2,1)
3332 else
3333 write(qunit,'(3(1pe14.6))') xp(ixp,ix1,ix2,1),xp(ixp,ix1,ix2,2),0.d0
3334 endif
3335 else
3336 write(qunit,'(3(1pe14.6))') xp(ixp,ix1,ix2,1),xp(ixp,ix1,ix2,2),0.d0
3337 endif
3338 enddo
3339 enddo
3340 write(qunit,'(a)')'</DataArray>'
3341 write(qunit,'(a)')'</Points>'
3342 ! connetivity part
3343 write(qunit,'(a)')'<Cells>'
3344 write(qunit,'(a)')'<DataArray type="Int32" Name="connectivity" format="ascii">'
3345 do ix2=1,nc2
3346 do ix1=1,nc1
3347 write(qunit,'(4(i7))') ix1-1+(ix2-1)*np1,ix1+(ix2-1)*np1,&
3348 ix1-1+ix2*np1,ix1+ix2*np1
3349 enddo
3350 enddo
3351 write(qunit,'(a)')'</DataArray>'
3352 ! offsets data array
3353 write(qunit,'(a)')'<DataArray type="Int32" Name="offsets" format="ascii">'
3354 do icel=1,nc
3355 write(qunit,'(i7)') icel*(2**2)
3356 enddo
3357 write(qunit,'(a)')'</DataArray>'
3358 ! VTK cell type data array
3359 write(qunit,'(a)')'<DataArray type="Int32" Name="types" format="ascii">'
3360 ! VTK_LINE=3; VTK_PIXEL=8; VTK_VOXEL=11 -> vtk-syntax
3361 vtk_type=8
3362 do icel=1,nc
3363 write(qunit,'(i2)') vtk_type
3364 enddo
3365 write(qunit,'(a)')'</DataArray>'
3366 write(qunit,'(a)')'</Cells>'
3367 write(qunit,'(a)')'</Piece>'
3368 enddo
3369 write(qunit,'(a)')'</UnstructuredGrid>'
3370 write(qunit,'(a)')'</VTKFile>'
3371 close(qunit)
3372 endif
3373 end subroutine write_image_vtucc
3374
3375 subroutine dot_product_loc(vec1,vec2,res)
3376 double precision, intent(in) :: vec1(1:3),vec2(1:3)
3377 double precision, intent(out) :: res
3378
3379 res=vec1(1)*vec2(1)+vec1(2)*vec2(2)+vec1(3)*vec2(3)
3380
3381 end subroutine dot_product_loc
3382
3383 subroutine cross_product_loc(vec_in1,vec_in2,vec_out)
3384 double precision, intent(in) :: vec_in1(1:3),vec_in2(1:3)
3385 double precision, intent(out) :: vec_out(1:3)
3386
3387 vec_out(1)=vec_in1(2)*vec_in2(3)-vec_in1(3)*vec_in2(2)
3388 vec_out(2)=vec_in1(3)*vec_in2(1)-vec_in1(1)*vec_in2(3)
3389 vec_out(3)=vec_in1(1)*vec_in2(2)-vec_in1(2)*vec_in2(1)
3390
3391 end subroutine cross_product_loc
3392
3394 integer :: j
3395 double precision :: LOS_psi
3396 double precision :: vec_car(1:3),vec_z(1:3),vec_temp1(1:3),vec_temp2(1:3)
3397 double precision :: vec_LOS_sph(1:3),vec_xI1_sph(1:3),vec_xI2_sph(1:3)
3398
3399 ! antiparallel to LOS in spherical
3400 vec_los(1)=1.d0
3401 vec_los(2)=dpi*los_theta/180.d0
3402 vec_los(3)=dpi*los_phi/180.d0
3403 ! LOS in cartesian
3404 call spherical_to_cartesian(vec_los,vec_car)
3405 vec_los=-vec_car
3406
3407 ! theta=0 in cartesian
3408 vec_z(:)=zero
3409 vec_z(3)=1.d0
3410
3411 ! x direction for image
3412 if (los_theta==zero) then
3413 vec_temp1(1)=1.d0
3414 vec_temp1(2)=dpi/2.d0
3415 vec_temp1(3)=dpi*los_phi/180.d0
3416 call spherical_to_cartesian(vec_temp1,vec_car)
3417 vec_temp1=-vec_car
3418 call cross_product_loc(vec_temp1,vec_z,vec_xi1)
3419 else
3421 endif
3422
3423 ! y direction for image
3425
3426 ! rotate the image
3427 vec_temp1=vec_xi1/sqrt(vec_xi1(1)**2+vec_xi1(2)**2+vec_xi1(3)**2)
3428 vec_temp2=vec_xi2/sqrt(vec_xi2(1)**2+vec_xi2(2)**2+vec_xi2(3)**2)
3429 los_psi=dpi*image_rotate/180.d0
3430 vec_xi1=vec_temp1*cos(los_psi)-vec_temp2*sin(los_psi)
3431 vec_xi2=vec_temp2*cos(los_psi)+vec_temp1*sin(los_psi)
3432
3433 do j=1,3
3434 if (abs(vec_los(j))<smalldouble) vec_los(j)=zero
3435 if (abs(vec_xi1(j))<smalldouble) vec_xi1(j)=zero
3436 if (abs(vec_xi2(j))<smalldouble) vec_xi2(j)=zero
3437 enddo
3438
3439 call cartesian_to_spherical(vec_los,vec_los_sph)
3440 call cartesian_to_spherical(vec_xi1,vec_xi1_sph)
3441 call cartesian_to_spherical(vec_xi2,vec_xi2_sph)
3442 vec_los_sph(2:3)=vec_los_sph(2:3)*180.d0/dpi
3443 vec_xi1_sph(2:3)=vec_xi1_sph(2:3)*180.d0/dpi
3444 vec_xi2_sph(2:3)=vec_xi2_sph(2:3)*180.d0/dpi
3445
3446 if (mype==0) write(*,'(a,f3.1,f6.1,f6.1,a)') ' LOS vector (spherial): [',vec_los_sph(1),vec_los_sph(2),vec_los_sph(3),']'
3447 if (mype==0) write(*,'(a,f3.1,f6.1,f6.1,a)') ' xI1 vector (spherial): [',vec_xi1_sph(1),vec_xi1_sph(2),vec_xi1_sph(3),']'
3448 if (mype==0) write(*,'(a,f3.1,f6.1,f6.1,a)') ' xI2 vector (spherial): [',vec_xi2_sph(1),vec_xi2_sph(2),vec_xi2_sph(3),']'
3449
3450 end subroutine init_vectors_spherical
3451
3452 subroutine spherical_to_cartesian(vec_sph,vec_car)
3453 ! angles in rad
3454 double precision, intent(in) :: vec_sph(1:3)
3455 double precision, intent(inout) :: vec_car(1:3)
3456
3457 vec_car(1)=vec_sph(1)*dsin(vec_sph(2))*dcos(vec_sph(3))
3458 vec_car(2)=vec_sph(1)*dsin(vec_sph(2))*dsin(vec_sph(3))
3459 vec_car(3)=vec_sph(1)*dcos(vec_sph(2))
3460
3461 end subroutine spherical_to_cartesian
3462
3463 subroutine cartesian_to_spherical(vec_car,vec_sph)
3464 ! angles in rad
3465 double precision, intent(in) :: vec_car(1:3)
3466 double precision, intent(inout) :: vec_sph(1:3)
3467
3468 vec_sph(1)=dsqrt(vec_car(1)**2+vec_car(2)**2+vec_car(3)**2)
3469 vec_sph(2)=dacos(vec_car(3)/vec_sph(1))
3470 vec_sph(3)=atan2(vec_car(2),vec_car(3))
3471
3472 end subroutine cartesian_to_spherical
3473
3475 integer :: j
3476 double precision :: LOS_psi
3477 double precision :: vec_z(1:3),vec_temp1(1:3),vec_temp2(1:3)
3478
3479 ! vectors for image coordinate
3480 vec_los(1)=-cos(dpi*los_phi/180.d0)*sin(dpi*los_theta/180.d0)
3481 vec_los(2)=-sin(dpi*los_phi/180.d0)*sin(dpi*los_theta/180.d0)
3482 vec_los(3)=-cos(dpi*los_theta/180.d0)
3483 do j=1,3
3484 if (abs(vec_los(j))<=smalldouble) vec_los(j)=zero
3485 enddo
3486 vec_z(:)=zero
3487 vec_z(3)=1.d0
3488 if (los_theta==zero) then
3489 vec_xi1(1)=cos(dpi*los_phi/180.d0)
3490 vec_xi1(2)=sin(dpi*los_phi/180.d0)
3491 vec_xi1(3)=zero
3492 else
3494 endif
3496 vec_temp1=vec_xi1/sqrt(vec_xi1(1)**2+vec_xi1(2)**2+vec_xi1(3)**2)
3497 vec_temp2=vec_xi2/sqrt(vec_xi2(1)**2+vec_xi2(2)**2+vec_xi2(3)**2)
3498 los_psi=dpi*image_rotate/180.d0
3499 vec_xi1=vec_temp1*cos(los_psi)-vec_temp2*sin(los_psi)
3500 vec_xi2=vec_temp2*cos(los_psi)+vec_temp1*sin(los_psi)
3501
3502 do j=1,3
3503 if (abs(vec_xi1(j))<smalldouble) vec_xi1(j)=zero
3504 if (abs(vec_xi2(j))<smalldouble) vec_xi2(j)=zero
3505 enddo
3506
3507 if (mype==0) write(*,'(a,f5.2,f6.2,f6.2,a)') ' LOS vector: [',vec_los(1),vec_los(2),vec_los(3),']'
3508 if (mype==0) write(*,'(a,f5.2,f6.2,f6.2,a)') ' xI1 vector: [',vec_xi1(1),vec_xi1(2),vec_xi1(3),']'
3509 if (mype==0) write(*,'(a,f5.2,f6.2,f6.2,a)') ' xI2 vector: [',vec_xi2(1),vec_xi2(2),vec_xi2(3),']'
3510
3511 end subroutine init_vectors_cartesian
3512
3513 subroutine get_cor_image_spherical(x_3D_sph,x_image)
3514 double precision, intent(in) :: x_3D_sph(1:3)
3515 double precision, intent(inout) :: x_image(1:2)
3516 double precision :: res,res_origin
3517 double precision :: x_3D(1:3)
3518
3519 call spherical_to_cartesian(x_3d_sph,x_3d)
3520 call dot_product_loc(x_3d,vec_xi1,res)
3521 x_image(1)=res
3522 call dot_product_loc(x_3d,vec_xi2,res)
3523 x_image(2)=res
3524
3525 end subroutine get_cor_image_spherical
3526
3527 subroutine get_cor_image(x_3D,x_image)
3528 double precision, intent(in) :: x_3D(1:3)
3529 double precision, intent(inout) :: x_image(1:2)
3530 double precision :: res,res_origin
3531
3532 call dot_product_loc(x_3d,vec_xi1,res)
3533 call dot_product_loc(x_origin,vec_xi1,res_origin)
3534 x_image(1)=res-res_origin
3535 call dot_product_loc(x_3d,vec_xi2,res)
3536 call dot_product_loc(x_origin,vec_xi2,res_origin)
3537 x_image(2)=res-res_origin
3538
3539 end subroutine get_cor_image
3540
3541end module mod_thermal_emission
subroutine, public mpistop(message)
Exit MPI-AMRVAC with an error message.
Module for physical and numeric constants.
double precision, parameter const_rsun
double precision, parameter kb_cgs
Boltzmann constant in cgs.
double precision, parameter half
double precision, parameter one
double precision, parameter dpi
Pi.
double precision, parameter zero
some frequently used numbers
double precision, parameter smalldouble
double precision, parameter mp_cgs
Proton mass in cgs.
double precision, parameter const_c
universal constants as specified in cgs units
Module with geometry-related routines (e.g., divergence, curl)
Definition mod_geometry.t:2
integer coordinate
Definition mod_geometry.t:7
integer, parameter spherical
integer, parameter cartesian
Definition mod_geometry.t:8
This module contains definitions of global parameters and variables and some generic functions/subrou...
character(len=std_len) filename_sxr
Base file name for synthetic SXR emission output.
integer spectrum_wl
wave length for spectrum
integer ixghi
Upper index of grid block arrays.
logical activate_unit_arcsec
use arcsec as length unit of images/spectra
character(len=std_len) filename_spectrum
Base file name for synthetic EUV spectrum output.
double precision global_time
The global simulation time.
integer snapshotini
Resume from the snapshot with this index.
character(len=std_len) filename_euv
Base file name for synthetic EUV emission output.
double precision unit_numberdensity
Physical scaling factor for number density.
character(len=std_len) filename_whitelight
Base file name for synthetic white light.
character(len=std_len) convert_type
Which format to use when converting.
double precision unit_length
Physical scaling factor for length.
double precision location_slit
location of the slit
double precision time_convert_factor
Conversion factor for time unit.
integer icomm
The MPI communicator.
character(len=std_len) whitelight_instrument
white light observation instrument
integer mype
The rank of the current MPI task.
double precision, dimension(:), allocatable, parameter d
integer ierrmpi
A global MPI error return code.
logical autoconvert
If true, already convert to output format during the run.
integer snapshotnext
IO: snapshot and collapsed views output numbers/labels.
logical dat_resolution
resolution of the images
double precision r_occultor
the white light emission below it (unit=Rsun) is not visible
integer, dimension(ndim) nstretchedblocks_baselevel
(even) number of (symmetrically) stretched blocks at AMR level 1, per dimension
double precision, dimension(^nd) qstretch_baselevel
stretch factor between cells at AMR level 1, per dimension
double precision unit_velocity
Physical scaling factor for velocity.
double precision, dimension(:,:), allocatable rnode
Corner coordinates.
double precision unit_temperature
Physical scaling factor for temperature.
logical si_unit
Use SI units (.true.) or use cgs units (.false.)
double precision los_theta
direction of the line of sight (LOS)
double precision spectrum_window_max
integer wavelength
wavelength for output
integer, dimension(ndim) stretch_type
What kind of stretching is used per dimension.
double precision, dimension(^nd) dxlevel
store unstretched cell size of current level
double precision instrument_resolution_factor
times for enhancing spatial resolution for EUV image/spectra
double precision spectrum_window_min
spectral window
integer refine_max_level
Maximal number of AMR levels.
integer direction_slit
direction of the slit (for dat resolution only)
double precision, dimension(1:3) x_origin
where the is the origin (X=0,Y=0) of image
integer, dimension(:,:), allocatable node
integer, parameter ixglo
Lower index of grid block arrays (always 1)
This module defines the procedures of a physics module. It contains function pointers for the various...
Definition mod_physics.t:4
double precision, dimension(1:3) vec_los
subroutine get_goes_flux_grid(ixil, ixol, w, x, dv, xboxl, xbl, fl, eflux_grid)
subroutine integrate_spectra_cartesian(igrid, wl, dwlg, xs, dxsg, spectra, numwl, numxs, fl)
subroutine get_spectrum_datresol(qunit, datatype, fl)
double precision, dimension(1:101) f_304
double precision, dimension(1:101) f_193
double precision, dimension(1:60) f_264
double precision, dimension(1:60) f_263
subroutine get_euv_image(qunit, fl)
double precision, dimension(1:60) t_eis1
subroutine get_sxr(ixil, ixol, w, x, fl, flux, el, eu)
subroutine get_unit_vector_spherical(x_sph, unitv_r, unitv_theta, unitv_phi)
double precision, dimension(1:101) f_131
subroutine get_line_info(wl, ion, mass, logte, line_center, spatial_px, spectral_px, sigma_psf, width_slit)
double precision, dimension(1:60) f_255
double precision, dimension(1:101) t_aia
subroutine write_image_vtucc(qunit, xc, wc, dxc, npiece, nc1, nc2, nwc, datatype)
subroutine get_cor_image(x_3d, x_image)
subroutine get_thomson_parameters(rl, a, b, c, d)
subroutine integrate_euv_datresol(igrid, nxif1, nxif2, xif1, xif2, dxif1, dxif2, fl, euv, dpl)
double precision, dimension(1:60) t_eis2
double precision, dimension(1:101) f_171
double precision, dimension(1:101) f_94
subroutine integrate_spectra_datresol(igrid, wl, dwl, spectra, numwl, numxs, dir_loc, fl)
double precision, dimension(1:3) vec_xi1
subroutine get_spectrum(qunit, datatype, fl)
subroutine cartesian_to_spherical(vec_car, vec_sph)
subroutine get_cor_image_spherical(x_3d_sph, x_image)
subroutine dot_product_loc(vec1, vec2, res)
subroutine integrate_emission_spherical(igrid, numxi1, numxi2, xi1, xi2, dxi, fl, datatype, em)
subroutine get_image(qunit, datatype, fl)
subroutine integrate_emission_cartesian(igrid, numxi1, numxi2, xi1, xi2, dxi, fl, datatype, em)
subroutine write_image_vticc(qunit, xo1, xo2, dxo1, dxo2, wo, nxo1, nxo2, nwo, nc1, nc2)
subroutine get_sxr_image(qunit, fl)
double precision, dimension(1:60) f_192
subroutine get_whitelight_thomson(rl, rin, ne, a, b, c, d, fluxtb, fluxpb)
subroutine get_image_datresol(qunit, datatype, fl)
subroutine get_goes_sxr_flux(xboxl, fl, eflux)
subroutine integrate_whitelight_spherical(igrid, numxi1, numxi2, numwi, xi1, xi2, dxi, fl, datatype, wlb)
double precision, dimension(1:3) vec_xi2
double precision, dimension(1:41) f_1354
subroutine cross_product_loc(vec_in1, vec_in2, vec_out)
subroutine integrate_sxr_datresol(igrid, nxif1, nxif2, xif1, xif2, dxif1, dxif2, fl, sxr)
double precision, dimension(1:101) f_335
subroutine output_data(qunit, xo1, xo2, dxo1, dxo2, wo, nxo1, nxo2, nwo, datatype)
double precision, dimension(1:41) t_iris
subroutine get_euv_spectrum(qunit, fl)
double precision, dimension(1:101) f_211
subroutine get_whitelight_image(qunit, fl)
subroutine get_euv(wl, ixil, ixol, w, x, fl, flux)
subroutine spherical_to_cartesian(vec_sph, vec_car)