VMEC
8.52
3D Equilibrium solver with nested flux surfaces.
Toggle main menu visibility
Loading...
Searching...
No Matches
dbgout.f90
Go to the documentation of this file.
1
module
dbgout
2
use
json
3
implicit none
4
5
logical
::
skip_dbgout_collison
= .false.
6
7
contains
8
9
!> check if any output is desired for the current iteration
10
!> check if the given context should be openend based on input file flags
11
!> check if
12
!> @param context_name a string describing the subroutine from which this function is called
13
!> @param repetition a number to distinguish two calls to this with the same value of iter2
14
!> @param id a number to replace iter2 in the output filename
15
!> @return true: debug output should be written and file is open; false otherwise
16
function
open_dbg_context
(context_name, repetition, id)
17
use
vmec_dim
,
only
:
ns
18
use
vmec_main
,
only
:
iter2
19
use
vmec_input
20
implicit none
21
22
character(len=*)
,
intent(in)
:: context_name
23
integer
,
intent(in)
,
optional
:: repetition
24
integer
,
intent(in)
,
optional
:: id
25
logical
::
open_dbg_context
26
27
character(len=255)
:: dump_filename
28
character(len=255)
:: output_folder
29
logical
:: should_write, file_exists
30
integer
:: iter_value_to_use, i
31
32
! enable semi-pretty-printing JSON data
33
json_pretty_print = .true.
34
35
if
(
present
(id))
then
36
iter_value_to_use = id
37
else
38
iter_value_to_use =
iter2
39
end if
40
41
! check if debug out should be written at all
42
should_write = .false.
43
do
i = 1,
num_iter2_to_dump
44
if
(iter_value_to_use .eq.
iter2_to_dump
(i))
then
45
should_write = .true.
46
end if
47
end do
! num_iter2_to_dump
48
49
! check if requested context is enabled by input flags
50
if
(trim(context_name) .eq.
"add_fluxes"
)
then
51
open_dbg_context
=
dump_add_fluxes
52
else
if
(trim(context_name) .eq.
"metric"
)
then
53
open_dbg_context
=
dump_metric
54
else
if
(trim(context_name) .eq.
"volume"
)
then
55
open_dbg_context
=
dump_volume
56
else
if
(trim(context_name) .eq.
"bcontrav"
)
then
57
open_dbg_context
=
dump_bcontrav
58
else
if
(trim(context_name) .eq.
"bcov"
)
then
59
open_dbg_context
=
dump_bcov
60
else
if
(trim(context_name) .eq.
"lambda_forces"
)
then
61
open_dbg_context
=
dump_lambda_forces
62
else
if
(trim(context_name) .eq.
"bcov_full"
)
then
63
open_dbg_context
=
dump_bcov_full
64
else
if
(trim(context_name) .eq.
"precondn"
)
then
65
open_dbg_context
=
dump_precondn
66
else
if
(trim(context_name) .eq.
"forceNorms_tcon"
)
then
67
open_dbg_context
=
dump_forcenorms_tcon
68
else
if
(trim(context_name) .eq.
"lulv_comb"
)
then
69
open_dbg_context
=
dump_lulv_comb
70
else
if
(trim(context_name) .eq.
"calc_fbal"
)
then
71
open_dbg_context
=
dump_calc_fbal
72
else
if
(trim(context_name) .eq.
"evolve"
)
then
73
open_dbg_context
=
dump_evolve
74
else
if
(trim(context_name) .eq.
"fixaray"
)
then
75
open_dbg_context
=
dump_fixaray
76
else
if
(trim(context_name) .eq.
"spectral_constraint"
)
then
77
open_dbg_context
=
dump_spectral_constraint
78
else
if
(trim(context_name) .eq.
"forces"
)
then
79
open_dbg_context
=
dump_forces
80
else
if
(trim(context_name) .eq.
"totzsp_input"
)
then
81
open_dbg_context
=
dump_totzsp_input
82
else
if
(trim(context_name) .eq.
"funct3d_geometry"
)
then
83
open_dbg_context
=
dump_funct3d_geometry
84
else
if
(trim(context_name) .eq.
"rbsq"
)
then
85
open_dbg_context
=
dump_rbsq
86
else
if
(trim(context_name) .eq.
"constraint_force"
)
then
87
open_dbg_context
=
dump_constraint_force
88
else
if
(trim(context_name) .eq.
"guess_axis"
)
then
89
open_dbg_context
=
dump_guess_axis
90
else
if
(trim(context_name) .eq.
"interp"
)
then
91
open_dbg_context
=
dump_interp
92
else
if
(trim(context_name) .eq.
"jacobian"
)
then
93
open_dbg_context
=
dump_jacobian
94
else
if
(trim(context_name) .eq.
"lamcal"
)
then
95
open_dbg_context
=
dump_lamcal
96
else
if
(trim(context_name) .eq.
"profil1d"
)
then
97
open_dbg_context
=
dump_profil1d
98
else
if
(trim(context_name) .eq.
"profil3d"
)
then
99
open_dbg_context
=
dump_profil3d
100
else
if
(trim(context_name) .eq.
"readin_boundary"
)
then
101
open_dbg_context
=
dump_readin_boundary
102
else
if
(trim(context_name) .eq.
"fsq"
)
then
103
open_dbg_context
=
dump_fsq
104
else
if
(trim(context_name) .eq.
"scale_m1"
)
then
105
open_dbg_context
=
dump_scale_m1
106
else
if
(trim(context_name) .eq.
"scalfor_out"
)
then
107
open_dbg_context
=
dump_scalfor_out
108
else
if
(trim(context_name) .eq.
"fsq1"
)
then
109
open_dbg_context
=
dump_fsq1
110
else
if
(trim(context_name) .eq.
"scalfor_R"
)
then
111
open_dbg_context
=
dump_scalfor_r
112
else
if
(trim(context_name) .eq.
"scalfor_Z"
)
then
113
open_dbg_context
=
dump_scalfor_z
114
else
if
(trim(context_name) .eq.
"symforce"
)
then
115
open_dbg_context
=
dump_symforce
116
else
if
(trim(context_name) .eq.
"tomnsps"
)
then
117
open_dbg_context
=
dump_tomnsps
118
else
if
(trim(context_name) .eq.
"tomnspa"
)
then
119
open_dbg_context
=
dump_tomnspa
120
else
if
(trim(context_name) .eq.
"phys_gc"
)
then
121
open_dbg_context
=
dump_phys_gc
122
else
if
(trim(context_name) .eq.
"multigrid_result"
)
then
123
open_dbg_context
=
dump_multigrid_result
124
125
! multigrid_result needs to be written once at end of many iterations,
126
! so the usual should_write logic needs to be broken here
127
should_write = .true.
128
129
else
if
(trim(context_name) .eq.
"printout"
)
then
130
open_dbg_context
=
dump_printout
131
132
! fileout
133
else
if
(trim(context_name) .eq.
"bcovar_fileout"
)
then
134
open_dbg_context
=
dump_bcovar_fileout
135
else
if
(trim(context_name) .eq.
"bss"
)
then
136
open_dbg_context
=
dump_bss
137
else
if
(trim(context_name) .eq.
"jxbforce_bsub_lowpass"
)
then
138
open_dbg_context
=
dump_jxbforce_bsub_lowpass
139
else
if
(trim(context_name) .eq.
"jxbout"
)
then
140
open_dbg_context
=
dump_jxbout
141
else
if
(trim(context_name) .eq.
"mercier"
)
then
142
open_dbg_context
=
dump_mercier
143
else
if
(trim(context_name) .eq.
"threed1_firstTable"
)
then
144
open_dbg_context
=
dump_threed1_firsttable
145
else
if
(trim(context_name) .eq.
"threed1_geomag"
)
then
146
open_dbg_context
=
dump_threed1_geomag
147
else
if
(trim(context_name) .eq.
"threed1_volquant"
)
then
148
open_dbg_context
=
dump_threed1_volquant
149
else
if
(trim(context_name) .eq.
"threed1_axis"
)
then
150
open_dbg_context
=
dump_threed1_axis
151
else
if
(trim(context_name) .eq.
"threed1_beta"
)
then
152
open_dbg_context
=
dump_threed1_beta
153
else
if
(trim(context_name) .eq.
"threed1_shafrint"
)
then
154
open_dbg_context
=
dump_threed1_shafrint
155
else
if
(trim(context_name) .eq.
"freeb_data"
)
then
156
open_dbg_context
=
dump_freeb_data
157
158
159
! NESTOR vac1
160
else
if
(trim(context_name) .eq.
"vac1n_vacuum"
)
then
161
open_dbg_context
=
dump_vac1n_vacuum
162
else
if
(trim(context_name) .eq.
"vac1n_precal"
)
then
163
open_dbg_context
=
dump_vac1n_precal
164
else
if
(trim(context_name) .eq.
"vac1n_surface"
)
then
165
open_dbg_context
=
dump_vac1n_surface
166
else
if
(trim(context_name) .eq.
"vac1n_bextern"
)
then
167
open_dbg_context
=
dump_vac1n_bextern
168
else
if
(trim(context_name) .eq.
"vac1n_analyt"
)
then
169
open_dbg_context
=
dump_vac1n_analyt
170
else
if
(trim(context_name) .eq.
"vac1n_greenf"
)
then
171
open_dbg_context
=
dump_vac1n_greenf
172
else
if
(trim(context_name) .eq.
"vac1n_fourp"
)
then
173
open_dbg_context
=
dump_vac1n_fourp
174
else
if
(trim(context_name) .eq.
"vac1n_fouri"
)
then
175
open_dbg_context
=
dump_vac1n_fouri
176
else
if
(trim(context_name) .eq.
"vac1n_solver"
)
then
177
open_dbg_context
=
dump_vac1n_solver
178
else
if
(trim(context_name) .eq.
"vac1n_bsqvac"
)
then
179
open_dbg_context
=
dump_vac1n_bsqvac
180
181
! NESTOR vac2
182
else
if
(trim(context_name) .eq.
"vac2_vacuum"
)
then
183
open_dbg_context
=
dump_vac2_vacuum
184
else
if
(trim(context_name) .eq.
"vac2_precal"
)
then
185
open_dbg_context
=
dump_vac2_precal
186
else
if
(trim(context_name) .eq.
"vac2_surface"
)
then
187
open_dbg_context
=
dump_vac2_surface
188
else
if
(trim(context_name) .eq.
"vac2_bexmat"
)
then
189
open_dbg_context
=
dump_vac2_bexmat
190
else
if
(trim(context_name) .eq.
"vac2_matrix"
)
then
191
open_dbg_context
=
dump_vac2_matrix
192
else
if
(trim(context_name) .eq.
"vac2_foumat_unreg"
)
then
193
open_dbg_context
=
dump_vac2_foumat_unreg
194
else
if
(trim(context_name) .eq.
"vac2_analin"
)
then
195
open_dbg_context
=
dump_vac2_analin
196
else
if
(trim(context_name) .eq.
"vac2_analyt"
)
then
197
open_dbg_context
=
dump_vac2_analyt
198
else
if
(trim(context_name) .eq.
"vac2_foumat"
)
then
199
open_dbg_context
=
dump_vac2_foumat
200
else
if
(trim(context_name) .eq.
"vac2_linsys"
)
then
201
open_dbg_context
=
dump_vac2_linsys
202
else
if
(trim(context_name) .eq.
"vac2_linslv"
)
then
203
open_dbg_context
=
dump_vac2_linslv
204
else
if
(trim(context_name) .eq.
"vac2_bsqvac"
)
then
205
open_dbg_context
=
dump_vac2_bsqvac
206
207
! default
208
else
209
write
(*,*)
"unknown debug output context: '"
,trim(context_name),
"'"
210
stop
211
end if
212
213
open_dbg_context
=
open_dbg_context
.and. should_write
214
215
! create output filename and open output file
216
if
(
open_dbg_context
)
then
217
218
! debugging output into separate folder "input_extension"
219
output_folder = trim(
input_extension
) //
"/"
// trim(context_name)
220
CALL
system(
"mkdir -p "
//trim(output_folder))
! NOTE: This only works on Linux/Unix !!!
221
222
if
(
present
(id))
then
223
if
(
present
(repetition))
then
224
write
(dump_filename, 998) trim(output_folder), &
225
trim(context_name), &
226
ns
, id, repetition, &
227
trim(
input_extension
)
228
else
229
write
(dump_filename, 999) trim(output_folder), &
230
trim(context_name), &
231
ns
, id, trim(
input_extension
)
232
end if
233
else
234
if
(
present
(repetition))
then
235
write
(dump_filename, 998) trim(output_folder), &
236
trim(context_name), &
237
ns
,
iter2
, repetition, &
238
trim(
input_extension
)
239
else
! default: ns, iter2 for filename
240
write
(dump_filename, 999) trim(output_folder), &
241
trim(context_name), &
242
ns
,
iter2
, trim(
input_extension
)
243
end if
244
end if
245
998
format
(a,
'/'
,a,
'_'
,i5.5,
'_'
,i6.6,
'_'
,i2.2,
'.'
,a,
'.json'
)
246
999
format
(a,
'/'
,a,
'_'
,i5.5,
'_'
,i6.6,
'_01.'
,a,
'.json'
)
247
248
! check if file already exists (and stop in that case)
249
inquire
(file=trim(dump_filename), exist=file_exists)
250
if
(file_exists)
then
251
if
(
skip_dbgout_collison
)
then
252
! Temporary hack to skip overwriting a file
253
! without halting the algorithm.
254
open_dbg_context
= .false.
255
return
256
end if
257
stop
"debug output file already exists: '"
//trim(dump_filename)//
"'"
258
end if
259
260
call
open_dbg_out(dump_filename)
261
end if
262
263
end
! open_dbg_context
264
265
end module
dbgout
dbgout
Definition
dbgout.f90:1
dbgout::skip_dbgout_collison
logical skip_dbgout_collison
Definition
dbgout.f90:5
dbgout::open_dbg_context
logical function open_dbg_context(context_name, repetition, id)
check if any output is desired for the current iteration check if the given context should be openend...
Definition
dbgout.f90:17
vmec_dim
Definition
vmec_dim.f90:2
vmec_dim::ns
integer ns
number of flux surfaces
Definition
vmec_dim.f90:17
vmec_input
Definition
vmec_input.f90:2
vmec_input::dump_vac2_analyt
logical dump_vac2_analyt
Definition
vmec_input.f90:162
vmec_input::dump_vac2_surface
logical dump_vac2_surface
Definition
vmec_input.f90:157
vmec_input::dump_threed1_axis
logical dump_threed1_axis
Definition
vmec_input.f90:138
vmec_input::dump_rbsq
logical dump_rbsq
Definition
vmec_input.f90:126
vmec_input::dump_scalfor_out
logical dump_scalfor_out
Definition
vmec_input.f90:118
vmec_input::dump_vac2_matrix
logical dump_vac2_matrix
Definition
vmec_input.f90:159
vmec_input::dump_printout
logical dump_printout
Definition
vmec_input.f90:127
vmec_input::dump_vac1n_fourp
logical dump_vac1n_fourp
Definition
vmec_input.f90:150
vmec_input::dump_scalfor_z
logical dump_scalfor_z
Definition
vmec_input.f90:121
vmec_input::dump_add_fluxes
logical dump_add_fluxes
individual flags to control debug output loosely related to similarly-named routines (checkpoints alo...
Definition
vmec_input.f90:90
vmec_input::dump_mercier
logical dump_mercier
Definition
vmec_input.f90:134
vmec_input::dump_guess_axis
logical dump_guess_axis
Definition
vmec_input.f90:108
vmec_input::dump_spectral_constraint
logical dump_spectral_constraint
Definition
vmec_input.f90:103
vmec_input::dump_fixaray
logical dump_fixaray
Definition
vmec_input.f90:102
vmec_input::dump_vac2_precal
logical dump_vac2_precal
Definition
vmec_input.f90:156
vmec_input::dump_vac2_analin
logical dump_vac2_analin
Definition
vmec_input.f90:161
vmec_input::dump_precondn
logical dump_precondn
Definition
vmec_input.f90:97
vmec_input::dump_vac1n_precal
logical dump_vac1n_precal
Definition
vmec_input.f90:145
vmec_input::dump_vac1n_vacuum
logical dump_vac1n_vacuum
Definition
vmec_input.f90:144
vmec_input::dump_vac2_foumat
logical dump_vac2_foumat
Definition
vmec_input.f90:163
vmec_input::dump_vac1n_bextern
logical dump_vac1n_bextern
Definition
vmec_input.f90:147
vmec_input::dump_vac1n_fouri
logical dump_vac1n_fouri
Definition
vmec_input.f90:151
vmec_input::dump_freeb_data
logical dump_freeb_data
Definition
vmec_input.f90:141
vmec_input::dump_fsq1
logical dump_fsq1
Definition
vmec_input.f90:119
vmec_input::dump_jxbout
logical dump_jxbout
Definition
vmec_input.f90:133
vmec_input::dump_lambda_forces
logical dump_lambda_forces
Definition
vmec_input.f90:95
vmec_input::dump_funct3d_geometry
logical dump_funct3d_geometry
Definition
vmec_input.f90:106
vmec_input::dump_jacobian
logical dump_jacobian
Definition
vmec_input.f90:110
vmec_input::dump_evolve
logical dump_evolve
Definition
vmec_input.f90:101
vmec_input::dump_vac2_vacuum
logical dump_vac2_vacuum
Definition
vmec_input.f90:155
vmec_input::dump_readin_boundary
logical dump_readin_boundary
Definition
vmec_input.f90:114
vmec_input::dump_vac2_bexmat
logical dump_vac2_bexmat
Definition
vmec_input.f90:158
vmec_input::dump_bcov_full
logical dump_bcov_full
Definition
vmec_input.f90:96
vmec_input::dump_vac2_linslv
logical dump_vac2_linslv
Definition
vmec_input.f90:165
vmec_input::dump_volume
logical dump_volume
Definition
vmec_input.f90:92
vmec_input::dump_symforce
logical dump_symforce
Definition
vmec_input.f90:122
vmec_input::dump_fsq
logical dump_fsq
Definition
vmec_input.f90:116
vmec_input::dump_multigrid_result
logical dump_multigrid_result
Definition
vmec_input.f90:125
vmec_input::dump_threed1_firsttable
logical dump_threed1_firsttable
Definition
vmec_input.f90:135
vmec_input::dump_bcov
logical dump_bcov
Definition
vmec_input.f90:94
vmec_input::dump_totzsp_input
logical dump_totzsp_input
Definition
vmec_input.f90:105
vmec_input::dump_tomnsps
logical dump_tomnsps
Definition
vmec_input.f90:123
vmec_input::dump_lamcal
logical dump_lamcal
Definition
vmec_input.f90:111
vmec_input::dump_tomnspa
logical dump_tomnspa
Definition
vmec_input.f90:124
vmec_input::dump_vac1n_surface
logical dump_vac1n_surface
Definition
vmec_input.f90:146
vmec_input::dump_forces
logical dump_forces
Definition
vmec_input.f90:104
vmec_input::dump_calc_fbal
logical dump_calc_fbal
Definition
vmec_input.f90:100
vmec_input::dump_constraint_force
logical dump_constraint_force
Definition
vmec_input.f90:107
vmec_input::dump_interp
logical dump_interp
Definition
vmec_input.f90:109
vmec_input::input_extension
character(len=100) input_extension
Definition
vmec_input.f90:81
vmec_input::dump_vac1n_bsqvac
logical dump_vac1n_bsqvac
Definition
vmec_input.f90:153
vmec_input::dump_threed1_beta
logical dump_threed1_beta
Definition
vmec_input.f90:139
vmec_input::dump_scalfor_r
logical dump_scalfor_r
Definition
vmec_input.f90:120
vmec_input::num_iter2_to_dump
integer, parameter num_iter2_to_dump
Definition
vmec_input.f90:14
vmec_input::dump_phys_gc
logical dump_phys_gc
Definition
vmec_input.f90:115
vmec_input::dump_metric
logical dump_metric
Definition
vmec_input.f90:91
vmec_input::dump_jxbforce_bsub_lowpass
logical dump_jxbforce_bsub_lowpass
Definition
vmec_input.f90:132
vmec_input::dump_bcovar_fileout
logical dump_bcovar_fileout
Definition
vmec_input.f90:130
vmec_input::dump_vac2_foumat_unreg
logical dump_vac2_foumat_unreg
Definition
vmec_input.f90:160
vmec_input::dump_lulv_comb
logical dump_lulv_comb
Definition
vmec_input.f90:99
vmec_input::dump_vac1n_solver
logical dump_vac1n_solver
Definition
vmec_input.f90:152
vmec_input::dump_vac1n_analyt
logical dump_vac1n_analyt
Definition
vmec_input.f90:148
vmec_input::dump_vac2_bsqvac
logical dump_vac2_bsqvac
Definition
vmec_input.f90:166
vmec_input::dump_vac1n_greenf
logical dump_vac1n_greenf
Definition
vmec_input.f90:149
vmec_input::dump_forcenorms_tcon
logical dump_forcenorms_tcon
Definition
vmec_input.f90:98
vmec_input::dump_profil1d
logical dump_profil1d
Definition
vmec_input.f90:112
vmec_input::dump_vac2_linsys
logical dump_vac2_linsys
Definition
vmec_input.f90:164
vmec_input::iter2_to_dump
integer, dimension(num_iter2_to_dump) iter2_to_dump
values of iter2 for which to dump data
Definition
vmec_input.f90:86
vmec_input::dump_profil3d
logical dump_profil3d
Definition
vmec_input.f90:113
vmec_input::dump_bss
logical dump_bss
Definition
vmec_input.f90:131
vmec_input::dump_scale_m1
logical dump_scale_m1
Definition
vmec_input.f90:117
vmec_input::dump_threed1_volquant
logical dump_threed1_volquant
Definition
vmec_input.f90:137
vmec_input::dump_bcontrav
logical dump_bcontrav
Definition
vmec_input.f90:93
vmec_input::dump_threed1_shafrint
logical dump_threed1_shafrint
Definition
vmec_input.f90:140
vmec_input::dump_threed1_geomag
logical dump_threed1_geomag
Definition
vmec_input.f90:136
vmec_main
Definition
vmec_main.f90:2
vmec_main::iter2
integer iter2
total number of iterations
Definition
vmec_main.f90:161
src
dbgout.f90
Generated on
for VMEC by
1.17.0