46#if defined(HAVE_NETCDF)
82#if defined(HAVE_NETCDF)
89 integer,
parameter,
private :: &
94 character(len=3),
parameter :: &
95 index2label(3) = (/
're ',
'im ',
'abs' /)
119 what_tag_in, how_tag_in, output_interval_tag_in, ignore_error)
120 type(namespace_t),
intent(in) :: namespace
121 class(space_t),
intent(in) :: space
122 logical,
intent(inout) :: what(MAX_OUTPUT_TYPES)
123 integer(int64),
intent(out) :: how(0:MAX_OUTPUT_TYPES)
124 integer,
intent(out) :: output_interval(0:MAX_OUTPUT_TYPES)
125 character(len=*),
optional,
intent(in) :: what_tag_in
126 character(len=*),
optional,
intent(in) :: how_tag_in
127 character(len=*),
optional,
intent(in) :: output_interval_tag_in
128 logical,
optional,
intent(in) :: ignore_error
131 integer :: ncols, nrows, iout, column_index, what_i
132 integer(int64) :: what_no_how(12)
133 character(len=80) :: what_tag
134 character(len=80) :: how_tag
135 character(len=80) :: output_interval_tag
136 character(len=80) :: output_column_marker
140 output_interval = 0_8
144 output_interval_tag =
optional_default(output_interval_tag_in,
'OutputInterval')
478 option__output__matrix_elements, &
479 option__output__berkeleygw, &
480 option__output__dos, &
481 option__output__tpa, &
482 option__output__mmb_den, &
483 option__output__j_flow, &
484 option__output__occ_matrices, &
485 option__output__effectiveu, &
486 option__output__magnetization, &
487 option__output__kanamoriu, &
488 option__output__stress, &
489 option__output__jdos &
492 if (
parse_block(namespace, what_tag, blk) == 0)
then
494 do iout = 0, nrows - 1
510 what(what_i) = .
true.
511 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
512 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
513 .or. (what_tag /=
'Output'))
then
521 else if (ncols == 2)
then
534 what(what_i) = .
true.
535 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
536 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
537 .or. (what_tag /=
'Output'))
then
539 if (how(what_i) == 0)
call parse_variable(namespace, how_tag, 0, how(what_i))
566 what(what_i) = .
true.
567 do column_index = 0, 1
569 if (output_column_marker ==
'output_interval')
then
571 else if (output_column_marker ==
'output_format')
then
572 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
573 .or. (what_tag /=
'Output'))
then
579 else if (len_trim(output_column_marker) /= 0)
then
584 if (output_interval(what_i) == 0)
then
585 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
587 if (how(what_i) == 0)
then
588 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
589 .or. (what_tag /=
'Output'))
then
608 call parse_variable(namespace, output_interval_tag, 50, output_interval(0))
612 do what_i = lbound(what, 1), ubound(what, 1)
613 if (what_tag ==
'Output')
then
614 if (what(what_i) .and. (.not. any(what_no_how == what_i)))
then
619 if (how(what_i) == 0 .and. .not.
optional_default(ignore_error, .false.))
then
620 write(
message(1),
'(a)')
'Must specify output method with variable OutputFormat.'
625 if (space%dim == 1)
then
626 if (
bitand(how(what_i), option__outputformat__axis_y) /= 0)
then
627 message(1) =
"OutputFormat = axis_y not available with Dimensions = 1."
630 if (
bitand(how(what_i), option__outputformat__plane_z) /= 0)
then
631 message(1) =
"OutputFormat = plane_z not available with Dimensions = 1."
634 if (
bitand(how(what_i), option__outputformat__xcrysden) /= 0)
then
635 message(1) =
"OutputFormat = xcrysden not available with Dimensions = 1."
640 if (space%dim <= 2)
then
641 if (
bitand(how(what_i), option__outputformat__axis_z) /= 0)
then
642 message(1) =
"OutputFormat = axis_z not available with Dimensions <= 2."
645 if (
bitand(how(what_i), option__outputformat__plane_x) /= 0)
then
646 message(1) =
"OutputFormat = plane_x not available with Dimensions <= 2."
649 if (
bitand(how(what_i), option__outputformat__plane_y) /= 0)
then
650 message(1) =
"OutputFormat = plane_y not available with Dimensions <= 2."
653 if (
bitand(how(what_i), option__outputformat__integrate_xy) /= 0)
then
654 message(1) =
"OutputFormat = integrate_xy not available with Dimensions <= 2."
657 if (
bitand(how(what_i), option__outputformat__integrate_xz) /= 0)
then
658 message(1) =
"OutputFormat = integrate_xz not available with Dimensions <= 2."
661 if (
bitand(how(what_i), option__outputformat__integrate_yz) /= 0)
then
662 message(1) =
"OutputFormat = integrate_yz not available with Dimensions <= 2."
665 if (
bitand(how(what_i), option__outputformat__dx) /= 0)
then
666 message(1) =
"OutputFormat = dx not available with Dimensions <= 2."
669 if (
bitand(how(what_i), option__outputformat__cube) /= 0)
then
670 message(1) =
"OutputFormat = cube not available with Dimensions <= 2."
673 if (
bitand(how(what_i), option__outputformat__poscar) /= 0)
then
674 message(1) =
"OutputFormat = POSCAR not available with Dimensions <= 2."
679 if (space%periodic_dim<=2)
then
680 if (
bitand(how(what_i), option__outputformat__poscar) /= 0)
then
681 message(1) =
"OutputFormat = POSCAR not available with periodic_dim <= 2."
686#if !defined(HAVE_NETCDF)
687 if (
bitand(how(what_i), option__outputformat__netcdf) /= 0)
then
688 message(1) =
'Octopus was compiled without NetCDF support.'
689 message(2) =
'It is not possible to write output in NetCDF format.'
693#if !defined(HAVE_ETSF_IO)
694 if (
bitand(how(what_i), option__outputformat__etsf) /= 0)
then
695 message(1) =
'Octopus was compiled without ETSF_IO support.'
696 message(2) =
'It is not possible to write output in ETSF format.'
705 if (output_interval(what_i) < 0)
then
706 message(1) =
"OutputInterval must be >= 0."
720 character(len=*),
intent(in) :: where
725 if (index(
where,
"AxisX") /= 0) how = ior(how, option__outputformat__axis_x)
726 if (index(
where,
"AxisY") /= 0) how = ior(how, option__outputformat__axis_y)
727 if (index(
where,
"AxisZ") /= 0) how = ior(how, option__outputformat__axis_z)
728 if (index(
where,
"PlaneX") /= 0) how = ior(how, option__outputformat__plane_x)
729 if (index(
where,
"PlaneY") /= 0) how = ior(how, option__outputformat__plane_y)
730 if (index(
where,
"PlaneZ") /= 0) how = ior(how, option__outputformat__plane_z)
731 if (index(
where,
"IntegrateXY") /= 0) how = ior(how, option__outputformat__integrate_xy)
732 if (index(
where,
"IntegrateXZ") /= 0) how = ior(how, option__outputformat__integrate_xz)
733 if (index(
where,
"IntegrateYZ") /= 0) how = ior(how, option__outputformat__integrate_yz)
734 if (index(
where,
"PlaneZ") /= 0) how = ior(how, option__outputformat__plane_z)
735 if (index(
where,
"DX") /= 0) how = ior(how, option__outputformat__dx)
736 if (index(
where,
"XCrySDen") /= 0) how = ior(how, option__outputformat__xcrysden)
737 if (index(
where,
"Binary") /= 0) how = ior(how, option__outputformat__binary)
738 if (index(
where,
"MeshIndex") /= 0) how = ior(how, option__outputformat__mesh_index)
739 if (index(
where,
"XYZ") /= 0) how = ior(how, option__outputformat__xyz)
740#if defined(HAVE_NETCDF)
741 if (index(
where,
"NETCDF") /= 0) how = ior(how, option__outputformat__netcdf)
743 if (index(
where,
"Cube") /= 0) how = ior(how, option__outputformat__cube)
744 if (index(
where,
"VTK") /= 0) how = ior(how, option__outputformat__vtk)
755 character(len=*),
intent(in) :: fname
756 real(real64),
intent(in) :: pos(:,:)
757 character(len=*),
intent(in) :: species(:)
758 character(len=*),
optional,
intent(in) :: header
760 integer :: iunit, n_atoms, iatom, min_dim
761 real(real64) :: position(3)
765 n_atoms =
size(pos, 2)
766 assert(
size(species) == n_atoms)
768 iunit =
io_open(trim(fname)//
'.xyz', namespace, action=
'write', position=
'asis')
770 write(iunit,
'(i6)') n_atoms
771 if (
present(header))
then
772 write(iunit,
'(a)') trim(adjustl(header))
778 min_dim = min(
size(pos, 1), 3)
779 position(1:3) = 0.0_real64
782 do iatom = 1, n_atoms
783 position(1:min_dim) = pos(1:min_dim, iatom)
784 write(iunit,
'(a10, 3(1x, f11.6))') trim(adjustl(species(iatom))), &
800 character(len=*),
intent(in) :: dir
801 character(len=*),
intent(in) :: fname
802 class(
space_t),
intent(in) :: space
804 real(real64),
intent(in) :: pos(:,:)
805 type(
atom_t),
intent(in) :: atoms(:)
806 class(
box_t),
intent(in) :: box
810 character(len=:),
allocatable :: info_str
811 character(len=LABEL_LEN),
allocatable :: species(:)
817 info_str = trim(space%short_info()) //
'; ' // trim(box%short_info(
unit_angstrom))
818 if (space%is_periodic())
then
819 info_str = info_str //
'; ' // trim(latt%short_info(
unit_angstrom))
822 safe_allocate(species(1:
size(atoms)))
823 do ia = 1,
size(atoms)
824 species(ia) = atoms(ia)%get_label()
829 safe_deallocate_a(species)
836 character(len=*),
intent(in) :: dir, fname
837 class(
space_t),
intent(in) :: space
839 real(real64),
intent(in) :: pos(:,:)
840 type(
atom_t),
intent(in) :: atoms(:)
841 class(
mesh_t),
intent(in) :: mesh
843 real(real64),
optional,
intent(in) :: total_forces(:,:)
846 real(real64),
allocatable :: forces(:,:)
853 iunit =
io_open(trim(dir)//
'/'//trim(fname)//
'.xsf', namespace, action=
'write', position=
'asis')
855 if (
present(total_forces))
then
856 safe_allocate(forces(1:space%dim, 1:
size(atoms)))
859 safe_deallocate_a(forces)
873 integer,
intent(in) :: iunit
874 class(
space_t),
intent(in) :: space
876 real(real64),
intent(in) :: pos(:,:)
877 type(
atom_t),
intent(in) :: atoms(:)
878 class(
mesh_t),
intent(in) :: mesh
879 real(real64),
optional,
intent(in) :: forces(:, :)
880 integer,
optional,
intent(in) :: index
882 integer :: idir, idir2, iatom, index_, natoms
883 character(len=7) :: index_str
884 real(real64) :: offset(space%dim)
885 real(real64) :: rlattice(space%dim, space%dim)
889 if (
present(index))
then
890 write(index_str,
'(a,i6)')
' ', index
893 write(index_str,
'(a)')
''
896 natoms =
size(pos, dim=2)
902 offset(1:space%dim) = latt%red_to_cart(spread(-
m_half, 1, space%dim))
904 do idir = space%periodic_dim + 1, space%dim
905 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
908 if (space%is_periodic())
then
909 if (index_ == 1)
then
910 select case (space%periodic_dim)
912 write(iunit,
'(a)')
'CRYSTAL'
914 write(iunit,
'(a)')
'SLAB'
916 write(iunit,
'(a)')
'POLYMER'
920 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
923 rlattice = latt%rlattice
924 do idir = space%periodic_dim+1, space%dim
925 rlattice(:,idir) = rlattice(:,idir)*
m_two*mesh%box%bounding_box_l(idir)
928 do idir = 1, space%dim
932 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
933 write(iunit,
'(i10, a)') natoms,
' 1'
935 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
940 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
942 if (
present(forces))
then
943 write(iunit,
'(5x, 3f12.6)', advance=
'no') forces(:, iatom)
955 integer,
intent(in) :: iunit
956 class(
space_t),
intent(in) :: space
958 real(real64),
intent(in) :: pos(:,:)
959 type(
atom_t),
intent(in) :: atoms(:)
960 class(
mesh_t),
intent(in) :: mesh
961 real(real64),
intent(in) :: centers(:, :)
962 integer,
intent(in) :: supercell(:)
963 real(real64),
optional,
intent(in) :: extra_atom(:)
965 integer :: idir, idir2, iatom, index_
966 character(len=7) :: index_str
967 real(real64) :: offset(3)
968 integer :: irep, nreplica
972 write(index_str,
'(a)')
''
975 nreplica = product(supercell(1:space%dim))
980 offset(1:space%dim) = latt%red_to_cart(spread(-
m_half, 1, space%dim))
981 offset(1:3) = offset(1:3) + centers(1:3,1)
983 do idir = space%periodic_dim + 1, 3
984 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
987 if(space%is_periodic())
then
989 select case(space%periodic_dim)
991 write(iunit,
'(a)')
'CRYSTAL'
993 write(iunit,
'(a)')
'SLAB'
995 write(iunit,
'(a)')
'POLYMER'
999 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
1001 do idir = 1, space%dim
1003 latt%rlattice(idir2, idir)*supercell(idir)), idir2 = 1, space%dim)
1006 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
1007 if(.not.
present(extra_atom))
then
1008 write(iunit,
'(i10, a)')
size(atoms)*nreplica,
' 1'
1010 write(iunit,
'(i10, a)')
size(atoms)*nreplica+1,
' 1'
1013 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
1017 do irep = 1, nreplica
1019 do iatom = 1,
size(atoms)
1020 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
1022 - offset(idir)), idir = 1, space%dim)
1026 write(iunit,
'(a10, 3f12.6)', advance=
'no')
'X', &
1034#if defined(HAVE_NETCDF)
1036 subroutine ncdf_error(func, status, filename, namespace, ierr)
1037 character(len=*),
intent(in) :: func
1038 integer,
intent(in) :: status
1039 character(len=*),
intent(in) :: filename
1041 integer,
intent(inout) :: ierr
1045 if (status == nf90_noerr)
then
1050 write(
message(1),
'(3a)')
"NETCDF error in function '" , trim(func) ,
"'"
1051 write(
message(2),
'(3a)')
"(reading/writing ", trim(filename) ,
")"
1052 write(
message(3),
'(6x,a,a)')
'Error code = ', trim(nf90_strerror(status))
1062 real(real64),
intent(in) :: in(:, :, :)
1063 real(real64),
intent(out) :: out(:, :, :)
1064 integer :: ix, iy, iz
1068 do ix = lbound(in, 1), ubound(in, 1)
1069 do iy = lbound(in, 2), ubound(in, 2)
1070 do iz = lbound(in, 3), ubound(in, 3)
1071 out(iz, iy, ix) = in(ix, iy, iz)
1081#include "io_function_inc.F90"
1084#include "complex.F90"
1085#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_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.
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 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, 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.