Octopus
xyzanim.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
23 use global_oct_m
24 use io_oct_m
25 use ions_oct_m
27 use mpi_oct_m
29 use parser_oct_m
31 use unit_oct_m
33
34 implicit none
35
36 private
37 public :: xyzanim_main
38
39contains
40
41 subroutine xyzanim_main() bind(c)
42 integer :: ierr
43
44 ! Initialize stuff
46
47 call getopt_init(ierr)
48 if (ierr == 0) call getopt_xyz_anim()
49 call getopt_end()
50
51 call parser_init()
52
53 call messages_init()
54
56
57 call io_init()
59
61
63
64 call io_end()
65 call messages_end()
66
67 call parser_end()
68 call global_end()
69
70 contains
71
72 subroutine generate_xyz_anim()
73
74 character(len=256) :: coords_file, comment
75 integer :: ierr, sampling, i, coords_unit, iter, j, record_length
76 logical :: multifiles
77 real(real64) :: time
78 type(ions_t), pointer :: ions
79
80 ! Sets the filenames
81 coords_file = 'td.general/coordinates'
82
83 !%Variable AnimationSampling
84 !%Type integer
85 !%Default 100
86 !%Section Utilities::oct-xyz-anim
87 !%Description
88 !% Sampling rate of the animation. The animation will be constructed using
89 !% the iteration numbers that are multiples of <tt>AnimationSampling</tt>.
90 !%End
91 call parse_variable(global_namespace, 'AnimationSampling', 100, sampling)
92 if (sampling < 1) then
93 message(1) = 'Sampling rate (AnimationSampling) should be bigger than 0'
94 call messages_fatal(1)
95 end if
96
97 !%Variable AnimationMultiFiles
98 !%Type logical
99 !%Default false
100 !%Section Utilities::oct-xyz-anim
101 !%Description
102 !% If true, each iteration written will be in a separate file.
103 !%End
104 call parse_variable(global_namespace, 'AnimationMultiFiles', .false., multifiles)
105
107
108 record_length = 100 + ions%space%dim*ions%natoms*3*20
109
110 ! Opens the coordinates file
111 coords_unit = io_open(coords_file, ions%namespace, action='read', recl = record_length)
112
113 call io_skip_header(coords_unit)
114 ierr = 0
115 do
116 read(unit = coords_unit, iostat = ierr, fmt = *) iter, time, &
117 ((ions%pos(j, i), j = 1, ions%space%dim), i = 1, ions%natoms)
118 if (ierr < 0) exit
119 if (ierr > 0) then
120 message(1) = 'Error while reading td.general/coordinates'
121 call messages_fatal(1)
122 end if
123 ions%pos = units_to_atomic(units_out%length, ions%pos)
124 if (mod(iter, sampling) == 0) then
125 write(comment, '(i10,f20.6)') iter, time
126 if (.not. multifiles) then
127 call io_mkdir('td.general', global_namespace)
128 call ions%write_xyz('td.general/movie', append = .true., comment = trim(comment))
129 else
130 call io_mkdir('td.general/movie/', ions%namespace)
131 write(coords_file,'(i7.7)')iter
132 call ions%write_xyz('td.general/movie/geo-' // trim(coords_file), append = .false.)
133 end if
134 end if
135 end do
136
137 safe_deallocate_p(ions)
138
139 call io_close(coords_unit)
140
141 end subroutine generate_xyz_anim
142 end subroutine xyzanim_main
143end module xyzanim_main_oct_m
145!! Local Variables:
146!! mode: f90
147!! coding: utf-8
148!! End:
This module provides an interface to the getopt C library, so that the command line arguments can be ...
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
Definition: global.F90:500
type(mpi_comm), parameter, public serial_dummy_comm
Alias MPI_COMM_UNDEFINED for the specific use case of initialising Octopus utilities with no MPI supp...
Definition: global.F90:268
subroutine, public init_octopus_globals(comm)
Initialise Octopus-specific global constants and files. This routine performs no initialisation calls...
Definition: global.F90:438
Definition: io.F90:93
subroutine, public io_init(defaults)
If the argument defaults is present and set to true, then the routine will not try to read anything f...
Definition: io.F90:142
subroutine, public io_close(iunit, grp)
Definition: io.F90:444
subroutine, public io_skip_header(iunit)
Definition: io.F90:623
subroutine, public io_end()
Definition: io.F90:248
subroutine, public io_mkdir(fname, namespace, parents)
Definition: io.F90:338
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:379
subroutine, public messages_end()
Definition: messages.F90:249
subroutine, public messages_init(output_dir)
Definition: messages.F90:196
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:138
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:386
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:317
type(namespace_t), public global_namespace
Definition: namespace.F90:112
subroutine, public parser_init()
Initialise the Octopus parser.
Definition: parser.F90:387
subroutine, public parser_end()
End the Octopus parser.
Definition: parser.F90:419
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
Definition: profiling.F90:122
subroutine, public profiling_end(namespace)
Definition: profiling.F90:455
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
Definition: profiling.F90:264
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:111
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
subroutine, public unit_system_init(namespace)
subroutine, public xyzanim_main()
Definition: xyzanim.F90:114
int true(void)
subroutine generate_xyz_anim()
Definition: xyzanim.F90:145