59 character(len=256) :: config_str
106 type(electrons_t),
pointer :: sys
108 character(MAX_PATH_LEN) :: basename, folder, ref_name, ref_folder, folder_default
109 integer :: c_start, c_end, c_step, c_start_default, length, c_how
110 logical :: iterate_folder, subtract_file
111 integer,
parameter :: CONVERT_FORMAT = 1, fourier_transform = 2, operation = 3
119 message(1) =
'Info: Converting files'
134 if (basename ==
" ") basename =
""
136 length = len_trim(basename)
138 if (basename(length-3:length) ==
'.obf')
then
139 basename = trim(basename(1:length-4))
171 if (iterate_folder)
then
172 folder_default =
'output_iter/td.'
175 folder_default =
'restart'
224 if (ref_name ==
" ") ref_name =
""
226 length = len_trim(ref_name)
228 if (ref_name(length-3:length) ==
'.obf')
then
229 ref_name = trim(ref_name(1:length-4))
256 CASE(fourier_transform)
259 c_start, c_end, c_step, sys%outp, subtract_file, &
260 ref_name, ref_folder)
264 c_start, c_end, c_step, sys%outp, iterate_folder, &
265 subtract_file, ref_name, ref_folder)
268 safe_deallocate_p(sys)
276 subroutine convert_low(mesh, namespace, space, ions, psolver, mc, basename, in_folder, c_start, c_end, c_step, outp, &
277 iterate_folder, subtract_file, ref_name, ref_folder)
278 class(
mesh_t),
intent(in) :: mesh
280 class(
space_t),
intent(in) :: space
281 type(
ions_t),
intent(in) :: ions
284 character(len=*),
intent(inout) :: basename
285 character(len=*),
intent(in) :: in_folder
286 integer,
intent(in) :: c_start
287 integer,
intent(in) :: c_end
288 integer,
intent(in) :: c_step
290 logical,
intent(in) :: iterate_folder
292 logical,
intent(in) :: subtract_file
293 character(len=*),
intent(inout) :: ref_name
294 character(len=*),
intent(inout) :: ref_folder
297 integer :: ierr, ii, folder_index, output_i
298 character(MAX_PATH_LEN) :: filename, out_name, folder, frmt, restart_folder
299 real(real64),
allocatable :: read_ff(:), read_rff(:), pot(:)
303 safe_allocate(read_ff(1:mesh%np))
304 safe_allocate(read_rff(1:mesh%np))
305 safe_allocate(pot(1:mesh%np))
308 write(
message(1),
'(5a,i5,a,i5,a,i5)')
"Converting '", trim(in_folder),
"/", trim(basename), &
309 "' from ", c_start,
" to ", c_end,
" every ", c_step
312 if (subtract_file)
then
313 write(
message(1),
'(a,a,a,a)')
"Reading ref-file from ", trim(ref_folder), trim(ref_name),
".obf"
315 dir=trim(ref_folder), mesh = mesh)
321 write(
message(1),
'(2a)')
"Failed to read from ref-file ", trim(ref_name)
322 write(
message(2),
'(2a)')
"from folder ", trim(ref_folder)
330 if (iterate_folder)
then
332 folder = in_folder(1:len_trim(in_folder)-1)
333 folder_index = index(folder,
'/', .
true.)
334 if(folder_index > 0) restart_folder = folder(1:folder_index)
336 restart_folder = in_folder
339 dir=trim(restart_folder), mesh = mesh)
341 do ii = c_start, c_end, c_step
342 if (iterate_folder)
then
344 write(folder,
'(a,i0.7,a)') in_folder(folder_index+1:len_trim(in_folder)-1),ii,
"/"
345 write(filename,
'(a,a,a)') trim(folder), trim(basename)
346 out_name = trim(basename)
349 if (c_start /= c_end)
then
353 write(frmt,
'(a,i0,a)')
"(a,i0.",10-len_trim(basename),
")"
354 write(filename, fmt=trim(frmt)) trim(basename), ii
355 write(out_name,
'(a)') trim(filename)
358 write(filename,
'(a,a,a,a)') trim(folder),
"/", trim(basename)
360 write(out_name,
'(a)') trim(basename)
368 write(
message(1),
'(a,a)')
"Error reading the file ", trim(filename)
369 write(
message(2),
'(a,i4)')
"Error code: ",ierr
370 write(
message(3),
'(a)')
"Skipping...."
374 if (subtract_file)
then
375 read_ff(:) = read_ff(:) - read_rff(:)
376 write(out_name,
'(a,a)') trim(out_name),
"-ref"
379 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
380 if (outp%how(output_i) /= 0)
then
382 trim(out_name), namespace, space, mesh, read_ff,
units_out%length**(-space%dim), ierr, &
383 pos=ions%pos, atoms=ions%atom)
386 if (outp%what(option__output__potential))
then
387 write(out_name,
'(a)')
"potential"
389 call dio_function_output(outp%how(option__output__potential), trim(restart_folder)//trim(folder), &
390 trim(out_name), namespace, space, mesh, pot,
units_out%energy, ierr, pos=ions%pos, atoms=ions%atom)
398 safe_deallocate_a(read_ff)
399 safe_deallocate_a(read_rff)
400 safe_deallocate_a(pot)
407 subroutine convert_transform(mesh, namespace, space, ions, mc, kpoints, basename, in_folder, c_start, c_end, c_step, outp, &
408 subtract_file, ref_name, ref_folder)
409 class(
mesh_t),
intent(in) :: mesh
411 class(
space_t),
intent(in) :: space
412 type(
ions_t),
intent(in) :: ions
415 character(len=*),
intent(inout) :: basename
416 character(len=*),
intent(in) :: in_folder
417 integer,
intent(in) :: c_start
418 integer,
intent(in) :: c_end
419 integer,
intent(in) :: c_step
421 logical,
intent(in) :: subtract_file
422 character(len=*),
intent(inout) :: ref_name
423 character(len=*),
intent(inout) :: ref_folder
425 integer :: ierr, i_space, i_time, nn(1:3), optimize_parity(1:3), wd_info, output_i
426 integer :: i_energy, e_end, e_start, e_point, chunk_size, read_count, t_point
427 logical :: optimize(1:3)
428 integer :: folder_index
429 character(MAX_PATH_LEN) :: filename, folder, restart_folder
430 real(real64) :: fdefault, w_max
431 real(real64),
allocatable :: read_ft(:), read_rff(:), point_tmp(:,:)
433 integer,
parameter :: FAST_FOURIER = 1, standard_fourier = 2
437 type(
batch_t) :: tdrho_b, wdrho_b
438 real(real64),
allocatable :: tdrho_a(:,:,:), wdrho_a(:,:,:)
442 complex(real64),
allocatable :: out_fft(:)
444 real(real64) :: start_time
445 integer :: time_steps
448 real(real64) :: max_energy
449 real(real64) :: min_energy
457 write(
message(1),
'(a)')
'Input: TDTimeStep must be positive.'
458 write(
message(2),
'(a)')
'Input: TDTimeStep reset to 0. Check input file'
462 call io_mkdir(
'wd.general', namespace)
485 call parse_variable(namespace,
'ConvertReadSize', mesh%np, chunk_size)
488 if (chunk_size == 0) chunk_size = mesh%np
490 if (mesh%mpi_grp%size > 1 .and. chunk_size /= mesh%np)
then
491 write(
message(1),*)
'Incompatible value for ConvertReadSize and Parallelizaion in Domains'
492 write(
message(2),*)
'Use the default value for ConvertReadSize (or set it to 0)'
497 start_time = c_start * dt
499 time_steps = (c_end - c_start) / c_step
512 if (max_energy > w_max)
then
513 write(
message(1),
'(a,f12.7)')
'Impossible to set ConvertEnergyMax to ', &
515 write(
message(2),
'(a)')
'ConvertEnergyMax is too large.'
516 write(
message(3),
'(a,f12.7,a)')
'ConvertEnergyMax reset to ', &
540 safe_allocate(read_ft(0:time_steps))
542 safe_allocate(read_rff(1:mesh%np))
544 select case (ft_method)
546 nn(1) = time_steps + 1
549 safe_allocate(out_fft(0:time_steps))
553 case (standard_fourier)
563 fdefault =
m_two *
m_pi / (dt * time_steps)
569 spectrum%start_time = c_start * dt
570 spectrum%end_time = c_end * dt
571 spectrum%energy_step = dw
572 spectrum%max_energy = max_energy
573 safe_allocate(tdrho_a(0:time_steps, 1, 1))
574 safe_allocate(wdrho_a(0:time_steps, 1, 1))
580 call kick_init(kick, namespace, space, kpoints, 1)
582 e_start = nint(min_energy / dw)
583 e_end = nint(max_energy / dw)
584 write(
message(1),
'(a,1x,i0.7,a,f12.7,a,i0.7,a,f12.7,a)')
'Frequency index:',e_start,
'(',&
590 if (subtract_file)
then
591 write(
message(1),
'(a,a,a,a)')
"Reading ref-file from ", trim(ref_folder), trim(ref_name),
".obf"
594 dir=trim(ref_folder), mesh = mesh)
600 write(
message(1),
'(2a)')
"Failed to read from ref-file ", trim(ref_name)
601 write(
message(2),
'(2a)')
"from folder ", trim(ref_folder)
607 do i_energy = e_start, e_end
608 write(filename,
'(a14,i0.7,a1)')
'wd.general/wd.',i_energy,
'/'
609 write(
message(1),
'(a,a,f12.7,a,1x,i7,a)')trim(filename),
' w =', &
614 call io_mkdir(trim(filename), namespace)
618 if (mesh%parallel_in_domains)
then
620 folder = in_folder(1:len_trim(in_folder)-1)
621 folder_index = index(folder,
'/', .
true.)
622 restart_folder = folder(1:folder_index)
624 dir=trim(restart_folder), mesh = mesh)
630 safe_allocate(point_tmp(1:chunk_size, 0:time_steps))
633 do i_space = 1, mesh%np
636 do i_time = c_start, c_end, c_step
638 if (mesh%parallel_in_domains .and. i_space == 1)
then
639 write(folder,
'(a,i0.7,a)') in_folder(folder_index+1:len_trim(in_folder)-1),i_time,
"/"
640 write(filename,
'(a,a,a)') trim(folder), trim(basename)
645 write(folder,
'(a,i0.7,a)') in_folder(1:len_trim(in_folder)-1),i_time,
"/"
646 write(filename,
'(a,a,a,a)') trim(folder), trim(basename),
".obf"
647 if (mod(i_space-1, chunk_size) == 0)
then
653 if (i_time == c_start) read_count = 0
657 if (ierr /= 0 .and. i_space == 1)
then
658 write(
message(1),
'(a,a,2i10)')
"Error reading the file ", trim(filename), i_space, i_time
659 write(
message(2),
'(a)')
"Skipping...."
660 write(
message(3),
'(a,i0)')
"Error :", ierr
665 if (i_time == c_start) read_count = read_count + 1
666 if (subtract_file)
then
667 read_ft(t_point) = point_tmp(read_count, t_point) - read_rff(i_space)
669 read_ft(t_point) = point_tmp(read_count, t_point)
672 t_point = t_point + 1
675 select case (ft_method)
681 point_tmp(read_count, 0:time_steps) = aimag(out_fft(0:time_steps)) * dt
682 case (standard_fourier)
683 tdrho_a(0:time_steps, 1, 1) = read_ft(0:time_steps)
686 call spectrum_signal_damp(spectrum%damp, spectrum%damp_factor, c_start + 1, c_start + time_steps + 1, &
687 kick%time, dt, tdrho_b)
689 c_start + 1, c_start + time_steps + 1, kick%time, dt, tdrho_b, min_energy, max_energy, &
690 spectrum%energy_step, wdrho_b)
693 do e_point = e_start, e_end
694 point_tmp(read_count, e_point) = - wdrho_a(e_point, 1, 1)
698 if (mod(i_space-1, 1000) == 0 .and.
mpi_world%rank == 0)
then
703 if (mesh%mpi_grp%size == 1)
then
704 if (mod(i_space, chunk_size) == 0)
then
706 write(
message(2),
'(a,i0)')
"Writing binary output: step ", i_space/chunk_size
708 do i_energy = e_start, e_end
709 write(filename,
'(a14,i0.7,a12)')
'wd.general/wd.',i_energy,
'/density.obf'
711 if (i_space == chunk_size)
then
722 if (mesh%mpi_grp%size == 1)
then
723 if (mod(mesh%np, chunk_size) /= 0)
then
724 do i_energy = e_start, e_end
725 write(filename,
'(a14,i0.7,a12)')
'wd.general/wd.',i_energy,
'/density.obf'
726 if (mesh%np < chunk_size)
call dwrite_header(trim(filename), mesh%np_global, ierr)
728 point_tmp(1:mod(mesh%np, chunk_size), i_energy), ierr, nohead=.
true.)
734 call mesh%mpi_grp%barrier()
736 if (mesh%parallel_in_domains)
then
737 do i_energy = e_start, e_end
738 write(filename,
'(a14,i0.7,a1)')
'wd.general/wd.',i_energy,
'/'
739 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
740 if (outp%how(output_i) /= 0)
then
742 trim(
'density'), namespace, space, mesh, point_tmp(:, i_energy), &
743 units_out%length**(-space%dim), ierr, pos=ions%pos, atoms=ions%atom)
750 if (any(outp%how /= option__outputformat__binary))
then
751 do i_energy = e_start, e_end
752 write(filename,
'(a14,i0.7,a1)')
'wd.general/wd.',i_energy,
'/'
754 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
755 if ((outp%how(output_i) /= 0) .and. (outp%how(output_i) /= option__outputformat__binary))
then
757 trim(
'density'), namespace, space, mesh, read_rff, &
758 units_out%length**(-space%dim), ierr, pos=ions%pos, atoms=ions%atom)
765 safe_deallocate_a(point_tmp)
766 safe_deallocate_a(read_ft)
767 safe_deallocate_a(read_rff)
769 select case (ft_method)
771 safe_deallocate_a(out_fft)
772 case (standard_fourier)
773 safe_deallocate_a(tdrho_a)
774 safe_deallocate_a(wdrho_a)
785 class(
mesh_t),
intent(in) :: mesh
787 class(
space_t),
intent(in) :: space
788 type(
ions_t),
intent(in) :: ions
792 integer :: ierr, ip, i_op, length, n_operations, output_i
796 real(real64) :: f_re, f_im
797 real(real64),
allocatable :: tmp_ff(:), scalar_ff(:)
799 character(len=200) :: var, scalar_expression
800 character(len=MAX_PATH_LEN) :: folder, filename, out_folder, out_filename
816 if (
parse_block(namespace,
'ConvertScalarOperation', blk) == 0)
then
820 if (n_operations == 0)
then
821 write(
message(1),
'(a)')
'No operations found. Check the input file'
832 call parse_variable(namespace,
'ConvertOutputFolder',
"convert", out_folder)
834 call io_mkdir(out_folder, namespace)
844 call parse_variable(namespace,
'ConvertOutputFilename',
'density', out_filename)
846 safe_allocate(tmp_ff(1:mesh%np))
847 safe_allocate(scalar_ff(1:mesh%np))
850 do i_op = 1, n_operations
859 length = len_trim(filename)
861 if (filename(length-3:length) ==
'.obf')
then
862 filename = trim(filename(1:length-4))
868 dir=trim(folder), mesh = mesh, exact=.
true.)
872 write(
message(1),
'(2a)')
"Failed to read mesh function ", trim(filename)
873 write(
message(2),
'(a,i0)')
"Error code: ", ierr
877 write(
message(1),
'(2a)')
"Failed to read from file ", trim(filename)
878 write(
message(2),
'(2a)')
"from folder ", trim(folder)
885 call parse_expression(f_re, f_im, trim(var), real(tmp_ff(ip), real64), trim(scalar_expression))
887 scalar_ff(ip) = scalar_ff(ip) + f_re
896 call mesh%mpi_grp%barrier()
901 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
902 if (outp%how(output_i) /= 0)
then
903 call dio_function_output(outp%how(output_i), trim(out_folder), trim(out_filename), namespace, space, mesh, &
904 scalar_ff, units, ierr, pos=ions%pos, atoms=ions%atom)
908 safe_deallocate_a(tmp_ff)
909 safe_deallocate_a(scalar_ff)
program oct_convert
This utility runs in parallel and can be used for post-processing of the results of Output.
subroutine convert_low(mesh, namespace, space, ions, psolver, mc, basename, in_folder, c_start, c_end, c_step, outp, iterate_folder, subtract_file, ref_name, ref_folder)
Giving a range of input files, it writes the corresponding output files.
subroutine convert_operate(mesh, namespace, space, ions, mc, outp)
Given a set of mesh function operations it computes a a resulting mesh function from linear combinati...
subroutine convert_transform(mesh, namespace, space, ions, mc, kpoints, basename, in_folder, c_start, c_end, c_step, outp, subtract_file, ref_name, ref_folder)
Giving a range of input files, it computes the Fourier transform of the file.
initialize a batch with existing memory
Each program/utility that needs to use the getopt features should have an interface here – the defini...
Prints out to iunit a message in the form: ["InputVariable" = value] where "InputVariable" is given b...
static void convert(multi *in, multi *out, int t_in, int t_out)
This module implements batches of mesh functions.
This module handles the calculation mode.
type(calc_mode_par_t), public calc_mode_par
Singleton instance of parallel calculation mode.
integer, parameter, public p_strategy_states
parallelization in states
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
subroutine, public fft_init(this, nn, dim, type, library, optimize, optimize_parity, comm, mpi_grp, use_aligned)
subroutine, public fft_all_init(namespace)
initialize the table
subroutine, public fft_all_end()
delete all plans
integer, parameter, public fft_real
integer, parameter, public fftlib_fftw
real(real64), parameter, public m_two
subroutine, public global_end()
Finalise parser varinfo file, and MPI.
real(real64), parameter, public m_zero
real(real64), parameter, public m_pi
some mathematical constants
subroutine, public global_init(communicator)
Initialise Octopus.
subroutine, public dwrite_header(fname, np_global, ierr)
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, public io_init(defaults)
If the argument defaults is present and set to true, then the routine will not try to read anything f...
subroutine, public io_close(iunit, grp)
subroutine, public io_end()
subroutine, public io_mkdir(fname, namespace, parents)
integer function, public io_open(file, namespace, action, status, form, position, die, recl, grp)
subroutine, public kick_end(kick)
subroutine, public kick_init(kick, namespace, space, kpoints, nspin)
This module defines the meshes, which are used in Octopus.
subroutine, public messages_end()
subroutine, public messages_print_with_emphasis(msg, iunit, namespace)
character(len=512), private msg
subroutine, public messages_init(output_dir)
subroutine, public messages_warning(no_lines, all_nodes, namespace)
subroutine, public print_date(str)
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_experimental(name, namespace)
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
type(mpi_grp_t), public mpi_world
This module handles the communicators for the various parallelization strategies.
type(namespace_t), public global_namespace
this module contains the low-level part of the output system
this module contains the output system
subroutine, public parser_init()
Initialise the Octopus parser.
subroutine, public parser_end()
End the Octopus parser.
integer function, public parse_block(namespace, name, blk, check_varinfo_)
subroutine, public dpoisson_solve(this, namespace, pot, rho, all_nodes, kernel, reset)
Calculates the Poisson equation. Given the density returns the corresponding potential.
subroutine, public profiling_end(namespace)
subroutine, public profiling_out(label)
Increment out counter and sum up difference between entry and exit time.
subroutine, public profiling_in(label, exclude)
Increment in counter and save entry time.
subroutine, public profiling_init(namespace)
Create profiling subdirectory.
subroutine, public restart_module_init(namespace)
integer, parameter, public restart_undefined
subroutine, public restart_init(restart, namespace, data_type, type, mc, ierr, mesh, dir, exact)
Initializes a restart object.
integer, parameter, public restart_type_load
subroutine, public restart_end(restart)
subroutine, public spectrum_fourier_transform(method, transform, noise, time_start, time_end, t0, time_step, time_function, energy_start, energy_end, energy_step, energy_function)
Computes the sine, cosine, (or "exponential") Fourier transform of the real function given in the tim...
subroutine, public spectrum_init(spectrum, namespace, default_energy_step, default_max_energy)
subroutine, public spectrum_signal_damp(damp_type, damp_factor, time_start, time_end, t0, time_step, time_function)
subroutine, public add_last_slash(str)
Adds a '/' in the end of the string, only if it missing. Useful for directories.
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
subroutine, public unit_system_init(namespace)
type(unit_system_t), public units_inp
the units systems for reading and writing
This module is intended to contain simple general-purpose utility functions and procedures.
character(len=256) function, public get_config_opts()
character(len=256) function, public get_optional_libraries()
subroutine, public print_header()
This subroutine prints the logo followed by information about the compilation and the system....
Class defining batches of mesh functions.
Class describing the electron system.
Describes mesh distribution to nodes.
Stores all communicators and groups.