45#if defined(HAVE_NETCDF)
79#if defined(HAVE_NETCDF)
86 integer,
parameter,
private :: &
91 character(len=3),
parameter :: &
92 index2label(3) = (/
're ',
'im ',
'abs' /)
117 what_tag_in, how_tag_in, output_interval_tag_in, ignore_error)
118 type(namespace_t),
intent(in) :: namespace
119 class(space_t),
intent(in) :: space
120 logical,
intent(inout) :: what(MAX_OUTPUT_TYPES)
121 integer(int64),
intent(out) :: how(0:MAX_OUTPUT_TYPES)
122 integer,
intent(out) :: output_interval(0:MAX_OUTPUT_TYPES)
123 character(len=*),
optional,
intent(in) :: what_tag_in
124 character(len=*),
optional,
intent(in) :: how_tag_in
125 character(len=*),
optional,
intent(in) :: output_interval_tag_in
126 logical,
optional,
intent(in) :: ignore_error
129 integer :: ncols, nrows, iout, column_index, what_i
130 integer(int64) :: what_no_how(12)
131 character(len=80) :: what_tag
132 character(len=80) :: how_tag
133 character(len=80) :: output_interval_tag
134 character(len=80) :: output_column_marker
138 output_interval = 0_8
142 output_interval_tag =
optional_default(output_interval_tag_in,
'OutputInterval')
467 what_no_how = (/ option__output__matrix_elements, option__output__berkeleygw, option__output__dos, &
468 option__output__tpa, option__output__mmb_den, option__output__j_flow, option__output__occ_matrices, &
469 option__output__effectiveu, option__output__magnetization, option__output__kanamoriu, option__output__stress, option__output__jdos /)
471 if (
parse_block(namespace, what_tag, blk) == 0)
then
473 do iout = 0, nrows - 1
489 what(what_i) = .
true.
490 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
491 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
492 .or. (what_tag /=
'Output'))
then
500 else if (ncols == 2)
then
513 what(what_i) = .
true.
514 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
515 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
516 .or. (what_tag /=
'Output'))
then
518 if (how(what_i) == 0)
call parse_variable(namespace, how_tag, 0, how(what_i))
545 what(what_i) = .
true.
546 do column_index = 0, 1
548 if (output_column_marker ==
'output_interval')
then
550 else if (output_column_marker ==
'output_format')
then
551 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
552 .or. (what_tag /=
'Output'))
then
558 else if (len_trim(output_column_marker) /= 0)
then
563 if (output_interval(what_i) == 0)
then
564 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
566 if (how(what_i) == 0)
then
567 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
568 .or. (what_tag /=
'Output'))
then
587 call parse_variable(namespace, output_interval_tag, 50, output_interval(0))
591 do what_i = lbound(what, 1), ubound(what, 1)
592 if (what_tag ==
'Output')
then
593 if (what(what_i) .and. (.not. any(what_no_how == what_i)))
then
598 if (how(what_i) == 0 .and. .not.
optional_default(ignore_error, .false.))
then
599 write(
message(1),
'(a)')
'Must specify output method with variable OutputFormat.'
604 if (space%dim == 1)
then
605 if (
bitand(how(what_i), option__outputformat__axis_y) /= 0)
then
606 message(1) =
"OutputFormat = axis_y not available with Dimensions = 1."
609 if (
bitand(how(what_i), option__outputformat__plane_z) /= 0)
then
610 message(1) =
"OutputFormat = plane_z not available with Dimensions = 1."
613 if (
bitand(how(what_i), option__outputformat__xcrysden) /= 0)
then
614 message(1) =
"OutputFormat = xcrysden not available with Dimensions = 1."
619 if (space%dim <= 2)
then
620 if (
bitand(how(what_i), option__outputformat__axis_z) /= 0)
then
621 message(1) =
"OutputFormat = axis_z not available with Dimensions <= 2."
624 if (
bitand(how(what_i), option__outputformat__plane_x) /= 0)
then
625 message(1) =
"OutputFormat = plane_x not available with Dimensions <= 2."
628 if (
bitand(how(what_i), option__outputformat__plane_y) /= 0)
then
629 message(1) =
"OutputFormat = plane_y not available with Dimensions <= 2."
632 if (
bitand(how(what_i), option__outputformat__integrate_xy) /= 0)
then
633 message(1) =
"OutputFormat = integrate_xy not available with Dimensions <= 2."
636 if (
bitand(how(what_i), option__outputformat__integrate_xz) /= 0)
then
637 message(1) =
"OutputFormat = integrate_xz not available with Dimensions <= 2."
640 if (
bitand(how(what_i), option__outputformat__integrate_yz) /= 0)
then
641 message(1) =
"OutputFormat = integrate_yz not available with Dimensions <= 2."
644 if (
bitand(how(what_i), option__outputformat__dx) /= 0)
then
645 message(1) =
"OutputFormat = dx not available with Dimensions <= 2."
648 if (
bitand(how(what_i), option__outputformat__cube) /= 0)
then
649 message(1) =
"OutputFormat = cube not available with Dimensions <= 2."
654#if !defined(HAVE_NETCDF)
655 if (
bitand(how(what_i), option__outputformat__netcdf) /= 0)
then
656 message(1) =
'Octopus was compiled without NetCDF support.'
657 message(2) =
'It is not possible to write output in NetCDF format.'
661#if !defined(HAVE_ETSF_IO)
662 if (
bitand(how(what_i), option__outputformat__etsf) /= 0)
then
663 message(1) =
'Octopus was compiled without ETSF_IO support.'
664 message(2) =
'It is not possible to write output in ETSF format.'
673 if (output_interval(what_i) < 0)
then
674 message(1) =
"OutputInterval must be >= 0."
688 character(len=*),
intent(in) :: where
693 if (index(
where,
"AxisX") /= 0) how = ior(how, option__outputformat__axis_x)
694 if (index(
where,
"AxisY") /= 0) how = ior(how, option__outputformat__axis_y)
695 if (index(
where,
"AxisZ") /= 0) how = ior(how, option__outputformat__axis_z)
696 if (index(
where,
"PlaneX") /= 0) how = ior(how, option__outputformat__plane_x)
697 if (index(
where,
"PlaneY") /= 0) how = ior(how, option__outputformat__plane_y)
698 if (index(
where,
"PlaneZ") /= 0) how = ior(how, option__outputformat__plane_z)
699 if (index(
where,
"IntegrateXY") /= 0) how = ior(how, option__outputformat__integrate_xy)
700 if (index(
where,
"IntegrateXZ") /= 0) how = ior(how, option__outputformat__integrate_xz)
701 if (index(
where,
"IntegrateYZ") /= 0) how = ior(how, option__outputformat__integrate_yz)
702 if (index(
where,
"PlaneZ") /= 0) how = ior(how, option__outputformat__plane_z)
703 if (index(
where,
"DX") /= 0) how = ior(how, option__outputformat__dx)
704 if (index(
where,
"XCrySDen") /= 0) how = ior(how, option__outputformat__xcrysden)
705 if (index(
where,
"Binary") /= 0) how = ior(how, option__outputformat__binary)
706 if (index(
where,
"MeshIndex") /= 0) how = ior(how, option__outputformat__mesh_index)
707 if (index(
where,
"XYZ") /= 0) how = ior(how, option__outputformat__xyz)
708#if defined(HAVE_NETCDF)
709 if (index(
where,
"NETCDF") /= 0) how = ior(how, option__outputformat__netcdf)
711 if (index(
where,
"Cube") /= 0) how = ior(how, option__outputformat__cube)
712 if (index(
where,
"VTK") /= 0) how = ior(how, option__outputformat__vtk)
723 character(len=*),
intent(in) :: dir
724 character(len=*),
intent(in) :: fname
725 class(
space_t),
intent(in) :: space
727 real(real64),
intent(in) :: pos(:,:)
728 type(
atom_t),
intent(in) :: atoms(:)
729 class(
box_t),
intent(in) :: box
734 real(real64) :: position
740 iunit =
io_open(trim(dir)//
'/'//trim(fname)//
'.xyz', namespace, action=
'write', position=
'asis')
742 write(iunit,
'(i6)')
size(atoms)
743 write(iunit,
'(a,a,a)', advance=
'no') trim(space%short_info()),
'; ', trim(box%short_info(
unit_angstrom))
744 if (space%is_periodic())
then
745 write(iunit,
'(a,a)')
'; ', trim(latt%short_info(
unit_angstrom))
751 do iatom = 1,
size(atoms)
752 write(iunit,
'(10a)', advance=
'no') atoms(iatom)%label
754 if (idir <= space%dim)
then
755 position = pos(idir, iatom)
771 character(len=*),
intent(in) :: dir, fname
772 class(
space_t),
intent(in) :: space
774 real(real64),
intent(in) :: pos(:,:)
775 type(
atom_t),
intent(in) :: atoms(:)
776 class(
mesh_t),
intent(in) :: mesh
778 real(real64),
optional,
intent(in) :: total_forces(:,:)
781 real(real64),
allocatable :: forces(:,:)
788 iunit =
io_open(trim(dir)//
'/'//trim(fname)//
'.xsf', namespace, action=
'write', position=
'asis')
790 if (
present(total_forces))
then
791 safe_allocate(forces(1:space%dim, 1:
size(atoms)))
794 safe_deallocate_a(forces)
808 integer,
intent(in) :: iunit
809 class(
space_t),
intent(in) :: space
811 real(real64),
intent(in) :: pos(:,:)
812 type(
atom_t),
intent(in) :: atoms(:)
813 class(
mesh_t),
intent(in) :: mesh
814 real(real64),
optional,
intent(in) :: forces(:, :)
815 integer,
optional,
intent(in) :: index
817 integer :: idir, idir2, iatom, index_, natoms
818 character(len=7) :: index_str
819 real(real64) :: offset(space%dim)
820 real(real64) :: rlattice(space%dim, space%dim)
824 if (
present(index))
then
825 write(index_str,
'(a,i6)')
' ', index
828 write(index_str,
'(a)')
''
831 natoms =
size(pos, dim=2)
837 offset(1:space%dim) = latt%red_to_cart(spread(-
m_half, 1, space%dim))
839 do idir = space%periodic_dim + 1, space%dim
840 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
843 if (space%is_periodic())
then
844 if (index_ == 1)
then
845 select case (space%periodic_dim)
847 write(iunit,
'(a)')
'CRYSTAL'
849 write(iunit,
'(a)')
'SLAB'
851 write(iunit,
'(a)')
'POLYMER'
855 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
858 rlattice = latt%rlattice
859 do idir = space%periodic_dim+1, space%dim
860 rlattice(:,idir) = rlattice(:,idir)*
m_two*mesh%box%bounding_box_l(idir)
863 do idir = 1, space%dim
867 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
868 write(iunit,
'(i10, a)') natoms,
' 1'
870 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
875 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
877 if (
present(forces))
then
878 write(iunit,
'(5x, 3f12.6)', advance=
'no') forces(:, iatom)
890 integer,
intent(in) :: iunit
891 class(
space_t),
intent(in) :: space
893 real(real64),
intent(in) :: pos(:,:)
894 type(
atom_t),
intent(in) :: atoms(:)
895 class(
mesh_t),
intent(in) :: mesh
896 real(real64),
intent(in) :: centers(:, :)
897 integer,
intent(in) :: supercell(:)
898 real(real64),
optional,
intent(in) :: extra_atom(:)
900 integer :: idir, idir2, iatom, index_
901 character(len=7) :: index_str
902 real(real64) :: offset(3)
903 integer :: irep, nreplica
907 write(index_str,
'(a)')
''
910 nreplica = product(supercell(1:space%dim))
915 offset(1:space%dim) = latt%red_to_cart(spread(-
m_half, 1, space%dim))
916 offset(1:3) = offset(1:3) + centers(1:3,1)
918 do idir = space%periodic_dim + 1, 3
919 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
922 if(space%is_periodic())
then
924 select case(space%periodic_dim)
926 write(iunit,
'(a)')
'CRYSTAL'
928 write(iunit,
'(a)')
'SLAB'
930 write(iunit,
'(a)')
'POLYMER'
934 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
936 do idir = 1, space%dim
938 latt%rlattice(idir2, idir)*supercell(idir)), idir2 = 1, space%dim)
941 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
942 if(.not.
present(extra_atom))
then
943 write(iunit,
'(i10, a)')
size(atoms)*nreplica,
' 1'
945 write(iunit,
'(i10, a)')
size(atoms)*nreplica+1,
' 1'
948 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
952 do irep = 1, nreplica
954 do iatom = 1,
size(atoms)
955 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
957 - offset(idir)), idir = 1, space%dim)
961 write(iunit,
'(a10, 3f12.6)', advance=
'no')
'X', &
969#if defined(HAVE_NETCDF)
971 subroutine ncdf_error(func, status, filename, namespace, ierr)
972 character(len=*),
intent(in) :: func
973 integer,
intent(in) :: status
974 character(len=*),
intent(in) :: filename
976 integer,
intent(inout) :: ierr
980 if (status == nf90_noerr)
then
985 write(
message(1),
'(3a)')
"NETCDF error in function '" , trim(func) ,
"'"
986 write(
message(2),
'(3a)')
"(reading/writing ", trim(filename) ,
")"
987 write(
message(3),
'(6x,a,a)')
'Error code = ', trim(nf90_strerror(status))
997 real(real64),
intent(in) :: in(:, :, :)
998 real(real64),
intent(out) :: out(:, :, :)
999 integer :: ix, iy, iz
1003 do ix = lbound(in, 1), ubound(in, 1)
1004 do iy = lbound(in, 2), ubound(in, 2)
1005 do iz = lbound(in, 3), ubound(in, 3)
1006 out(iz, iy, ix) = in(ix, iy, iz)
1016#include "io_function_inc.F90"
1019#include "complex.F90"
1020#include "io_function_inc.F90"
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
real(real64), parameter, public m_two
real(real64), parameter, public m_zero
real(real64), parameter, public m_half
This module implements the index, used for the mesh points.
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. Includes information about ...
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:
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:
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, namespace, total_forces)
subroutine, public dout_cf_netcdf(filename, ierr, cf, cube, space, spacing, transpose, unit, namespace)
Writes a cube_function in netcdf format.
subroutine dio_function_output_global_bz(how, dir, fname, namespace, kpoints, ff, unit, ierr)
subroutine ncdf_error(func, status, filename, namespace, ierr)
integer, parameter, private zoutput_kind
subroutine, public zio_function_output_global(how, dir, fname, namespace, space, mesh, ff, unit, ierr)
subroutine, public zout_cf_netcdf(filename, ierr, cf, cube, space, spacing, transpose, unit, namespace)
Writes a cube_function in netcdf format.
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)
subroutine, public io_close(iunit, grp)
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
This module defines various routines, operating on mesh functions.
This module defines the meshes, which are used in Octopus.
subroutine, public messages_variable_is_block(namespace, name)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public messages_obsolete_variable(namespace, name, rep)
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_input_error(namespace, var, details, row, column)
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
type(mpi_grp_t), public mpi_world
Some general things and nomenclature:
integer function, public parse_block(namespace, name, blk, check_varinfo_)
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
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.
class to tell whether a point is inside or outside
Describes mesh distribution to nodes.