VMEC 8.52
3D Equilibrium solver with nested flux surfaces.
Loading...
Searching...
No Matches
dbgout.f90
Go to the documentation of this file.
1module dbgout
2 use json
3 implicit none
4
5 logical :: skip_dbgout_collison = .false.
6
7contains
8
16function 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
52 else if (trim(context_name) .eq. "metric") then
54 else if (trim(context_name) .eq. "volume") then
56 else if (trim(context_name) .eq. "bcontrav") then
58 else if (trim(context_name) .eq. "bcov") then
60 else if (trim(context_name) .eq. "lambda_forces") then
62 else if (trim(context_name) .eq. "bcov_full") then
64 else if (trim(context_name) .eq. "precondn") then
66 else if (trim(context_name) .eq. "forceNorms_tcon") then
68 else if (trim(context_name) .eq. "lulv_comb") then
70 else if (trim(context_name) .eq. "calc_fbal") then
72 else if (trim(context_name) .eq. "evolve") then
74 else if (trim(context_name) .eq. "fixaray") then
76 else if (trim(context_name) .eq. "spectral_constraint") then
78 else if (trim(context_name) .eq. "forces") then
80 else if (trim(context_name) .eq. "totzsp_input") then
82 else if (trim(context_name) .eq. "funct3d_geometry") then
84 else if (trim(context_name) .eq. "rbsq") then
86 else if (trim(context_name) .eq. "constraint_force") then
88 else if (trim(context_name) .eq. "guess_axis") then
90 else if (trim(context_name) .eq. "interp") then
92 else if (trim(context_name) .eq. "jacobian") then
94 else if (trim(context_name) .eq. "lamcal") then
96 else if (trim(context_name) .eq. "profil1d") then
98 else if (trim(context_name) .eq. "profil3d") then
100 else if (trim(context_name) .eq. "readin_boundary") then
102 else if (trim(context_name) .eq. "fsq") then
104 else if (trim(context_name) .eq. "scale_m1") then
106 else if (trim(context_name) .eq. "scalfor_out") then
108 else if (trim(context_name) .eq. "fsq1") then
110 else if (trim(context_name) .eq. "scalfor_R") then
112 else if (trim(context_name) .eq. "scalfor_Z") then
114 else if (trim(context_name) .eq. "symforce") then
116 else if (trim(context_name) .eq. "tomnsps") then
118 else if (trim(context_name) .eq. "tomnspa") then
120 else if (trim(context_name) .eq. "phys_gc") then
122 else if (trim(context_name) .eq. "multigrid_result") then
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
131
132 ! fileout
133 else if (trim(context_name) .eq. "bcovar_fileout") then
135 else if (trim(context_name) .eq. "bss") then
137 else if (trim(context_name) .eq. "jxbforce_bsub_lowpass") then
139 else if (trim(context_name) .eq. "jxbout") then
141 else if (trim(context_name) .eq. "mercier") then
143 else if (trim(context_name) .eq. "threed1_firstTable") then
145 else if (trim(context_name) .eq. "threed1_geomag") then
147 else if (trim(context_name) .eq. "threed1_volquant") then
149 else if (trim(context_name) .eq. "threed1_axis") then
151 else if (trim(context_name) .eq. "threed1_beta") then
153 else if (trim(context_name) .eq. "threed1_shafrint") then
155 else if (trim(context_name) .eq. "freeb_data") then
157
158
159 ! NESTOR vac1
160 else if (trim(context_name) .eq. "vac1n_vacuum") then
162 else if (trim(context_name) .eq. "vac1n_precal") then
164 else if (trim(context_name) .eq. "vac1n_surface") then
166 else if (trim(context_name) .eq. "vac1n_bextern") then
168 else if (trim(context_name) .eq. "vac1n_analyt") then
170 else if (trim(context_name) .eq. "vac1n_greenf") then
172 else if (trim(context_name) .eq. "vac1n_fourp") then
174 else if (trim(context_name) .eq. "vac1n_fouri") then
176 else if (trim(context_name) .eq. "vac1n_solver") then
178 else if (trim(context_name) .eq. "vac1n_bsqvac") then
180
181 ! NESTOR vac2
182 else if (trim(context_name) .eq. "vac2_vacuum") then
184 else if (trim(context_name) .eq. "vac2_precal") then
186 else if (trim(context_name) .eq. "vac2_surface") then
188 else if (trim(context_name) .eq. "vac2_bexmat") then
190 else if (trim(context_name) .eq. "vac2_matrix") then
192 else if (trim(context_name) .eq. "vac2_foumat_unreg") then
194 else if (trim(context_name) .eq. "vac2_analin") then
196 else if (trim(context_name) .eq. "vac2_analyt") then
198 else if (trim(context_name) .eq. "vac2_foumat") then
200 else if (trim(context_name) .eq. "vac2_linsys") then
202 else if (trim(context_name) .eq. "vac2_linslv") then
204 else if (trim(context_name) .eq. "vac2_bsqvac") then
206
207
208 ! default
209 else
210 write(*,*) "unknown debug output context: '",trim(context_name),"'"
211 stop
212 end if
213
214 open_dbg_context = open_dbg_context .and. should_write
215
216 ! create output filename and open output file
217 if (open_dbg_context) then
218
219 ! debugging output into separate folder "input_extension"
220 output_folder = trim(input_extension) // "/" // trim(context_name)
221 CALL system("mkdir -p "//trim(output_folder)) ! NOTE: This only works on Linux/Unix !!!
222
223 if (present(id)) then
224 if (present(repetition)) then
225 write(dump_filename, 998) trim(output_folder), &
226 trim(context_name), &
227 ns, id, repetition, &
228 trim(input_extension)
229 else
230 write(dump_filename, 999) trim(output_folder), &
231 trim(context_name), &
232 ns, id, trim(input_extension)
233 end if
234 else
235 if (present(repetition)) then
236 write(dump_filename, 998) trim(output_folder), &
237 trim(context_name), &
238 ns, iter2, repetition, &
239 trim(input_extension)
240 else ! default: ns, iter2 for filename
241 write(dump_filename, 999) trim(output_folder), &
242 trim(context_name), &
243 ns, iter2, trim(input_extension)
244 end if
245 end if
246998 format(a,'/',a,'_',i5.5,'_',i6.6,'_',i2.2,'.',a,'.json')
247999 format(a,'/',a,'_',i5.5,'_',i6.6,'_01.',a,'.json')
248
249 ! check if file already exists (and stop in that case)
250 inquire(file=trim(dump_filename), exist=file_exists)
251 if (file_exists) then
252 if (skip_dbgout_collison) then
253 ! Temporary hack to skip overwriting a file
254 ! without halting the algorithm.
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
263end ! open_dbg_context
264
265end module dbgout
logical skip_dbgout_collison
Definition dbgout.f90:5
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
integer ns
number of flux surfaces
Definition vmec_dim.f90:17
logical dump_vac2_analyt
logical dump_vac2_surface
logical dump_threed1_axis
logical dump_rbsq
logical dump_scalfor_out
logical dump_vac2_matrix
logical dump_printout
logical dump_vac1n_fourp
logical dump_scalfor_z
logical dump_add_fluxes
individual flags to control debug output loosely related to similarly-named routines (checkpoints alo...
logical dump_mercier
logical dump_guess_axis
logical dump_spectral_constraint
logical dump_fixaray
logical dump_vac2_precal
logical dump_vac2_analin
logical dump_precondn
logical dump_vac1n_precal
logical dump_vac1n_vacuum
logical dump_vac2_foumat
logical dump_vac1n_bextern
logical dump_vac1n_fouri
logical dump_freeb_data
logical dump_fsq1
logical dump_jxbout
logical dump_lambda_forces
logical dump_funct3d_geometry
logical dump_jacobian
logical dump_evolve
logical dump_vac2_vacuum
logical dump_readin_boundary
logical dump_vac2_bexmat
logical dump_bcov_full
logical dump_vac2_linslv
logical dump_volume
logical dump_symforce
logical dump_fsq
logical dump_multigrid_result
logical dump_threed1_firsttable
logical dump_bcov
logical dump_totzsp_input
logical dump_tomnsps
logical dump_lamcal
logical dump_tomnspa
logical dump_vac1n_surface
logical dump_forces
logical dump_calc_fbal
logical dump_constraint_force
logical dump_interp
character(len=100) input_extension
logical dump_vac1n_bsqvac
logical dump_threed1_beta
logical dump_scalfor_r
integer, parameter num_iter2_to_dump
logical dump_phys_gc
logical dump_metric
logical dump_jxbforce_bsub_lowpass
logical dump_bcovar_fileout
logical dump_vac2_foumat_unreg
logical dump_lulv_comb
logical dump_vac1n_solver
logical dump_vac1n_analyt
logical dump_vac2_bsqvac
logical dump_vac1n_greenf
logical dump_forcenorms_tcon
logical dump_profil1d
logical dump_vac2_linsys
integer, dimension(num_iter2_to_dump) iter2_to_dump
values of iter2 for which to dump data
logical dump_profil3d
logical dump_bss
logical dump_scale_m1
logical dump_threed1_volquant
logical dump_bcontrav
logical dump_threed1_shafrint
logical dump_threed1_geomag
integer iter2
total number of iterations