-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParseInput.F90
executable file
·333 lines (296 loc) · 9.23 KB
/
ParseInput.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
! Contains global variables, tracking settings, etc.
MODULE ParseInput
IMPLICIT NONE
LOGICAL :: verbose
INTEGER :: nsteps ! number of timesteps
INTEGER :: trackrate ! 0=carrington, 1=snodgrass, 2=custom
INTEGER :: crot, cmlon ! defines the central time
LOGICAL :: dotilesize(6) ! dotilesize(i) is for 2^(i-1) degrees
REAL :: lonrn, latrn, clon, clat ! ranges and center lat/lons
REAL :: memlimittotal ! max GB of memory to allocate for tiles
CHARACTER(LEN=200) :: masterlist, background
INTEGER :: backgroundset
CHARACTER(LEN=400) :: outdir
INTEGER :: loaddops ! number of dopplergrams to keep in memory
REAL :: apode ! apodization something
REAL :: a0,a2,a4 ! tracking rate
LOGICAL :: dotiming ! record timing info
REAL :: densepack ! fraction to overlap by
LOGICAL :: mdi ! use mdi settings
INTEGER :: doppix ! linear size of dopplergram in pixels
LOGICAL :: makepspec ! instead of writing tile out, make it into a pspec
LOGICAL :: extended ! use extended header info, from newer dopplergrams
LOGICAL :: use_gridfile
CHARACTER(LEN=400) :: gridfile, fname_guess, fitout
INTEGER :: maxtiles
CONTAINS
SUBROUTINE Usage()
IMPLICIT NONE
PRINT*, "Minimal Usage: ./atlas"
PRINT*, "Other Options:"
PRINT*, " -v Verbose Mode"
PRINT*, " -r [#] Tracking rate (0=car, 1=snod, 2=custom)"
PRINT*, " -ml [file] Master list of dopplergrams"
PRINT*, " -bk [file] Background fits file"
PRINT*, " -ts[32,16,8,4,2,1] Do tilesize [#]"
PRINT*, " -clon [#], -clat [#] Central lon/lat"
PRINT*, " -lonrn [#], -latrn [#] Lon/lat ranges"
PRINT*, " -memlimit [#] Total memory limit in GB"
PRINT*, " -loaddops [#] Number of dopplergrams to load at a time"
PRINT*, " -time Record timing info for performance analysis"
PRINT*, " -outdir [dir] Directory to save output in"
PRINT*, " -mdi Use MDI settings (dopplergram size, scale, etc)"
PRINT*, " -pspec Turn tracked tile into an unwrapped pspec"
PRINT*, " -extend Use extended header info from newer dopplergrams"
PRINT*, " -grid [file] File to read grid from"
PRINT*, " -fitguess [file] Guess table for fitting"
PRINT*, " -fitout [file] File to save fits to (binary)"
PRINT*, " -maxtiles [#] Number of tiles per MPI process to hold in memory at once"
END SUBROUTINE Usage
! Note the lack of IMPLICIT NONE
! Poor coding? Maybe.
SUBROUTINE ReadCommandLine()
INTEGER :: ii, argcount, currarg, tempint, tempint2
REAL :: tempreal
CHARACTER(LEN=200) :: strbuffer
argcount = IARGC()
! Read command line arguments
DO ii=1,argcount
CALL getarg(ii,strbuffer)
IF (strbuffer .EQ. "--help" .OR. strbuffer .EQ. "-h") THEN
CALL Usage()
STOP
ENDIF
! verbose mode
IF (strbuffer .EQ. "-v") THEN
verbose = .TRUE.
! parse time
ELSEIF (strbuffer .EQ. "-t") THEN
CALL getarg(ii+1,strbuffer)
IF (INDEX(strbuffer,":") .EQ. 5) THEN ! assume crot has 4 digits
READ(strbuffer(1:4),*) tempint
READ(strbuffer(6:LEN_TRIM(strbuffer)),*) tempint2
IF (tempint .GT. 2000 .AND. tempint .LT. 3000 .AND. &
tempint2 .GE. 0 .AND. tempint2 .LE. 360) THEN
crot = tempint
cmlon = tempint2
ELSE
PRINT*, "Invalid Time"
ENDIF
ELSE
PRINT*, "Invalid Time. Example: 2096:180"
ENDIF
! number of time steps
ELSEIF (strbuffer .EQ. "-l") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempint
IF (tempint .GE. 3 .AND. tempint .LE. 15000) THEN
nsteps = tempint
ELSE
PRINT*, "Invalid number of steps, using default."
ENDIF
! tracking rate
ELSEIF (strbuffer .EQ. "-r") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) trackrate
IF (trackrate .EQ. 0) THEN ! carrington
a0 = 0D0
a2 = 0D0
a4 = 0D0
ELSE IF (trackrate .EQ. 1) THEN ! snodgrass
a0 = -0.02893D0
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 2) THEN ! custom
a0 = -0.04330D0 ! snodgrass + 10 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 3) THEN ! custom
a0 = -0.06485D0 ! snodgrass + 25 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 4) THEN ! custom
a0 = -0.10077D0 ! snodgrass + 50 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 5) THEN ! custom
a0 = -0.17261D0 ! snodgrass + 100 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 6) THEN ! custom
a0 = -0.38813D0 ! snodgrass + 250 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 7) THEN ! custom
a0 = 0.33027D0 ! snodgrass - 250 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 8) THEN ! custom
a0 = -0.747321D0 ! snodgrass + 500 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE IF (trackrate .EQ. 9) THEN ! custom
a0 = 0.689461D0 ! snodgrass - 500 m/s
a2 = -0.341D0
a4 = -0.5037D0
ELSE
PRINT*, "Invalid tracking rate, defaulting to snodgrass"
a0 = -0.02893D0
a2 = -0.341D0
a4 = -0.5037D0
ENDIF
! dopplergram master list
ELSEIF (strbuffer .EQ. "-ml") THEN
masterlist = ""
CALL getarg(ii+1,masterlist)
! background file
ELSEIF (strbuffer .EQ. "-bk") THEN
background = ""
CALL getarg(ii+1,background)
backgroundset = 1
! tile save directory
ELSEIF (strbuffer .EQ. "-outdir") THEN
outdir = ""
CALL getarg(ii+1,outdir)
! do tilesizes
ELSEIF (strbuffer .EQ. "-ts32") THEN
dotilesize(6) = .TRUE.
ELSEIF (strbuffer .EQ. "-ts16") THEN
dotilesize(5) = .TRUE.
ELSEIF (strbuffer .EQ. "-ts8") THEN
dotilesize(4) = .TRUE.
ELSEIF (strbuffer .EQ. "-ts4") THEN
dotilesize(3) = .TRUE.
ELSEIF (strbuffer .EQ. "-ts2") THEN
dotilesize(2) = .TRUE.
ELSEIF (strbuffer .EQ. "-ts1") THEN
dotilesize(1) = .TRUE.
! central lat/lon
ELSEIF (strbuffer .EQ. "-clon") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempreal
clon = tempreal
ELSEIF (strbuffer .EQ. "-clat") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempreal
clat = tempreal
! lat/lon ranges
ELSEIF (strbuffer .EQ. "-lonrn") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempreal
lonrn = tempreal
ELSEIF (strbuffer .EQ. "-latrn") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempreal
latrn = tempreal
! memory limit
ELSEIF (strbuffer .EQ. "-memlimit") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempreal
memlimittotal = tempreal
! number of dops to load at a time
ELSEIF (strbuffer .EQ. "-loaddops") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempint
loaddops = tempint
! record timing info
ELSEIF (strbuffer .EQ. "-time") THEN
dotiming = .TRUE.
! densepack
ELSEIF (strbuffer .EQ. "-densepack") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempreal
IF (tempreal .GT. 0D0 .AND. tempreal .LT. 1D0) THEN
densepack = tempreal
ENDIF
ELSEIF (strbuffer .EQ. "-mdi") THEN
mdi = .TRUE.
doppix = 1024
ELSEIF (strbuffer .EQ. "-pspec") THEN
makepspec = .TRUE.
ELSEIF (strbuffer .EQ. "-extend") THEN
extended = .TRUE.
ELSEIF (strbuffer .EQ. "-grid") THEN
use_gridfile = .TRUE.
CALL getarg(ii+1,gridfile)
ELSEIF (strbuffer .EQ. "-fitguess") THEN
CALL getarg(ii+1,fname_guess)
ELSEIF (strbuffer .EQ. "-fitout") THEN
CALL getarg(ii+1,fitout)
ELSEIF (strbuffer .EQ. "-maxtiles") THEN
CALL getarg(ii+1,strbuffer)
READ(strbuffer,*) tempint
IF (tempint .GE. 1 .AND. tempint .LE. 500) THEN
maxtiles = tempint
ELSE
PRINT*, "Invalid number of tiles, using 1"
maxtiles = 1
ENDIF
ENDIF
ENDDO
END SUBROUTINE ReadCommandLine
! Set the default values of various run parameters
! It is best to call this before reading in any conflicting information..
SUBROUTINE SetDefaults()
verbose = .FALSE.
nsteps = 2048
trackrate = 1
a0 = -0.02893D0
a2 = -0.341D0
a4 = -0.5037D0
lonrn = 0D0
latrn = 0D0
clon = 120D0
clat = 0D0
dotilesize(1) = .FALSE.
dotilesize(2) = .FALSE.
dotilesize(3) = .FALSE.
dotilesize(4) = .FALSE.
dotilesize(5) = .FALSE.
dotilesize(6) = .FALSE.
memlimittotal = 8.0
masterlist = "doplist"
loaddops = 8
apode = 0.9375D0
dotiming = .FALSE.
densepack = 0.5D0
background = ""
backgroundset = 0
mdi = .FALSE.
doppix = 4096
makepspec = .TRUE.
extended = .FALSE.
use_gridfile = .FALSE.
gridfile = ""
fname_guess = "16_deg.model"
fitout = "fitout"
maxtiles = 1
END SUBROUTINE SetDefaults
! Print the run details to stdout
SUBROUTINE PrintDetails()
INTEGER :: ii
PRINT*, "Run Details:"
! WRITE(*,'(A,I4)') " Carrington Rotation = ",crot
! WRITE(*,'(A,I3)') " Central Meridian Longitude = ", cmlon
SELECT CASE (trackrate)
CASE (0)
PRINT*, " Tracking at Carrington Rate"
CASE (1)
PRINT*, " Tracking at Snodgrass Rate"
CASE (2)
PRINT*, " Tracking at Custom Rate"
END SELECT
WRITE(*,'(A,A)') " Master List File: ", TRIM(masterlist)
WRITE(*,'(A$)') " Tracking Tilesizes: "
DO ii=1,6
IF (dotilesize(ii)) THEN
WRITE(*,'(I0,A$)'), 2**(ii-1), " "
ENDIF
ENDDO
WRITE(*,'(A,I5)') " Dopplergram Size: ", doppix
WRITE(*,'(A)') ""
PRINT*, " Central Lon/Lat: ", clon, clat
PRINT*, " Lon/Lat Ranges: ", lonrn, latrn
WRITE(*,'(A)') ""
END SUBROUTINE PrintDetails
END MODULE