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(13)
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')
487 option__output__matrix_elements, &
488 option__output__berkeleygw, &
489 option__output__dos, &
490 option__output__tpa, &
491 option__output__mmb_den, &
492 option__output__j_flow, &
493 option__output__occ_matrices, &
494 option__output__effectiveu, &
495 option__output__magnetization, &
496 option__output__kanamoriu, &
497 option__output__stress, &
498 option__output__jdos, &
499 option__output__pdos &
502 if (
parse_block(namespace, what_tag, blk) == 0)
then
504 do iout = 0, nrows - 1
520 what(what_i) = .
true.
521 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
522 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
523 .or. (what_tag /=
'Output'))
then
531 else if (ncols == 2)
then
544 what(what_i) = .
true.
545 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
546 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
547 .or. (what_tag /=
'Output'))
then
549 if (how(what_i) == 0)
call parse_variable(namespace, how_tag, 0, how(what_i))
576 what(what_i) = .
true.
577 do column_index = 0, 1
579 if (output_column_marker ==
'output_interval')
then
581 else if (output_column_marker ==
'output_format')
then
582 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
583 .or. (what_tag /=
'Output'))
then
589 else if (len_trim(output_column_marker) /= 0)
then
594 if (output_interval(what_i) == 0)
then
595 call parse_variable(namespace, output_interval_tag, 50, output_interval(what_i))
597 if (how(what_i) == 0)
then
598 if (((what_tag ==
'Output') .and. (.not. any(what_no_how == what_i)))&
599 .or. (what_tag /=
'Output'))
then
618 call parse_variable(namespace, output_interval_tag, 50, output_interval(0))
622 do what_i = lbound(what, 1), ubound(what, 1)
623 if (what_tag ==
'Output')
then
624 if (what(what_i) .and. (.not. any(what_no_how == what_i)))
then
629 if (how(what_i) == 0 .and. .not.
optional_default(ignore_error, .false.))
then
630 write(
message(1),
'(a)')
'Must specify output method with variable OutputFormat.'
635 if (space%dim == 1)
then
636 if (
bitand(how(what_i), option__outputformat__axis_y) /= 0)
then
637 message(1) =
"OutputFormat = axis_y not available with Dimensions = 1."
640 if (
bitand(how(what_i), option__outputformat__plane_z) /= 0)
then
641 message(1) =
"OutputFormat = plane_z not available with Dimensions = 1."
644 if (
bitand(how(what_i), option__outputformat__xcrysden) /= 0)
then
645 message(1) =
"OutputFormat = xcrysden not available with Dimensions = 1."
650 if (space%dim <= 2)
then
651 if (
bitand(how(what_i), option__outputformat__axis_z) /= 0)
then
652 message(1) =
"OutputFormat = axis_z not available with Dimensions <= 2."
655 if (
bitand(how(what_i), option__outputformat__plane_x) /= 0)
then
656 message(1) =
"OutputFormat = plane_x not available with Dimensions <= 2."
659 if (
bitand(how(what_i), option__outputformat__plane_y) /= 0)
then
660 message(1) =
"OutputFormat = plane_y not available with Dimensions <= 2."
663 if (
bitand(how(what_i), option__outputformat__integrate_xy) /= 0)
then
664 message(1) =
"OutputFormat = integrate_xy not available with Dimensions <= 2."
667 if (
bitand(how(what_i), option__outputformat__integrate_xz) /= 0)
then
668 message(1) =
"OutputFormat = integrate_xz not available with Dimensions <= 2."
671 if (
bitand(how(what_i), option__outputformat__integrate_yz) /= 0)
then
672 message(1) =
"OutputFormat = integrate_yz not available with Dimensions <= 2."
675 if (
bitand(how(what_i), option__outputformat__dx) /= 0)
then
676 message(1) =
"OutputFormat = dx not available with Dimensions <= 2."
679 if (
bitand(how(what_i), option__outputformat__cube) /= 0)
then
680 message(1) =
"OutputFormat = cube not available with Dimensions <= 2."
683 if (
bitand(how(what_i), option__outputformat__poscar) /= 0)
then
684 message(1) =
"OutputFormat = POSCAR not available with Dimensions <= 2."
689 if (space%periodic_dim<=2)
then
690 if (
bitand(how(what_i), option__outputformat__poscar) /= 0)
then
691 message(1) =
"OutputFormat = POSCAR not available with periodic_dim <= 2."
696#if !defined(HAVE_NETCDF)
697 if (
bitand(how(what_i), option__outputformat__netcdf) /= 0)
then
698 message(1) =
'Octopus was compiled without NetCDF support.'
699 message(2) =
'It is not possible to write output in NetCDF format.'
703#if !defined(HAVE_ETSF_IO)
704 if (
bitand(how(what_i), option__outputformat__etsf) /= 0)
then
705 message(1) =
'Octopus was compiled without ETSF_IO support.'
706 message(2) =
'It is not possible to write output in ETSF format.'
715 if (output_interval(what_i) < 0)
then
716 message(1) =
"OutputInterval must be >= 0."
730 character(len=*),
intent(in) :: where
735 if (index(
where,
"AxisX") /= 0) how = ior(how, option__outputformat__axis_x)
736 if (index(
where,
"AxisY") /= 0) how = ior(how, option__outputformat__axis_y)
737 if (index(
where,
"AxisZ") /= 0) how = ior(how, option__outputformat__axis_z)
738 if (index(
where,
"PlaneX") /= 0) how = ior(how, option__outputformat__plane_x)
739 if (index(
where,
"PlaneY") /= 0) how = ior(how, option__outputformat__plane_y)
740 if (index(
where,
"PlaneZ") /= 0) how = ior(how, option__outputformat__plane_z)
741 if (index(
where,
"IntegrateXY") /= 0) how = ior(how, option__outputformat__integrate_xy)
742 if (index(
where,
"IntegrateXZ") /= 0) how = ior(how, option__outputformat__integrate_xz)
743 if (index(
where,
"IntegrateYZ") /= 0) how = ior(how, option__outputformat__integrate_yz)
744 if (index(
where,
"DX") /= 0) how = ior(how, option__outputformat__dx)
745 if (index(
where,
"XCrySDen") /= 0) how = ior(how, option__outputformat__xcrysden)
746 if (index(
where,
"Binary") /= 0) how = ior(how, option__outputformat__binary)
747 if (index(
where,
"MeshIndex") /= 0) how = ior(how, option__outputformat__mesh_index)
748 if (index(
where,
"XYZ") /= 0) how = ior(how, option__outputformat__xyz)
749#if defined(HAVE_NETCDF)
750 if (index(
where,
"NETCDF") /= 0) how = ior(how, option__outputformat__netcdf)
752 if (index(
where,
"Cube") /= 0) how = ior(how, option__outputformat__cube)
753 if (index(
where,
"VTK") /= 0) how = ior(how, option__outputformat__vtk)
754 if (index(
where,
"ASCII") /= 0) how = ior(how, option__outputformat__ascii)
755 if (index(
where,
"Bild") /= 0) how = ior(how, option__outputformat__bild)
766 character(len=*),
intent(in) :: fname
767 real(real64),
intent(in) :: pos(:,:)
768 character(len=*),
intent(in) :: species(:)
769 character(len=*),
optional,
intent(in) :: header
771 integer :: iunit, n_atoms, iatom, min_dim
772 real(real64) :: position(3)
776 n_atoms =
size(pos, 2)
777 assert(
size(species) == n_atoms)
779 iunit =
io_open(trim(fname)//
'.xyz', namespace, action=
'write', position=
'asis')
781 write(iunit,
'(i6)') n_atoms
782 if (
present(header))
then
783 write(iunit,
'(a)') trim(adjustl(header))
789 min_dim = min(
size(pos, 1), 3)
790 position(1:3) = 0.0_real64
793 do iatom = 1, n_atoms
794 position(1:min_dim) = pos(1:min_dim, iatom)
795 write(iunit,
'(a10, 3(1x, f15.10))') trim(adjustl(species(iatom))), &
811 character(len=*),
intent(in) :: dir
812 character(len=*),
intent(in) :: fname
813 class(
space_t),
intent(in) :: space
815 real(real64),
intent(in) :: pos(:,:)
816 type(
atom_t),
intent(in) :: atoms(:)
817 class(
box_t),
intent(in) :: box
821 character(len=:),
allocatable :: info_str, dir_fname
822 character(len=LABEL_LEN),
allocatable :: species(:)
828 info_str = trim(space%short_info()) //
'; ' // trim(box%short_info(
unit_angstrom))
829 if (space%is_periodic())
then
830 info_str = info_str //
'; ' // trim(latt%short_info(
unit_angstrom))
833 safe_allocate(species(1:
size(atoms)))
834 do ia = 1,
size(atoms)
835 species(ia) = atoms(ia)%get_label()
838 dir_fname = trim(dir) //
'/' // trim(fname)
841 safe_deallocate_a(species)
848 character(len=*),
intent(in) :: dir, fname
849 class(
space_t),
intent(in) :: space
851 real(real64),
intent(in) :: pos(:,:)
852 type(
atom_t),
intent(in) :: atoms(:)
853 class(
mesh_t),
intent(in) :: mesh
855 real(real64),
optional,
intent(in) :: total_forces(:,:)
858 real(real64),
allocatable :: forces(:,:)
865 iunit =
io_open(trim(dir)//
'/'//trim(fname)//
'.xsf', namespace, action=
'write', position=
'asis')
867 if (
present(total_forces))
then
868 safe_allocate(forces(1:space%dim, 1:
size(atoms)))
871 safe_deallocate_a(forces)
885 integer,
intent(in) :: iunit
886 class(
space_t),
intent(in) :: space
888 real(real64),
intent(in) :: pos(:,:)
889 type(
atom_t),
intent(in) :: atoms(:)
890 class(
mesh_t),
intent(in) :: mesh
891 real(real64),
optional,
intent(in) :: forces(:, :)
892 integer,
optional,
intent(in) :: index
894 integer :: idir, idir2, iatom, index_, natoms
895 character(len=7) :: index_str
896 real(real64) :: offset(space%dim)
897 real(real64) :: rlattice(space%dim, space%dim)
901 if (
present(index))
then
902 write(index_str,
'(a,i6)')
' ', index
905 write(index_str,
'(a)')
''
908 natoms =
size(pos, dim=2)
914 offset(1:space%dim) = latt%red_to_cart(spread(-
m_half, 1, space%dim))
916 do idir = space%periodic_dim + 1, space%dim
917 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
920 if (space%is_periodic())
then
921 if (index_ == 1)
then
922 select case (space%periodic_dim)
924 write(iunit,
'(a)')
'CRYSTAL'
926 write(iunit,
'(a)')
'SLAB'
928 write(iunit,
'(a)')
'POLYMER'
932 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
935 rlattice = latt%rlattice
936 do idir = space%periodic_dim+1, space%dim
937 rlattice(:,idir) = rlattice(:,idir)*
m_two*mesh%box%bounding_box_l(idir)
940 do idir = 1, space%dim
944 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
945 write(iunit,
'(i10, a)') natoms,
' 1'
947 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
952 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
954 if (
present(forces))
then
955 write(iunit,
'(5x, 3f12.6)', advance=
'no') forces(:, iatom)
967 integer,
intent(in) :: iunit
968 class(
space_t),
intent(in) :: space
970 real(real64),
intent(in) :: pos(:,:)
971 type(
atom_t),
intent(in) :: atoms(:)
972 class(
mesh_t),
intent(in) :: mesh
973 real(real64),
intent(in) :: centers(:, :)
974 integer,
intent(in) :: supercell(:)
975 real(real64),
optional,
intent(in) :: extra_atom(:)
977 integer :: idir, idir2, iatom, index_
978 character(len=7) :: index_str
979 real(real64) :: offset(3)
980 integer :: irep, nreplica
984 write(index_str,
'(a)')
''
987 nreplica = product(supercell(1:space%dim))
992 offset(1:space%dim) = latt%red_to_cart(spread(-
m_half, 1, space%dim))
993 offset(1:3) = offset(1:3) + centers(1:3,1)
995 do idir = space%periodic_dim + 1, 3
996 offset(idir) = -(mesh%idx%ll(idir) - 1)/2 * mesh%spacing(idir)
999 if(space%is_periodic())
then
1000 if(index_ == 1)
then
1001 select case(space%periodic_dim)
1003 write(iunit,
'(a)')
'CRYSTAL'
1005 write(iunit,
'(a)')
'SLAB'
1007 write(iunit,
'(a)')
'POLYMER'
1011 write(iunit,
'(a)')
'PRIMVEC'//trim(index_str)
1013 do idir = 1, space%dim
1015 latt%rlattice(idir2, idir)*supercell(idir)), idir2 = 1, space%dim)
1018 write(iunit,
'(a)')
'PRIMCOORD'//trim(index_str)
1019 if(.not.
present(extra_atom))
then
1020 write(iunit,
'(i10, a)')
size(atoms)*nreplica,
' 1'
1022 write(iunit,
'(i10, a)')
size(atoms)*nreplica+1,
' 1'
1025 write(iunit,
'(a)')
'ATOMS'//trim(index_str)
1029 do irep = 1, nreplica
1031 do iatom = 1,
size(atoms)
1032 write(iunit,
'(a10, 3f12.6)', advance=
'no') trim(atoms(iatom)%label), &
1034 - offset(idir)), idir = 1, space%dim)
1038 if(
present(extra_atom))
then
1039 write(iunit,
'(a10, 3f12.6)', advance=
'no')
'X', &
1048#if defined(HAVE_NETCDF)
1050 subroutine ncdf_error(func, status, filename, namespace, ierr)
1051 character(len=*),
intent(in) ::
func
1052 integer,
intent(in) :: status
1053 character(len=*),
intent(in) :: filename
1055 integer,
intent(inout) :: ierr
1057 push_sub(ncdf_error)
1059 if (status == nf90_noerr)
then
1064 write(
message(1),
'(3a)')
"NETCDF error in function '" , trim(
func) ,
"'"
1065 write(
message(2),
'(3a)')
"(reading/writing ", trim(filename) ,
")"
1066 write(
message(3),
'(6x,a,a)')
'Error code = ', trim(nf90_strerror(status))
1071 end subroutine ncdf_error
1076 real(real64),
intent(in) :: in(:, :, :)
1077 real(real64),
intent(out) :: out(:, :, :)
1078 integer :: ix, iy, iz
1082 do ix = lbound(in, 1), ubound(in, 1)
1083 do iy = lbound(in, 2), ubound(in, 2)
1084 do iz = lbound(in, 3), ubound(in, 3)
1085 out(iz, iy, ix) = in(ix, iy, iz)
1095#include "io_function_inc.F90"
1098#include "complex.F90"
1099#include "io_function_inc.F90"
real(real64) function func(r1, rn, n, a)
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 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)
type(mpi_grp_t), public mpi_world
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_)
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.