46#if defined(HAVE_NETCDF)
83#if defined(HAVE_NETCDF)
90 integer,
parameter,
private :: &
95 character(len=3),
parameter :: &
96 index2label(3) = (/
're ',
'im ',
'abs' /)
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
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
141 output_interval = 0_8
145 output_interval_tag =
optional_default(output_interval_tag_in,
'OutputInterval')
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 &
529 if (
parse_block(namespace, what_tag, blk) == 0)
then
531 do iout = 0, nrows - 1
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
558 else if (ncols == 2)
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
576 if (how(what_i) == 0)
call parse_variable(namespace, how_tag, 0, how(what_i))
603 what(what_i) = .
true.
604 do column_index = 0, 1
606 if (output_column_marker ==
'output_interval')
then
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
616 else if (len_trim(output_column_marker) /= 0)
then
621 if (output_interval(what_i) == 0)
then
622 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
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
645 call parse_variable(namespace, output_interval_tag, 50, output_interval(0))
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
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.'
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."
667 if (
bitand(how(what_i), option__outputformat__plane_z) /= 0)
then
668 message(1) =
"OutputFormat = plane_z not available with Dimensions = 1."
671 if (
bitand(how(what_i), option__outputformat__xcrysden) /= 0)
then
672 message(1) =
"OutputFormat = xcrysden not available with Dimensions = 1."
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."
682 if (
bitand(how(what_i), option__outputformat__plane_x) /= 0)
then
683 message(1) =
"OutputFormat = plane_x not available with Dimensions <= 2."
686 if (
bitand(how(what_i), option__outputformat__plane_y) /= 0)
then
687 message(1) =
"OutputFormat = plane_y not available with Dimensions <= 2."
690 if (
bitand(how(what_i), option__outputformat__integrate_xy) /= 0)
then
691 message(1) =
"OutputFormat = integrate_xy not available with Dimensions <= 2."
694 if (
bitand(how(what_i), option__outputformat__integrate_xz) /= 0)
then
695 message(1) =
"OutputFormat = integrate_xz not available with Dimensions <= 2."
698 if (
bitand(how(what_i), option__outputformat__integrate_yz) /= 0)
then
699 message(1) =
"OutputFormat = integrate_yz not available with Dimensions <= 2."
702 if (
bitand(how(what_i), option__outputformat__dx) /= 0)
then
703 message(1) =
"OutputFormat = dx not available with Dimensions <= 2."
706 if (
bitand(how(what_i), option__outputformat__cube) /= 0)
then
707 message(1) =
"OutputFormat = cube not available with Dimensions <= 2."
710 if (
bitand(how(what_i), option__outputformat__poscar) /= 0)
then
711 message(1) =
"OutputFormat = POSCAR not available with Dimensions <= 2."
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."
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.'
735 if (output_interval(what_i) < 0)
then
736 message(1) =
"OutputInterval must be >= 0."
750 character(len=*),
intent(in) :: where
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)
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)
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
791 integer :: iunit, n_atoms, iatom, min_dim
792 real(real64) :: position(3)
796 n_atoms =
size(pos, 2)
797 assert(
size(species) == n_atoms)
799 iunit =
io_open(trim(fname)//
'.xyz', namespace, action=
'write', position=
'asis')
801 write(iunit,
'(i6)') n_atoms
802 if (
present(header))
then
803 write(iunit,
'(a)') trim(adjustl(header))
809 min_dim = min(
size(pos, 1), 3)
810 position(1:3) = 0.0_real64
813 do iatom = 1, n_atoms
815 write(iunit,
'(a10, 3(1x, f13.8))') trim(adjustl(species(iatom))), position
830 character(len=*),
intent(in) :: dir
831 character(len=*),
intent(in) :: fname
832 class(
space_t),
intent(in) :: space
834 real(real64),
contiguous,
intent(in) :: pos(:,:)
835 type(
atom_t),
contiguous,
intent(in) :: atoms(:)
836 class(
box_t),
intent(in) :: box
840 character(len=:),
allocatable :: info_str, dir_fname
841 character(len=LABEL_LEN),
allocatable :: species(:)
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))
852 safe_allocate(species(1:
size(atoms)))
853 do ia = 1,
size(atoms)
854 species(ia) = atoms(ia)%get_label()
857 dir_fname = trim(dir) //
'/' // trim(fname)
860 safe_deallocate_a(species)
870 character(len=*),
intent(in) :: dir
871 character(len=*),
intent(in) :: fname
872 class(
space_t),
intent(in) :: space
874 real(real64),
contiguous,
intent(in) :: pos(:,:)
875 type(
atom_t),
contiguous,
intent(in) :: atoms(:)
876 class(
box_t),
intent(in) :: box
880 character(len=512),
allocatable :: info_str
881 character(len=:),
allocatable :: dir_fname
882 character(len=LABEL_LEN),
allocatable :: species(:)
886 assert(space%dim == 3)
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]"
897 write(info_str,
'(A, "; Lattice = """, 9(F13.8,","), """")') &
901 safe_allocate(species(1:
size(atoms)))
902 do ia = 1,
size(atoms)
903 species(ia) = atoms(ia)%get_label()
906 dir_fname = trim(dir) //
'/' // trim(fname)
909 safe_deallocate_a(species)
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
918 real(real64),
contiguous,
intent(in) :: pos(:,:)
919 type(
atom_t),
contiguous,
intent(in) :: atoms(:)
920 class(
mesh_t),
intent(in) :: mesh
923 real(real64),
contiguous,
optional,
intent(in) :: total_forces(:,:)
926 real(real64),
allocatable :: forces(:,:)
928 if (.not. mpi_grp%is_root())
return
933 iunit =
io_open(trim(dir)//
'/'//trim(fname)//
'.xsf', namespace, action=
'write', position=
'asis')
935 if (
present(total_forces))
then
936 safe_allocate(forces(1:space%dim, 1:
size(atoms)))
939 safe_deallocate_a(forces)
953 integer,
intent(in) :: iunit
954 class(
space_t),
intent(in) :: space
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
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)
969 if (
present(index))
then
970 write(index_str,
'(a,i6)')
' ', index
973 write(index_str,
'(a)')
''
976 natoms =
size(pos, dim=2)
982 offset(1:space%dim) = latt%red_to_cart(spread(-
m_half, 1, space%dim))
984 do idir = space%periodic_dim + 1, space%dim
985 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
988 if (space%is_periodic())
then
989 if (index_ == 1)
then
990 select case (space%periodic_dim)
992 write(iunit,
'(a)')
'CRYSTAL'
994 write(iunit,
'(a)')
'SLAB'
996 write(iunit,
'(a)')
'POLYMER'
1000 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
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)
1008 do idir = 1, space%dim
1012 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
1013 write(iunit,
'(i10, a)') natoms,
' 1'
1015 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
1019 do iatom = 1, natoms
1020 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
1022 if (
present(forces))
then
1023 write(iunit,
'(5x, 3f12.6)', advance=
'no') forces(:, iatom)
1035 integer,
intent(in) :: iunit
1036 class(
space_t),
intent(in) :: space
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(:)
1045 integer :: idir, idir2, iatom, index_
1046 character(len=7) :: index_str
1047 real(real64) :: offset(3)
1048 integer :: irep, nreplica
1052 write(index_str,
'(a)')
''
1055 nreplica = product(supercell(1:space%dim))
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)
1063 do idir = space%periodic_dim + 1, 3
1064 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
1067 if(space%is_periodic())
then
1068 if(index_ == 1)
then
1069 select case(space%periodic_dim)
1071 write(iunit,
'(a)')
'CRYSTAL'
1073 write(iunit,
'(a)')
'SLAB'
1075 write(iunit,
'(a)')
'POLYMER'
1079 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
1081 do idir = 1, space%dim
1083 latt%rlattice(idir2, idir)*supercell(idir)), idir2 = 1, space%dim)
1086 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
1087 if(.not.
present(extra_atom))
then
1088 write(iunit,
'(i10, a)')
size(atoms)*nreplica,
' 1'
1090 write(iunit,
'(i10, a)')
size(atoms)*nreplica+1,
' 1'
1093 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
1097 do irep = 1, nreplica
1099 do iatom = 1,
size(atoms)
1100 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
1102 - offset(idir)), idir = 1, space%dim)
1106 if(
present(extra_atom))
then
1107 write(iunit,
'(a10, 3f12.6)', advance=
'no')
'X', &
1116#if defined(HAVE_NETCDF)
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
1123 integer,
intent(inout) :: ierr
1125 push_sub(ncdf_error)
1127 if (status == nf90_noerr)
then
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))
1139 end subroutine ncdf_error
1144 real(real64),
intent(in) :: in(:, :, :)
1145 real(real64),
contiguous,
intent(out) :: out(:, :, :)
1146 integer :: ix, iy, iz
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)
1163#include "io_function_inc.F90"
1166#include "complex.F90"
1167#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://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)
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)
Some general things and nomenclature:
subroutine, public parse_block_string(blk, l, c, res, convert_to_c)
integer function, public parse_block(namespace, name, blk, check_varinfo_)
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
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.
This is defined even when running serial.