(git:6344619)
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 REAL(kind=dp), PARAMETER :: eps_temp = 5.0e-03_dp
283
284 INTEGER :: file_ptr, i, temp_size
285 LOGICAL :: flag
286 REAL(kind=dp), ALLOCATABLE, DIMENSION(:) :: tmp_temp
287 REAL(kind=dp), DIMENSION(nr_mv_types) :: mv_weight_tmp
288
289 cpassert(ASSOCIATED(tmc_env))
290 cpassert(ASSOCIATED(tmc_env%m_env))
291 cpassert(ASSOCIATED(tmc_env%params))
292 cpassert(ASSOCIATED(tmc_env%m_env%gt_act))
293
294 IF (file_name == tmc_default_restart_in_file_name) THEN
295 INQUIRE (file=tmc_default_restart_in_file_name, exist=flag)
296 cpassert(flag)
297 CALL open_file(file_name=tmc_default_restart_in_file_name, file_status="OLD", &
298 file_action="READ", unit_number=file_ptr)
299 READ (file_ptr, *) file_name
300 CALL close_file(unit_number=file_ptr)
301 END IF
302
303 CALL open_file(file_name=file_name, file_status="OLD", file_form="UNFORMATTED", &
304 file_action="READ", unit_number=file_ptr)
305 READ (file_ptr) temp_size
306 IF (temp_size /= SIZE(tmc_env%params%Temp)) THEN
307 CALL cp_abort(__location__, &
308 "the actual specified temperatures does not "// &
309 "fit in amount with the one from restart file ")
310 END IF
311 ALLOCATE (tmp_temp(temp_size))
312 READ (file_ptr) tmp_temp(:), &
313 tmc_env%m_env%gt_act%nr, &
314 tmc_env%m_env%gt_act%rng_seed, &
315 tmc_env%m_env%gt_act%rnd_nr, &
316 tmc_env%m_env%gt_act%prob_acc, &
317 tmc_env%m_env%gt_act%mv_conf, & !
318 tmc_env%m_env%gt_act%mv_next_conf, & !
319 tmc_env%m_env%result_count(0:), &
320 mv_weight_tmp, & !
321 tmc_env%params%move_types%acc_count, &
322 tmc_env%params%move_types%mv_count, &
323 tmc_env%params%move_types%subbox_acc_count, &
324 tmc_env%params%move_types%subbox_count, & !
325 tmc_env%params%cell%hmat, &
326 job_counts, &
327 timings
328
329 IF (any(abs(tmc_env%params%Temp(:) - tmp_temp(:)) >= eps_temp)) THEN
330 CALL cp_abort(__location__, "the temperatures differ from the previous calculation. "// &
331 "There were the following temperatures used:")
332 END IF
333 IF (any(mv_weight_tmp(:) /= tmc_env%params%move_types%mv_weight(:))) THEN
334 cpwarn("The amount of mv types differs between the original and the restart run.")
335 END IF
336
337 DO i = 1, SIZE(tmc_env%params%Temp)
338 tmc_env%m_env%gt_act%conf(i)%elem => tmc_env%m_env%result_list(i)%elem
339 READ (file_ptr) tmc_env%m_env%result_list(i)%elem%nr, &
340 tmc_env%m_env%result_list(i)%elem%rng_seed, &
341 tmc_env%m_env%result_list(i)%elem%pos, &
342 tmc_env%m_env%result_list(i)%elem%vel, &
343 tmc_env%m_env%result_list(i)%elem%box_scale, &
344 tmc_env%m_env%result_list(i)%elem%potential, &
345 tmc_env%m_env%result_list(i)%elem%e_pot_approx, &
346 tmc_env%m_env%result_list(i)%elem%ekin, &
347 tmc_env%m_env%result_list(i)%elem%ekin_before_md, &
348 tmc_env%m_env%result_list(i)%elem%temp_created
349 END DO
350 CALL close_file(unit_number=file_ptr)
351 END SUBROUTINE read_restart_file
352
353 !----------------------------------------------------------------------------
354 ! printing configuration in file
355 !----------------------------------------------------------------------------
356
357! **************************************************************************************************
358!> \brief select the correct configuration to print out the
359!> (coordinates, forces, cell ...)
360!> \param result_list list of configurations for each temperature
361!> \param result_count list with number of Markov Chain number
362!> for each teperature (index 0 for global tree)
363!> \param conf_updated index of the updated (modified element)
364!> \param accepted acceptance flag
365!> \param tmc_params TMC environment parameters
366!> \author Mandes 02.2013
367! **************************************************************************************************
368 SUBROUTINE write_result_list_element(result_list, result_count, conf_updated, &
369 accepted, tmc_params)
370 TYPE(elem_array_type), DIMENSION(:), POINTER :: result_list
371 INTEGER, DIMENSION(:), POINTER :: result_count
372 INTEGER :: conf_updated
373 LOGICAL, INTENT(IN) :: accepted
374 TYPE(tmc_param_type), POINTER :: tmc_params
375
376 CHARACTER(LEN=*), PARAMETER :: routinen = 'write_result_list_element'
377
378 CHARACTER(LEN=default_path_length) :: file_name
379 INTEGER :: handle, i
380
381 file_name = ""
382
383 cpassert(ASSOCIATED(result_list))
384 cpassert(ASSOCIATED(result_count))
385 cpassert(ASSOCIATED(tmc_params))
386 cpassert(ASSOCIATED(tmc_params%Temp))
387 cpassert(conf_updated >= 0)
388 cpassert(conf_updated <= SIZE(tmc_params%Temp))
389
390 ! start the timing
391 CALL timeset(routinen, handle)
392
393 IF (conf_updated == 0) THEN
394 ! for debugging print every configuration of every temperature
395 DO i = 1, SIZE(tmc_params%Temp)
396 WRITE (file_name, *) "every_step_", trim(tmc_default_trajectory_file_name)
397 CALL write_element_in_file(elem=result_list(i)%elem, &
398 tmc_params=tmc_params, conf_nr=result_count(0), &
399 file_name=expand_file_name_temp(file_name=file_name, rvalue=tmc_params%Temp(i)))
400 END DO
401 ELSE
402 IF ((.NOT. tmc_params%print_only_diff_conf) .OR. &
403 (tmc_params%print_only_diff_conf .AND. accepted)) THEN
404 CALL write_element_in_file(elem=result_list(conf_updated)%elem, &
405 tmc_params=tmc_params, conf_nr=result_count(conf_updated), &
407 rvalue=tmc_params%Temp(conf_updated)))
408 END IF
409 END IF
410 ! end the timing
411 CALL timestop(handle)
412 END SUBROUTINE write_result_list_element
413
414! **************************************************************************************************
415!> \brief writes the trajectory element in a file from sub tree element
416!> \param elem actual tree element to be printed out
417!> \param tmc_params TMC environment parameters
418!> \param temp_index ...
419!> \param file_name file name will be extended by type of file (pos, cell,...)
420!> \param conf_nr Markov chain element number
421!> \param conf_info whole header line
422!> \author Mandes 11.2012
423! **************************************************************************************************
424 SUBROUTINE write_element_in_file(elem, tmc_params, temp_index, file_name, conf_nr, &
425 conf_info)
426 TYPE(tree_type), POINTER :: elem
427 TYPE(tmc_param_type), POINTER :: tmc_params
428 INTEGER, OPTIONAL :: temp_index
429 CHARACTER(LEN=*), OPTIONAL :: file_name
430 INTEGER, OPTIONAL :: conf_nr
431 CHARACTER(LEN=*), OPTIONAL :: conf_info
432
433 CHARACTER(LEN=*), PARAMETER :: routinen = 'write_element_in_file'
434
435 CHARACTER(LEN=default_path_length) :: file_name_act, tmp_name
436 CHARACTER(LEN=default_string_length) :: header
437 INTEGER :: file_ptr, handle, i, nr_atoms
438 LOGICAL :: file_exists, print_it
439 REAL(kind=dp) :: vol
440 REAL(kind=dp), DIMENSION(3, 3) :: hmat_scaled
441
442 file_name_act = ""
443 tmp_name = ""
444 header = ""
445 print_it = .true.
446
447 cpassert(ASSOCIATED(elem))
448 cpassert(ASSOCIATED(tmc_params))
449 cpassert(ASSOCIATED(tmc_params%atoms))
450 cpassert(PRESENT(conf_nr) .OR. PRESENT(conf_info))
451
452 IF (print_it) THEN
453 ! start the timing
454 CALL timeset(routinen, handle)
455
456 ! set default file name
457 IF (PRESENT(file_name)) THEN
458 cpassert(file_name /= "")
459 file_name_act = file_name
460 ELSE
461 cpassert(ASSOCIATED(tmc_params%Temp))
462 cpassert(PRESENT(temp_index))
464 rvalue=tmc_params%Temp(temp_index))
465 END IF
466
467 nr_atoms = SIZE(elem%pos)/tmc_params%dim_per_elem
468
469 ! set header (for coordinate or force file)
470 IF (tmc_params%print_trajectory .OR. tmc_params%print_forces) THEN
471 IF (PRESENT(conf_info)) THEN
472 WRITE (header, *) trim(adjustl(conf_info))
473 ELSE
474 !WRITE(header,FMT="(A,I8,A,F20.10)") " i = ", conf_nr,", E = ", elem%potential
475 WRITE (header, fmt="(A,I8,A,F20.10,F20.10,A,I8,I8)") "i =", conf_nr, " ,E =", &
476 elem%potential, elem%ekin, " st elem", elem%sub_tree_nr, elem%nr
477 END IF
478 END IF
479
480 ! write the coordinates
481 IF (tmc_params%print_trajectory) THEN
482 tmp_name = expand_file_name_ending(file_name_act, "xyz")
483 CALL open_file(file_name=tmp_name, file_status="UNKNOWN", &
484 file_action="WRITE", file_position="APPEND", &
485 unit_number=file_ptr)
486 WRITE (file_ptr, fmt="(I8)") nr_atoms
487 WRITE (file_ptr, *) trim(header)
488 DO i = 1, SIZE(elem%pos), tmc_params%dim_per_elem
489 WRITE (file_ptr, fmt="(A4,1X,1000F20.10)") &
490 trim(tmc_params%atoms((i - 1)/tmc_params%dim_per_elem + 1)%name), &
491 elem%pos(i:i + tmc_params%dim_per_elem - 1)*au2a
492 END DO
493 CALL close_file(unit_number=file_ptr)
494 END IF
495
496 ! write the forces
497 IF (tmc_params%print_forces) THEN
498 tmp_name = expand_file_name_ending(file_name_act, "frc")
499 CALL open_file(file_name=tmp_name, file_status="UNKNOWN", &
500 file_action="WRITE", file_position="APPEND", &
501 unit_number=file_ptr)
502 WRITE (file_ptr, fmt="(I8)") nr_atoms
503 WRITE (file_ptr, *) trim(header)
504 DO i = 1, SIZE(elem%pos), tmc_params%dim_per_elem
505 WRITE (file_ptr, fmt="(A4,1X,1000F20.10)") &
506 trim(tmc_params%atoms((i - 1)/tmc_params%dim_per_elem + 1)%name), &
507 elem%frc(i:i + tmc_params%dim_per_elem - 1)
508 END DO
509 CALL close_file(unit_number=file_ptr)
510 END IF
511
512 ! write the cell dipoles
513 IF (tmc_params%print_dipole) THEN
514 CALL write_dipoles_in_file(file_name=file_name_act, &
515 conf_nr=conf_nr, dip=elem%dipole)
516 END IF
517
518 ! write the cell file
519 IF (tmc_params%print_cell) THEN
520 tmp_name = expand_file_name_ending(file_name_act, "cell")
521 ! header
522 INQUIRE (file=tmp_name, exist=file_exists) ! file_exists will be TRUE if the file exist
523 IF (.NOT. file_exists) THEN
524 CALL open_file(file_name=tmp_name, file_status="NEW", &
525 file_action="WRITE", unit_number=file_ptr)
526 WRITE (file_ptr, fmt='(A,9(7X,A2," [Angstrom]"),6X,A)') &
527 "# MC step ", "Ax", "Ay", "Az", "Bx", "By", "Bz", "Cx", "Cy", "Cz", &
528 "Volume [Angstrom^3]"
529 ELSE
530 CALL open_file(file_name=tmp_name, file_status="OLD", &
531 file_action="WRITE", file_position="APPEND", &
532 unit_number=file_ptr)
533 END IF
534 CALL get_scaled_cell(cell=tmc_params%cell, &
535 box_scale=elem%box_scale, scaled_hmat=hmat_scaled, &
536 vol=vol)
537 WRITE (file_ptr, fmt="(I8,9(1X,F19.10),1X,F24.10)") conf_nr, &
538 hmat_scaled(:, :)*au2a, vol*au2a**3
539 !TODO better cell output e.g. using cell_types routine
540 CALL close_file(unit_number=file_ptr)
541 END IF
542
543 ! write the different energies
544 IF (tmc_params%print_energies) THEN
545 tmp_name = expand_file_name_ending(file_name_act, "ener")
546 ! header
547 INQUIRE (file=tmp_name, exist=file_exists) ! file_exists will be TRUE if the file exist
548 IF (.NOT. file_exists) THEN
549 CALL open_file(file_name=tmp_name, file_status="NEW", &
550 file_action="WRITE", unit_number=file_ptr)
551 WRITE (file_ptr, fmt='(A,4A20)') &
552 "# MC step ", " exact ", " approx ", " last SCF ", " kinetic "
553 ELSE
554 CALL open_file(file_name=tmp_name, file_status="OLD", &
555 file_action="WRITE", file_position="APPEND", &
556 unit_number=file_ptr)
557 END IF
558 WRITE (file_ptr, fmt="(I8,14F20.10)") conf_nr, elem%potential, elem%e_pot_approx, &
559 elem%scf_energies(mod(elem%scf_energies_count, 4) + 1), elem%ekin
560 CALL close_file(unit_number=file_ptr)
561 END IF
562
563 ! end the timing
564 CALL timestop(handle)
565 END IF
566 END SUBROUTINE write_element_in_file
567
568! **************************************************************************************************
569!> \brief writes the cell dipoles in dipole trajectory file
570!> \param file_name ...
571!> \param conf_nr ...
572!> \param dip ...
573!> \param file_ext ...
574!> \param
575!> \author Mandes 11.2012
576! **************************************************************************************************
577 SUBROUTINE write_dipoles_in_file(file_name, conf_nr, dip, file_ext)
578 CHARACTER(LEN=default_path_length) :: file_name
579 INTEGER :: conf_nr
580 REAL(kind=dp), DIMENSION(:), POINTER :: dip
581 CHARACTER(LEN=*), INTENT(in), OPTIONAL :: file_ext
582
583 CHARACTER(LEN=default_path_length) :: file_name_tmp
584 INTEGER :: file_ptr
585 LOGICAL :: file_exists
586
587 cpassert(ASSOCIATED(dip))
588
589 IF (PRESENT(file_ext)) THEN
590 cpassert(file_ext /= "")
591 file_name_tmp = expand_file_name_ending(file_name, trim(file_ext))
592 ELSE
593 file_name_tmp = expand_file_name_ending(file_name, "dip")
594 END IF
595 INQUIRE (file=file_name_tmp, exist=file_exists)
596 IF (.NOT. file_exists) THEN
597 CALL open_file(file_name=file_name_tmp, file_status="NEW", &
598 file_action="WRITE", unit_number=file_ptr)
599 WRITE (file_ptr, fmt='(A8,10A20)') "# conf_nr", "dip_x [C Angstrom]", &
600 "dip_y [C Angstrom]", "dip_z [C Angstrom]"
601 ELSE
602 CALL open_file(file_name=file_name_tmp, file_status="OLD", &
603 file_action="WRITE", file_position="APPEND", &
604 unit_number=file_ptr)
605 END IF
606 WRITE (file_ptr, fmt="(I8,10F20.10)") conf_nr, dip(:)
607 CALL close_file(unit_number=file_ptr)
608 END SUBROUTINE write_dipoles_in_file
609
610 !----------------------------------------------------------------------------
611 ! read configuration from file
612 !----------------------------------------------------------------------------
613
614! **************************************************************************************************
615!> \brief read the trajectory element from a file from sub tree element
616!> \param elem actual tree element to be printed out
617!> \param tmc_ana TMC analysis environment parameters
618!> \param conf_nr Markov chain element number
619!> (input the old number and read only if conf nr from file is greater
620!> \param stat ...
621!> \author Mandes 03.2013
622! **************************************************************************************************
623 SUBROUTINE read_element_from_file(elem, tmc_ana, conf_nr, stat)
624 TYPE(tree_type), POINTER :: elem
625 TYPE(tmc_analysis_env), POINTER :: tmc_ana
626 INTEGER :: conf_nr, stat
627
628 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_element_from_file'
629
630 INTEGER :: conf_nr_old, handle, i_tmp
631 LOGICAL :: files_conf_missmatch
632
633 stat = tmc_status_ok
634 conf_nr_old = conf_nr
635 files_conf_missmatch = .false.
636
637 cpassert(ASSOCIATED(elem))
638 cpassert(ASSOCIATED(tmc_ana))
639 cpassert(ASSOCIATED(tmc_ana%atoms))
640
641 ! start the timing
642 CALL timeset(routinen, handle)
643
644 ! read the coordinates
645 IF (tmc_ana%id_traj > 0) THEN
646 i_tmp = conf_nr_old
647 CALL read_pos_from_file(elem=elem, tmc_ana=tmc_ana, stat=stat, &
648 conf_nr=i_tmp)
649 IF (stat == tmc_status_wait_for_new_task) THEN
650 CALL cp_warn(__location__, &
651 'end of position file reached at line '// &
652 cp_to_string(real(tmc_ana%lc_traj, kind=dp))//", last element "// &
653 cp_to_string(tmc_ana%last_elem%nr))
654 ELSE
655 cpassert(i_tmp > conf_nr_old)
656 conf_nr = i_tmp
657 elem%nr = i_tmp
658 END IF
659 END IF
660
661 ! read the forces
662 ! TODO if necessary
663
664 ! read the dipoles file
665 IF (tmc_ana%id_dip > 0 .AND. stat == tmc_status_ok) THEN
666 i_tmp = conf_nr_old
667 search_conf_dip: DO
668 CALL read_dipole_from_file(elem=elem, tmc_ana=tmc_ana, stat=stat, &
669 conf_nr=i_tmp)
670 IF (stat == tmc_status_wait_for_new_task) THEN
671 CALL cp_warn(__location__, &
672 'end of dipole file reached at line'// &
673 cp_to_string(real(tmc_ana%lc_dip, kind=dp)))
674 EXIT search_conf_dip
675 END IF
676 ! check consitence with pos file
677 IF (tmc_ana%id_traj > 0) THEN
678 IF (i_tmp == conf_nr) THEN
679 files_conf_missmatch = .false.
680 EXIT search_conf_dip
681 ELSE
682 ! the configuration numbering differ from the position file,
683 ! but we keep on searching for the correct configuration
684 files_conf_missmatch = .true.
685 END IF
686 ! if no pos file, just take the next conf
687 ELSE IF (i_tmp > conf_nr_old) THEN
688 conf_nr = i_tmp
689 elem%nr = i_tmp
690 EXIT search_conf_dip
691 END IF
692 END DO search_conf_dip
693 END IF
694
695 ! read the cell file
696 IF (tmc_ana%id_cell > 0 .AND. stat == tmc_status_ok) THEN
697 search_conf_cell: DO
698 CALL read_cell_from_file(elem=elem, tmc_ana=tmc_ana, stat=stat, &
699 conf_nr=i_tmp)
700 IF (stat == tmc_status_wait_for_new_task) THEN
701 CALL cp_warn(__location__, &
702 'end of cell file reached at line at line'// &
703 cp_to_string(real(tmc_ana%lc_cell, kind=dp)))
704 EXIT search_conf_cell
705 END IF
706 ! check consitence with pos file
707 IF (tmc_ana%id_traj > 0) THEN
708 IF (i_tmp == conf_nr) THEN
709 files_conf_missmatch = .false.
710 EXIT search_conf_cell
711 ELSE
712 ! the configuration numbering differ from the position file,
713 ! but we keep on searching for the correct configuration
714 files_conf_missmatch = .true.
715 END IF
716 ! if no pos file, just take the next conf
717 ELSE IF (i_tmp > conf_nr_old) THEN
718 conf_nr = i_tmp
719 elem%nr = i_tmp
720 EXIT search_conf_cell
721 END IF
722 END DO search_conf_cell
723
724 END IF
725
726 ! write the different energies
727 ! TODO if necessary
728
729 IF (files_conf_missmatch) THEN
730 CALL cp_warn(__location__, &
731 'there is a missmatch in the configuration numbering. '// &
732 "Read number of lines (pos|cell|dip)"// &
733 cp_to_string(tmc_ana%lc_traj)//"|"// &
734 cp_to_string(tmc_ana%lc_cell)//"|"// &
735 cp_to_string(tmc_ana%lc_dip))
736 END IF
737
738 ! end the timing
739 CALL timestop(handle)
740 END SUBROUTINE read_element_from_file
741
742! **************************************************************************************************
743!> \brief search for the next configurational position in file
744!> \param elem actual tree element to be read
745!> \param tmc_ana ...
746!> \param stat ...
747!> \param conf_nr Markov chain element number
748!> (input the old number and read only if conf nr from file is greater
749!> \param header_info ...
750!> \author Mandes 03.2013
751! **************************************************************************************************
752 SUBROUTINE read_pos_from_file(elem, tmc_ana, stat, conf_nr, header_info)
753 TYPE(tree_type), POINTER :: elem
754 TYPE(tmc_analysis_env), POINTER :: tmc_ana
755 INTEGER :: stat, conf_nr
756 CHARACTER(LEN=*), OPTIONAL :: header_info
757
758 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_pos_from_file'
759
760 CHARACTER(LEN=default_string_length) :: c_tmp
761 INTEGER :: handle, i, i_tmp, status
762
763 stat = tmc_status_failed
764
765 cpassert(ASSOCIATED(elem))
766 cpassert(ASSOCIATED(elem%pos))
767 cpassert(ASSOCIATED(tmc_ana))
768 cpassert(tmc_ana%id_traj > 0)
769
770 ! start the timing
771 CALL timeset(routinen, handle)
772
773 search_next_conf: DO
774 c_tmp(:) = " "
775 tmc_ana%lc_traj = tmc_ana%lc_traj + 1
776 READ (tmc_ana%id_traj, '(A)', iostat=status) c_tmp(:)
777 IF (status > 0) THEN
778 CALL cp_abort(__location__, &
779 "configuration header read error at line: "// &
780 cp_to_string(tmc_ana%lc_traj)//": "//c_tmp)
781 END IF
782 IF (status < 0) THEN ! end of file reached
784 EXIT search_next_conf
785 END IF
786 IF (index(c_tmp, "=") > 0) THEN
787 READ (c_tmp(index(c_tmp, "=") + 1:), *, iostat=status) i_tmp ! read the configuration number
788 IF (status /= 0) THEN
789 CALL cp_abort(__location__, &
790 "configuration header read error (for conf nr) at line: "// &
791 cp_to_string(tmc_ana%lc_traj))
792 END IF
793 IF (i_tmp > conf_nr) THEN
794 ! TODO we could also read the energy ...
795 conf_nr = i_tmp
796 IF (PRESENT(header_info)) header_info = c_tmp
797 stat = tmc_status_ok
798 EXIT search_next_conf
799 END IF
800 END IF
801 END DO search_next_conf
802
803 IF (stat == tmc_status_ok) THEN
804 pos_loop: DO i = 1, SIZE(elem%pos), tmc_ana%dim_per_elem
805 tmc_ana%lc_traj = tmc_ana%lc_traj + 1
806 READ (tmc_ana%id_traj, fmt="(A4,1X,1000F20.10)", iostat=status) &
807 c_tmp, elem%pos(i:i + tmc_ana%dim_per_elem - 1)
808 IF (status /= 0) THEN
809 CALL cp_abort(__location__, &
810 "configuration pos read error at line: "// &
811 cp_to_string(tmc_ana%lc_traj))
812 END IF
813 END DO pos_loop
814 elem%pos(:) = elem%pos(:)/au2a
815 END IF
816
817 ! end the timing
818 CALL timestop(handle)
819 END SUBROUTINE read_pos_from_file
820
821! **************************************************************************************************
822!> \brief search for the dipole entry
823!> \param elem actual tree element to be read
824!> \param tmc_ana ...
825!> \param stat ...
826!> \param conf_nr Markov chain element number
827!> (input the old number and read only if conf nr from file is greater
828!> \author Mandes 03.2013
829! **************************************************************************************************
830 SUBROUTINE read_dipole_from_file(elem, tmc_ana, stat, conf_nr)
831 TYPE(tree_type), POINTER :: elem
832 TYPE(tmc_analysis_env), POINTER :: tmc_ana
833 INTEGER :: stat, conf_nr
834
835 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_dipole_from_file'
836
837 CHARACTER(LEN=250) :: c_tmp
838 INTEGER :: handle, status
839
840 stat = tmc_status_failed
841
842 cpassert(ASSOCIATED(elem))
843 cpassert(ASSOCIATED(elem%dipole))
844 cpassert(ASSOCIATED(tmc_ana))
845 cpassert(tmc_ana%id_dip > 0)
846
847 ! start the timing
848 CALL timeset(routinen, handle)
849 tmc_ana%lc_dip = tmc_ana%lc_dip + 1
850 READ (tmc_ana%id_dip, fmt="(A)", iostat=status) c_tmp
851 IF (status == 0) THEN
852 ! skip the initial line (header)
853 IF (index(c_tmp, "#") > 0) THEN
854 tmc_ana%lc_dip = tmc_ana%lc_dip + 1
855 READ (tmc_ana%id_dip, fmt="(A)", iostat=status) c_tmp
856 END IF
857 END IF
858 IF (status == 0) THEN
859 READ (c_tmp, fmt="(I8,10F20.10)", iostat=status) &
860 conf_nr, elem%dipole(:)
861 END IF
862 IF (status == 0) THEN ! success
863 stat = tmc_status_ok
864 ELSE IF (status < 0) THEN ! end of file reached
866 ELSE
867 IF (status /= 0) THEN
868 cpwarn("configuration dipole read error at line: "//cp_to_string(tmc_ana%lc_dip))
869 END IF
870 stat = tmc_status_failed
871 END IF
872
873 ! end the timing
874 CALL timestop(handle)
875 END SUBROUTINE read_dipole_from_file
876
877! **************************************************************************************************
878!> \brief search for the cell entry
879!> \param elem actual tree element to be read
880!> \param tmc_ana ...
881!> \param stat ...
882!> \param conf_nr Markov chain element number
883!> (input the old number and read only if conf nr from file is greater
884!> \author Mandes 03.2013
885! **************************************************************************************************
886 SUBROUTINE read_cell_from_file(elem, tmc_ana, stat, conf_nr)
887 TYPE(tree_type), POINTER :: elem
888 TYPE(tmc_analysis_env), POINTER :: tmc_ana
889 INTEGER :: stat, conf_nr
890
891 CHARACTER(LEN=*), PARAMETER :: routinen = 'read_cell_from_file'
892
893 CHARACTER(LEN=250) :: c_tmp
894 INTEGER :: handle, status
895 REAL(kind=dp) :: r_tmp
896 REAL(kind=dp), DIMENSION(3, 3) :: hmat
897
898 stat = tmc_status_failed
899
900 cpassert(ASSOCIATED(elem))
901 cpassert(ASSOCIATED(tmc_ana))
902 cpassert(ASSOCIATED(tmc_ana%cell))
903 cpassert(tmc_ana%id_cell > 0)
904
905 ! start the timing
906 CALL timeset(routinen, handle)
907
908 tmc_ana%lc_cell = tmc_ana%lc_cell + 1
909 READ (tmc_ana%id_cell, fmt="(A)", iostat=status) c_tmp
910 IF (status == 0) THEN
911 ! skip the initial line (header)
912 IF (index(c_tmp, "#") > 0) THEN
913 tmc_ana%lc_cell = tmc_ana%lc_cell + 1
914 READ (tmc_ana%id_cell, fmt="(A)", iostat=status) c_tmp
915 END IF
916 END IF
917 IF (status == 0) THEN
918 READ (c_tmp, fmt="(I8,9(1X,F19.10),1X,F24.10)", iostat=status) conf_nr, &
919 hmat(:, :), r_tmp
920 END IF
921 IF (status < 0) THEN ! end of file reached
923 ELSE IF (status > 0) THEN
924 IF (status /= 0) THEN
925 cpabort("configuration cell read error at line: "//cp_to_string(tmc_ana%lc_cell))
926 END IF
927 stat = tmc_status_failed
928 ELSE
929 IF (elem%nr < 0) elem%nr = conf_nr
930 hmat(:, :) = hmat(:, :)/au2a
931 ! get the box scaling
932 CALL get_cell_scaling(cell=tmc_ana%cell, scaled_hmat=hmat, &
933 box_scale=elem%box_scale)
934 stat = tmc_status_ok
935 END IF
936 ! end the timing
937 CALL timestop(handle)
938 END SUBROUTINE read_cell_from_file
939
940 !----------------------------------------------------------------------------
941 ! get the configurations from file and calc
942 !----------------------------------------------------------------------------
943
944! **************************************************************************************************
945!> \brief opens the files for reading configurations data to analyze
946!> \param tmc_ana ...
947!> \param stat ...
948!> \param dir_ind ...
949!> \param
950!> \author Mandes 02.2013
951! **************************************************************************************************
952 SUBROUTINE analyse_files_open(tmc_ana, stat, dir_ind)
953 TYPE(tmc_analysis_env), POINTER :: tmc_ana
954 INTEGER :: stat
955 INTEGER, OPTIONAL :: dir_ind
956
957 CHARACTER(LEN=*), PARAMETER :: routinen = 'analyse_files_open'
958
959 CHARACTER(LEN=default_path_length) :: dir_name, file_name_act, file_name_temp
960 INTEGER :: handle
961 LOGICAL :: file_exists
962
963 cpassert(ASSOCIATED(tmc_ana))
964
966
967 ! start the timing
968 CALL timeset(routinen, handle)
969
970 IF (PRESENT(dir_ind)) THEN
971 cpassert(ASSOCIATED(tmc_ana%dirs))
972 cpassert(dir_ind > 0)
973 cpassert(dir_ind <= SIZE(tmc_ana%dirs))
974
975 IF (index(tmc_ana%dirs(dir_ind), "/", back=.true.) == &
976 len_trim(tmc_ana%dirs(dir_ind))) THEN
977 dir_name = trim(tmc_ana%dirs(dir_ind))
978 ELSE
979 dir_name = trim(tmc_ana%dirs(dir_ind))//"/"
980 END IF
981 ELSE
982 dir_name = "./"
983 END IF
984
985 ! open the files
986 file_name_temp = expand_file_name_temp( &
988 rvalue=tmc_ana%temperature)
989 ! position file
990 IF (tmc_ana%costum_pos_file_name /= "") THEN
991 file_name_act = trim(dir_name)//tmc_ana%costum_pos_file_name
992 ELSE
993 file_name_act = trim(dir_name)// &
994 expand_file_name_ending(file_name_temp, "xyz")
995 END IF
996 INQUIRE (file=file_name_act, exist=file_exists)
997 IF (file_exists) THEN
998 CALL open_file(file_name=file_name_act, file_status="OLD", &
999 file_action="READ", unit_number=tmc_ana%id_traj)
1000 WRITE (tmc_ana%io_unit, fmt='(T2,A,"| ",A,T41,A40)') "TMC_ANA", &
1001 "read xyz file", trim(file_name_act)
1002 END IF
1003
1004 ! cell file
1005 IF (tmc_ana%costum_cell_file_name /= "") THEN
1006 file_name_act = trim(dir_name)//tmc_ana%costum_cell_file_name
1007 ELSE
1008 file_name_act = trim(dir_name)// &
1009 expand_file_name_ending(file_name_temp, "cell")
1010 END IF
1011 INQUIRE (file=file_name_act, exist=file_exists)
1012 IF (file_exists) THEN
1013 CALL open_file(file_name=file_name_act, file_status="OLD", &
1014 file_action="READ", unit_number=tmc_ana%id_cell)
1015 WRITE (tmc_ana%io_unit, fmt='(T2,A,"| ",A,T41,A40)') "TMC_ANA", &
1016 "read cell file", trim(file_name_act)
1017 END IF
1018
1019 ! dipole file
1020 IF (tmc_ana%costum_dip_file_name /= "") THEN
1021 file_name_act = trim(dir_name)//tmc_ana%costum_dip_file_name
1022 ELSE
1023 file_name_act = trim(dir_name)// &
1024 expand_file_name_ending(file_name_temp, "dip")
1025 END IF
1026 INQUIRE (file=file_name_act, exist=file_exists)
1027 IF (file_exists) THEN
1028 CALL open_file(file_name=file_name_act, file_status="OLD", &
1029 file_action="READ", unit_number=tmc_ana%id_dip)
1030 WRITE (tmc_ana%io_unit, fmt='(T2,A,"| ",A,T41,A40)') "TMC_ANA", &
1031 "read dip file", trim(file_name_act)
1032 END IF
1033
1034 IF (tmc_ana%id_traj > 0 .OR. tmc_ana%id_cell > 0 .OR. &
1035 tmc_ana%id_dip > 0) THEN
1036 stat = tmc_status_ok
1037 ELSE
1038 CALL cp_warn(__location__, &
1039 "There is no file to open for temperature "//cp_to_string(tmc_ana%temperature)// &
1040 "K in directory "//trim(dir_name))
1041 END IF
1042 ! end the timing
1043 CALL timestop(handle)
1044 END SUBROUTINE analyse_files_open
1045
1046! **************************************************************************************************
1047!> \brief close the files for reading configurations data to analyze
1048!> \param tmc_ana ...
1049!> \param
1050!> \author Mandes 02.2013
1051! **************************************************************************************************
1052 SUBROUTINE analyse_files_close(tmc_ana)
1053 TYPE(tmc_analysis_env), POINTER :: tmc_ana
1054
1055 CHARACTER(LEN=*), PARAMETER :: routinen = 'analyse_files_close'
1056
1057 INTEGER :: handle
1058
1059 cpassert(ASSOCIATED(tmc_ana))
1060
1061 ! start the timing
1062 CALL timeset(routinen, handle)
1063
1064 ! position file
1065 IF (tmc_ana%id_traj > 0) CALL close_file(unit_number=tmc_ana%id_traj)
1066
1067 ! cell file
1068 IF (tmc_ana%id_cell > 0) CALL close_file(unit_number=tmc_ana%id_cell)
1069
1070 ! dipole file
1071 IF (tmc_ana%id_dip > 0) CALL close_file(unit_number=tmc_ana%id_dip)
1072
1073 ! end the timing
1074 CALL timestop(handle)
1075 END SUBROUTINE analyse_files_close
1076
1077END MODULE tmc_file_io
Utility routines to open and close files.
Definition cp_files.F:22
logical function, public file_exists(file_name)
Checks if a file exists, considering also the file discovery mechanism.
Definition cp_files.F:518
subroutine, public open_file(file_name, unit_number, file_status, file_form, file_action, file_position, file_pad, file_access, debug)
Opens a file and returns its logical unit number.
Definition cp_files.F:197
subroutine, public close_file(unit_number, file_status)
Closes an open file given by its logical unit number.
Definition cp_files.F:64
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