33#include "../base/base_uses.f90"
39 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'tmc_dot_tree'
56 FUNCTION get_dot_file_name(tmc_params, ind)
RESULT(filename)
57 TYPE(tmc_param_type),
POINTER :: tmc_params
59 CHARACTER(LEN=50) :: filename
63 cpassert(
ASSOCIATED(tmc_params))
65 cpassert(
ASSOCIATED(tmc_params%Temp))
66 cpassert(ind <=
SIZE(tmc_params%Temp))
72 rvalue=tmc_params%Temp(ind)))
75 cpassert(filename /=
"")
76 END FUNCTION get_dot_file_name
85 INTEGER :: file_ptr, i
87 cpassert(
ASSOCIATED(tmc_params))
90 CALL open_file(file_name=get_dot_file_name(tmc_params, 0), file_status=
"REPLACE", &
91 file_action=
"WRITE", unit_number=file_ptr)
92 WRITE (file_ptr, *)
"digraph G {"
93 WRITE (file_ptr, *)
' size="8.27,11.69"'
94 CALL write_legend(file_ptr)
95 CALL close_file(unit_number=file_ptr, keep_preconnection=.true.)
98 DO i = 1,
SIZE(tmc_params%Temp)
99 CALL open_file(file_name=get_dot_file_name(tmc_params, i), file_status=
"REPLACE", &
100 file_action=
"WRITE", unit_number=file_ptr)
101 WRITE (file_ptr, *)
"digraph G {"
102 WRITE (file_ptr, *)
' size="8.27,11.69"'
103 CALL write_legend(file_ptr)
104 CALL close_file(unit_number=file_ptr, keep_preconnection=.true.)
116 INTEGER :: file_ptr, i
118 cpassert(
ASSOCIATED(tmc_params))
121 CALL open_file(file_name=get_dot_file_name(tmc_params, 0), &
122 file_status=
"OLD", file_action=
"WRITE", &
123 file_position=
"APPEND", unit_number=file_ptr)
124 WRITE (file_ptr, *)
"}"
127 DO i = 1,
SIZE(tmc_params%Temp)
128 CALL open_file(file_name=get_dot_file_name(tmc_params, i), file_status=
"OLD", &
129 file_action=
"WRITE", file_position=
"APPEND", unit_number=file_ptr)
130 WRITE (file_ptr, *)
"}"
140 SUBROUTINE write_legend(file_ptr)
141 INTEGER,
INTENT(IN) :: file_ptr
143 cpassert(file_ptr > 0)
145 WRITE (file_ptr, *)
'//LEGEND'
146 WRITE (file_ptr, *)
'subgraph clusterLegend {'
147 WRITE (file_ptr, *)
' label="Legend:" labelloc=t fontsize=30'
148 WRITE (file_ptr, *)
' centered=false'
149 WRITE (file_ptr, *)
' color=black'
150 WRITE (file_ptr, *)
' leg1 -> leg2 -> leg2_2 -> leg2_3 -> leg2_4 -> leg3 -> '// &
151 'leg4 -> leg5 -> leg6 -> leg7_1 -> leg7 -> '// &
152 'leg8_1 -> leg8 -> leg9 -> leg10 [style=invis]'
153 WRITE (file_ptr, *)
' {rank=same leg1 [fontsize=30, label="node created" , color=black]}'
154 WRITE (file_ptr, *)
' {rank=same leg2 [fontsize=30, label="configuration created" , style=filled, color=gray]}'
155 WRITE (file_ptr, *)
' {rank=same leg2_2 [fontsize=30, label="calc energy" , style=filled, color=brown]}'
156 WRITE (file_ptr, *)
' {rank=same leg2_2 [fontsize=30, label="calc energy" , style=filled, color=wheat]}'
157 WRITE (file_ptr, *)
' {rank=same leg2_3 [fontsize=30, label="calc HMC" , style=filled, color=goldenrod]}'
158 WRITE (file_ptr, *)
' {rank=same leg2_4 [fontsize=30, label="calc NMC" , style=filled, color=peru]}'
159 WRITE (file_ptr, *)
' {rank=same leg3 [fontsize=30, label="accepted" , color=greenyellow]}'
160 WRITE (file_ptr, *)
' {rank=same leg4 [fontsize=30, label="rejected" , color=red]}'
161 WRITE (file_ptr, *)
' {rank=same leg5 [fontsize=30, label="trajec" , '// &
162 'style=filled, color=gold, shape=polygon, sides=4]}'
163 WRITE (file_ptr, *)
' {rank=same leg6 [fontsize=30, label="energy calculated" , '// &
164 'style=filled, color=blue, fontcolor=white]}'
165 WRITE (file_ptr, *)
' {rank=same leg7_1 [fontsize=30, label="cancel NMC send" , '// &
166 'style=filled, color=deeppink, fontcolor=white]}'
167 WRITE (file_ptr, *)
' {rank=same leg7 [fontsize=30, label="canceled NMC" , '// &
168 'style=filled, color=darkorchid1, fontcolor=white]}'
169 WRITE (file_ptr, *)
' {rank=same leg8_1 [fontsize=30, label="cancel ENERGY send" , '// &
170 'style=filled, color=cornflowerblue]}'
171 WRITE (file_ptr, *)
' {rank=same leg8 [fontsize=30, label="canceled ENERGY" , '// &
172 'style=filled, color=cyan]}'
173 WRITE (file_ptr, *)
' {rank=same leg9 [fontsize=30, label="deleted" , '// &
174 'style=filled, shape=polygon, sides=3, color=black,fontcolor=white]}'
175 WRITE (file_ptr, *)
' {rank=same leg10 [fontsize=30, label="deleted trajectory" , '// &
176 'style=filled, shape=polygon, sides=5, color=gold]}'
177 WRITE (file_ptr, *)
' }'
178 END SUBROUTINE write_legend
187 SUBROUTINE write_color(node_nr, stat, filename)
188 INTEGER :: node_nr, stat
189 CHARACTER(LEN=50) :: filename
191 CHARACTER(len=11) :: label
194 cpassert(filename /=
"")
195 cpassert(node_nr >= 0)
197 CALL open_file(file_name=filename, file_status=
"OLD", &
198 file_action=
"WRITE", file_position=
"APPEND", unit_number=file_ptr)
199 WRITE (label, fmt=
'(I10,A)') node_nr,
"["
202 WRITE (file_ptr, *) trim(label),
'style=filled, color=gray]'
204 WRITE (file_ptr, *) trim(label),
'color=green]'
206 WRITE (file_ptr, *) trim(label),
'color=red]'
208 WRITE (file_ptr, *) trim(label),
'style=filled, color=green, shape=polygon, sides=4]'
210 WRITE (file_ptr, *) trim(label),
'style=filled, color=red, shape=polygon, sides=4]'
212 WRITE (file_ptr, *) trim(label),
'style=filled, color=blue]'
214 WRITE (file_ptr, *) trim(label),
'style=filled, color=deeppink]'
216 WRITE (file_ptr, *) trim(label),
'style=filled, color=cornflowerblue]'
218 WRITE (file_ptr, *) trim(label),
'style=filled, color=darkorchid1]'
220 WRITE (file_ptr, *) trim(label),
'style=filled, color=cyan]'
222 WRITE (file_ptr, *) trim(label),
'shape=polygon, sides=3]'
224 WRITE (file_ptr, *) trim(label),
'style=filled, shape=polygon, sides=5]'
226 WRITE (file_ptr, *) trim(label),
'style=filled, color=brown]'
228 WRITE (file_ptr, *) trim(label),
'style=filled, color=wheat]'
230 WRITE (file_ptr, *) trim(label),
'style=filled, color=goldenrod]'
232 WRITE (file_ptr, *) trim(label),
'style=filled, color=peru]'
236 CALL close_file(unit_number=file_ptr, keep_preconnection=.true.)
237 END SUBROUTINE write_color
248 SUBROUTINE create_dot_branch(parent_nr, child_nr, acc, tmc_params, tree)
249 INTEGER :: parent_nr, child_nr
256 cpassert(
ASSOCIATED(tmc_params))
258 CALL open_file(file_name=get_dot_file_name(tmc_params, tree), &
259 file_status=
"OLD", file_action=
"WRITE", &
260 file_position=
"APPEND", unit_number=file_ptr)
262 WRITE (file_ptr, *) parent_nr,
" -> ", child_nr,
":nw [color=darkolivegreen1]"
264 WRITE (file_ptr, *) parent_nr,
" -> ", child_nr,
":ne [color=coral]"
266 CALL close_file(unit_number=file_ptr, keep_preconnection=.true.)
267 END SUBROUTINE create_dot_branch
281 cpassert(
ASSOCIATED(new_element))
283 cpassert(
ASSOCIATED(tmc_params))
285 CALL create_dot_branch(parent_nr=new_element%parent%nr, &
286 child_nr=new_element%nr, &
287 acc=
ASSOCIATED(new_element%parent%acc, new_element), &
288 tmc_params=tmc_params, tree=conf)
302 CHARACTER(len=1000) :: list_of_nr
303 INTEGER :: file_ptr, i, ref_count
306 NULLIFY (tmp_pt_list_elem)
308 cpassert(
ASSOCIATED(new_element))
309 cpassert(
ASSOCIATED(tmc_params))
314 DO i = 1,
SIZE(new_element%conf(:))
315 WRITE (list_of_nr, *) trim(adjustl(list_of_nr)), new_element%conf(i)%elem%sub_tree_nr
318 WRITE (list_of_nr, *) trim(adjustl(list_of_nr)),
'\n '
319 DO i = 1,
SIZE(new_element%conf(:))
320 WRITE (list_of_nr, *) trim(adjustl(list_of_nr)),
" ", new_element%conf(i)%elem%nr
324 WRITE (list_of_nr, *) trim(adjustl(list_of_nr)),
'\n ref'
325 DO i = 1,
SIZE(new_element%conf(:))
327 tmp_pt_list_elem => new_element%conf(i)%elem%gt_nodes_references
328 DO WHILE (
ASSOCIATED(tmp_pt_list_elem))
329 ref_count = ref_count + 1
331 IF (.false.)
WRITE (list_of_nr, *) trim(adjustl(list_of_nr)),
" ", tmp_pt_list_elem%gt_elem%nr
332 tmp_pt_list_elem => tmp_pt_list_elem%next
335 IF (.false.)
WRITE (list_of_nr, *) trim(adjustl(list_of_nr)),
' | '
337 IF (.true.)
WRITE (list_of_nr, *) trim(adjustl(list_of_nr)), ref_count,
' | '
341 IF (.NOT.
ASSOCIATED(new_element%parent))
THEN
342 IF (new_element%nr > 1)
THEN
343 CALL cp_warn(__location__, &
344 "try to create dot, but no parent on node "// &
348 CALL create_dot_branch(parent_nr=new_element%parent%nr, &
349 child_nr=new_element%nr, &
350 acc=
ASSOCIATED(new_element%parent%acc, new_element), &
351 tmc_params=tmc_params, tree=0)
354 CALL open_file(file_name=get_dot_file_name(tmc_params, 0), &
355 file_status=
"OLD", file_action=
"WRITE", &
356 file_position=
"APPEND", unit_number=file_ptr)
357 IF (new_element%swaped)
THEN
358 WRITE (file_ptr, *) new_element%nr,
'[label="', new_element%nr,
' |', new_element%mv_conf,
' |', &
360 trim(adjustl(list_of_nr)),
'", shape=polygon, peripheries=3, sides=5]'
362 WRITE (file_ptr, *) new_element%nr,
'[label="', new_element%nr,
' |', new_element%mv_conf,
' |', &
363 new_element%conf(new_element%mv_conf)%elem%move_type,
'\n ', &
364 trim(adjustl(list_of_nr)),
'"]'
366 CALL close_file(file_ptr, keep_preconnection=.true.)
380 CHARACTER(len=1000) :: list_of_nr
384 cpassert(
ASSOCIATED(tree_element))
385 cpassert(
ASSOCIATED(tmc_params))
389 tmp_pt_list_elem => tree_element%gt_nodes_references
391 DO WHILE (
ASSOCIATED(tmp_pt_list_elem))
392 ref_count = ref_count + 1
395 WRITE (list_of_nr, *) trim(adjustl(list_of_nr)),
" ", tmp_pt_list_elem%gt_elem%nr
396 WRITE (list_of_nr, *) trim(adjustl(list_of_nr)),
' | '
399 IF (.true.)
WRITE (list_of_nr, *) ref_count,
' | '
400 tmp_pt_list_elem => tmp_pt_list_elem%next
402 WRITE (*, *)
"mark subtree", tree_element%sub_tree_nr,
" node", tree_element%nr,
" with status ", &
403 tree_element%stat,
"ref ", trim(adjustl(list_of_nr))
406 CALL write_color(node_nr=tree_element%nr, stat=tree_element%stat, &
407 filename=get_dot_file_name(tmc_params, tree_element%sub_tree_nr))
421 cpassert(
ASSOCIATED(gt_tree_element))
422 cpassert(
ASSOCIATED(tmc_params))
424 IF (debug > 8)
WRITE (*, *)
"mark global tree node color", gt_tree_element%nr, gt_tree_element%stat
425 CALL write_color(node_nr=gt_tree_element%nr, stat=gt_tree_element%stat, &
426 filename=get_dot_file_name(tmc_params, 0))
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
various routines to log and control the output. The idea is that decisions about where to log should ...
module for printing tree structures in GraphViz dot files for visualizing the trees
subroutine, public finalize_draw_tree(tmc_params)
close the dot files (write tails)
subroutine, public init_draw_trees(tmc_params)
initializes the dot files (open and write headers)
subroutine, public create_dot(new_element, conf, tmc_params)
interfaces the creating of a branch for subtree elements
subroutine, public create_global_tree_dot_color(gt_tree_element, tmc_params)
interfaces the change of color for global tree node on the basis of the element status
subroutine, public create_global_tree_dot(new_element, tmc_params)
creates new dot and arrow from element one level up (for subtree) additional handling of nodes with s...
subroutine, public create_dot_color(tree_element, tmc_params)
interfaces the change of color for subtree elements on the basis of the element status
writing and printing the files, trajectory (pos, cell, dipoles) as well as restart files
character(len=default_path_length) function, public expand_file_name_char(file_name, extra)
placing a character string at the end of a file name (before the file extension)
character(len=default_path_length) function, public expand_file_name_temp(file_name, rvalue)
placing the temperature at the end of a file name (before the file extension)
tree nodes creation, searching, deallocation, references etc.
integer, parameter, public mv_type_swap_conf
module handles definition of the tree nodes for the global and the subtrees binary tree parent elemen...
integer, parameter, public status_deleted
integer, parameter, public status_accepted
integer, parameter, public status_calculate_energy
integer, parameter, public status_calculate_md
integer, parameter, public status_canceled_ener
integer, parameter, public status_calculated
integer, parameter, public status_cancel_ener
integer, parameter, public status_cancel_nmc
integer, parameter, public status_canceled_nmc
integer, parameter, public status_calc_approx_ener
integer, parameter, public status_rejected
integer, parameter, public status_calculate_nmc_steps
integer, parameter, public status_accepted_result
integer, parameter, public status_deleted_result
integer, parameter, public status_created
integer, parameter, public status_rejected_result
module handles definition of the tree nodes for the global and the subtrees binary tree parent elemen...