File: weights.f90

package info (click to toggle)
neat 2.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 4,108 kB
  • sloc: f90: 7,385; python: 211; makefile: 78; sh: 64
file content (259 lines) | stat: -rw-r--r-- 9,253 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
!weights.f90, read in a configuration file defining the weighting scheme to be used
!(C) Roger Wesson
module mod_weights
use mod_types
use mod_abundIO
use mod_globals

contains

subroutine setweights(configfile,weights,linelist,ILs,H_Balmer,H_Paschen,HeII_lines)

        implicit none
        character(len=512) :: configfile
        character(len=16) :: quantity
        character(len=24) :: filecheck
        real(kind=dp) :: weight
        type(weightingarray) :: weights
        type(line),dimension(:) :: linelist
        type(cel),dimension(88) :: ILs
        integer, dimension(3:40) :: H_Balmer
        integer, dimension(4:39) :: H_Paschen
        integer, dimension(20,2:6) :: HeII_lines
        integer :: io, lineno, upper, lower

!balmer and paschen defaults

        where (H_Balmer.gt.0)
          linelist(H_Balmer)%weight = -1
        elsewhere
          linelist(H_Balmer)%weight = 0.d0
        endwhere

        where (H_Paschen.gt.0)
          linelist(H_Paschen)%weight = -1
        elsewhere
          linelist(H_Paschen)%weight = 0.d0
        endwhere

!open config file

        open(631, file=trim(configfile),iostat=io,status="old")
        read(631,"(24A)") filecheck

        if (index(filecheck,"NEAT configuration").eq.0) then
          print *,"           ",trim(configfile)," doesn't appear to be a NEAT configuration file"
          call exit(109)
        endif

        do while (IO .ge. 0)
          read(631,*,end=111) quantity

          if (quantity(1:1).ne."#") then
            backspace(631)
            read(631,"(A16,F5.2)") quantity,weight

!conditions for weight assignment here. it's going to be ugly, no way around it

!low ionisation densities
            if (trim(quantity).eq."oiiDens") then
              weights%oiiDens = weight
              cycle
            elseif (trim(quantity).eq."siiDens") then
              weights%siiDens = weight
              cycle
            !low ionisation temperatures
            elseif (trim(quantity).eq."oiiTemp") then
              weights%oiiTemp = weight
              cycle
            elseif (trim(quantity).eq."siiTemp") then
              weights%siiTemp = weight
              cycle
            elseif (trim(quantity).eq."niiTemp") then
              weights%niiTemp = weight
              cycle
            elseif (trim(quantity).eq."ciTemp") then
              weights%ciTemp = weight
              cycle
            elseif (trim(quantity).eq."oiTemp") then
              weights%oiTemp = weight
              cycle
            !medium ionisation densities
            elseif (trim(quantity).eq."cliiiDens") then
              weights%cliiiDens = weight
              cycle
            elseif (trim(quantity).eq."ciiiDens") then
              weights%ciiiDens = weight
              cycle
            elseif (trim(quantity).eq."arivDens") then
              weights%arivDens = weight
              cycle
            elseif (trim(quantity).eq."oiiiIRDens") then
              weights%oiiiIRDens = weight
              cycle
            elseif (trim(quantity).eq."ariiiIRDens") then
              weights%ariiiIRDens = weight
              cycle
            elseif (trim(quantity).eq."siiiIRDens") then
              weights%siiiIRDens = weight
              cycle
            elseif (trim(quantity).eq."neiiiIRDens") then
              weights%neiiiIRDens = weight
              cycle
            !medium ionisation temperatures
            elseif (trim(quantity).eq."oiiiTemp") then
              weights%oiiiTemp = weight
              cycle
            elseif (trim(quantity).eq."siiiTemp") then
              weights%siiiTemp = weight
              cycle
            elseif (trim(quantity).eq."ariiiTemp") then
              weights%ariiiTemp = weight
              cycle
            elseif (trim(quantity).eq."neiiiTemp") then
              weights%neiiiTemp = weight
              cycle
            elseif (trim(quantity).eq."neiiiIRTemp") then
              weights%neiiiIRTemp = weight
              cycle
            elseif (trim(quantity).eq."oiiiIRTemp") then
              weights%oiiiIRTemp = weight
              cycle
            elseif (trim(quantity).eq."oiiiUVTemp") then
              weights%oiiiUVTemp = weight
              cycle
            !high ionisation densities
            elseif (trim(quantity).eq."neivDens") then
              weights%neivDens = weight
              cycle
            !high ionisation temperatures
            elseif (trim(quantity).eq."arvTemp") then
              weights%arvTemp = weight
              cycle
            elseif (trim(quantity).eq."nevTemp") then
              weights%nevTemp = weight
              cycle
            !balmer weights for extinction calculation
            elseif (trim(quantity).eq."ha") then
              weights%ha = weight
              cycle
            elseif (trim(quantity).eq."hg") then
              weights%hg = weight
              cycle
            elseif (trim(quantity).eq."hd") then
              weights%hd = weight
              cycle
            !helium abundance weights
            elseif (trim(quantity).eq."he4471") then
              weights%he4471 = weight
              cycle
            elseif (trim(quantity).eq."he5876") then
              weights%he5876 = weight
              cycle
            elseif (trim(quantity).eq."he6678") then
              weights%he6678 = weight
              cycle
            elseif (quantity(1:2).eq."he") then
              read(quantity(3:4),"(I2)") upper
              read(quantity(5:6),"(I2)") lower
              if (HeII_lines(upper,lower) .gt. 0) then
                if (weight .ge. 0.d0) then
                  weights%heii(upper,lower) = weight
                else
                  weights%heii(upper,lower) = linelist(HeII_lines(upper,lower))%intensity
                endif
                linelist(HeII_lines(upper,lower))%weight = weights%heii(upper,lower)
              endif
              cycle
            elseif (quantity(1:1).eq."H") then !balmer line weight
              backspace(631)
              read(631,"(A16,F5.2)") quantity,weight
              read(quantity(2:3),"(I2)") lineno
              if (H_Balmer(lineno).gt.0) then
                linelist(H_Balmer(lineno))%weight = weight
              endif

            elseif(quantity(1:1).eq."P") then !paschen line weight
              backspace(631)
              read(631,"(A16,F5.2)") quantity,weight
              read(quantity(2:3),"(I2)") lineno
              if (H_Paschen(lineno).gt.0) then
                linelist(H_Paschen(lineno))%weight = weight
              endif

!nii recombination line multiplets
            elseif(trim(quantity).eq."niiV3") then
              weights%niiV3 = weight
              cycle
            elseif(trim(quantity).eq."niiV5") then
              weights%niiV5 = weight
              cycle
            elseif(trim(quantity).eq."niiV8") then
              weights%niiV8 = weight
              cycle
            elseif(trim(quantity).eq."niiV12") then
              weights%niiV12 = weight
              cycle
            elseif(trim(quantity).eq."niiV20") then
              weights%niiV20 = weight
              cycle
            elseif(trim(quantity).eq."niiV28") then
              weights%niiV28 = weight
              cycle
            elseif(trim(quantity).eq."nii3d4f") then
              weights%nii3d4f = weight
              cycle
!oii recombination line multiplets
            elseif(trim(quantity).eq."oiiV1") then
              weights%oiiV1 = weight
              cycle
            elseif(trim(quantity).eq."oiiV2") then
              weights%oiiV2 = weight
              cycle
            elseif(trim(quantity).eq."oiiV5") then
              weights%oiiV5 = weight
              cycle
            elseif(trim(quantity).eq."oiiV10") then
              weights%oiiV10 = weight
              cycle
            elseif(trim(quantity).eq."oiiV11") then
              weights%oiiV11 = weight
              cycle
            elseif(trim(quantity).eq."oiiV12") then
              weights%oiiV12 = weight
              cycle
            elseif(trim(quantity).eq."oiiV19") then
              weights%oiiV19 = weight
              cycle
            elseif(trim(quantity).eq."oiiV20") then
              weights%oiiV20 = weight
              cycle
            elseif(trim(quantity).eq."oiiV25") then
              weights%oiiV25 = weight
              cycle
            elseif(trim(quantity).eq."oiiV28") then
              weights%oiiV28 = weight
              cycle
            elseif(trim(quantity).eq."oiiV33") then
              weights%oiiV33 = weight
              cycle
            elseif(trim(quantity).eq."oii3d4f") then
              weights%oii3d4f = weight
              cycle

            elseif (ILs(get_ion(quantity(1:11),ILs))%location .gt. 0) then !it's a CEL, get its location in the linelist array to set the weight
              linelist(ILs(get_ion(quantity(1:11),ILs))%location)%weight = weight
            endif
          endif
        enddo
        111 continue

!where the weight is the observed flux, set it here

        where (linelist%weight .lt. 0)
          linelist%weight = linelist%intensity
        endwhere

end subroutine setweights

end module