Octopus
io_function.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 atom_oct_m
24 use box_oct_m
26 use comm_oct_m
28 use cube_oct_m
29 use debug_oct_m
31 use fft_oct_m
32 use global_oct_m
33 use index_oct_m
34 use io_oct_m
36 use io_csv_oct_m
37 use iso_c_binding
40 use mesh_oct_m
43 use mpi_oct_m
46#if defined(HAVE_NETCDF)
47 use netcdf
48#endif
50 use parser_oct_m
53 use space_oct_m
55 use unit_oct_m
57 use utils_oct_m
59 use vtk_oct_m
60
61 implicit none
62
63 private
64 public :: &
82
83#if defined(HAVE_NETCDF)
84 public :: &
85 dout_cf_netcdf, &
86 zout_cf_netcdf
87#endif
88
90 integer, parameter, private :: &
91 DOUTPUT_KIND = 1, &
92 zoutput_kind = -1
95 character(len=3), parameter :: &
96 index2label(3) = (/ 're ', 'im ', 'abs' /)
97
98
101 end interface io_function_output_vector
102
105 end interface io_function_output_vector_bz
106
109 end interface io_function_output_global_bz
110
113 end interface io_function_output_supercell
114
115
116contains
117
118 ! ---------------------------------------------------------
119 subroutine io_function_read_what_how_when(namespace, space, what, how, output_interval, &
120 what_tag_in, how_tag_in, output_interval_tag_in, ignore_error)
121 type(namespace_t), intent(in) :: namespace
122 class(space_t), intent(in) :: space
123 logical, intent(inout) :: what(MAX_OUTPUT_TYPES)
124 integer(int64), intent(out) :: how(0:MAX_OUTPUT_TYPES)
125 integer, intent(out) :: output_interval(0:MAX_OUTPUT_TYPES)
126 character(len=*), optional, intent(in) :: what_tag_in
127 character(len=*), optional, intent(in) :: how_tag_in
128 character(len=*), optional, intent(in) :: output_interval_tag_in
129 logical, optional, intent(in) :: ignore_error
130
131 type(block_t) :: blk
132 integer :: ncols, nrows, iout, column_index, what_i
133 integer(int64) :: what_no_how(13)
134 character(len=80) :: what_tag
135 character(len=80) :: how_tag
136 character(len=80) :: output_interval_tag
137 character(len=80) :: output_column_marker
139
140 how = 0_8
141 output_interval = 0_8
142 ncols = 0
143 what_tag = optional_default(what_tag_in, 'Output')
144 how_tag = optional_default(how_tag_in, 'OutputFormat')
145 output_interval_tag = optional_default(output_interval_tag_in, 'OutputInterval')
146
147 call messages_obsolete_variable(namespace, 'OutputHow', 'OutputFormat')
148 call messages_obsolete_variable(namespace, 'Output_KPT', 'Output')
149 call messages_obsolete_variable(namespace, 'OutputLDA_U' , 'Output')
150 call messages_obsolete_variable(namespace, 'OutputEvery', 'OutputInterval')
151
152 !%Variable Output
153 !%Type block
154 !%Default none
155 !%Section Output
156 !%Description
157 !% Specifies what to print.
158 !% Each output must be in a separate row. Optionally individual output formats and output intervals can be defined
159 !% for each row or they can be read separately from <tt>OutputFormat</tt> and <tt>OutputInterval</tt> variables
160 !% in the input file.
161 !% The output files are written at the end of the run into the output directory for the
162 !% relevant kind of run (<i>e.g.</i> <tt>static</tt> for <tt>CalculationMode = gs</tt>).
163 !% Time-dependent simulations print only per iteration, including always the last. The frequency of output per iteration
164 !% (available for <tt>CalculationMode</tt> = <tt>gs</tt>, <tt>unocc</tt>, <tt>td</tt>, and <tt>opt_control</tt>)
165 !% is set by <tt>OutputInterval</tt> and the directory is set by <tt>OutputIterDir</tt>.
166 !% For linear-response run modes, the derivatives of many quantities can be printed, as listed in
167 !% the options below. Indices in the filename are labelled as follows:
168 !% <tt>sp</tt> = spin (or spinor component), <tt>k</tt> = <i>k</i>-point, <tt>st</tt> = state/band.
169 !% There is no tag for directions, given as a letter. The perturbation direction is always
170 !% the last direction for linear-response quantities, and a following +/- indicates the sign of the frequency.
171 !%
172 !% Example (minimal):
173 !% <br><br><tt>%Output
174 !% <br>&nbsp;&nbsp;density
175 !% <br>&nbsp;&nbsp;potential
176 !% <br>%<br></tt>
177 !%
178 !% Example (with OutputFormat):
179 !% <br><br><tt>%Output
180 !% <br>&nbsp;&nbsp;density | cube + axis_z
181 !% <br>&nbsp;&nbsp;potential | cube
182 !% <br>%<br></tt>
183 !%
184 !% Example (with OutputFormat, incomplete):
185 !% <br><br><tt>%Output
186 !% <br>&nbsp;&nbsp;density | cube + axis_z
187 !% <br>&nbsp;&nbsp;potential
188 !% <br>%<br></tt>
189 !%
190 !% Example (tagged):
191 !% <br><br><tt>%Output
192 !% <br>&nbsp;&nbsp;density | "output_format" | cube + axis_z | "output_interval" | 50
193 !% <br>&nbsp;&nbsp;potential | "output_format" | cube | "output_interval" | 20
194 !% <br>%<br></tt>
195 !%
196 !% Example (tagged, incomplete):
197 !% <br><br><tt>%Output
198 !% <br>&nbsp;&nbsp;density | "output_format" | cube + axis_z
199 !% <br>&nbsp;&nbsp;potential | "output_interval" | 20
200 !% <br>%<br></tt>
201 !% Missing information for the incomplete blocks will be parsed form the out-of-block
202 !% definitions. It is also possible to mix the order of columns in the tagged format.
203 !% See <tt>OutputFormat</tt>, and <tt>OutputInterval</tt>.
204 !%Option potential 1
205 !% Outputs Kohn-Sham potential, separated by parts. File names are <tt>v0</tt> for
206 !% the local part of the ionic potential, <tt>vc</tt> for the classical potential (if it exists),
207 !% <tt>vh</tt> for the Hartree potential, <tt>vks</tt> for the local part of the Kohn-Sham potential, and
208 !% <tt>vxc-</tt> for the exchange-correlation potentials. For <tt>vks</tt> and <tt>vxc</tt>,
209 !% a suffix for spin is added in the spin-polarized case.
210 !%Option density 2
211 !% Outputs density. The output file is called <tt>density-</tt>, or <tt>lr_density-</tt> in linear response.
212 !%Option wfs 3
213 !% Outputs wavefunctions. Which wavefunctions are to be printed is specified
214 !% by the variable <tt>OutputWfsNumber</tt> -- see below. The output file is called
215 !% <tt>wf-</tt>, or <tt>lr_wf-</tt> in linear response.
216 !%Option wfs_sqmod 4
217 !% Outputs modulus squared of the wavefunctions.
218 !% The output file is called <tt>sqm-wf-</tt>. For linear response, the filename is <tt>sqm_lr_wf-</tt>.
219 !%Option geometry 5
220 !% Outputs file containing the coordinates of the atoms treated within quantum mechanics.
221 !% If <tt>OutputFormat = xyz</tt>, the file is called <tt>geometry.xyz</tt>; a
222 !% file <tt>crystal.xyz</tt> is written with a supercell geometry if the system is periodic;
223 !% if point charges were defined in the PDB file (see <tt>PDBCoordinates</tt>), they will be output
224 !% in the file <tt>geometry_classical.xyz</tt>.
225 !% If <tt>OutputFormat = xcrysden</tt>, a file called <tt>geometry.xsf</tt> is written.
226 !%Option current 6
227 !% Outputs the total current density. The output file is called <tt>current-</tt>.
228 !% For linear response, the filename is <tt>lr_current-</tt>.
229 !%Option ELF 7
230 !% Outputs electron localization function (ELF). The output file is called <tt>elf-</tt>.
231 !% Only in 2D and 3D.
232 !% For PAW, the ELF is built from the all-electron quantities.
233 !% The sharp all-electron features near the nuclei are only as accurate as the
234 !% real-space grid allows, so a fine <tt>Spacing</tt> is needed there.
235 !%Option ELF_basins 8
236 !% Outputs basins of attraction of the ELF. The output file is called
237 !% <tt>elf_rs_basins.info</tt>. Only in 2D and 3D.
238 !%Option Bader 9
239 !% Outputs Laplacian of the density which shows lone pairs, bonded charge concentrations
240 !% and regions subject to electrophilic or nucleophilic attack.
241 !% See RF Bader, <i>Atoms in Molecules: A Quantum Theory</i> (Oxford Univ. Press, Oxford, 1990).
242 !%Option el_pressure 10
243 !% Outputs electronic pressure. See Tao, Vignale, and Tokatly, <i>Phys Rev Lett</i> <b>100</b>, 206405 (2008).
244 !%Option matrix_elements 11
245 !% Outputs a series of matrix elements of the Kohn-Sham states. What is output can
246 !% be controlled by the <tt>OutputMatrixElements</tt> variable.
247 !%Option pol_density 12
248 !% Outputs dipole-moment density <tt>dipole_density-</tt>, or polarizability density <tt>alpha_density-</tt>
249 !% in linear response. If <tt>ResponseMethod = finite_differences</tt>, the hyperpolarizability density
250 !% <tt>beta_density-</tt> is also printed.
251 !%Option mesh_r 13
252 !% Outputs values of the coordinates over the grid. Files
253 !% will be called <tt>mesh_r-</tt> followed by the direction.
254 !%Option kinetic_energy_density 14
255 !% Outputs kinetic-energy density, defined as:
256 !%
257 !% <math>\tau_\sigma(\vec{r}) = \sum_{i=1}^{N_\sigma}
258 !% \left| \vec{\nabla} \phi_{i\sigma}(\vec{r}) \right|^2\,. </math>
259 !%
260 !% The index <math>\sigma</math> is the spin index for the spin-polarized case,
261 !% or if you are using spinors. For spin-unpolarized calculations, you
262 !% get the total kinetic-energy density. The previous expression assumes full
263 !% or null occupations. If fractional occupation numbers, each term in the sum
264 !% is weighted by the occupation. Also, if we are working with an infinite
265 !% system, all <i>k</i>-points are summed up, with their corresponding weights. The
266 !% files will be called <tt>tau-sp1</tt> and <tt>tau-sp2</tt>, if the spin-resolved kinetic
267 !% energy density is produced (runs in spin-polarized and spinors mode), or
268 !% only <tt>tau</tt> if the run is in spin-unpolarized mode.
269 !%
270 !% Note that the code does not the U(1)gauge-invariant kinetic energy density, but simply the kinetic energy density.
271 !%
272 !% For PAW, the all-electron kinetic-energy density is reconstructed by adding the one-center
273 !% correction <math>\sum_a (\tau^1_a - \tilde{\tau}^1_a)</math>, built from the all-electron and
274 !% pseudo partial waves, to the smooth (pseudo-orbital) kinetic-energy density. The all-electron kinetic-energy density is very sharply peaked
275 !% at the nuclei, so its pointwise value and integral converge slowly with <tt>Spacing</tt>.
276 !%Option dos 15
277 !% Outputs density of states. See <tt>DOSEnergyMax</tt>, <tt>DOSEnergyMin</tt>, <tt>DOSEnergyPoints</tt>,
278 !% and <tt>DOSGamma</tt>.
279 !%Option tpa 16
280 !% Outputs transition-potential approximation (TPA) matrix elements, using <math>\vec{q}</math>-vector specified
281 !% by <tt>MomentumTransfer</tt>.
282 !%Option forces 17
283 !% Outputs file <tt>forces.xsf</tt> containing structure and forces on the atoms as
284 !% a vector associated with each atom, which can be visualized with XCrySDen.
285 !%Option wfs_fourier 18
286 !% (Experimental) Outputs wavefunctions in Fourier space. This is
287 !% only implemented for the ETSF file format output. The file will
288 !% be called <tt>wfs-pw-etsf.nc</tt>.
289 !%Option xc_density 19
290 !% Outputs the XC density, which is the charge density that
291 !% generates the XC potential. (This is <math>-1/4\pi</math> times
292 !% the Laplacian of the XC potential). The files are called <tt>nxc</tt>.
293 !%Option PES_wfs 20
294 !% Outputs the photoelectron wavefunctions. The file name is <tt>pes_wfs-</tt>
295 !% plus the orbital number.
296 !%Option PES_density 21
297 !% Outputs the photolectron density. Output file is <tt>pes_dens-</tt> plus spin species if
298 !% spin-polarized calculation is performed.
299 !%Option PES 22
300 !% Outputs the time-dependent photoelectron spectrum.
301 !%Option BerkeleyGW 23
302 !% Output for a run with <a href=http://www.berkeleygw.org>BerkeleyGW</a>.
303 !% See <tt>Output::BerkeleyGW</tt> for further specification.
304 !%Option delta_perturbation 24
305 !% Outputs the "kick", or time-delta perturbation applied to compute optical response in real time.
306 !%Option external_td_potential 25
307 !% Outputs the (scalar) time-dependent potential.
308 !%Option mmb_wfs 26
309 !% Triggers the ModelMB wavefunctions to be output for each state.
310 !%Option mmb_den 27
311 !% Triggers the ModelMB density matrix to be output for each state, and the particles
312 !% specified by the <tt>DensitytoCalc</tt> block. Calculates, and outputs, the reduced density
313 !% matrix. For the moment the trace is made over the second dimension, and
314 !% the code is limited to 2D. The idea is to model <i>N</i> particles in 1D as an
315 !% <i>N</i>-dimensional non-interacting problem, then to trace out <i>N</i>-1 coordinates.
316 !%Option potential_gradient 28
317 !% Prints the gradient of the potential.
318 !%Option energy_density 29
319 !% Outputs the total energy density to a file called
320 !% <tt>energy_density</tt>.
321 !% Note that for PAW, the kinetic part of the energy density is reconstructed to all-electron accuracy
322 !% (the one-center <math>\tau^1-\tilde{\tau}^1</math> correction), while the external, Hartree
323 !% and XC energy-density terms are evaluated on the smooth density.
324 !%Option heat_current 30
325 !% Outputs the total heat current density. The output file is
326 !% called <tt>heat_current-</tt>.
327 !%Option photon_correlator 31
328 !% Outputs the electron-photon correlation function. The output file is
329 !% called <tt>photon_correlator</tt>.
330 !%Option J_flow 32
331 !% todo: document J_flow option!
332 !%Option current_kpt 33
333 !% Outputs the current density resolved in momentum space. The output file is called <tt>current_kpt-</tt>.
334 !%Option density_kpt 34
335 !% Outputs the electronic density resolved in momentum space.
336 !%Option occ_matrices 35
337 !% Only for DFT+U calculations.
338 !% Outputs the occupation matrices of DFT+U
339 !%Option effectiveU 36
340 !% Only for DFT+U calculations.
341 !% Outputs the value of the effectiveU for each atoms
342 !%Option magnetization 37
343 !% Only for DFT+U calculations.
344 !% Outputs file containing structure and magnetization of the localized subspace
345 !% on the atoms as a vector associated with each atom, which can be visualized.
346 !% For the moment, it only works if a +U is added on one type of orbital per atom.
347 !%Option local_orbitals 38
348 !% Only for DFT+U calculations.
349 !% Outputs the localized orbitals that form the correlated subspace
350 !%Option kanamoriU 39
351 !% Only for DFT+U calculations.
352 !% Outputs the Kanamori interaction parameters U, U`, and J.
353 !% These parameters are not determined self-consistently, but are taken from the
354 !% occupation matrices and Coulomb integrals comming from a standard +U calculation.
355 !%Option xc_torque 40
356 !% Outputs the exchange-correlation torque. Only for the spinor case and in the 3D case.
357 !%Option eigenval_kpt 41
358 !% Outputs the eigenvalues resolved in momentum space, with one file for each band.
359 !%Option stress 42
360 !% Outputs the stress tensor and each of its contributing terms
361 !%Option current_dia 43
362 !% Outputs the diamagnetic current density from a non-uniform vector potential.
363 !% The output file is called <tt>current_dia-</tt>.
364 !%Option jdos 44
365 !% Outputs the joint density of states.
366 !% The same variables as for the regular DOS are used to control the energies and broadening.
367 !%Option ldos 45
368 !% Outputs the local density of states
369 !% The broadening uses the same value as the regular DOS. The energies at which the LDOS is computed are
370 !% specified by the <tt>LDOSEnergies</tt> block.
371 !%Option pdos 46
372 !% Outputs the projected density of states.
373 !% At the moment, the PDOS is computed from the bare pseudo-atomic orbitals, directly taken from
374 !% the pseudopotentials. The orbitals are not orthonormalized, in order to preserve their
375 !% atomic orbitals character. As a consequence, the sum of the different PDOS does not integrate
376 !% to the total DOS.
377 !%
378 !% The radii of the orbitals are controled by the threshold defined by <tt>AOThreshold</tt>,
379 !% and the fact that they are normalized or not by <tt>AONormalize</tt>.
380 !%Option density_ae 47
381 !% Outputs the all-electron density reconstructed from the PAW one-center terms,
382 !% <math>n = \tilde{n} + \sum_a (n^1_a - \tilde{n}^1_a)</math>, where <math>n^1_a</math> and
383 !% <math>\tilde{n}^1_a</math> are the all-electron and pseudo one-center densities built from
384 !% the partial waves of atom <math>a</math>. For other pseudopotentials, it is identical to
385 !% <tt>density</tt>. The sharp all-electron features near the nuclei are resolved only as well as
386 !% the real-space <tt>Spacing</tt> allows.
387 !%Option wfs_ae 48
388 !% Outputs the all-electron Kohn-Sham wavefunctions reconstructed from the PAW one-center terms,
389 !% <math>\psi = \tilde\psi + \sum_a \sum_i (\phi_i - \tilde\phi_i) Y_{l_i m_i} \langle \beta_i | \tilde\psi \rangle</math>
390 !% (Bloechl PRB 50, 17953 (1994)), where <math>\phi_i</math>/<math>\tilde\phi_i</math> are the
391 !% all-electron/pseudo partial waves and <math>\beta_i</math> the PAW projectors. Which states are
392 !% printed is controlled by <tt>OutputWfsNumber</tt>, as for <tt>wfs</tt>; the output files are
393 !% called <tt>wf_ae-</tt>. For other pseudopotentials it is identical to <tt>wfs</tt>. The sharp
394 !% all-electron features near the nuclei are resolved only as well as the real-space
395 !% <tt>Spacing</tt> allows.
396 !%End
397
398 !%Variable OutputFormat
399 !%Type flag
400 !%Default 0
401 !%Section Output
402 !%Description
403 !% Describes the format of the output files.
404 !% This variable can also be defined inside the <tt>Output</tt> block.
405 !% See <tt>Output</tt>.
406 !% Example: <tt>axis_x + plane_x + dx</tt>
407 !%Option axis_x bit(0)
408 !% The values of the function on the <i>x</i> axis are printed. The string <tt>.y=0,z=0</tt> is appended
409 !% to previous file names.
410 !% For non-orthogonal cells, this correspond to the first lattice vector instead the x axis.
411 !%Option axis_y bit(1)
412 !% The values of the function on the <i>y</i> axis are printed. The string <tt>.x=0,z=0</tt> is appended
413 !% to previous file names.
414 !% For non-orthogonal cells, this correspond to the second lattice vector instead the y axis.
415 !%Option axis_z bit(2)
416 !% The values of the function on the <i>z</i> axis are printed. The string <tt>.x=0,y=0</tt> is appended
417 !% to previous file names.
418 !% For non-orthogonal cells, this correspond to the third lattice vector instead the z axis.
419 !%Option plane_x bit(3)
420 !% A plane slice at <i>x</i> = 0 is printed. The string <tt>.x=0</tt> is appended
421 !% to previous file names.
422 !%Option plane_y bit(4)
423 !% A plane slice at <i>y</i> = 0 is printed. The string <tt>.y=0</tt> is appended
424 !% to previous file names.
425 !%Option plane_z bit(5)
426 !% A plane slice at <i>z</i> = 0 is printed. The string <tt>.z=0</tt> is appended to
427 !% previous file names.
428 !%Option dx bit(6)
429 !% For printing three-dimensional information, the open-source program
430 !% visualization tool <a href=http://www.opendx.org>OpenDX</a> can be used. The string
431 !% <tt>.dx</tt> is appended to previous file names. Available only in 3D.
432 !%Option netcdf bit(7)
433 !% Outputs in <a href=http://www.unidata.ucar.edu/packages/netcdf>NetCDF</a> format. This file
434 !% can then be read, for example, by OpenDX. The string <tt>.ncdf</tt> is appended to previous file names.
435 !% Requires the NetCDF library. Only writes the real part of complex functions.
436 !%Option mesh_index bit(8)
437 !% Generates output files of a given quantity (density, wavefunctions, ...) which include
438 !% the internal numbering of mesh points. Since this mode produces large datafiles this is only
439 !% useful for small meshes and debugging purposes.
440 !% The output can also be used to display the mesh directly. A Gnuplot script for mesh visualization
441 !% can be found under <tt>PREFIX/share/octopus/util/display_mesh_index.gp</tt>.
442 !%Option xcrysden bit(9)
443 !% A format for printing structures and three-dimensional information, which can be visualized by
444 !% the free open-source program <a href=http://www.xcrysden.org>XCrySDen</a> and others. The string
445 !% <tt>.xsf</tt> is appended to previous file names. Note that lattice vectors and coordinates are as
446 !% specified by <tt>UnitsOutput</tt>. Available in 2D and 3D.
447 !%Option matlab bit(10)
448 !% In combination with <tt>plane_x</tt>, <tt>plane_y</tt> and
449 !% <tt>plane_z</tt>, this option produces output files which are
450 !% suitable for 2D Matlab functions like <tt>mesh()</tt>,
451 !% <tt>surf()</tt>, or <tt>waterfall()</tt>. To load these files
452 !% into Matlab you can use, <i>e.g.</i>
453 !%<tt>
454 !% >> density = load('static/density-1.x=0.matlab.abs');
455 !% >> mesh(density);
456 !%</tt>
457 !%Option meshgrid bit(11)
458 !% Outputs in Matlab mode the internal mesh in a format similar to
459 !%<tt>
460 !% >> [x,y] = meshgrid(-2:.2:2,-1:.15:1)
461 !%</tt>
462 !% The <i>x</i> meshgrid is contained in a file <tt>*.meshgrid.x</tt> and the <i>y</i>-grid can be found in
463 !% <tt>*.meshgrid.y</tt>.
464 !%Option boundary_points bit(12)
465 !% This option includes the output of the mesh enlargement. Default is without.
466 !% Supported only by <tt>binary</tt>, <tt>axis</tt>, <tt>plane</tt>, <tt>mesh_index</tt>,
467 !% and <tt>matlab</tt> formats.
468 !% Not all types of <tt>Output</tt> will have this information available. Not supported when parallel in domains.
469 !%Option binary bit(13)
470 !% Plain binary, new format.
471 !%Option xyz bit(15)
472 !% Geometry will be output in XYZ format. Does not affect other outputs.
473 !%Option cube bit(16)
474 !% Generates output in the <a href=http://paulbourke.net/dataformats/cube>cube file format</a>.
475 !% Available only in 3D. Only writes the real part of complex functions.
476 !% This output format always uses atomic units.
477 !%Option bild bit(19)
478 !% Generates output in <a href=http://plato.cgl.ucsf.edu/chimera/docs/UsersGuide/bild.html>BILD format</a>.
479 !%Option vtk bit(20)
480 !% Generates output in <a href=http://www.vtk.org/VTK/img/file-formats.pdf>VTK legacy format</a>.
481 !%Option integrate_xy bit(21)
482 !% Integrates the function in the x-y plane and the result on the <i>z</i> axis is printed.
483 !%Option integrate_xz bit(22)
484 !% Integrates the function in the x-z plane and the result on the <i>y</i> axis is printed
485 !%Option integrate_yz bit(23)
486 !% Integrates the function in the y-z plane and the result on the <i>x</i> axis is printed
487 !%Option ascii bit(24)
488 !% Plain text format regardless of dimensionality. For the moment only employed by the oct-phototoelectron_spectrum
489 !% post-processing utility.
490 !%Option poscar bit(25)
491 !% Write geometry in POSCAR format.
492 !% Note that atoms are not ordered by labels and that species names are taken from the Octopus input,
493 !% and are not truncated to two letters.
494 !%End
495
496 !%Variable OutputInterval
497 !%Type integer
498 !%Default 50
499 !%Section Output
500 !%Description
501 !% The output requested by variable <tt>Output</tt> is written
502 !% to the directory <tt>OutputIterDir</tt>
503 !% when the iteration number is a multiple of the <tt>OutputInterval</tt> variable.
504 !% Subdirectories are named Y.X, where Y is <tt>td</tt>, <tt>scf</tt>, or <tt>unocc</tt>, and
505 !% X is the iteration number. To use the working directory, specify <tt>"."</tt>
506 !% Must be >= 0. If it is 0, then no output is written. For <tt>gs</tt> and <tt>unocc</tt>
507 !% calculations, <tt>OutputDuringSCF</tt> must be set too for this output to be produced.
508 !% This variable can also be defined inside the <tt>Output</tt> block.
509 !% See <tt>Output</tt>.
510 !%End
511
512
513 what_no_how = (/ &
514 option__output__matrix_elements, &
515 option__output__berkeleygw, &
516 option__output__dos, &
517 option__output__tpa, &
518 option__output__mmb_den, &
519 option__output__j_flow, &
520 option__output__occ_matrices, &
521 option__output__effectiveu, &
522 option__output__magnetization, &
523 option__output__kanamoriu, &
524 option__output__stress, &
525 option__output__jdos, &
526 option__output__pdos &
527 /)
528
529 if (parse_block(namespace, what_tag, blk) == 0) then
530 nrows = parse_block_n(blk)
531 do iout = 0, nrows - 1
532 ncols = max(ncols , parse_block_cols(blk, iout))
533 end do
534
535 if (ncols == 1) then
536 !new format, Type 0
537 !%Output
538 ! density
539 ! wfs
540 !%
541 do iout = 1, nrows
542 call parse_block_integer(blk, iout - 1, 0, what_i)
543 if (.not. varinfo_valid_option(what_tag, what_i)) then
544 call messages_input_error(namespace, what_tag)
545 end if
546 if (what_i > 0) then
547 what(what_i) = .true.
548 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
549 if (((what_tag == 'Output') .and. (.not. any(what_no_how == what_i)))&
550 .or. (what_tag /= 'Output')) then
551 call parse_variable(namespace, how_tag, 0, how(what_i))
552 if (.not. varinfo_valid_option(how_tag, how(what_i), is_flag=.true.)) then
553 call messages_input_error(namespace, how_tag)
554 end if
555 end if
556 end if
557 end do
558 else if (ncols == 2) then
559 !new format, Type 1
560 !%Output
561 ! density | cube + axis_z
562 ! wfs | cube
563 !%
564
565 do iout = 1, nrows
566 call parse_block_integer(blk, iout - 1, 0, what_i)
567 if (.not. varinfo_valid_option(what_tag, what_i)) then
568 call messages_input_error(namespace, what_tag)
569 end if
570 if (what_i > 0) then
571 what(what_i) = .true.
572 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
573 if (((what_tag == 'Output') .and. (.not. any(what_no_how == what_i)))&
574 .or. (what_tag /= 'Output')) then
575 call parse_block_integer(blk, iout - 1, 1, how(what_i))
576 if (how(what_i) == 0) call parse_variable(namespace, how_tag, 0, how(what_i))
577 if (.not. varinfo_valid_option(how_tag, how(what_i), is_flag=.true.)) then
578 call messages_input_error(namespace, how_tag)
579 end if
580 end if
581 end if
582 end do
583
584 else
585 !new format, Type 2 (tagged)
586 !%Output
587 ! density | "output_interval" | 10 | "output_format" | cube + axis_z
588 ! wfs | "output_format" | cube | "output_interval" | 50
589 !%
590 !
591 ! OR
592 !
593 !%Output
594 ! density | "output_interval" | 10 | "output_format" | cube + axis_z
595 ! wfs | "output_format" | cube
596 !%
597 do iout = 1, nrows
598 call parse_block_integer(blk, iout - 1, 0, what_i)
599 if (.not. varinfo_valid_option(what_tag, what_i)) then
600 call messages_input_error(namespace, what_tag)
601 end if
602 if (what_i > 0) then
603 what(what_i) = .true.
604 do column_index = 0, 1
605 call parse_block_string(blk, iout - 1, 1 + column_index * 2, output_column_marker)
606 if (output_column_marker == 'output_interval') then
607 call parse_block_integer(blk, iout - 1, 2 + column_index * 2, output_interval(what_i))
608 else if (output_column_marker == 'output_format') then
609 if (((what_tag == 'Output') .and. (.not. any(what_no_how == what_i)))&
610 .or. (what_tag /= 'Output')) then
611 call parse_block_integer(blk, iout - 1, 2 + column_index * 2, how(what_i))
612 if (.not. varinfo_valid_option(how_tag, how(what_i), is_flag=.true.)) then
613 call messages_input_error(namespace, how_tag)
614 end if
615 end if
616 else if (len_trim(output_column_marker) /= 0) then
617 ! Unknown output_column_marker
618 call messages_input_error(namespace, what_tag)
619 else
620 ! no output_column_marker -> full output info is not in this block
621 if (output_interval(what_i) == 0) then
622 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
623 end if
624 if (how(what_i) == 0) then
625 if (((what_tag == 'Output') .and. (.not. any(what_no_how == what_i)))&
626 .or. (what_tag /= 'Output')) then
627 call parse_variable(namespace, how_tag, 0, how(what_i))
628 if (.not. varinfo_valid_option(how_tag, how(what_i), is_flag=.true.)) then
629 call messages_input_error(namespace, how_tag)
630 end if
631 end if
632 end if
633 end if
634 end do
635 end if
636 end do
637 end if
638 call parse_block_end(blk)
639 else
640
641 call messages_variable_is_block(namespace, what_tag)
642
643 ! Output block does not exist but we may have OutputHow/OutputInterval
644 call parse_variable(namespace, how_tag, 0, how(0))
645 call parse_variable(namespace, output_interval_tag, 50, output_interval(0))
646 end if
647
648
649 do what_i = lbound(what, 1), ubound(what, 1)
650 if (what_tag == 'Output') then
651 if (what(what_i) .and. (.not. any(what_no_how == what_i))) then
652 if (.not. varinfo_valid_option(how_tag, how(what_i), is_flag=.true.)) then
653 call messages_input_error(namespace, how_tag)
654 end if
655
656 if (how(what_i) == 0 .and. .not. optional_default(ignore_error, .false.)) then
657 write(message(1), '(a)') 'Must specify output method with variable OutputFormat.'
658 call messages_fatal(1, only_root_writes = .true., namespace=namespace)
659 end if
660
661 ! some modes are not available in some circumstances
662 if (space%dim == 1) then
663 if (bitand(how(what_i), option__outputformat__axis_y) /= 0) then
664 message(1) = "OutputFormat = axis_y not available with Dimensions = 1."
665 call messages_fatal(1, namespace=namespace)
666 end if
667 if (bitand(how(what_i), option__outputformat__plane_z) /= 0) then
668 message(1) = "OutputFormat = plane_z not available with Dimensions = 1."
669 call messages_fatal(1, namespace=namespace)
670 end if
671 if (bitand(how(what_i), option__outputformat__xcrysden) /= 0) then
672 message(1) = "OutputFormat = xcrysden not available with Dimensions = 1."
673 call messages_fatal(1, namespace=namespace)
674 end if
675 end if
676
677 if (space%dim <= 2) then
678 if (bitand(how(what_i), option__outputformat__axis_z) /= 0) then
679 message(1) = "OutputFormat = axis_z not available with Dimensions <= 2."
680 call messages_fatal(1, namespace=namespace)
681 end if
682 if (bitand(how(what_i), option__outputformat__plane_x) /= 0) then
683 message(1) = "OutputFormat = plane_x not available with Dimensions <= 2."
684 call messages_fatal(1, namespace=namespace)
685 end if
686 if (bitand(how(what_i), option__outputformat__plane_y) /= 0) then
687 message(1) = "OutputFormat = plane_y not available with Dimensions <= 2."
688 call messages_fatal(1, namespace=namespace)
689 end if
690 if (bitand(how(what_i), option__outputformat__integrate_xy) /= 0) then
691 message(1) = "OutputFormat = integrate_xy not available with Dimensions <= 2."
692 call messages_fatal(1, namespace=namespace)
693 end if
694 if (bitand(how(what_i), option__outputformat__integrate_xz) /= 0) then
695 message(1) = "OutputFormat = integrate_xz not available with Dimensions <= 2."
696 call messages_fatal(1, namespace=namespace)
697 end if
698 if (bitand(how(what_i), option__outputformat__integrate_yz) /= 0) then
699 message(1) = "OutputFormat = integrate_yz not available with Dimensions <= 2."
700 call messages_fatal(1, namespace=namespace)
701 end if
702 if (bitand(how(what_i), option__outputformat__dx) /= 0) then
703 message(1) = "OutputFormat = dx not available with Dimensions <= 2."
704 call messages_fatal(1, namespace=namespace)
705 end if
706 if (bitand(how(what_i), option__outputformat__cube) /= 0) then
707 message(1) = "OutputFormat = cube not available with Dimensions <= 2."
708 call messages_fatal(1, namespace=namespace)
709 end if
710 if (bitand(how(what_i), option__outputformat__poscar) /= 0) then
711 message(1) = "OutputFormat = POSCAR not available with Dimensions <= 2."
712 call messages_fatal(1, namespace=namespace)
713 end if
714 end if
715
716 if (space%periodic_dim<=2) then
717 if (bitand(how(what_i), option__outputformat__poscar) /= 0) then
718 message(1) = "OutputFormat = POSCAR not available with periodic_dim <= 2."
719 call messages_fatal(1, namespace=namespace)
720 end if
721 end if
722
723#if !defined(HAVE_NETCDF)
724 if (bitand(how(what_i), option__outputformat__netcdf) /= 0) then
725 message(1) = 'Octopus was compiled without NetCDF support.'
726 message(2) = 'It is not possible to write output in NetCDF format.'
727 call messages_fatal(2, namespace=namespace)
728 end if
729#endif
730
731
732 end if
733 end if
734
735 if (output_interval(what_i) < 0) then
736 message(1) = "OutputInterval must be >= 0."
737 call messages_fatal(1, namespace=namespace)
738 end if
739 end do
740
742 end subroutine io_function_read_what_how_when
743
744 ! -------------------------------------------------------------------
747 ! ".", "func", mesh, sb, func, M_ONE, ierr)
748 ! -------------------------------------------------------------------
749 integer(int64) function io_function_fill_how(where) result(how)
750 character(len=*), intent(in) :: where
751
752 push_sub(io_function_fill_how)
753
754 how = 0
755 if (index(where, "AxisX") /= 0) how = ior(how, option__outputformat__axis_x)
756 if (index(where, "AxisY") /= 0) how = ior(how, option__outputformat__axis_y)
757 if (index(where, "AxisZ") /= 0) how = ior(how, option__outputformat__axis_z)
758 if (index(where, "PlaneX") /= 0) how = ior(how, option__outputformat__plane_x)
759 if (index(where, "PlaneY") /= 0) how = ior(how, option__outputformat__plane_y)
760 if (index(where, "PlaneZ") /= 0) how = ior(how, option__outputformat__plane_z)
761 if (index(where, "IntegrateXY") /= 0) how = ior(how, option__outputformat__integrate_xy)
762 if (index(where, "IntegrateXZ") /= 0) how = ior(how, option__outputformat__integrate_xz)
763 if (index(where, "IntegrateYZ") /= 0) how = ior(how, option__outputformat__integrate_yz)
764 if (index(where, "DX") /= 0) how = ior(how, option__outputformat__dx)
765 if (index(where, "XCrySDen") /= 0) how = ior(how, option__outputformat__xcrysden)
766 if (index(where, "Binary") /= 0) how = ior(how, option__outputformat__binary)
767 if (index(where, "MeshIndex") /= 0) how = ior(how, option__outputformat__mesh_index)
768 if (index(where, "XYZ") /= 0) how = ior(how, option__outputformat__xyz)
769#if defined(HAVE_NETCDF)
770 if (index(where, "NETCDF") /= 0) how = ior(how, option__outputformat__netcdf)
771#endif
772 if (index(where, "Cube") /= 0) how = ior(how, option__outputformat__cube)
773 if (index(where, "VTK") /= 0) how = ior(how, option__outputformat__vtk)
774 if (index(where, "ASCII") /= 0) how = ior(how, option__outputformat__ascii)
775 if (index(where, "Bild") /= 0) how = ior(how, option__outputformat__bild)
776
777 pop_sub(io_function_fill_how)
778 end function io_function_fill_how
779
784 subroutine write_standard_xyz_file(namespace, fname, pos, species, header)
785 type(namespace_t), intent(in) :: namespace
786 character(len=*), intent(in) :: fname
787 real(real64), contiguous, intent(in) :: pos(:,:)
788 character(len=*), contiguous, intent(in) :: species(:)
789 character(len=*), optional, intent(in) :: header
790
791 integer :: iunit, n_atoms, iatom, min_dim
792 real(real64) :: position(3)
793
795
796 n_atoms = size(pos, 2)
797 assert(size(species) == n_atoms)
798
799 iunit = io_open(trim(fname)//'.xyz', namespace, action='write', position='asis')
800
801 write(iunit, '(i6)') n_atoms
802 if (present(header)) then
803 write(iunit, '(a)') trim(adjustl(header))
804 else
805 write(iunit, '(a)')
806 endif
807
808 ! Ensure a set of three coordinate components is written for 1D, 2D and ND systems
809 min_dim = min(size(pos, 1), 3)
810 position(1:3) = 0.0_real64
811
812 ! xyz-style labels and positions:
813 do iatom = 1, n_atoms
814 position(1:min_dim) = units_from_atomic(unit_angstrom, pos(1:min_dim, iatom))
815 write(iunit, '(a10, 3(1x, f13.8))') trim(adjustl(species(iatom))), position
816 end do
817
818 call io_close(iunit)
819
822 end subroutine write_standard_xyz_file
823
829 subroutine write_canonicalized_xyz_file(dir, fname, space, latt, pos, atoms, box, namespace)
830 character(len=*), intent(in) :: dir
831 character(len=*), intent(in) :: fname
832 class(space_t), intent(in) :: space
833 type(lattice_vectors_t), intent(in) :: latt
834 real(real64), contiguous, intent(in) :: pos(:,:)
835 type(atom_t), contiguous, intent(in) :: atoms(:)
836 class(box_t), intent(in) :: box
837 type(namespace_t), intent(in) :: namespace
838
839 integer :: ia
840 character(len=:), allocatable :: info_str, dir_fname
841 character(len=LABEL_LEN), allocatable :: species(:)
842
844
845 call io_mkdir(dir, namespace)
846
847 info_str = trim(space%short_info()) // '; ' // trim(box%short_info(unit_angstrom))
848 if (space%is_periodic()) then
849 info_str = info_str // '; ' // trim(latt%short_info(unit_angstrom))
850 end if
851
852 safe_allocate(species(1:size(atoms)))
853 do ia = 1, size(atoms)
854 species(ia) = atoms(ia)%get_label()
855 enddo
857 dir_fname = trim(dir) // '/' // trim(fname)
858 call write_standard_xyz_file(namespace, dir_fname, pos, species, info_str)
859
860 safe_deallocate_a(species)
861
863
864 end subroutine write_canonicalized_xyz_file
865
869 subroutine write_extended_xyz_file(dir, fname, space, latt, pos, atoms, box, namespace)
870 character(len=*), intent(in) :: dir
871 character(len=*), intent(in) :: fname
872 class(space_t), intent(in) :: space
873 type(lattice_vectors_t), intent(in) :: latt
874 real(real64), contiguous, intent(in) :: pos(:,:)
875 type(atom_t), contiguous, intent(in) :: atoms(:)
876 class(box_t), intent(in) :: box
877 type(namespace_t), intent(in) :: namespace
878
879 integer :: ia, i, j
880 character(len=512), allocatable :: info_str
881 character(len=:), allocatable :: dir_fname
882 character(len=LABEL_LEN), allocatable :: species(:)
883
885
886 assert(space%dim == 3)
887
888 call io_mkdir(dir, namespace)
889
890 select case (space%periodic_dim)
891 case (0); info_str = "PBC = [ F, F, F]"
892 case (1); info_str = "PBC = [ T, F, F]"
893 case (2); info_str = "PBC = [ T, T, F]"
894 case (3); info_str = "PBC = [ T, T, T]"
895 end select
896
897 write(info_str, '(A, "; Lattice = """, 9(F13.8,","), """")') &
898 trim(info_str), &
899 (( units_from_atomic(unit_angstrom, latt%rlattice(j,i)), j = 1, 3 ), i = 1, 3)
900
901 safe_allocate(species(1:size(atoms)))
902 do ia = 1, size(atoms)
903 species(ia) = atoms(ia)%get_label()
904 enddo
905
906 dir_fname = trim(dir) // '/' // trim(fname)
907 call write_standard_xyz_file(namespace, dir_fname, pos, species, info_str)
908
909 safe_deallocate_a(species)
910
912 end subroutine write_extended_xyz_file
913
914 subroutine write_xsf_geometry_file(dir, fname, space, latt, pos, atoms, mesh, mpi_grp, namespace, total_forces)
915 character(len=*), intent(in) :: dir, fname
916 class(space_t), intent(in) :: space
917 type(lattice_vectors_t), intent(in) :: latt
918 real(real64), contiguous, intent(in) :: pos(:,:)
919 type(atom_t), contiguous, intent(in) :: atoms(:)
920 class(mesh_t), intent(in) :: mesh
921 type(mpi_grp_t), intent(in) :: mpi_grp
922 type(namespace_t), intent(in) :: namespace
923 real(real64), contiguous, optional, intent(in) :: total_forces(:,:)
924
925 integer :: iunit
926 real(real64), allocatable :: forces(:,:)
927
928 if (.not. mpi_grp%is_root()) return
929
931
932 call io_mkdir(dir, namespace)
933 iunit = io_open(trim(dir)//'/'//trim(fname)//'.xsf', namespace, action='write', position='asis')
934
935 if (present(total_forces)) then
936 safe_allocate(forces(1:space%dim, 1:size(atoms)))
937 forces = units_from_atomic(units_out%force, total_forces)
938 call write_xsf_geometry(iunit, space, latt, pos, atoms, mesh, forces = forces)
939 safe_deallocate_a(forces)
940 else
941 call write_xsf_geometry(iunit, space, latt, pos, atoms, mesh)
942 end if
943
944 call io_close(iunit)
945
947 end subroutine write_xsf_geometry_file
948
949 ! ---------------------------------------------------------
952 subroutine write_xsf_geometry(iunit, space, latt, pos, atoms, mesh, forces, index)
953 integer, intent(in) :: iunit
954 class(space_t), intent(in) :: space
955 type(lattice_vectors_t), intent(in) :: latt
956 real(real64), intent(in) :: pos(:,:)
957 type(atom_t), intent(in) :: atoms(:)
958 class(mesh_t), intent(in) :: mesh
959 real(real64), contiguous, optional, intent(in) :: forces(:, :)
960 integer, optional, intent(in) :: index
961
962 integer :: idir, idir2, iatom, index_, natoms
963 character(len=7) :: index_str
964 real(real64) :: offset(space%dim)
965 real(real64) :: rlattice(space%dim, space%dim)
966
967 push_sub(write_xsf_geometry)
968
969 if (present(index)) then
970 write(index_str, '(a,i6)') ' ', index
971 index_ = index
972 else
973 write(index_str, '(a)') ''
974 index_ = 1
975 end if
976 natoms = size(pos, dim=2)
977
978 ! The corner of the cell is always (0,0,0) to XCrySDen
979 ! so the offset is applied to the atomic coordinates.
980 ! Along periodic dimensions the offset is -1/2 in reduced coordinates, as
981 ! our origin is at the center of the cell instead of being at the edge.
982 offset(1:space%dim) = latt%red_to_cart(spread(-m_half, 1, space%dim))
983 ! Offset in aperiodic directions:
984 do idir = space%periodic_dim + 1, space%dim
985 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
986 end do
987
988 if (space%is_periodic()) then
989 if (index_ == 1) then
990 select case (space%periodic_dim)
991 case (3)
992 write(iunit, '(a)') 'CRYSTAL'
993 case (2)
994 write(iunit, '(a)') 'SLAB'
995 case (1)
996 write(iunit, '(a)') 'POLYMER'
997 end select
998 end if
999
1000 write(iunit, '(a)') 'PRIMVEC'//trim(index_str)
1001
1002 !Computes the rlattice corresponding to the 3D periodic version of the simulation box
1003 rlattice = latt%rlattice
1004 do idir = space%periodic_dim+1, space%dim
1005 rlattice(:,idir) = rlattice(:,idir)*m_two*mesh%box%bounding_box_l(idir)
1006 end do
1007
1008 do idir = 1, space%dim
1009 write(iunit, '(3f12.6)') (units_from_atomic(units_out%length, rlattice(idir2, idir)), idir2 = 1, space%dim)
1010 end do
1011
1012 write(iunit, '(a)') 'PRIMCOORD'//trim(index_str)
1013 write(iunit, '(i10, a)') natoms, ' 1'
1014 else
1015 write(iunit, '(a)') 'ATOMS'//trim(index_str)
1016 end if
1017
1018 ! BoxOffset should be considered here
1019 do iatom = 1, natoms
1020 write(iunit, '(a10, 3f12.6)', advance='no') trim(atoms(iatom)%label), &
1021 (units_from_atomic(units_out%length, pos(idir, iatom) - offset(idir)), idir = 1, space%dim)
1022 if (present(forces)) then
1023 write(iunit, '(5x, 3f12.6)', advance='no') forces(:, iatom)
1024 end if
1025 write(iunit, '()')
1026 end do
1027
1028 pop_sub(write_xsf_geometry)
1029 end subroutine write_xsf_geometry
1030
1031! ---------------------------------------------------------
1034 subroutine write_xsf_geometry_supercell(iunit, space, latt, pos, atoms, mesh, centers, supercell, extra_atom)
1035 integer, intent(in) :: iunit
1036 class(space_t), intent(in) :: space
1037 type(lattice_vectors_t), intent(in) :: latt
1038 real(real64), contiguous, intent(in) :: pos(:,:)
1039 type(atom_t), contiguous, intent(in) :: atoms(:)
1040 class(mesh_t), intent(in) :: mesh
1041 real(real64), contiguous, intent(in) :: centers(:, :)
1042 integer, contiguous, intent(in) :: supercell(:)
1043 real(real64), contiguous, optional, intent(in) :: extra_atom(:)
1044
1045 integer :: idir, idir2, iatom, index_
1046 character(len=7) :: index_str
1047 real(real64) :: offset(3)
1048 integer :: irep, nreplica
1049
1051
1052 write(index_str, '(a)') ''
1053 index_ = 1
1054
1055 nreplica = product(supercell(1:space%dim))
1056
1057 ! The corner of the cell is always (0,0,0) to XCrySDen
1058 ! so the offset is applied to the atomic coordinates.
1059 ! Offset in periodic directions:
1060 offset(1:space%dim) = latt%red_to_cart(spread(-m_half, 1, space%dim))
1061 offset(1:3) = offset(1:3) + centers(1:3,1)
1062 ! Offset in aperiodic directions:
1063 do idir = space%periodic_dim + 1, 3
1064 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
1065 end do
1066
1067 if(space%is_periodic()) then
1068 if(index_ == 1) then
1069 select case(space%periodic_dim)
1070 case(3)
1071 write(iunit, '(a)') 'CRYSTAL'
1072 case(2)
1073 write(iunit, '(a)') 'SLAB'
1074 case(1)
1075 write(iunit, '(a)') 'POLYMER'
1076 end select
1077 end if
1078
1079 write(iunit, '(a)') 'PRIMVEC'//trim(index_str)
1080
1081 do idir = 1, space%dim
1082 write(iunit, '(3f12.6)') (units_from_atomic(units_out%length, &
1083 latt%rlattice(idir2, idir)*supercell(idir)), idir2 = 1, space%dim)
1084 end do
1085
1086 write(iunit, '(a)') 'PRIMCOORD'//trim(index_str)
1087 if(.not.present(extra_atom)) then
1088 write(iunit, '(i10, a)') size(atoms)*nreplica, ' 1'
1089 else
1090 write(iunit, '(i10, a)') size(atoms)*nreplica+1, ' 1'
1091 end if
1092 else
1093 write(iunit, '(a)') 'ATOMS'//trim(index_str)
1094 end if
1095
1096
1097 do irep = 1, nreplica
1098 ! BoxOffset should be considered here
1099 do iatom = 1, size(atoms)
1100 write(iunit, '(a10, 3f12.6)', advance='no') trim(atoms(iatom)%label), &
1101 (units_from_atomic(units_out%length, pos(idir, iatom) + centers(idir, irep) &
1102 - offset(idir)), idir = 1, space%dim)
1103 write(iunit, '()')
1104 end do
1105 end do
1106 if(present(extra_atom)) then
1107 write(iunit, '(a10, 3f12.6)', advance='no') 'X', &
1108 (units_from_atomic(units_out%length, extra_atom(idir) - offset(idir)), idir = 1, space%dim)
1109 write(iunit, '()')
1110 end if
1111
1113 end subroutine write_xsf_geometry_supercell
1114
1115
1116#if defined(HAVE_NETCDF)
1117 ! ---------------------------------------------------------
1118 subroutine ncdf_error(func, status, filename, namespace, ierr)
1119 character(len=*), intent(in) :: func
1120 integer, intent(in) :: status
1121 character(len=*), intent(in) :: filename
1122 type(namespace_t), intent(in) :: namespace
1123 integer, intent(inout) :: ierr
1124
1125 push_sub(ncdf_error)
1126
1127 if (status == nf90_noerr) then
1128 pop_sub(ncdf_error)
1129 return
1130 end if
1131
1132 write(message(1),'(3a)') "NETCDF error in function '" , trim(func) , "'"
1133 write(message(2),'(3a)') "(reading/writing ", trim(filename) , ")"
1134 write(message(3), '(6x,a,a)')'Error code = ', trim(nf90_strerror(status))
1135 call messages_warning(3, namespace=namespace)
1136 ierr = 5
1137
1138 pop_sub(ncdf_error)
1139 end subroutine ncdf_error
1140#endif
1141
1142 ! ---------------------------------------------------------
1143 subroutine transpose3(in, out)
1144 real(real64), intent(in) :: in(:, :, :)
1145 real(real64), contiguous, intent(out) :: out(:, :, :)
1146 integer :: ix, iy, iz
1147
1148 push_sub(transpose3)
1149
1150 do ix = lbound(in, 1), ubound(in, 1)
1151 do iy = lbound(in, 2), ubound(in, 2)
1152 do iz = lbound(in, 3), ubound(in, 3)
1153 out(iz, iy, ix) = in(ix, iy, iz)
1154 end do
1155 end do
1156 end do
1157
1158 pop_sub(transpose3)
1159 end subroutine transpose3
1160
1161#include "undef.F90"
1162#include "real.F90"
1163#include "io_function_inc.F90"
1164
1165#include "undef.F90"
1166#include "complex.F90"
1167#include "io_function_inc.F90"
1168#include "undef.F90"
1169
1170end module io_function_oct_m
1171
1172!! Local Variables:
1173!! mode: f90
1174!! coding: utf-8
1175!! End:
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
Definition: fft.F90:97
real(real64), parameter, public m_two
Definition: global.F90:175
real(real64), parameter, public m_half
Definition: global.F90:179
This module implements the index, used for the mesh points.
Definition: index.F90:101
subroutine zio_function_output_vector_bz(how, dir, fname, namespace, space, kpt, kpoints, ff, unit, ierr, grp, root)
subroutine, public write_canonicalized_xyz_file(dir, fname, space, latt, pos, atoms, box, namespace)
Write canonicalized xyz file with atom labels and positions in Angstroms.
subroutine, public zio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
subroutine, public dio_function_output_global(how, dir, fname, namespace, space, mesh, ff, unit, ierr)
subroutine, public io_function_read_what_how_when(namespace, space, what, how, output_interval, what_tag_in, how_tag_in, output_interval_tag_in, ignore_error)
subroutine, public zio_function_input(filename, namespace, space, mesh, ff, ierr, map)
Reads a mesh function from file filename, and puts it into ff. If the map argument is passed,...
subroutine, public write_xsf_geometry(iunit, space, latt, pos, atoms, mesh, forces, index)
for format specification see: http://www.xcrysden.org/doc/XSF.html#__toc__11
subroutine zio_function_output_vector(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
subroutine write_xsf_geometry_supercell(iunit, space, latt, pos, atoms, mesh, centers, supercell, extra_atom)
for format specification see: http://www.xcrysden.org/doc/XSF.html#__toc__11
subroutine, public write_extended_xyz_file(dir, fname, space, latt, pos, atoms, box, namespace)
Write an extended xyz file compatible with ASE.
subroutine dio_function_output_supercell(how, dir, fname, mesh, space, latt, ff, centers, supercell, unit, ierr, namespace, pos, atoms, grp, root, is_global, extra_atom)
subroutine, public dio_function_output(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
Top-level IO routine for functions defined on the mesh.
subroutine dio_function_output_vector(how, dir, fname, namespace, space, mesh, ff, unit, ierr, pos, atoms, grp, root)
subroutine transpose3(in, out)
subroutine zio_function_output_supercell(how, dir, fname, mesh, space, latt, ff, centers, supercell, unit, ierr, namespace, pos, atoms, grp, root, is_global, extra_atom)
subroutine, public write_xsf_geometry_file(dir, fname, space, latt, pos, atoms, mesh, mpi_grp, namespace, total_forces)
subroutine dio_function_output_global_bz(how, dir, fname, namespace, kpoints, ff, unit, ierr)
integer, parameter, private zoutput_kind
subroutine, public write_standard_xyz_file(namespace, fname, pos, species, header)
Write a standard xyz file with atom labels and positions (in Angstrom).
subroutine, public zio_function_output_global(how, dir, fname, namespace, space, mesh, ff, unit, ierr)
subroutine dio_function_output_vector_bz(how, dir, fname, namespace, space, kpt, kpoints, ff, unit, ierr, grp, root)
integer(int64) function, public io_function_fill_how(where)
Use this function to quickly plot functions for debugging purposes: call dio_function_output(io_funct...
subroutine, public dio_function_input(filename, namespace, space, mesh, ff, ierr, map)
Reads a mesh function from file filename, and puts it into ff. If the map argument is passed,...
subroutine zio_function_output_global_bz(how, dir, fname, namespace, kpoints, ff, unit, ierr)
Definition: io.F90:93
subroutine, public io_close(iunit, grp)
Definition: io.F90:444
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
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
Definition: mesh.F90:97
subroutine, public messages_variable_is_block(namespace, name)
Definition: messages.F90:1004
subroutine, public messages_warning(no_lines, all_nodes, namespace)
Definition: messages.F90:501
subroutine, public messages_obsolete_variable(namespace, name, rep)
Definition: messages.F90:980
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
subroutine, public messages_input_error(namespace, var, details, row, column)
Definition: messages.F90:671
Some general things and nomenclature:
Definition: par_vec.F90:150
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
Definition: parser.F90:795
integer function, public parse_block(namespace, name, blk, check_varinfo_)
Definition: parser.F90:600
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
Definition: profiling.F90:122
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_t), public unit_angstrom
For XYZ files.
type(unit_system_t), public units_out
This module is intended to contain simple general-purpose utility functions and procedures.
Definition: utils.F90:99
class to tell whether a point is inside or outside
Definition: box.F90:120
Describes mesh distribution to nodes.
Definition: mesh.F90:165
This is defined even when running serial.
Definition: mpi.F90:121
int true(void)