(git:5e7fe52)
Loading...
Searching...
No Matches
tmc_file_io.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7
8! **************************************************************************************************
9!> \brief - writing and printing the files, trajectory (pos, cell, dipoles) as
10!> well as restart files
11!> - usually just the Markov Chain elements are regarded, the elements
12!> beside this trajectory are neglected
13!> - futrthermore (by option) just the accepted configurations
14!> are print out to reduce the file sizes
15!> \par History
16!> 12.2012 created [Mandes Schoenherr]
17!> \author Mandes
18! **************************************************************************************************
19
21 USE cp_files, ONLY: close_file,&
24 USE kinds, ONLY: default_path_length,&
26 dp
27 USE physcon, ONLY: au2a => angstrom
32 USE tmc_stati, ONLY: tmc_status_failed,&
40 USE tmc_types, ONLY: tmc_env_type,&
42#include "../base/base_uses.f90"
43
44 IMPLICIT NONE
45
46 PRIVATE
47
48 CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'tmc_file_io'
49
50 ! filename manipulation
52 ! read/write restart file
54 ! write the configuration
56 PUBLIC :: write_element_in_file
57 PUBLIC :: write_dipoles_in_file
58 ! analysis read
60
61CONTAINS
62
63!------------------------------------------------------------------------------
64! routines for manipulating the file name
65!------------------------------------------------------------------------------
66! **************************************************************************************************
67!> \brief placing a character string at the end of a file name
68!> (instead of the ending)
69!> \param file_name original file name
70!> \param extra string to be added before the file extension
71!> \return the new filename
72!> \author Mandes 11.2012
73! **************************************************************************************************
74 FUNCTION expand_file_name_ending(file_name, extra) RESULT(result_file_name)
75 CHARACTER(LEN=*) :: file_name, extra
76 CHARACTER(LEN=default_path_length) :: result_file_name
77
78 INTEGER :: ind
79
80 cpassert(file_name /= "")
81
82 ind = index(file_name, ".", back=.true.)
83 IF (.NOT. ind == 0) THEN
84 WRITE (result_file_name, *) file_name(1:ind - 1), ".", &
85 trim(adjustl(extra))
86 ELSE
87 WRITE (result_file_name, *) trim(file_name), ".", extra
88 END IF
89 result_file_name = trim(adjustl(result_file_name))
90 cpassert(result_file_name /= "")
91 END FUNCTION expand_file_name_ending
92
93! **************************************************************************************************
94!> \brief placing a character string at the end of a file name
95!> (before the file extension)
96!> \param file_name original file name
97!> \param extra string to be added before the file extension
98!> \return the new filename
99!> \author Mandes 11.2012
100! **************************************************************************************************
101 FUNCTION expand_file_name_char(file_name, extra) RESULT(result_file_name)
102 CHARACTER(LEN=*) :: file_name, extra
103 CHARACTER(LEN=default_path_length) :: result_file_name
104
105 INTEGER :: ind
106
107 cpassert(file_name /= "")
108
109 ind = index(file_name, ".", back=.true.)
110 IF (.NOT. ind == 0) THEN
111 WRITE (result_file_name, *) file_name(1:ind - 1), "_", &
112 trim(adjustl(extra)), file_name(ind:len_trim(file_name))
113 ELSE
114 WRITE (result_file_name, *) trim(file_name), "_", extra
115 END IF
116 result_file_name = trim(adjustl(result_file_name))
117 cpassert(result_file_name /= "")
118 END FUNCTION expand_file_name_char
119
120! **************************************************************************************************
121!> \brief placing the temperature at the end of a file name
122!> (before the file extension)
123!> \param file_name original file name
124!> \param rvalue temperature to be added
125!> \return the new filename
126!> \author Mandes 11.2012
127! **************************************************************************************************
128 FUNCTION expand_file_name_temp(file_name, rvalue) RESULT(result_file_name)
129 CHARACTER(LEN=*) :: file_name
130 REAL(kind=dp) :: rvalue
131 CHARACTER(LEN=default_path_length) :: result_file_name
132
133 CHARACTER(LEN=18) :: rval_to_string
134 INTEGER :: ind
135
136 cpassert(file_name /= "")
137
138 rval_to_string = ""
139
140 WRITE (rval_to_string, "(F16.2)") rvalue
141 ind = index(file_name, ".", back=.true.)
142 IF (.NOT. ind == 0) THEN
143 WRITE (result_file_name, *) file_name(1:ind - 1), "_T", &
144 trim(adjustl(rval_to_string)), file_name(ind:len_trim(file_name))
145 ELSE
146 IF (len(file_name) == 0) THEN
147 WRITE (result_file_name, *) trim(file_name), "T", trim(adjustl(rval_to_string)), &
148 file_name(ind:len_trim(file_name))
149 ELSE
150 WRITE (result_file_name, *) trim(file_name), "_T", trim(adjustl(rval_to_string))
151 END IF
152 END IF
153 result_file_name = trim(adjustl(result_file_name))
154 cpassert(result_file_name /= "")
155 END FUNCTION expand_file_name_temp
156
157! **************************************************************************************************
158!> \brief placing an integer at the end of a file name
159!> (before the file extension)
160!> \param file_name original file name
161!> \param ivalue number to be added
162!> \return the new filename
163!> \author Mandes 11.2012
164! **************************************************************************************************
165 FUNCTION expand_file_name_int(file_name, ivalue) RESULT(result_file_name)
166 CHARACTER(LEN=*) :: file_name
167 INTEGER :: ivalue
168 CHARACTER(LEN=default_path_length) :: result_file_name
169
170 CHARACTER(LEN=18) :: rval_to_string
171 INTEGER :: ind
172
173 cpassert(file_name /= "")
174
175 rval_to_string = ""
176
177 WRITE (rval_to_string, *) ivalue
178 ind = index(file_name, ".", back=.true.)
179 IF (.NOT. ind == 0) THEN
180 WRITE (result_file_name, *) file_name(1:ind - 1), "_", &
181 trim(adjustl(rval_to_string)), file_name(ind:len_trim(file_name))
182 ELSE
183 IF (len(file_name) == 0) THEN
184 WRITE (result_file_name, *) trim(file_name), "", trim(adjustl(rval_to_string)), &
185 file_name(ind:len_trim(file_name))
186 ELSE
187 WRITE (result_file_name, *) trim(file_name), "_", trim(adjustl(rval_to_string)), &
188 file_name(ind:len_trim(file_name))
189 END IF
190 END IF
191 result_file_name = trim(adjustl(result_file_name))
192 cpassert(result_file_name /= "")
193 END FUNCTION expand_file_name_int
194
195!------------------------------------------------------------------------------
196! routines for reading and writing RESTART file
197!------------------------------------------------------------------------------
198! **************************************************************************************************
199!> \brief prints out the TMC restart files with all last configurations and
200!> counters etc.
201!> \param tmc_env the tmc environment, storing result lists and counters an in
202!> temperatures
203!> \param job_counts the counters for counting the submitted different job types
204!> \param timings ...
205!> \author Mandes 11.2012
206! **************************************************************************************************
207 SUBROUTINE print_restart_file(tmc_env, job_counts, timings)
208 TYPE(tmc_env_type), POINTER :: tmc_env
209 INTEGER, DIMENSION(:) :: job_counts
210 REAL(kind=dp), DIMENSION(4) :: timings
211
212 CHARACTER(LEN=default_path_length) :: c_tmp, file_name
213 INTEGER :: f_unit, i
214
215 c_tmp = ""
216 cpassert(ASSOCIATED(tmc_env))
217 cpassert(ASSOCIATED(tmc_env%m_env))
218 cpassert(ASSOCIATED(tmc_env%params))
219 cpassert(ASSOCIATED(tmc_env%m_env%gt_act))
220
221 WRITE (c_tmp, fmt='(I9.9)') tmc_env%m_env%result_count(0)
222 file_name = trim(expand_file_name_char( &
224 extra=c_tmp))
225 CALL open_file(file_name=file_name, file_status="REPLACE", &
226 file_action="WRITE", file_form="UNFORMATTED", &
227 unit_number=f_unit)
228 WRITE (f_unit) SIZE(tmc_env%params%Temp)
229 WRITE (f_unit) tmc_env%params%Temp(:), &
230 tmc_env%m_env%gt_act%nr, &
231 tmc_env%m_env%gt_act%rng_seed, &
232 tmc_env%m_env%gt_act%rnd_nr, &
233 tmc_env%m_env%gt_act%prob_acc, &
234 tmc_env%m_env%gt_act%mv_conf, &
235 tmc_env%m_env%gt_act%mv_next_conf, &
236 tmc_env%m_env%result_count(0:), &
237 tmc_env%params%move_types%mv_weight, &
238 tmc_env%params%move_types%acc_count, &
239 tmc_env%params%move_types%mv_count, &
240 tmc_env%params%move_types%subbox_acc_count, &
241 tmc_env%params%move_types%subbox_count, &
242 tmc_env%params%cell%hmat, &
243 job_counts, &
244 timings
245 DO i = 1, SIZE(tmc_env%params%Temp)
246 WRITE (f_unit) tmc_env%m_env%result_list(i)%elem%nr, &
247 tmc_env%m_env%result_list(i)%elem%rng_seed, &
248 tmc_env%m_env%result_list(i)%elem%pos, &
249 tmc_env%m_env%result_list(i)%elem%vel, &
250 tmc_env%m_env%result_list(i)%elem%box_scale, &
251 tmc_env%m_env%result_list(i)%elem%potential, &
252 tmc_env%m_env%result_list(i)%elem%e_pot_approx, &
253 tmc_env%m_env%result_list(i)%elem%ekin, &
254 tmc_env%m_env%result_list(i)%elem%ekin_before_md, &
255 tmc_env%m_env%result_list(i)%elem%temp_created
256 END DO
257 CALL close_file(unit_number=f_unit)
258 ! write the file, where the restart file name is written in
260 file_action="WRITE", file_status="REPLACE", &
261 unit_number=f_unit)
262 WRITE (f_unit, *) trim(file_name)
263 CALL close_file(unit_number=f_unit)
264 END SUBROUTINE print_restart_file
265
266! **************************************************************************************************
267!> \brief reads the TMC restart file with all last configurations and
268!> counters etc.
269!> \param tmc_env the tmc environment, storing result lists and counters an in
270!> temperatures
271!> \param job_counts the counters for counting the submitted different job types
272!> \param timings ...
273!> \param file_name the restart file name
274!> \author Mandes 11.2012
275! **************************************************************************************************
276 SUBROUTINE read_restart_file(tmc_env, job_counts, timings, file_name)
277 TYPE(tmc_env_type), POINTER :: tmc_env
278 INTEGER, DIMENSION(:) :: job_counts
279 REAL(kind=dp), DIMENSION(4) :: timings
280 CHARACTER(LEN=*) :: file_name
281
282 INTEGER :: file_ptr, i, temp_size
283 LOGICAL :: flag
284 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: tmp_temp
285 REAL(kind=dp), DIMENSION(nr_mv_types) :: mv_weight_tmp
286
287 cpassert(ASSOCIATED(tmc_env))
288 cpassert(ASSOCIATED(tmc_env%m_env))
289 cpassert(ASSOCIATED(tmc_env%params))
290 cpassert(ASSOCIATED(tmc_env%m_env%gt_act))
291
292 IF (file_name == tmc_default_restart_in_file_name) THEN
293 INQUIRE (file=tmc_default_restart_in_file_name, exist=flag)
294 cpassert(flag)
295 CALL open_file(file_name=tmc_default_restart_in_file_name, file_status="OLD", &
296 file_action="READ", unit_number=file_ptr)
297 READ (file_ptr, *) file_name
298 CALL close_file(unit_number=file_ptr)
299 END IF
300
301 CALL open_file(file_name=file_name, file_status="OLD", file_form="UNFORMATTED", &
302 file_action="READ", unit_number=file_ptr)
303 READ (file_ptr) temp_size
304 IF (temp_size /= SIZE(tmc_env%params%Temp)) THEN
305 CALL cp_abort(__location__, &
306 "the actual specified temperatures does not "// &
307 "fit in amount with the one from restart file ")
308 END IF
309 ALLOCATE (tmp_temp(temp_size))
310 READ (file_ptr) tmp_temp(:), &
311 tmc_env%m_env%gt_act%nr, &
312 tmc_env%m_env%gt_act%rng_seed, &
313 tmc_env%m_env%gt_act%rnd_nr, &
314 tmc_env%m_env%gt_act%prob_acc, &
315 tmc_env%m_env%gt_act%mv_conf, & !
316 tmc_env%m_env%gt_act%mv_next_conf, & !
317 tmc_env%m_env%result_count(0:), &
318 mv_weight_tmp, & !
319 tmc_env%params%move_types%acc_count, &
320 tmc_env%params%move_types%mv_count, &
321 tmc_env%params%move_types%subbox_acc_count, &
322 tmc_env%params%move_types%subbox_count, & !
323 tmc_env%params%cell%hmat, &
324 job_counts, &
325 timings
326
327 IF (any(abs(tmc_env%params%Temp(:) - tmp_temp(:)) >= 0.005)) THEN
328 CALL cp_abort(__location__, "the temperatures differ from the previous calculation. "// &
329 "There were the following temperatures used:")
330 END IF
331 IF (any(mv_weight_tmp(:) /= tmc_env%params%move_types%mv_weight(:))) THEN
332 cpwarn("The amount of mv types differs between the original and the restart run.")
333 END IF
334
335 DO i = 1, SIZE(tmc_env%params%Temp)
336 tmc_env%m_env%gt_act%conf(i)%elem => tmc_env%m_env%result_list(i)%elem
337 READ (file_ptr) tmc_env%m_env%result_list(i)%elem%nr, &
338 tmc_env%m_env%result_list(i)%elem%rng_seed, &
339 tmc_env%m_env%result_list(i)%elem%pos, &
340 tmc_env%m_env%result_list(i)%elem%vel, &
341 tmc_env%m_env%result_list(i)%elem%box_scale, &
342 tmc_env%m_env%result_list(i)%elem%potential, &
343 tmc_env%m_env%result_list(i)%elem%e_pot_approx, &
344 tmc_env%m_env%result_list(i)%elem%ekin, &
345 tmc_env%m_env%result_list(i)%elem%ekin_before_md, &
346 tmc_env%m_env%result_list(i)%elem%temp_created
347 END DO
348 CALL close_file(unit_number=file_ptr)
349 END SUBROUTINE read_restart_file
350
351 !----------------------------------------------------------------------------
352 ! printing configuration in file
353 !----------------------------------------------------------------------------
354
355! **************************************************************************************************
356!> \brief select the correct configuration to print out the
357!> (coordinates, forces, cell ...)
358!> \param result_list list of configurations for each temperature
359!> \param result_count list with number of Markov Chain number
360!> for each teperature (index 0 for global tree)
361!> \param conf_updated index of the updated (modified element)
362!> \param accepted acceptance flag
363!> \param tmc_params TMC environment parameters
364!> \author Mandes 02.2013
365! **************************************************************************************************
366 SUBROUTINE write_result_list_element(result_list, result_count, conf_updated, &
367 accepted, tmc_params)
368 TYPE(elem_array_type), DIMENSION(:), POINTER :: result_list
369 INTEGER, DIMENSION(:), POINTER :: result_count
370 INTEGER :: conf_updated
371 LOGICAL, INTENT(IN) :: accepted
372 TYPE(tmc_param_type), POINTER :: tmc_params
373
374 CHARACTER(LEN=*), PARAMETER :: routinen = 'write_result_list_element'
375
376 CHARACTER(LEN=default_path_length) :: file_name
377 INTEGER :: handle, i
378
379 file_name = ""
380
381 cpassert(ASSOCIATED(result_list))
382 cpassert(ASSOCIATED(result_count))
383 cpassert(ASSOCIATED(tmc_params))
384 cpassert(ASSOCIATED(tmc_params%Temp))
385 cpassert(conf_updated >= 0)
386 cpassert(conf_updated <= SIZE(tmc_params%Temp))
387
388 ! start the timing
389 CALL timeset(routinen, handle)
390
391 IF (conf_updated == 0) THEN
392 ! for debugging print every configuration of every temperature
393 DO i = 1, SIZE(tmc_params%Temp)
394 WRITE (file_name, *) "every_step_", trim(tmc_default_trajectory_file_name)
395 CALL write_element_in_file(elem=result_list(i)%elem, &
396 tmc_params=tmc_params, conf_nr=result_count(0), &
397 file_name=expand_file_name_temp(file_name=file_name, rvalue=tmc_params%Temp(i)))
398 END DO
399 ELSE
400 IF ((.NOT. tmc_params%print_only_diff_conf) .OR. &
401 (tmc_params%print_only_diff_conf .AND. accepted)) THEN
402 CALL write_element_in_file(elem=result_list(conf_updated)%elem, &
403 tmc_params=tmc_params, conf_nr=result_count(conf_updated), &
405 rvalue=tmc_params%Temp(conf_updated)))
406 END IF
407 END IF
408 ! end the timing
409 CALL timestop(handle)
410 END SUBROUTINE write_result_list_element
411
412! **************************************************************************************************
413!> \brief writes the trajectory element in a file from sub tree element
414!> \param elem actual tree element to be printed out
415!> \param tmc_params TMC environment parameters
416!> \param temp_index ...
417!> \param file_name file name will be extended by type of file (pos, cell,...)
418!> \param conf_nr Markov chain element number
419!> \param conf_info whole header line
420!> \author Mandes 11.2012
421! **************************************************************************************************
422 SUBROUTINE write_element_in_file(elem, tmc_params, temp_index, file_name, conf_nr, &
423 conf_info)
424 TYPE(tree_type), POINTER :: elem
425 TYPE(tmc_param_type), POINTER :: tmc_params
426 INTEGER, OPTIONAL :: temp_index
427 CHARACTER(LEN=*), OPTIONAL :: file_name
428 INTEGER, OPTIONAL :: conf_nr
429 CHARACTER(LEN=*), OPTIONAL :: conf_info
430
431 CHARACTER(LEN=*), PARAMETER :: routinen = 'write_element_in_file'
432
433 CHARACTER(LEN=default_path_length) :: file_name_act, tmp_name
434 CHARACTER(LEN=default_string_length) :: header
435 INTEGER :: file_ptr, handle, i, nr_atoms
436 LOGICAL :: file_exists, print_it
437 REAL(kind=dp) :: vol
438 REAL(kind=dp), DIMENSION(3, 3) :: hmat_scaled
439
440 file_name_act = ""
441 tmp_name = ""
442 header = ""
443 print_it = .true.
444
445 cpassert(ASSOCIATED(elem))
446 cpassert(ASSOCIATED(tmc_params))
447 cpassert(ASSOCIATED(tmc_params%atoms))
448 cpassert(PRESENT(conf_nr) .OR. PRESENT(conf_info))
449
450 IF (print_it) THEN
451 ! start the timing
452 CALL timeset(routinen, handle)
453
454 ! set default file name
455 IF (PRESENT(file_name)) THEN
456 cpassert(file_name /= "")
457 file_name_act = file_name
458 ELSE
459 cpassert(ASSOCIATED(tmc_params%Temp))
460 cpassert(PRESENT(temp_index))
462 rvalue=tmc_params%Temp(temp_index))
463 END IF
464
465 nr_atoms = SIZE(elem%pos)/tmc_params%dim_per_elem
466
467 ! set header (for coordinate or force file)
468 IF (tmc_params%print_trajectory .OR. tmc_params%print_forces) THEN
469 IF (PRESENT(conf_info)) THEN
470 WRITE (header, *) trim(adjustl(conf_info))
471 ELSE
472 !WRITE(header,FMT="(A,I8,A,F20.10)") " i = ", conf_nr,", E = ", elem%potential
473 WRITE (header, fmt="(A,I8,A,F20.10,F20.10,A,I8,I8)") "i =", conf_nr, " ,E =", &
474 elem%potential, elem%ekin, " st elem", elem%sub_tree_nr, elem%nr
475 END IF
476 END IF
477
478 ! write the coordinates
479 IF (tmc_params%print_trajectory) THEN
480 tmp_name = expand_file_name_ending(file_name_act, "xyz")
481 CALL open_file(file_name=tmp_name, file_status="UNKNOWN", &
482 file_action="WRITE", file_position="APPEND", &
483 unit_number=file_ptr)
484 WRITE (file_ptr, fmt="(I8)") nr_atoms
485 WRITE (file_ptr, *) trim(header)
486 DO i = 1, SIZE(elem%pos), tmc_params%dim_per_elem
487 WRITE (file_ptr, fmt="(A4,1X,1000F20.10)") &
488 trim(tmc_params%atoms((i - 1)/tmc_params%dim_per_elem + 1)%name), &
489 elem%pos(i:i + tmc_params%dim_per_elem - 1)*au2a
490 END DO
491 CALL close_file(unit_number=file_ptr)
492 END IF
493
494 ! write the forces
495 IF (tmc_params%print_forces) THEN
496 tmp_name = expand_file_name_ending(file_name_act, "frc")
497 CALL open_file(file_name=tmp_name, file_status="UNKNOWN", &
498 file_action="WRITE", file_position="APPEND", &
499 unit_number=file_ptr)
500 WRITE (file_ptr, fmt="(I8)") nr_atoms
501 WRITE (file_ptr, *) trim(header)
502 DO i = 1, SIZE(elem%pos), tmc_params%dim_per_elem
503 WRITE (file_ptr, fmt="(A4,1X,1000F20.10)") &
504 trim(tmc_params%atoms((i - 1)/tmc_params%dim_per_elem + 1)%name), &
505 elem%frc(i:i + tmc_params%dim_per_elem - 1)
506 END DO
507 CALL close_file(unit_number=file_ptr)
508 END IF
509
510 ! write the cell dipoles
511 IF (tmc_params%print_dipole) THEN
512 CALL write_dipoles_in_file(file_name=file_name_act, &
513 conf_nr=conf_nr, dip=elem%dipole)
514 END IF
515
516 ! write the cell file
517 IF (tmc_params%print_cell) THEN
518 tmp_name = expand_file_name_ending(file_name_act, "cell")
519 ! header
520 INQUIRE (file=tmp_name, exist=file_exists) ! file_exists will be TRUE if the file exist
521 IF (.NOT. file_exists) THEN
522 CALL open_file(file_name=tmp_name, file_status="NEW", &
523 file_action="WRITE", unit_number=file_ptr)
524 WRITE (file_ptr, fmt='(A,9(7X,A2," [Angstrom]"),6X,A)') &
525 "# MC step ", "Ax", "Ay", "Az", "Bx", "By", "Bz", "Cx", "Cy", "Cz", &
526 "Volume [Angstrom^3]"
527 ELSE
528 CALL open_file(file_name=tmp_name, file_status="OLD", &
529 file_action="WRITE", file_position="APPEND", &
530 unit_number=file_ptr)
531 END IF
532 CALL get_scaled_cell(cell=tmc_params%cell, &
533 box_scale=elem%box_scale, scaled_hmat=hmat_scaled, &
534 vol=vol)
535 WRITE (file_ptr, fmt="(I8,9(1X,F19.10),1X,F24.10)") conf_nr, &
536 hmat_scaled(:, :)*au2a, vol*au2a**3
537 !TODO better cell output e.g. using cell_types routine
538 CALL close_file(unit_number=file_ptr)
539 END IF
540
541 ! write the different energies
542 IF (tmc_params%print_energies) THEN
543 tmp_name = expand_file_name_ending(file_name_act, "ener")
544 ! header
545 INQUIRE (file=tmp_name, exist=file_exists) ! file_exists will be TRUE if the file exist
546 IF (.NOT. file_exists) THEN
547 CALL open_file(file_name=tmp_name, file_status="NEW", &
548 file_action="WRITE", unit_number=file_ptr)
549 WRITE (file_ptr, fmt='(A,4A20)') &
550 "# MC step ", " exact ", " approx ", " last SCF ", " kinetic "
551 ELSE
552 CALL open_file(file_name=tmp_name, file_status="OLD", &
553 file_action="WRITE", file_position="APPEND", &
554 unit_number=file_ptr)
555 END IF
556 WRITE (file_ptr, fmt="(I8,14F20.10)") conf_nr, elem%potential, elem%e_pot_approx, &
557 elem%scf_energies(mod(elem%scf_energies_count, 4) + 1), elem%ekin
558 CALL close_file(unit_number=file_ptr)
559 END IF
560
561 ! end the timing
562 CALL timestop(handle)
563 END IF
564 END SUBROUTINE write_element_in_file
565
566! **************************************************************************************************
567!> \brief writes the cell dipoles in dipole trajectory file
568!> \param file_name ...
569!> \param conf_nr ...
570!> \param dip ...
571!> \param file_ext ...
572!> \param
573!> \author Mandes 11.2012
574! **************************************************************************************************
575 SUBROUTINE write_dipoles_in_file(file_name, conf_nr, dip, file_ext)
576 CHARACTER(LEN=default_path_length) :: file_name
577 INTEGER :: conf_nr
578 REAL(kind=dp), DIMENSION(:), POINTER :: dip
579 CHARACTER(LEN=*), INTENT(in), OPTIONAL :: file_ext
580
581 CHARACTER(LEN=default_path_length) :: file_name_tmp
582 INTEGER :: file_ptr
583 LOGICAL :: file_exists
584
585 cpassert(ASSOCIATED(dip))
586
587 IF (PRESENT(file_ext)) THEN
588 cpassert(file_ext /= "")
589 file_name_tmp = expand_file_name_ending(file_name, trim(file_ext))
590 ELSE
591 file_name_tmp = expand_file_name_ending(file_name, "dip")
592 END IF
593 INQUIRE (file=file_name_tmp, exist=file_exists)
594 IF (.NOT. file_exists) THEN
595 CALL open_file(file_name=file_name_tmp, file_status="NEW", &
596 file_action="WRITE", unit_number=file_ptr)
597 WRITE (file_ptr, fmt='(A8,10A20)') "# conf_nr", "dip_x [C Angstrom]", &
598 "dip_y [C Angstrom]", "dip_z [C Angstrom]"
599 ELSE
600 CALL open_file(file_name=file_name_tmp, file_status="OLD", &
601 file_action="WRITE", file_position="APPEND", &
602 unit_number=file_ptr)
603 END IF
604 WRITE (file_ptr, fmt="(I8,10F20.10)") conf_nr, dip(:)
605 CALL close_file(unit_number=file_ptr)
606 END SUBROUTINE write_dipoles_in_file
607
608 !----------------------------------------------------------------------------
609 ! read configuration from file
610 !----------------------------------------------------------------------------
611
612! **************************************************************************************************
613!> \brief read the trajectory element from a file from sub tree element
614!> \param elem actual tree element to be printed out
615!> \param tmc_ana TMC analysis environment parameters
616!> \param conf_nr Markov chain element number
617!> (input the old number and read only if conf nr from file is greater
618!> \param stat ...
619!> \author Mandes 03.2013
620! **************************************************************************************************
621 SUBROUTINE read_element_from_file(elem, tmc_ana, conf_nr, stat)
622 TYPE(tree_type), POINTER :: elem
623 TYPE(tmc_analysis_env), POINTER :: tmc_ana
624 INTEGER :: conf_nr, stat
625
626 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_element_from_file'
627
628 INTEGER :: conf_nr_old, handle, i_tmp
629 LOGICAL :: files_conf_missmatch
630
631 stat = tmc_status_ok
632 conf_nr_old = conf_nr
633 files_conf_missmatch = .false.
634
635 cpassert(ASSOCIATED(elem))
636 cpassert(ASSOCIATED(tmc_ana))
637 cpassert(ASSOCIATED(tmc_ana%atoms))
638
639 ! start the timing
640 CALL timeset(routinen, handle)
641
642 ! read the coordinates
643 IF (tmc_ana%id_traj > 0) THEN
644 i_tmp = conf_nr_old
645 CALL read_pos_from_file(elem=elem, tmc_ana=tmc_ana, stat=stat, &
646 conf_nr=i_tmp)
647 IF (stat == tmc_status_wait_for_new_task) THEN
648 CALL cp_warn(__location__, &
649 'end of position file reached at line '// &
650 cp_to_string(real(tmc_ana%lc_traj, kind=dp))//", last element "// &
651 cp_to_string(tmc_ana%last_elem%nr))
652 ELSE
653 cpassert(i_tmp > conf_nr_old)
654 conf_nr = i_tmp
655 elem%nr = i_tmp
656 END IF
657 END IF
658
659 ! read the forces
660 ! TODO if necessary
661
662 ! read the dipoles file
663 IF (tmc_ana%id_dip > 0 .AND. stat == tmc_status_ok) THEN
664 i_tmp = conf_nr_old
665 search_conf_dip: DO
666 CALL read_dipole_from_file(elem=elem, tmc_ana=tmc_ana, stat=stat, &
667 conf_nr=i_tmp)
668 IF (stat == tmc_status_wait_for_new_task) THEN
669 CALL cp_warn(__location__, &
670 'end of dipole file reached at line'// &
671 cp_to_string(real(tmc_ana%lc_dip, kind=dp)))
672 EXIT search_conf_dip
673 END IF
674 ! check consitence with pos file
675 IF (tmc_ana%id_traj > 0) THEN
676 IF (i_tmp == conf_nr) THEN
677 files_conf_missmatch = .false.
678 EXIT search_conf_dip
679 ELSE
680 ! the configuration numbering differ from the position file,
681 ! but we keep on searching for the correct configuration
682 files_conf_missmatch = .true.
683 END IF
684 ! if no pos file, just take the next conf
685 ELSE IF (i_tmp > conf_nr_old) THEN
686 conf_nr = i_tmp
687 elem%nr = i_tmp
688 EXIT search_conf_dip
689 END IF
690 END DO search_conf_dip
691 END IF
692
693 ! read the cell file
694 IF (tmc_ana%id_cell > 0 .AND. stat == tmc_status_ok) THEN
695 search_conf_cell: DO
696 CALL read_cell_from_file(elem=elem, tmc_ana=tmc_ana, stat=stat, &
697 conf_nr=i_tmp)
698 IF (stat == tmc_status_wait_for_new_task) THEN
699 CALL cp_warn(__location__, &
700 'end of cell file reached at line at line'// &
701 cp_to_string(real(tmc_ana%lc_cell, kind=dp)))
702 EXIT search_conf_cell
703 END IF
704 ! check consitence with pos file
705 IF (tmc_ana%id_traj > 0) THEN
706 IF (i_tmp == conf_nr) THEN
707 files_conf_missmatch = .false.
708 EXIT search_conf_cell
709 ELSE
710 ! the configuration numbering differ from the position file,
711 ! but we keep on searching for the correct configuration
712 files_conf_missmatch = .true.
713 END IF
714 ! if no pos file, just take the next conf
715 ELSE IF (i_tmp > conf_nr_old) THEN
716 conf_nr = i_tmp
717 elem%nr = i_tmp
718 EXIT search_conf_cell
719 END IF
720 END DO search_conf_cell
721
722 END IF
723
724 ! write the different energies
725 ! TODO if necessary
726
727 IF (files_conf_missmatch) THEN
728 CALL cp_warn(__location__, &
729 'there is a missmatch in the configuration numbering. '// &
730 "Read number of lines (pos|cell|dip)"// &
731 cp_to_string(tmc_ana%lc_traj)//"|"// &
732 cp_to_string(tmc_ana%lc_cell)//"|"// &
733 cp_to_string(tmc_ana%lc_dip))
734 END IF
735
736 ! end the timing
737 CALL timestop(handle)
738 END SUBROUTINE read_element_from_file
739
740! **************************************************************************************************
741!> \brief search for the next configurational position in file
742!> \param elem actual tree element to be read
743!> \param tmc_ana ...
744!> \param stat ...
745!> \param conf_nr Markov chain element number
746!> (input the old number and read only if conf nr from file is greater
747!> \param header_info ...
748!> \author Mandes 03.2013
749! **************************************************************************************************
750 SUBROUTINE read_pos_from_file(elem, tmc_ana, stat, conf_nr, header_info)
751 TYPE(tree_type), POINTER :: elem
752 TYPE(tmc_analysis_env), POINTER :: tmc_ana
753 INTEGER :: stat, conf_nr
754 CHARACTER(LEN=*), OPTIONAL :: header_info
755
756 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_pos_from_file'
757
758 CHARACTER(LEN=default_string_length) :: c_tmp
759 INTEGER :: handle, i, i_tmp, status
760
761 stat = tmc_status_failed
762
763 cpassert(ASSOCIATED(elem))
764 cpassert(ASSOCIATED(elem%pos))
765 cpassert(ASSOCIATED(tmc_ana))
766 cpassert(tmc_ana%id_traj > 0)
767
768 ! start the timing
769 CALL timeset(routinen, handle)
770
771 search_next_conf: DO
772 c_tmp(:) = " "
773 tmc_ana%lc_traj = tmc_ana%lc_traj + 1
774 READ (tmc_ana%id_traj, '(A)', iostat=status) c_tmp(:)
775 IF (status > 0) THEN
776 CALL cp_abort(__location__, &
777 "configuration header read error at line: "// &
778 cp_to_string(tmc_ana%lc_traj)//": "//c_tmp)
779 END IF
780 IF (status < 0) THEN ! end of file reached
782 EXIT search_next_conf
783 END IF
784 IF (index(c_tmp, "=") > 0) THEN
785 READ (c_tmp(index(c_tmp, "=") + 1:), *, iostat=status) i_tmp ! read the configuration number
786 IF (status /= 0) THEN
787 CALL cp_abort(__location__, &
788 "configuration header read error (for conf nr) at line: "// &
789 cp_to_string(tmc_ana%lc_traj))
790 END IF
791 IF (i_tmp > conf_nr) THEN
792 ! TODO we could also read the energy ...
793 conf_nr = i_tmp
794 IF (PRESENT(header_info)) header_info = c_tmp
795 stat = tmc_status_ok
796 EXIT search_next_conf
797 END IF
798 END IF
799 END DO search_next_conf
800
801 IF (stat == tmc_status_ok) THEN
802 pos_loop: DO i = 1, SIZE(elem%pos), tmc_ana%dim_per_elem
803 tmc_ana%lc_traj = tmc_ana%lc_traj + 1
804 READ (tmc_ana%id_traj, fmt="(A4,1X,1000F20.10)", iostat=status) &
805 c_tmp, elem%pos(i:i + tmc_ana%dim_per_elem - 1)
806 IF (status /= 0) THEN
807 CALL cp_abort(__location__, &
808 "configuration pos read error at line: "// &
809 cp_to_string(tmc_ana%lc_traj))
810 END IF
811 END DO pos_loop
812 elem%pos(:) = elem%pos(:)/au2a
813 END IF
814
815 ! end the timing
816 CALL timestop(handle)
817 END SUBROUTINE read_pos_from_file
818
819! **************************************************************************************************
820!> \brief search for the dipole entry
821!> \param elem actual tree element to be read
822!> \param tmc_ana ...
823!> \param stat ...
824!> \param conf_nr Markov chain element number
825!> (input the old number and read only if conf nr from file is greater
826!> \author Mandes 03.2013
827! **************************************************************************************************
828 SUBROUTINE read_dipole_from_file(elem, tmc_ana, stat, conf_nr)
829 TYPE(tree_type), POINTER :: elem
830 TYPE(tmc_analysis_env), POINTER :: tmc_ana
831 INTEGER :: stat, conf_nr
832
833 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_dipole_from_file'
834
835 CHARACTER(LEN=250) :: c_tmp
836 INTEGER :: handle, status
837
838 stat = tmc_status_failed
839
840 cpassert(ASSOCIATED(elem))
841 cpassert(ASSOCIATED(elem%dipole))
842 cpassert(ASSOCIATED(tmc_ana))
843 cpassert(tmc_ana%id_dip > 0)
844
845 ! start the timing
846 CALL timeset(routinen, handle)
847 tmc_ana%lc_dip = tmc_ana%lc_dip + 1
848 READ (tmc_ana%id_dip, fmt="(A)", iostat=status) c_tmp
849 IF (status == 0) THEN
850 ! skip the initial line (header)
851 IF (index(c_tmp, "#") > 0) THEN
852 tmc_ana%lc_dip = tmc_ana%lc_dip + 1
853 READ (tmc_ana%id_dip, fmt="(A)", iostat=status) c_tmp
854 END IF
855 END IF
856 IF (status == 0) THEN
857 READ (c_tmp, fmt="(I8,10F20.10)", iostat=status) &
858 conf_nr, elem%dipole(:)
859 END IF
860 IF (status == 0) THEN ! success
861 stat = tmc_status_ok
862 ELSE IF (status < 0) THEN ! end of file reached
864 ELSE
865 IF (status /= 0) THEN
866 cpwarn("configuration dipole read error at line: "//cp_to_string(tmc_ana%lc_dip))
867 END IF
868 stat = tmc_status_failed
869 END IF
870
871 ! end the timing
872 CALL timestop(handle)
873 END SUBROUTINE read_dipole_from_file
874
875! **************************************************************************************************
876!> \brief search for the cell entry
877!> \param elem actual tree element to be read
878!> \param tmc_ana ...
879!> \param stat ...
880!> \param conf_nr Markov chain element number
881!> (input the old number and read only if conf nr from file is greater
882!> \author Mandes 03.2013
883! **************************************************************************************************
884 SUBROUTINE read_cell_from_file(elem, tmc_ana, stat, conf_nr)
885 TYPE(tree_type), POINTER :: elem
886 TYPE(tmc_analysis_env), POINTER :: tmc_ana
887 INTEGER :: stat, conf_nr
888
889 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_cell_from_file'
890
891 CHARACTER(LEN=250) :: c_tmp
892 INTEGER :: handle, status
893 REAL(kind=dp) :: r_tmp
894 REAL(kind=dp), DIMENSION(3, 3) :: hmat
895
896 stat = tmc_status_failed
897
898 cpassert(ASSOCIATED(elem))
899 cpassert(ASSOCIATED(tmc_ana))
900 cpassert(ASSOCIATED(tmc_ana%cell))
901 cpassert(tmc_ana%id_cell > 0)
902
903 ! start the timing
904 CALL timeset(routinen, handle)
905
906 tmc_ana%lc_cell = tmc_ana%lc_cell + 1
907 READ (tmc_ana%id_cell, fmt="(A)", iostat=status) c_tmp
908 IF (status == 0) THEN
909 ! skip the initial line (header)
910 IF (index(c_tmp, "#") > 0) THEN
911 tmc_ana%lc_cell = tmc_ana%lc_cell + 1
912 READ (tmc_ana%id_cell, fmt="(A)", iostat=status) c_tmp
913 END IF
914 END IF
915 IF (status == 0) THEN
916 READ (c_tmp, fmt="(I8,9(1X,F19.10),1X,F24.10)", iostat=status) conf_nr, &
917 hmat(:, :), r_tmp
918 END IF
919 IF (status < 0) THEN ! end of file reached
921 ELSE IF (status > 0) THEN
922 IF (status /= 0) THEN
923 cpabort("configuration cell read error at line: "//cp_to_string(tmc_ana%lc_cell))
924 END IF
925 stat = tmc_status_failed
926 ELSE
927 IF (elem%nr < 0) elem%nr = conf_nr
928 hmat(:, :) = hmat(:, :)/au2a
929 ! get the box scaling
930 CALL get_cell_scaling(cell=tmc_ana%cell, scaled_hmat=hmat, &
931 box_scale=elem%box_scale)
932 stat = tmc_status_ok
933 END IF
934 ! end the timing
935 CALL timestop(handle)
936 END SUBROUTINE read_cell_from_file
937
938 !----------------------------------------------------------------------------
939 ! get the configurations from file and calc
940 !----------------------------------------------------------------------------
941
942! **************************************************************************************************
943!> \brief opens the files for reading configurations data to analyze
944!> \param tmc_ana ...
945!> \param stat ...
946!> \param dir_ind ...
947!> \param
948!> \author Mandes 02.2013
949! **************************************************************************************************
950 SUBROUTINE analyse_files_open(tmc_ana, stat, dir_ind)
951 TYPE(tmc_analysis_env), POINTER :: tmc_ana
952 INTEGER :: stat
953 INTEGER, OPTIONAL :: dir_ind
954
955 CHARACTER(LEN=*), PARAMETER :: routinen = 'analyse_files_open'
956
957 CHARACTER(LEN=default_path_length) :: dir_name, file_name_act, file_name_temp
958 INTEGER :: handle
959 LOGICAL :: file_exists
960
961 cpassert(ASSOCIATED(tmc_ana))
962
964
965 ! start the timing
966 CALL timeset(routinen, handle)
967
968 IF (PRESENT(dir_ind)) THEN
969 cpassert(ASSOCIATED(tmc_ana%dirs))
970 cpassert(dir_ind > 0)
971 cpassert(dir_ind <= SIZE(tmc_ana%dirs))
972
973 IF (index(tmc_ana%dirs(dir_ind), "/", back=.true.) == &
974 len_trim(tmc_ana%dirs(dir_ind))) THEN
975 dir_name = trim(tmc_ana%dirs(dir_ind))
976 ELSE
977 dir_name = trim(tmc_ana%dirs(dir_ind))//"/"
978 END IF
979 ELSE
980 dir_name = "./"
981 END IF
982
983 ! open the files
984 file_name_temp = expand_file_name_temp( &
986 rvalue=tmc_ana%temperature)
987 ! position file
988 IF (tmc_ana%costum_pos_file_name /= "") THEN
989 file_name_act = trim(dir_name)//tmc_ana%costum_pos_file_name
990 ELSE
991 file_name_act = trim(dir_name)// &
992 expand_file_name_ending(file_name_temp, "xyz")
993 END IF
994 INQUIRE (file=file_name_act, exist=file_exists)
995 IF (file_exists) THEN
996 CALL open_file(file_name=file_name_act, file_status="OLD", &
997 file_action="READ", unit_number=tmc_ana%id_traj)
998 WRITE (tmc_ana%io_unit, fmt='(T2,A,"| ",A,T41,A40)') "TMC_ANA", &
999 "read xyz file", trim(file_name_act)
1000 END IF
1001
1002 ! cell file
1003 IF (tmc_ana%costum_cell_file_name /= "") THEN
1004 file_name_act = trim(dir_name)//tmc_ana%costum_cell_file_name
1005 ELSE
1006 file_name_act = trim(dir_name)// &
1007 expand_file_name_ending(file_name_temp, "cell")
1008 END IF
1009 INQUIRE (file=file_name_act, exist=file_exists)
1010 IF (file_exists) THEN
1011 CALL open_file(file_name=file_name_act, file_status="OLD", &
1012 file_action="READ", unit_number=tmc_ana%id_cell)
1013 WRITE (tmc_ana%io_unit, fmt='(T2,A,"| ",A,T41,A40)') "TMC_ANA", &
1014 "read cell file", trim(file_name_act)
1015 END IF
1016
1017 ! dipole file
1018 IF (tmc_ana%costum_dip_file_name /= "") THEN
1019 file_name_act = trim(dir_name)//tmc_ana%costum_dip_file_name
1020 ELSE
1021 file_name_act = trim(dir_name)// &
1022 expand_file_name_ending(file_name_temp, "dip")
1023 END IF
1024 INQUIRE (file=file_name_act, exist=file_exists)
1025 IF (file_exists) THEN
1026 CALL open_file(file_name=file_name_act, file_status="OLD", &
1027 file_action="READ", unit_number=tmc_ana%id_dip)
1028 WRITE (tmc_ana%io_unit, fmt='(T2,A,"| ",A,T41,A40)') "TMC_ANA", &
1029 "read dip file", trim(file_name_act)
1030 END IF
1031
1032 IF (tmc_ana%id_traj > 0 .OR. tmc_ana%id_cell > 0 .OR. &
1033 tmc_ana%id_dip > 0) THEN
1034 stat = tmc_status_ok
1035 ELSE
1036 CALL cp_warn(__location__, &
1037 "There is no file to open for temperature "//cp_to_string(tmc_ana%temperature)// &
1038 "K in directory "//trim(dir_name))
1039 END IF
1040 ! end the timing
1041 CALL timestop(handle)
1042 END SUBROUTINE analyse_files_open
1043
1044! **************************************************************************************************
1045!> \brief close the files for reading configurations data to analyze
1046!> \param tmc_ana ...
1047!> \param
1048!> \author Mandes 02.2013
1049! **************************************************************************************************
1050 SUBROUTINE analyse_files_close(tmc_ana)
1051 TYPE(tmc_analysis_env), POINTER :: tmc_ana
1052
1053 CHARACTER(LEN=*), PARAMETER :: routinen = 'analyse_files_close'
1054
1055 INTEGER :: handle
1056
1057 cpassert(ASSOCIATED(tmc_ana))
1058
1059 ! start the timing
1060 CALL timeset(routinen, handle)
1061
1062 ! position file
1063 IF (tmc_ana%id_traj > 0) CALL close_file(unit_number=tmc_ana%id_traj)
1064
1065 ! cell file
1066 IF (tmc_ana%id_cell > 0) CALL close_file(unit_number=tmc_ana%id_cell)
1067
1068 ! dipole file
1069 IF (tmc_ana%id_dip > 0) CALL close_file(unit_number=tmc_ana%id_dip)
1070
1071 ! end the timing
1072 CALL timestop(handle)
1073 END SUBROUTINE analyse_files_close
1074
1075END MODULE tmc_file_io
Utility routines to open and close files. Tracking of preconnections.
Definition cp_files.F:16
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.
Definition cp_files.F:311
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.
Definition cp_files.F:122
logical function, public file_exists(file_name)
Checks if file exists, considering also the file discovery mechanism.
Definition cp_files.F:504
various routines to log and control the output. The idea is that decisions about where to log should ...
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
integer, parameter, public default_string_length
Definition kinds.F:57
integer, parameter, public default_path_length
Definition kinds.F:58
Definition of physical constants:
Definition physcon.F:68
real(kind=dp), parameter, public angstrom
Definition physcon.F:144
Timing routines for accounting.
Definition timings.F:17
module provides variables for the TMC analysis tool
calculation section for TreeMonteCarlo
subroutine, public get_scaled_cell(cell, box_scale, scaled_hmat, scaled_cell, vol, abc, vec)
handles properties and calculations of a scaled cell
subroutine, public get_cell_scaling(cell, scaled_hmat, box_scale)
handles properties and calculations of a scaled cell
writing and printing the files, trajectory (pos, cell, dipoles) as well as restart files
Definition tmc_file_io.F:20
subroutine, public analyse_files_close(tmc_ana)
close the files for reading configurations data to analyze
subroutine, public write_result_list_element(result_list, result_count, conf_updated, accepted, tmc_params)
select the correct configuration to print out the (coordinates, forces, cell ...)
subroutine, public print_restart_file(tmc_env, job_counts, timings)
prints out the TMC restart files with all last configurations and counters etc.
subroutine, public write_dipoles_in_file(file_name, conf_nr, dip, file_ext)
writes the cell dipoles in dipole trajectory file
subroutine, public read_element_from_file(elem, tmc_ana, conf_nr, stat)
read the trajectory element from a file from sub tree element
subroutine, public write_element_in_file(elem, tmc_params, temp_index, file_name, conf_nr, conf_info)
writes the trajectory element in a file from sub tree element
subroutine, public analyse_files_open(tmc_ana, stat, dir_ind)
opens the files for reading configurations data to analyze
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)
character(len=default_path_length) function, public expand_file_name_int(file_name, ivalue)
placing an integer at the end of a file name (before the file extension)
subroutine, public read_restart_file(tmc_env, job_counts, timings, file_name)
reads the TMC restart file with all last configurations and counters etc.
tree nodes creation, searching, deallocation, references etc.
integer, parameter, public nr_mv_types
tree nodes creation, searching, deallocation, references etc.
Definition tmc_stati.F:15
integer, parameter, public tmc_status_failed
Definition tmc_stati.F:57
character(len= *), parameter, public tmc_default_trajectory_file_name
Definition tmc_stati.F:24
integer, parameter, public tmc_status_wait_for_new_task
Definition tmc_stati.F:52
character(len= *), parameter, public tmc_default_restart_in_file_name
Definition tmc_stati.F:28
character(len= *), parameter, public tmc_default_restart_out_file_name
Definition tmc_stati.F:26
integer, parameter, public tmc_status_ok
Definition tmc_stati.F:51
module handles definition of the tree nodes for the global and
module handles definition of the tree nodes for the global and
Definition tmc_types.F:34