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
21program xyzanim
23 use global_oct_m
24 use io_oct_m
25 use ions_oct_m
28 use parser_oct_m
30 use unit_oct_m
32
33 implicit none
34
35 integer :: ierr
36
37 ! Initialize stuff
39
40 call getopt_init(ierr)
41 if (ierr == 0) call getopt_xyz_anim()
42 call getopt_end()
43
44 call parser_init()
45
46 call messages_init()
47
49
50 call io_init()
52
54
56
57 call io_end()
58 call messages_end()
59
60 call parser_end()
61 call global_end()
62
63contains
64
65 subroutine generate_xyz_anim()
66
67 character(len=256) :: coords_file, comment
68 integer :: ierr, sampling, i, coords_unit, iter, j, record_length
69 logical :: multifiles
70 real(real64) :: time
71 type(ions_t), pointer :: ions
72
73 ! Sets the filenames
74 coords_file = 'td.general/coordinates'
75
76 !%Variable AnimationSampling
77 !%Type integer
78 !%Default 100
79 !%Section Utilities::oct-xyz-anim
80 !%Description
81 !% Sampling rate of the animation. The animation will be constructed using
82 !% the iteration numbers that are multiples of <tt>AnimationSampling</tt>.
83 !%End
84 call parse_variable(global_namespace, 'AnimationSampling', 100, sampling)
85 if (sampling < 1) then
86 message(1) = 'Sampling rate (AnimationSampling) should be bigger than 0'
87 call messages_fatal(1)
88 end if
89
90 !%Variable AnimationMultiFiles
91 !%Type logical
92 !%Default false
93 !%Section Utilities::oct-xyz-anim
94 !%Description
95 !% If true, each iteration written will be in a separate file.
96 !%End
97 call parse_variable(global_namespace, 'AnimationMultiFiles', .false., multifiles)
98
100
101 record_length = 100 + ions%space%dim*ions%natoms*3*20
102
103 ! Opens the coordinates file
104 coords_unit = io_open(coords_file, ions%namespace, action='read', recl = record_length)
105
106 call io_skip_header(coords_unit)
107 ierr = 0
108 do while(ierr == 0)
109 read(unit = coords_unit, iostat = ierr, fmt = *) iter, time, &
110 ((ions%pos(j, i), j = 1, ions%space%dim), i = 1, ions%natoms)
111 ions%pos = units_to_atomic(units_out%length, ions%pos)
112 if (mod(iter, sampling) == 0) then
113 write(comment, '(i10,f20.6)') iter, time
114 if (.not. multifiles) then
115 call io_mkdir('td.general', global_namespace)
116 call ions%write_xyz('td.general/movie', append = .true., comment = trim(comment))
117 else
118 call io_mkdir('td.general/movie/', ions%namespace)
119 write(coords_file,'(i7.7)')iter
120 call ions%write_xyz('td.general/movie/geo-' + trim(coords_file), append = .false.)
121 end if
122 end if
123 end do
124
125 safe_deallocate_p(ions)
126
127 call io_close(coords_unit)
128
129 end subroutine generate_xyz_anim
130
131end program xyzanim
132
133!! Local Variables:
134!! mode: f90
135!! coding: utf-8
136!! End:
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:381
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:264
subroutine, public init_octopus_globals(comm)
Initialise Octopus-specific global constants and files. This routine performs no initialisation calls...
Definition: global.F90:353
Definition: io.F90:114
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:166
subroutine, public io_close(iunit, grp)
Definition: io.F90:468
subroutine, public io_skip_header(iunit)
Definition: io.F90:679
subroutine, public io_end()
Definition: io.F90:265
subroutine, public io_mkdir(fname, namespace, parents)
Definition: io.F90:354
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
Definition: io.F90:395
subroutine, public messages_end()
Definition: messages.F90:277
subroutine, public messages_init(output_dir)
Definition: messages.F90:224
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
Definition: messages.F90:160
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
Definition: messages.F90:420
type(namespace_t), public global_namespace
Definition: namespace.F90:132
subroutine, public parser_init()
Initialise the Octopus parser.
Definition: parser.F90:450
subroutine, public parser_end()
End the Octopus parser.
Definition: parser.F90:481
subroutine, public profiling_end(namespace)
Definition: profiling.F90:413
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
Definition: profiling.F90:255
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
Definition: unit.F90:132
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
subroutine, public unit_system_init(namespace)
int true(void)
program xyzanim
Definition: xyzanim.F90:114
subroutine generate_xyz_anim()
Definition: xyzanim.F90:159