48#include "./base/base_uses.f90"
54 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'kpoint_io'
56 INTEGER,
PARAMETER :: version = 1
76 particle_set, qs_kind_set)
85 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_kpoints_restart'
86 CHARACTER(LEN=30),
DIMENSION(2),
PARAMETER :: &
87 keys = [
"SCF%PRINT%RESTART_HISTORY",
"SCF%PRINT%RESTART "]
89 INTEGER :: handle, ic, ikey, ires, ispin, nimages, &
91 INTEGER,
DIMENSION(3) :: cell
92 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
96 CALL timeset(routinen, handle)
104 DO ikey = 1,
SIZE(keys)
107 dft_section, keys(ikey)),
cp_p_file))
THEN
110 extension=
".kp", file_status=
"REPLACE", file_action=
"WRITE", &
111 do_backup=.true., file_form=
"UNFORMATTED")
115 nspin =
SIZE(denmat, 1)
116 nimages =
SIZE(denmat, 2)
117 NULLIFY (cell_to_index)
118 IF (nimages > 1)
THEN
121 cpassert(
ASSOCIATED(scf_env%scf_work1))
122 fmat => scf_env%scf_work1(1)
125 IF (ires > 0)
WRITE (ires) ispin, nspin, nimages
127 IF (nimages > 1)
THEN
132 IF (ires > 0)
WRITE (ires) ic, cell
146 CALL timestop(handle)
157 INTEGER,
INTENT(IN) :: ic
158 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
159 INTEGER,
DIMENSION(3) :: cell
161 INTEGER :: i1, i2, i3
164 allcell:
DO i3 = lbound(cell_to_index, 3), ubound(cell_to_index, 3)
165 DO i2 = lbound(cell_to_index, 2), ubound(cell_to_index, 2)
166 DO i1 = lbound(cell_to_index, 1), ubound(cell_to_index, 1)
167 IF (cell_to_index(i1, i2, i3) == ic)
THEN
188 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
191 CHARACTER(LEN=*),
INTENT(IN),
OPTIONAL :: basis_type
193 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_kpoints_file_header'
195 CHARACTER(LEN=default_string_length) :: basis_type_local
196 INTEGER :: handle, iatom, ikind, iset, ishell, &
197 lmax, lshell, nao, natom, nset, &
198 nset_max, nsgf, nshell_max
199 INTEGER,
DIMENSION(:),
POINTER :: nset_info, nshell
200 INTEGER,
DIMENSION(:, :),
POINTER :: l, nshell_info
201 INTEGER,
DIMENSION(:, :, :),
POINTER :: nso_info
205 CALL timeset(routinen, handle)
209 IF (
PRESENT(basis_type))
THEN
210 basis_type_local = basis_type
212 basis_type_local =
"ORB"
216 natom =
SIZE(particle_set, 1)
221 NULLIFY (orb_basis_set, dftb_parameter)
222 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
223 CALL get_qs_kind(qs_kind_set(ikind), basis_type=basis_type_local, &
224 basis_set=orb_basis_set, dftb_parameter=dftb_parameter)
225 IF (
ASSOCIATED(orb_basis_set))
THEN
230 nset_max = max(nset_max, nset)
232 nshell_max = max(nshell_max, nshell(iset))
234 ELSEIF (
ASSOCIATED(dftb_parameter))
THEN
236 nset_max = max(nset_max, 1)
237 nshell_max = max(nshell_max, lmax + 1)
239 cpabort(
"Unknown basis type.")
243 ALLOCATE (nso_info(nshell_max, nset_max, natom))
244 nso_info(:, :, :) = 0
246 ALLOCATE (nshell_info(nset_max, natom))
247 nshell_info(:, :) = 0
249 ALLOCATE (nset_info(natom))
254 NULLIFY (orb_basis_set, dftb_parameter)
255 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
256 CALL get_qs_kind(qs_kind_set(ikind), basis_type=basis_type_local, &
257 basis_set=orb_basis_set, dftb_parameter=dftb_parameter)
258 IF (
ASSOCIATED(orb_basis_set))
THEN
259 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, nsgf=nsgf, nset=nset, nshell=nshell, l=l)
261 nset_info(iatom) = nset
263 nshell_info(iset, iatom) = nshell(iset)
264 DO ishell = 1, nshell(iset)
265 lshell = l(ishell, iset)
266 nso_info(ishell, iset, iatom) =
nso(lshell)
269 ELSEIF (
ASSOCIATED(dftb_parameter))
THEN
272 nshell_info(1, iatom) = lmax + 1
273 DO ishell = 1, lmax + 1
275 nso_info(ishell, 1, iatom) =
nso(lshell)
277 nao = nao + (lmax + 1)**2
279 cpabort(
"Unknown basis set type.")
284 WRITE (ires) natom, nao, nset_max, nshell_max
285 WRITE (ires) nset_info
286 WRITE (ires) nshell_info
287 WRITE (ires) nso_info
289 DEALLOCATE (nset_info, nshell_info, nso_info)
292 CALL timestop(handle)
308 para_env, id_nr, dft_section, natom_mismatch)
312 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: fmwork
313 INTEGER,
INTENT(IN) :: natom
315 INTEGER,
INTENT(IN) :: id_nr
317 LOGICAL,
INTENT(OUT) :: natom_mismatch
319 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_kpoints_restart'
321 CHARACTER(LEN=default_path_length) :: file_name
322 INTEGER :: handle, restart_unit
326 CALL timeset(routinen, handle)
331 IF (para_env%is_source())
THEN
336 file_name = trim(file_name)//
".bak-"//adjustl(
cp_to_string(id_nr))
340 file_action=
"READ", &
341 file_form=
"UNFORMATTED", &
343 unit_number=restart_unit)
347 CALL read_kpoints_restart_low(denmat, kpoints, fmwork(1), para_env, &
348 natom, restart_unit, natom_mismatch)
351 CALL para_env%bcast(natom_mismatch)
354 IF (para_env%is_source())
CALL close_file(unit_number=restart_unit)
356 CALL timestop(handle)
373 SUBROUTINE read_kpoints_restart_low(denmat, kpoints, fmat, para_env, &
374 natom, rst_unit, natom_mismatch)
380 INTEGER,
INTENT(IN) :: natom, rst_unit
381 LOGICAL,
INTENT(OUT) :: natom_mismatch
383 INTEGER :: ic, image, ispin, nao, nao_read, &
384 natom_read, ni, nimages, nset_max, &
385 nshell_max, nspin, nspin_read, &
387 INTEGER,
DIMENSION(3) :: cell
388 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
389 LOGICAL :: natom_match
391 cpassert(
ASSOCIATED(denmat))
394 nspin =
SIZE(denmat, 1)
395 nimages =
SIZE(denmat, 2)
396 NULLIFY (cell_to_index)
397 IF (nimages > 1)
THEN
401 IF (para_env%is_source())
THEN
402 READ (rst_unit) version_read
403 IF (version_read /= version)
THEN
404 CALL cp_abort(__location__, &
405 " READ RESTART : Version of restart file not supported")
407 READ (rst_unit) natom_read, nao_read, nset_max, nshell_max
408 natom_match = (natom_read == natom)
409 IF (natom_match)
THEN
410 IF (nao_read /= nao)
THEN
411 CALL cp_abort(__location__, &
412 " READ RESTART : Different number of basis functions")
421 CALL para_env%bcast(natom_match)
422 natom_mismatch = .NOT. natom_match
424 IF (natom_mismatch)
THEN
425 CALL cp_warn(__location__, &
426 " READ RESTART : WARNING : DIFFERENT natom, returning ")
431 IF (para_env%is_source())
THEN
432 READ (rst_unit) ispin, nspin_read, ni
434 CALL para_env%bcast(ispin)
435 CALL para_env%bcast(nspin_read)
436 CALL para_env%bcast(ni)
437 IF (nspin_read /= nspin)
THEN
438 CALL cp_abort(__location__, &
439 " READ RESTART : Different spin polarisation not supported")
442 IF (para_env%is_source())
THEN
443 READ (rst_unit) image, cell
445 CALL para_env%bcast(image)
446 CALL para_env%bcast(cell)
450 IF (nimages > 1)
THEN
451 image = get_index(cell, cell_to_index)
452 ELSE IF (sum(abs(cell(:))) == 0)
THEN
457 IF (image >= 1 .AND. image <= nimages)
THEN
461 IF (ispin == nspin_read)
EXIT
466 END SUBROUTINE read_kpoints_restart_low
474 FUNCTION get_index(cell, cell_to_index)
RESULT(index)
475 INTEGER,
DIMENSION(3),
INTENT(IN) :: cell
476 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
479 IF (cell(1) >= lbound(cell_to_index, 1) .AND. cell(1) <= ubound(cell_to_index, 1) .AND. &
480 cell(2) >= lbound(cell_to_index, 2) .AND. cell(2) <= ubound(cell_to_index, 2) .AND. &
481 cell(3) >= lbound(cell_to_index, 3) .AND. cell(3) <= ubound(cell_to_index, 3))
THEN
483 index = cell_to_index(cell(1), cell(2), cell(3))
491 END FUNCTION get_index
Define the atomic kind types and their sub types.
subroutine, public get_atomic_kind(atomic_kind, fist_potential, element_symbol, name, mass, kind_number, natom, atom_list, rcov, rvdw, z, qeff, apol, cpol, mm_radius, shell, shell_active, damping)
Get attributes of an atomic kind.
subroutine, public get_gto_basis_set(gto_basis_set, name, aliases, norm_type, kind_radius, ncgf, nset, nsgf, cgf_symbol, sgf_symbol, norm_cgf, set_radius, lmax, lmin, lx, ly, lz, m, ncgf_set, npgf, nsgf_set, nshell, cphi, pgf_radius, sphi, scon, zet, first_cgf, first_sgf, l, last_cgf, last_sgf, n, gcc, maxco, maxl, maxpgf, maxsgf_set, maxshell, maxso, nco_sum, npgf_sum, nshell_sum, maxder, short_kind_radius, npgf_seg_sum)
...
subroutine, public dbcsr_get_info(matrix, nblkrows_total, nblkcols_total, nfullrows_total, nfullcols_total, nblkrows_local, nblkcols_local, nfullrows_local, nfullcols_local, my_prow, my_pcol, local_rows, local_cols, proc_row_dist, proc_col_dist, row_blk_size, col_blk_size, row_blk_offset, col_blk_offset, distribution, name, matrix_type, group)
...
DBCSR operations in CP2K.
subroutine, public copy_dbcsr_to_fm(matrix, fm)
Copy a DBCSR matrix to a BLACS matrix.
subroutine, public copy_fm_to_dbcsr(fm, matrix, keep_sparsity)
Copy a BLACS matrix to a dbcsr matrix.
Utility routines to open and close files. Tracking of preconnections.
subroutine, public open_file(file_name, file_status, file_form, file_action, file_position, file_pad, unit_number, debug, skip_get_unit_number, file_access)
Opens the requested file using a free unit number.
subroutine, public close_file(unit_number, file_status, keep_preconnection)
Close an open file given by its logical unit number. Optionally, keep the file and unit preconnected.
represent a full matrix distributed on many processors
subroutine, public cp_fm_write_unformatted(fm, unit)
...
subroutine, public cp_fm_read_unformatted(fm, unit)
...
various routines to log and control the output. The idea is that decisions about where to log should ...
type(cp_logger_type) function, pointer, public cp_get_default_logger()
returns the default logger
routines to handle the output, The idea is to remove the decision of wheter to output and what to out...
integer function, public cp_print_key_unit_nr(logger, basis_section, print_key_path, extension, middle_name, local, log_filename, ignore_should_output, file_form, file_position, file_action, file_status, do_backup, on_file, is_new_file, mpi_io, fout)
...
subroutine, public cp_print_key_finished_output(unit_nr, logger, basis_section, print_key_path, local, ignore_should_output, on_file, mpi_io)
should be called after you finish working with a unit obtained with cp_print_key_unit_nr,...
integer, parameter, public cp_p_file
integer function, public cp_print_key_should_output(iteration_info, basis_section, print_key_path, used_print_key, first_time)
returns what should be done with the given property if btest(res,cp_p_store) then the property should...
Defines the basic variable types.
integer, parameter, public default_string_length
integer, parameter, public default_path_length
Restart file for k point calculations.
subroutine, public read_kpoints_restart(denmat, kpoints, fmwork, natom, para_env, id_nr, dft_section, natom_mismatch)
...
subroutine, public write_kpoints_restart(denmat, kpoints, scf_env, dft_section, particle_set, qs_kind_set)
...
subroutine, public write_kpoints_file_header(qs_kind_set, particle_set, ires, basis_type)
...
integer function, dimension(3), public get_cell(ic, cell_to_index)
...
Types and basic routines needed for a kpoint calculation.
subroutine, public get_kpoint_info(kpoint, kp_scheme, nkp_grid, kp_shift, symmetry, verbose, full_grid, use_real_wfn, eps_geo, parallel_group_size, kp_range, nkp, xkp, wkp, para_env, blacs_env_all, para_env_kp, para_env_inter_kp, blacs_env, kp_env, kp_aux_env, mpools, iogrp, nkp_groups, kp_dist, cell_to_index, index_to_cell, sab_nl, sab_nl_nosym, inversion_symmetry_only, symmetry_backend, symmetry_reduction_method)
Retrieve information from a kpoint environment.
Interface to the message passing library MPI.
Provides Cartesian and spherical orbital pointers and indices.
integer, dimension(:), allocatable, public nso
Define the data structure for the particle information.
Definition of the DFTB parameter types.
Working with the DFTB parameter types.
subroutine, public get_dftb_atom_param(dftb_parameter, name, typ, defined, z, zeff, natorb, lmax, skself, occupation, eta, energy, cutoff, xi, di, rcdisp, dudq)
...
Define the quickstep kind type and their sub types.
subroutine, public get_qs_kind(qs_kind, basis_set, basis_type, ncgf, nsgf, all_potential, tnadd_potential, gth_potential, sgp_potential, upf_potential, cneo_potential, se_parameter, dftb_parameter, xtb_parameter, dftb3_param, zatom, zeff, elec_conf, mao, lmax_dftb, alpha_core_charge, ccore_charge, core_charge, core_charge_radius, paw_proj_set, paw_atom, hard_radius, hard0_radius, max_rad_local, covalent_radius, vdw_radius, gpw_type_forced, harmonics, max_iso_not0, max_s_harm, grid_atom, ngrid_ang, ngrid_rad, lmax_rho0, dft_plus_u_atom, l_of_dft_plus_u, n_of_dft_plus_u, u_minus_j, u_of_dft_plus_u, j_of_dft_plus_u, alpha_of_dft_plus_u, beta_of_dft_plus_u, j0_of_dft_plus_u, occupation_of_dft_plus_u, dispersion, bs_occupation, magnetization, no_optimize, addel, laddel, naddel, orbitals, max_scf, eps_scf, smear, u_ramping, u_minus_j_target, eps_u_ramping, init_u_ramping_each_scf, reltmat, ghost, monovalent, floating, name, element_symbol, pao_basis_size, pao_model_file, pao_potentials, pao_descriptors, nelec)
Get attributes of an atomic kind.
Definition and initialisation of the mo data type.
subroutine, public wfn_restart_file_name(filename, exist, section, logger, kp, xas, rtp)
...
module that contains the definitions of the scf types
type of a logger, at the moment it contains just a print level starting at which level it should be l...
Contains information about kpoints.
stores all the informations relevant to an mpi environment
Provides all information about a quickstep kind.