47#include "./base/base_uses.f90"
53 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'kpoint_io'
55 INTEGER,
PARAMETER :: version = 1
74 particle_set, qs_kind_set)
83 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_kpoints_restart'
84 CHARACTER(LEN=30),
DIMENSION(2),
PARAMETER :: &
85 keys = (/
"SCF%PRINT%RESTART_HISTORY",
"SCF%PRINT%RESTART "/)
87 INTEGER :: handle, ic, ikey, ires, ispin, nimages, &
89 INTEGER,
DIMENSION(3) :: cell
90 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
94 CALL timeset(routinen, handle)
102 DO ikey = 1,
SIZE(keys)
105 dft_section, keys(ikey)),
cp_p_file))
THEN
108 extension=
".kp", file_status=
"REPLACE", file_action=
"WRITE", &
109 do_backup=.true., file_form=
"UNFORMATTED")
111 CALL write_kpoints_file_header(qs_kind_set, particle_set, ires)
113 nspin =
SIZE(denmat, 1)
114 nimages =
SIZE(denmat, 2)
115 NULLIFY (cell_to_index)
116 IF (nimages > 1)
THEN
119 cpassert(
ASSOCIATED(scf_env%scf_work1))
120 fmat => scf_env%scf_work1(1)
123 IF (ires > 0)
WRITE (ires) ispin, nspin, nimages
125 IF (nimages > 1)
THEN
126 cell = get_cell(ic, cell_to_index)
130 IF (ires > 0)
WRITE (ires) ic, cell
144 CALL timestop(handle)
154 FUNCTION get_cell(ic, cell_to_index)
RESULT(cell)
155 INTEGER,
INTENT(IN) :: ic
156 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
157 INTEGER,
DIMENSION(3) :: cell
159 INTEGER :: i1, i2, i3
162 allcell:
DO i3 = lbound(cell_to_index, 3), ubound(cell_to_index, 3)
163 DO i2 = lbound(cell_to_index, 2), ubound(cell_to_index, 2)
164 DO i1 = lbound(cell_to_index, 1), ubound(cell_to_index, 1)
165 IF (cell_to_index(i1, i2, i3) == ic)
THEN
175 END FUNCTION get_cell
183 SUBROUTINE write_kpoints_file_header(qs_kind_set, particle_set, ires)
185 TYPE(
qs_kind_type),
DIMENSION(:),
POINTER :: qs_kind_set
189 CHARACTER(LEN=*),
PARAMETER :: routinen =
'write_kpoints_file_header'
191 INTEGER :: handle, iatom, ikind, iset, ishell, &
192 lmax, lshell, nao, natom, nset, &
193 nset_max, nsgf, nshell_max
194 INTEGER,
DIMENSION(:),
POINTER :: nset_info, nshell
195 INTEGER,
DIMENSION(:, :),
POINTER :: l, nshell_info
196 INTEGER,
DIMENSION(:, :, :),
POINTER :: nso_info
200 CALL timeset(routinen, handle)
204 natom =
SIZE(particle_set, 1)
209 NULLIFY (orb_basis_set, dftb_parameter)
210 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
212 basis_set=orb_basis_set, dftb_parameter=dftb_parameter)
213 IF (
ASSOCIATED(orb_basis_set))
THEN
218 nset_max = max(nset_max, nset)
220 nshell_max = max(nshell_max, nshell(iset))
222 ELSEIF (
ASSOCIATED(dftb_parameter))
THEN
224 nset_max = max(nset_max, 1)
225 nshell_max = max(nshell_max, lmax + 1)
227 cpabort(
"Unknown basis type.")
231 ALLOCATE (nso_info(nshell_max, nset_max, natom))
232 nso_info(:, :, :) = 0
234 ALLOCATE (nshell_info(nset_max, natom))
235 nshell_info(:, :) = 0
237 ALLOCATE (nset_info(natom))
242 NULLIFY (orb_basis_set, dftb_parameter)
243 CALL get_atomic_kind(particle_set(iatom)%atomic_kind, kind_number=ikind)
245 basis_set=orb_basis_set, dftb_parameter=dftb_parameter)
246 IF (
ASSOCIATED(orb_basis_set))
THEN
247 CALL get_gto_basis_set(gto_basis_set=orb_basis_set, nsgf=nsgf, nset=nset, nshell=nshell, l=l)
249 nset_info(iatom) = nset
251 nshell_info(iset, iatom) = nshell(iset)
252 DO ishell = 1, nshell(iset)
253 lshell = l(ishell, iset)
254 nso_info(ishell, iset, iatom) =
nso(lshell)
257 ELSEIF (
ASSOCIATED(dftb_parameter))
THEN
260 nshell_info(1, iatom) = lmax + 1
261 DO ishell = 1, lmax + 1
263 nso_info(ishell, 1, iatom) =
nso(lshell)
265 nao = nao + (lmax + 1)**2
267 cpabort(
"Unknown basis set type.")
272 WRITE (ires) natom, nao, nset_max, nshell_max
273 WRITE (ires) nset_info
274 WRITE (ires) nshell_info
275 WRITE (ires) nso_info
277 DEALLOCATE (nset_info, nshell_info, nso_info)
280 CALL timestop(handle)
282 END SUBROUTINE write_kpoints_file_header
296 para_env, id_nr, dft_section, natom_mismatch)
300 TYPE(
cp_fm_type),
DIMENSION(:),
INTENT(INOUT) :: fmwork
301 INTEGER,
INTENT(IN) :: natom
303 INTEGER,
INTENT(IN) :: id_nr
305 LOGICAL,
INTENT(OUT) :: natom_mismatch
307 CHARACTER(LEN=*),
PARAMETER :: routinen =
'read_kpoints_restart'
309 CHARACTER(LEN=default_path_length) :: file_name
310 INTEGER :: handle, restart_unit
314 CALL timeset(routinen, handle)
319 IF (para_env%is_source())
THEN
324 file_name = trim(file_name)//
".bak-"//adjustl(
cp_to_string(id_nr))
328 file_action=
"READ", &
329 file_form=
"UNFORMATTED", &
331 unit_number=restart_unit)
335 CALL read_kpoints_restart_low(denmat, kpoints, fmwork(1), para_env, &
336 natom, restart_unit, natom_mismatch)
339 CALL para_env%bcast(natom_mismatch)
342 IF (para_env%is_source())
CALL close_file(unit_number=restart_unit)
344 CALL timestop(handle)
361 SUBROUTINE read_kpoints_restart_low(denmat, kpoints, fmat, para_env, &
362 natom, rst_unit, natom_mismatch)
368 INTEGER,
INTENT(IN) :: natom, rst_unit
369 LOGICAL,
INTENT(OUT) :: natom_mismatch
371 INTEGER :: ic, image, ispin, nao, nao_read, &
372 natom_read, ni, nimages, nset_max, &
373 nshell_max, nspin, nspin_read, &
375 INTEGER,
DIMENSION(3) :: cell
376 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
377 LOGICAL :: natom_match
379 cpassert(
ASSOCIATED(denmat))
382 nspin =
SIZE(denmat, 1)
383 nimages =
SIZE(denmat, 2)
384 NULLIFY (cell_to_index)
385 IF (nimages > 1)
THEN
389 IF (para_env%is_source())
THEN
390 READ (rst_unit) version_read
391 IF (version_read /= version)
THEN
392 CALL cp_abort(__location__, &
393 " READ RESTART : Version of restart file not supported")
395 READ (rst_unit) natom_read, nao_read, nset_max, nshell_max
396 natom_match = (natom_read == natom)
397 IF (natom_match)
THEN
398 IF (nao_read /= nao)
THEN
399 CALL cp_abort(__location__, &
400 " READ RESTART : Different number of basis functions")
409 CALL para_env%bcast(natom_match)
410 natom_mismatch = .NOT. natom_match
412 IF (natom_mismatch)
THEN
413 CALL cp_warn(__location__, &
414 " READ RESTART : WARNING : DIFFERENT natom, returning ")
419 IF (para_env%is_source())
THEN
420 READ (rst_unit) ispin, nspin_read, ni
422 CALL para_env%bcast(ispin)
423 CALL para_env%bcast(nspin_read)
424 CALL para_env%bcast(ni)
425 IF (nspin_read /= nspin)
THEN
426 CALL cp_abort(__location__, &
427 " READ RESTART : Different spin polarisation not supported")
430 IF (para_env%is_source())
THEN
431 READ (rst_unit) image, cell
433 CALL para_env%bcast(image)
434 CALL para_env%bcast(cell)
438 IF (nimages > 1)
THEN
439 image = get_index(cell, cell_to_index)
440 ELSE IF (sum(abs(cell(:))) == 0)
THEN
445 IF (image >= 1 .AND. image <= nimages)
THEN
449 IF (ispin == nspin_read)
EXIT
454 END SUBROUTINE read_kpoints_restart_low
462 FUNCTION get_index(cell, cell_to_index)
RESULT(index)
463 INTEGER,
DIMENSION(3),
INTENT(IN) :: cell
464 INTEGER,
DIMENSION(:, :, :),
POINTER :: cell_to_index
467 IF (cell(1) >= lbound(cell_to_index, 1) .AND. cell(1) <= ubound(cell_to_index, 1) .AND. &
468 cell(2) >= lbound(cell_to_index, 2) .AND. cell(2) <= ubound(cell_to_index, 2) .AND. &
469 cell(3) >= lbound(cell_to_index, 3) .AND. cell(3) <= ubound(cell_to_index, 3))
THEN
471 index = cell_to_index(cell(1), cell(2), cell(3))
479 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_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)
...
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)
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, 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, 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.