64 character(len=256) :: config_str
110 class(electrons_t),
pointer :: sys
112 character(MAX_PATH_LEN) :: basename, folder, ref_name, ref_folder, folder_default
113 integer :: c_start, c_end, c_step, c_start_default, length, c_how
114 logical :: iterate_folder, subtract_file
115 integer,
parameter :: CONVERT_FORMAT = 1, fourier_transform = 2, operation = 3
122 message(1) =
'Info: Converting files'
137 if (basename ==
" ") basename =
""
139 length = len_trim(basename)
141 if (basename(length-3:length) ==
'.obf')
then
142 basename = trim(basename(1:length-4))
174 if (iterate_folder)
then
175 folder_default =
'output_iter/td.'
178 folder_default =
'restart'
227 if (ref_name ==
" ") ref_name =
""
229 length = len_trim(ref_name)
231 if (ref_name(length-3:length) ==
'.obf')
then
232 ref_name = trim(ref_name(1:length-4))
259 CASE(fourier_transform)
262 c_start, c_end, c_step, sys%outp, subtract_file, &
263 ref_name, ref_folder)
267 c_start, c_end, c_step, sys%outp, iterate_folder, &
268 subtract_file, ref_name, ref_folder)
271 safe_deallocate_p(sys)
279 subroutine convert_low(mesh, namespace, space, ions, psolver, mc, basename, in_folder, c_start, c_end, c_step, outp, &
280 iterate_folder, subtract_file, ref_name, ref_folder)
281 class(
mesh_t),
intent(in) :: mesh
283 class(
space_t),
intent(in) :: space
284 type(
ions_t),
intent(in) :: ions
287 character(len=*),
intent(inout) :: basename
288 character(len=*),
intent(in) :: in_folder
289 integer,
intent(in) :: c_start
290 integer,
intent(in) :: c_end
291 integer,
intent(in) :: c_step
293 logical,
intent(in) :: iterate_folder
295 logical,
intent(in) :: subtract_file
296 character(len=*),
intent(inout) :: ref_name
297 character(len=*),
intent(inout) :: ref_folder
300 integer :: ierr, ii, folder_index, output_i
301 character(MAX_PATH_LEN) :: filename, out_name, folder, frmt, restart_folder
302 real(real64),
allocatable :: read_ff(:), read_rff(:), pot(:)
306 safe_allocate(read_ff(1:mesh%np))
307 safe_allocate(read_rff(1:mesh%np))
308 safe_allocate(pot(1:mesh%np))
311 write(
message(1),
'(5a,i5,a,i5,a,i5)')
"Converting '", trim(in_folder),
"/", trim(basename), &
312 "' from ", c_start,
" to ", c_end,
" every ", c_step
315 if (subtract_file)
then
316 write(
message(1),
'(a,a,a,a)')
"Reading ref-file from ", trim(ref_folder), trim(ref_name),
".obf"
318 dir=trim(ref_folder), mesh = mesh)
321 call restart%read_mesh_function(trim(ref_name), mesh, read_rff, ierr)
324 write(
message(1),
'(2a)')
"Failed to read from ref-file ", trim(ref_name)
325 write(
message(2),
'(2a)')
"from folder ", trim(ref_folder)
333 if (iterate_folder)
then
335 folder = in_folder(1:len_trim(in_folder)-1)
336 folder_index = index(folder,
'/', .
true.)
337 if(folder_index > 0) restart_folder = folder(1:folder_index)
339 restart_folder = in_folder
342 dir=trim(restart_folder), mesh = mesh)
344 do ii = c_start, c_end, c_step
345 if (iterate_folder)
then
347 write(folder,
'(a,i0.7,a)') in_folder(folder_index+1:len_trim(in_folder)-1),ii,
"/"
348 write(filename,
'(a,a,a)') trim(folder), trim(basename)
349 out_name = trim(basename)
352 if (c_start /= c_end)
then
356 write(frmt,
'(a,i0,a)')
"(a,i0.",10-len_trim(basename),
")"
357 write(filename, fmt=trim(frmt)) trim(basename), ii
358 write(out_name,
'(a)') trim(filename)
361 write(filename,
'(a,a,a,a)') trim(folder),
"/", trim(basename)
363 write(out_name,
'(a)') trim(basename)
368 call restart%read_mesh_function(trim(filename), mesh, read_ff, ierr)
371 write(
message(1),
'(a,a)')
"Error reading the file ", trim(filename)
372 write(
message(2),
'(a,i4)')
"Error code: ",ierr
373 write(
message(3),
'(a)')
"Skipping...."
377 if (subtract_file)
then
378 read_ff(:) = read_ff(:) - read_rff(:)
379 write(out_name,
'(a,a)') trim(out_name),
"-ref"
382 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
383 if (outp%how(output_i) /= 0)
then
385 trim(out_name), namespace, space, mesh, read_ff,
units_out%length**(-space%dim), ierr, &
386 pos=ions%pos, atoms=ions%atom)
389 if (outp%what(option__output__potential))
then
390 write(out_name,
'(a)')
"potential"
392 call dio_function_output(outp%how(option__output__potential), trim(restart_folder)//trim(folder), &
393 trim(out_name), namespace, space, mesh, pot,
units_out%energy, ierr, pos=ions%pos, atoms=ions%atom)
401 safe_deallocate_a(read_ff)
402 safe_deallocate_a(read_rff)
403 safe_deallocate_a(pot)
410 subroutine convert_transform(mesh, namespace, space, ions, mc, kpoints, basename, in_folder, c_start, c_end, c_step, outp, &
411 subtract_file, ref_name, ref_folder)
412 class(
mesh_t),
intent(in) :: mesh
414 class(
space_t),
intent(in) :: space
415 type(
ions_t),
intent(in) :: ions
418 character(len=*),
intent(inout) :: basename
419 character(len=*),
intent(in) :: in_folder
420 integer,
intent(in) :: c_start
421 integer,
intent(in) :: c_end
422 integer,
intent(in) :: c_step
424 logical,
intent(in) :: subtract_file
425 character(len=*),
intent(inout) :: ref_name
426 character(len=*),
intent(inout) :: ref_folder
428 integer :: ierr, i_space, i_time, nn(1:3), optimize_parity(1:3), wd_info, output_i
429 integer :: i_energy, e_end, e_start, e_point, chunk_size, read_count, t_point
430 logical :: optimize(1:3)
431 integer :: folder_index
432 character(MAX_PATH_LEN) :: filename, folder, restart_folder
433 real(real64) :: fdefault, w_max
434 real(real64),
allocatable :: read_ft(:), read_rff(:), point_tmp(:,:)
436 integer,
parameter :: FAST_FOURIER = 1, standard_fourier = 2
440 type(
batch_t) :: tdrho_b, wdrho_b
441 real(real64),
allocatable :: tdrho_a(:,:,:), wdrho_a(:,:,:)
445 complex(real64),
allocatable :: out_fft(:)
447 real(real64) :: start_time
448 integer :: time_steps
451 real(real64) :: max_energy
452 real(real64) :: min_energy
460 write(
message(1),
'(a)')
'Input: TDTimeStep must be positive.'
464 call io_mkdir(
'wd.general', namespace)
487 call parse_variable(namespace,
'ConvertReadSize', mesh%np, chunk_size)
490 if (chunk_size == 0) chunk_size = mesh%np
492 if (mesh%mpi_grp%size > 1 .and. chunk_size /= mesh%np)
then
493 write(
message(1),*)
'Incompatible value for ConvertReadSize and Parallelizaion in Domains'
494 write(
message(2),*)
'Use the default value for ConvertReadSize (or set it to 0)'
499 if (c_step <= 0)
then
500 write(
message(1),
'(a)')
'Input: ConvertStep must be positive for Fourier transform.'
504 start_time = c_start * dt
506 time_steps = (c_end - c_start) / c_step
507 if (time_steps <= 0)
then
508 write(
message(1),
'(a)')
'Input: ConvertEnd must be larger than ConvertStart for Fourier transform.'
523 if (max_energy > w_max)
then
524 write(
message(1),
'(a,f12.7)')
'Impossible to set ConvertEnergyMax to ', &
526 write(
message(2),
'(a)')
'ConvertEnergyMax is too large.'
527 write(
message(3),
'(a,f12.7,a)')
'ConvertEnergyMax reset to ', &
551 safe_allocate(read_ft(0:time_steps))
553 safe_allocate(read_rff(1:mesh%np))
555 select case (ft_method)
557 nn(1) = time_steps + 1
560 safe_allocate(out_fft(0:time_steps))
565 case (standard_fourier)
575 fdefault =
m_two *
m_pi / (dt * time_steps)
581 spectrum%start_time = c_start * dt
582 spectrum%end_time = c_end * dt
583 spectrum%energy_step = dw
584 spectrum%max_energy = max_energy
585 safe_allocate(tdrho_a(0:time_steps, 1, 1))
586 safe_allocate(wdrho_a(0:time_steps, 1, 1))
592 call kick_init(kick, namespace, space, kpoints, 1)
594 e_start = nint(min_energy / dw)
595 e_end = nint(max_energy / dw)
596 write(
message(1),
'(a,1x,i0.7,a,f12.7,a,i0.7,a,f12.7,a)')
'Frequency index:',e_start,
'(',&
602 if (subtract_file)
then
603 write(
message(1),
'(a,a,a,a)')
"Reading ref-file from ", trim(ref_folder), trim(ref_name),
".obf"
606 dir=trim(ref_folder), mesh = mesh)
609 call restart%read_mesh_function(trim(ref_name), mesh, read_rff, ierr)
612 write(
message(1),
'(2a)')
"Failed to read from ref-file ", trim(ref_name)
613 write(
message(2),
'(2a)')
"from folder ", trim(ref_folder)
619 do i_energy = e_start, e_end
620 write(filename,
'(a14,i0.7,a1)')
'wd.general/wd.',i_energy,
'/'
621 write(
message(1),
'(a,a,f12.7,a,1x,i7,a)')trim(filename),
' w =', &
626 call io_mkdir(trim(filename), namespace)
630 if (mesh%parallel_in_domains)
then
632 folder = in_folder(1:len_trim(in_folder)-1)
633 folder_index = index(folder,
'/', .
true.)
634 restart_folder = folder(1:folder_index)
636 dir=trim(restart_folder), mesh = mesh)
642 safe_allocate(point_tmp(1:chunk_size, 0:time_steps))
645 do i_space = 1, mesh%np
649 do i_time = c_start, c_end, c_step
651 if (mesh%parallel_in_domains .and. i_space == 1)
then
652 write(folder,
'(a,i0.7,a)') in_folder(folder_index+1:len_trim(in_folder)-1),i_time,
"/"
653 write(filename,
'(a,a,a)') trim(folder), trim(basename)
654 call restart%read_mesh_function(trim(filename), mesh, point_tmp(:, t_point), ierr)
658 write(folder,
'(a,i0.7,a)') in_folder(1:len_trim(in_folder)-1),i_time,
"/"
659 write(filename,
'(a,a,a,a)') trim(folder), trim(basename),
".obf"
660 if (mod(i_space-1, chunk_size) == 0)
then
666 if (i_time == c_start) read_count = 0
670 if (ierr /= 0 .and. i_space == 1)
then
671 write(
message(1),
'(a,a,2i10)')
"Error reading the file ", trim(filename), i_space, i_time
672 write(
message(2),
'(a)')
"Skipping...."
673 write(
message(3),
'(a,i0)')
"Error :", ierr
678 if (i_time == c_start) read_count = read_count + 1
679 if (subtract_file)
then
680 read_ft(t_point) = point_tmp(read_count, t_point) - read_rff(i_space)
682 read_ft(t_point) = point_tmp(read_count, t_point)
685 t_point = t_point + 1
688 select case (ft_method)
695 point_tmp(read_count, 0:time_steps) = aimag(out_fft(0:time_steps)) * dt
696 case (standard_fourier)
697 tdrho_a(0:time_steps, 1, 1) = read_ft(0:time_steps)
700 call spectrum_signal_damp(spectrum%damp, spectrum%damp_factor, c_start + 1, c_start + time_steps + 1, &
701 kick%time, dt, tdrho_b)
703 c_start + 1, c_start + time_steps + 1, kick%time, dt, tdrho_b, min_energy, max_energy, &
704 spectrum%energy_step, wdrho_b)
707 do e_point = e_start, e_end
708 point_tmp(read_count, e_point) = - wdrho_a(e_point, 1, 1)
712 if (mod(i_space-1, 1000) == 0 .and.
mpi_world%is_root())
then
717 if (mesh%mpi_grp%size == 1)
then
718 if (mod(i_space, chunk_size) == 0)
then
720 write(
message(2),
'(a,i0)')
"Writing binary output: step ", i_space/chunk_size
722 do i_energy = e_start, e_end
723 write(filename,
'(a14,i0.7,a12)')
'wd.general/wd.',i_energy,
'/density.obf'
725 if (i_space == chunk_size)
then
736 if (mesh%mpi_grp%size == 1)
then
737 if (mod(mesh%np, chunk_size) /= 0)
then
738 do i_energy = e_start, e_end
739 write(filename,
'(a14,i0.7,a12)')
'wd.general/wd.',i_energy,
'/density.obf'
740 if (mesh%np < chunk_size)
call dwrite_header(trim(filename), mesh%np_global, ierr)
742 point_tmp(1:mod(mesh%np, chunk_size), i_energy), ierr, nohead=.
true.)
748 call mesh%mpi_grp%barrier()
750 if (mesh%parallel_in_domains)
then
751 do i_energy = e_start, e_end
752 write(filename,
'(a14,i0.7,a1)')
'wd.general/wd.',i_energy,
'/'
753 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
754 if (outp%how(output_i) /= 0)
then
756 trim(
'density'), namespace, space, mesh, point_tmp(:, i_energy), &
757 units_out%length**(-space%dim), ierr, pos=ions%pos, atoms=ions%atom)
764 if (any(outp%how /= option__outputformat__binary))
then
765 do i_energy = e_start, e_end
766 write(filename,
'(a14,i0.7,a1)')
'wd.general/wd.',i_energy,
'/'
768 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
769 if ((outp%how(output_i) /= 0) .and. (outp%how(output_i) /= option__outputformat__binary))
then
771 trim(
'density'), namespace, space, mesh, read_rff, &
772 units_out%length**(-space%dim), ierr, pos=ions%pos, atoms=ions%atom)
779 safe_deallocate_a(point_tmp)
780 safe_deallocate_a(read_ft)
781 safe_deallocate_a(read_rff)
783 select case (ft_method)
785 safe_deallocate_a(out_fft)
786 case (standard_fourier)
787 safe_deallocate_a(tdrho_a)
788 safe_deallocate_a(wdrho_a)
799 class(
mesh_t),
intent(in) :: mesh
801 class(
space_t),
intent(in) :: space
802 type(
ions_t),
intent(in) :: ions
806 integer :: ierr, ip, i_op, length, n_operations, output_i
810 real(real64) :: f_re, f_im
811 real(real64),
allocatable :: tmp_ff(:), scalar_ff(:)
813 character(len=200) :: var, scalar_expression
814 character(len=MAX_PATH_LEN) :: folder, filename, out_folder, out_filename
830 if (
parse_block(namespace,
'ConvertScalarOperation', blk) == 0)
then
834 if (n_operations == 0)
then
835 write(
message(1),
'(a)')
'No operations found. Check the input file'
846 call parse_variable(namespace,
'ConvertOutputFolder',
"convert", out_folder)
848 call io_mkdir(out_folder, namespace)
858 call parse_variable(namespace,
'ConvertOutputFilename',
'density', out_filename)
860 safe_allocate(tmp_ff(1:mesh%np))
861 safe_allocate(scalar_ff(1:mesh%np))
864 do i_op = 1, n_operations
873 length = len_trim(filename)
875 if (filename(length-3:length) ==
'.obf')
then
876 filename = trim(filename(1:length-4))
882 dir=trim(folder), mesh = mesh, exact=.
true.)
884 call restart%read_mesh_function(trim(filename), mesh, tmp_ff, ierr)
886 write(
message(1),
'(2a)')
"Failed to read mesh function ", trim(filename)
887 write(
message(2),
'(a,i0)')
"Error code: ", ierr
891 write(
message(1),
'(2a)')
"Failed to read from file ", trim(filename)
892 write(
message(2),
'(2a)')
"from folder ", trim(folder)
899 call parse_expression(f_re, f_im, trim(var), real(tmp_ff(ip), real64), trim(scalar_expression))
901 scalar_ff(ip) = scalar_ff(ip) + f_re
910 call mesh%mpi_grp%barrier()
915 do output_i = lbound(outp%how, 1), ubound(outp%how, 1)
916 if (outp%how(output_i) /= 0)
then
917 call dio_function_output(outp%how(output_i), trim(out_folder), trim(out_filename), namespace, space, mesh, &
918 scalar_ff, units, ierr, pos=ions%pos, atoms=ions%atom)
922 safe_deallocate_a(tmp_ff)
923 safe_deallocate_a(scalar_ff)
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.
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_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.
initialize a batch with existing memory
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_octopus(config_str)
subroutine, public getopt_init(ierr)
Initializes the getopt machinery. Must be called before attempting to parse the options....
subroutine, public getopt_end
This utility runs in parallel and can be used for post-processing of the results of Output.
subroutine, public convert_main()
Fast Fourier Transform module. This module provides a single interface that works with different FFT ...
subroutine, public fft_all_init(namespace)
initialize the table
subroutine, public fft_init(this, nn, dim, type, library, optimize, optimize_parity, comm, mpi_grp, use_aligned, howmany, nthreads, single)
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
complex(real64), parameter, public m_z0
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)
System information (time, memory, sysname)
subroutine, public loct_progress_bar(a, maxcount)
A wrapper around the progress bar, such that it can be silenced without needing to dress the call wit...
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 parse_block_string(blk, l, c, res, convert_to_c)
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.
/* To use the profiling module, call profiling_in and profiling_out with the label of the region as a...
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.
integer, parameter, public restart_undefined
integer, parameter, public restart_type_load
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 string containing compile-time options.
character(len=256) function, public get_optional_libraries()
Character string containing optional external 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.