(git:2c0d679)
Loading...
Searching...
No Matches
f77_interface Module Reference

interface to use cp2k as library More...

Data Types

type  f_env_type

Functions/Subroutines

subroutine, public init_cp2k (init_mpi, ierr, mpi_comm)
 initializes cp2k, needs to be called once before using any of the other functions when using cp2k as library
subroutine, public configure_dbcsr (mpi_comm, output_unit)
 Configure DBCSR with CP2K's hooks and selected accelerator device. For an active library the DBCSR API only updates the output unit. Initialization belongs to init_cp2k, except for FARMING which must temporarily initialize DBCSR on each job's own MPI communicator.
subroutine, public finalize_cp2k (finalize_mpi, ierr)
 cleanup after you have finished using this interface
subroutine, public f_env_get_from_id (f_env_id, f_env)
 ...
subroutine, public f_env_add_defaults (f_env_id, f_env, handle)
 adds the default environments of the f_env to the stack of the defaults, and returns a new error and sets failure to true if something went wrong
subroutine, public f_env_rm_defaults (f_env, ierr, handle)
 removes the default environments of the f_env to the stack of the defaults, and sets ierr accordingly to the failuers stored in error It also releases the error
recursive subroutine, public create_force_env (new_env_id, input_declaration, input_path, output_path, mpi_comm, output_unit, owns_out_unit, input, ierr, work_dir, initial_variables)
 creates a new force environment using the given input, and writing the output to the given output unit
recursive subroutine, public destroy_force_env (env_id, ierr, q_finalize)
 deallocates the force_env with the given id
subroutine, public get_natom (env_id, n_atom, ierr)
 returns the number of atoms in the given force env
subroutine, public get_nparticle (env_id, n_particle, ierr)
 returns the number of particles in the given force env
subroutine, public get_cell (env_id, cell, per, ierr)
 gets a cell
subroutine, public get_qmmm_cell (env_id, cell, ierr)
 gets the qmmm cell
subroutine, public get_result_r1 (env_id, description, n, result, res_exist, ierr)
 gets a result from CP2K that is a real 1D array
subroutine, public get_force (env_id, frc, n_el, ierr)
 gets the forces of the particles
subroutine, public get_stress_tensor (env_id, stress_tensor, ierr, available)
 gets the stress tensor
subroutine, public get_pos (env_id, pos, n_el, ierr)
 gets the positions of the particles
subroutine, public set_cell (env_id, new_cell, ierr)
 sets a new cell
subroutine, public set_pos (env_id, new_pos, n_el, ierr)
 sets the positions of the particles
subroutine, public set_vel (env_id, new_vel, n_el, ierr)
 sets the velocities of the particles
recursive subroutine, public calc_energy_force (env_id, calc_force, ierr)
 updates the energy and the forces of given force_env
subroutine, public get_energy (env_id, e_pot, ierr)
 returns the energy of the last configuration calculated
recursive subroutine, public calc_energy (env_id, pos, n_el, e_pot, ierr)
 returns the energy of the configuration given by the positions passed as argument
recursive subroutine, public calc_force (env_id, pos, n_el_pos, e_pot, force, n_el_force, ierr)
 returns the energy of the configuration given by the positions passed as argument
subroutine, public check_input (input_declaration, input_file_path, output_file_path, echo_input, mpi_comm, initial_variables, ierr)
 performs a check of the input

Variables

type(f_env_p_type), dimension(:), pointer, save f_envs
type(mp_para_env_type), pointer, save, public default_para_env

Detailed Description

interface to use cp2k as library

Note
useful additions for the future would be:
  • string(path) based set/get of simple values (to change the new input during the run and extract more data (energy types for example).
  • set/get of a subset of atoms
History
07.2004 created [fawzi] 11.2004 parallel version [fawzi]
Author
fawzi & Johanna

Function/Subroutine Documentation

◆ init_cp2k()

subroutine, public f77_interface::init_cp2k ( logical, intent(in) init_mpi,
integer, intent(out) ierr,
type(mp_comm_type), intent(in), optional mpi_comm )

initializes cp2k, needs to be called once before using any of the other functions when using cp2k as library

Parameters
init_mpiif the mpi environment should be initialized
ierrreturns a number different from 0 if there was an error
mpi_comman existing mpi communicator (if not given mp_comm_world will be used)
Author
fawzi

Definition at line 230 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ configure_dbcsr()

subroutine, public f77_interface::configure_dbcsr ( class(mp_comm_type), intent(in) mpi_comm,
integer, intent(in) output_unit )

Configure DBCSR with CP2K's hooks and selected accelerator device. For an active library the DBCSR API only updates the output unit. Initialization belongs to init_cp2k, except for FARMING which must temporarily initialize DBCSR on each job's own MPI communicator.

Parameters
mpi_commcommunicator for initialization (ignored if already initialized)
output_unitdiagnostic output unit, negative on non-I/O ranks

Definition at line 337 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ finalize_cp2k()

subroutine, public f77_interface::finalize_cp2k ( logical, intent(in) finalize_mpi,
integer, intent(out) ierr )

cleanup after you have finished using this interface

Parameters
finalize_mpiif the mpi environment should be finalized
ierrreturns a number different from 0 if there was an error
Author
fawzi

Definition at line 360 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_env_get_from_id()

subroutine, public f77_interface::f_env_get_from_id ( integer, intent(in) f_env_id,
type(f_env_type), pointer f_env )

...

Parameters
f_env_id...
f_env...

Definition at line 476 of file f77_interface.F.

Here is the caller graph for this function:

◆ f_env_add_defaults()

subroutine, public f77_interface::f_env_add_defaults ( integer, intent(in) f_env_id,
type(f_env_type), pointer f_env,
integer, intent(out), optional handle )

adds the default environments of the f_env to the stack of the defaults, and returns a new error and sets failure to true if something went wrong

Parameters
f_env_idthe f_env from where to take the defaults
f_envwill contain the f_env corresponding to f_env_id
handle...
Author
fawzi
Note
The following routines need to be synchronized wrt. adding/removing of the default environments (logging, performance,error): environment:cp2k_init, environment:cp2k_finalize, f77_interface:f_env_add_defaults, f77_interface:f_env_rm_defaults, f77_interface:create_force_env, f77_interface:destroy_force_env

Definition at line 507 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_env_rm_defaults()

subroutine, public f77_interface::f_env_rm_defaults ( type(f_env_type), pointer f_env,
integer, intent(out), optional ierr,
integer, intent(in), optional handle )

removes the default environments of the f_env to the stack of the defaults, and sets ierr accordingly to the failuers stored in error It also releases the error

Parameters
f_envthe f_env from where to take the defaults
ierrvariable that will be set to a number different from 0 if error contains an error (otherwise it will be set to 0)
handle...
Author
fawzi
Note
The following routines need to be synchronized wrt. adding/removing of the default environments (logging, performance,error): environment:cp2k_init, environment:cp2k_finalize, f77_interface:f_env_add_defaults, f77_interface:f_env_rm_defaults, f77_interface:create_force_env, f77_interface:destroy_force_env

Definition at line 551 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_force_env()

recursive subroutine, public f77_interface::create_force_env ( integer, intent(out) new_env_id,
type(section_type), pointer input_declaration,
character(len=*), intent(in) input_path,
character(len=*), intent(in), optional output_path,
class(mp_comm_type), intent(in), optional mpi_comm,
integer, intent(in), optional output_unit,
logical, intent(in), optional owns_out_unit,
type(section_vals_type), optional, pointer input,
integer, intent(out), optional ierr,
character(len=*), intent(in), optional work_dir,
character(len=*), dimension(:, :), optional initial_variables )

creates a new force environment using the given input, and writing the output to the given output unit

Parameters
new_env_idwill contain the id of the newly created environment
input_declaration...
input_pathwhere to read the input (if the input is given it can a virtual path)
output_pathfilename (or name of the unit) for the output
mpi_commthe mpi communicator to be used for this environment it will not be freed when you get rid of the force_env
output_unitif given it should be the unit for the output and no file is open (should be valid on the processor with rank 0)
owns_out_unitif the output unit should be closed upon destroing of the force_env (defaults to true if not default_output_unit)
inputthe parsed input, if given and valid it is used instead of parsing from file
ierrwill return a number different from 0 if there was an error
work_dir...
initial_variableskey-value list of initial preprocessor variables
Author
fawzi
Note
The following routines need to be synchronized wrt. adding/removing of the default environments (logging, performance,error): environment:cp2k_init, environment:cp2k_finalize, f77_interface:f_env_add_defaults, f77_interface:f_env_rm_defaults, f77_interface:create_force_env, f77_interface:destroy_force_env

Definition at line 621 of file f77_interface.F.

Here is the caller graph for this function:

◆ destroy_force_env()

recursive subroutine, public f77_interface::destroy_force_env ( integer, intent(in) env_id,
integer, intent(out) ierr,
logical, intent(in), optional q_finalize )

deallocates the force_env with the given id

Parameters
env_idthe id of the force_env to remove
ierrwill contain a number different from 0 if
q_finalize...
Author
fawzi
Note
The following routines need to be synchronized wrt. adding/removing of the default environments (logging, performance,error): environment:cp2k_init, environment:cp2k_finalize, f77_interface:f_env_add_defaults, f77_interface:f_env_rm_defaults, f77_interface:create_force_env, f77_interface:destroy_force_env

Definition at line 1015 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_natom()

subroutine, public f77_interface::get_natom ( integer, intent(in) env_id,
integer, intent(out) n_atom,
integer, intent(out) ierr )

returns the number of atoms in the given force env

Parameters
env_idid of the force_env
n_atom...
ierrwill return a number different from 0 if there was an error
Date
22.11.2010 (MK)
Author
fawzi

Definition at line 1060 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_nparticle()

subroutine, public f77_interface::get_nparticle ( integer, intent(in) env_id,
integer, intent(out) n_particle,
integer, intent(out) ierr )

returns the number of particles in the given force env

Parameters
env_idid of the force_env
n_particle...
ierrwill return a number different from 0 if there was an error
Author
Matthias Krack

Definition at line 1083 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_cell()

subroutine, public f77_interface::get_cell ( integer, intent(in) env_id,
real(kind=dp), dimension(3, 3) cell,
integer, dimension(3), optional per,
integer, intent(out) ierr )

gets a cell

Parameters
env_idid of the force_env
cellthe array with the cell matrix
perperiodicity
ierrwill return a number different from 0 if there was an error
Author
Joost VandeVondele

Definition at line 1106 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_qmmm_cell()

subroutine, public f77_interface::get_qmmm_cell ( integer, intent(in) env_id,
real(kind=dp), dimension(3, 3) cell,
integer, intent(out) ierr )

gets the qmmm cell

Parameters
env_idid of the force_env
cellthe array with the cell matrix
ierrwill return a number different from 0 if there was an error
Author
Holly Judge

Definition at line 1134 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_result_r1()

subroutine, public f77_interface::get_result_r1 ( integer env_id,
character(len=default_string_length) description,
integer n,
real(kind=dp), dimension(1:n) result,
logical, optional res_exist,
integer ierr )

gets a result from CP2K that is a real 1D array

Parameters
env_idid of the force_env
descriptionthe tag of the result
N...
RESULT...
res_exist...
ierrwill return a number different from 0 if there was an error
Author
Joost VandeVondele

Definition at line 1165 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_force()

subroutine, public f77_interface::get_force ( integer, intent(in) env_id,
real(kind=dp), dimension(1:n_el) frc,
integer, intent(in) n_el,
integer, intent(out) ierr )

gets the forces of the particles

Parameters
env_idid of the force_env
frcthe array where to write the forces
n_elnumber of positions (3*nparticle) just to check
ierrwill return a number different from 0 if there was an error
Date
22.11.2010 (MK)
Author
fawzi

Definition at line 1210 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_stress_tensor()

subroutine, public f77_interface::get_stress_tensor ( integer, intent(in) env_id,
real(kind=dp), dimension(3, 3), intent(out) stress_tensor,
integer, intent(out) ierr,
logical, intent(out), optional available )

gets the stress tensor

Parameters
env_idid of the force_env
stress_tensorthe array where to write the stress tensor
ierrwill return a number different from 0 if there was an error
availablewhether the potential stress was calculated
Author
Ole Schuett

Definition at line 1233 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_pos()

subroutine, public f77_interface::get_pos ( integer, intent(in) env_id,
real(kind=dp), dimension(1:n_el) pos,
integer, intent(in) n_el,
integer, intent(out) ierr )

gets the positions of the particles

Parameters
env_idid of the force_env
posthe array where to write the positions
n_elnumber of positions (3*nparticle) just to check
ierrwill return a number different from 0 if there was an error
Date
22.11.2010 (MK)
Author
fawzi

Definition at line 1268 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_cell()

subroutine, public f77_interface::set_cell ( integer, intent(in) env_id,
real(kind=dp), dimension(3, 3) new_cell,
integer, intent(out) ierr )

sets a new cell

Parameters
env_idid of the force_env
new_cellthe array with the cell matrix
ierrwill return a number different from 0 if there was an error
Author
Joost VandeVondele

Definition at line 1314 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_pos()

subroutine, public f77_interface::set_pos ( integer, intent(in) env_id,
real(kind=dp), dimension(1:n_el) new_pos,
integer, intent(in) n_el,
integer, intent(out) ierr )

sets the positions of the particles

Parameters
env_idid of the force_env
new_posthe array with the new positions
n_elnumber of positions (3*nparticle) just to check
ierrwill return a number different from 0 if there was an error
Date
22.11.2010 updated (MK)
Author
fawzi

Definition at line 1347 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_vel()

subroutine, public f77_interface::set_vel ( integer, intent(in) env_id,
real(kind=dp), dimension(1:n_el) new_vel,
integer, intent(in) n_el,
integer, intent(out) ierr )

sets the velocities of the particles

Parameters
env_idid of the force_env
new_velthe array with the new velocities
n_elnumber of velocities (3*nparticle) just to check
ierrwill return a number different from 0 if there was an error
Date
22.11.2010 updated (MK)
Author
fawzi

Definition at line 1375 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_energy_force()

recursive subroutine, public f77_interface::calc_energy_force ( integer, intent(in) env_id,
logical, intent(in) calc_force,
integer, intent(out) ierr )

updates the energy and the forces of given force_env

Parameters
env_idid of the force_env that you want to update
calc_forceif the forces should be updated, if false the forces might be wrong.
ierrwill return a number different from 0 if there was an error
Author
fawzi

Definition at line 1402 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_energy()

subroutine, public f77_interface::get_energy ( integer, intent(in) env_id,
real(kind=dp), intent(out) e_pot,
integer, intent(out) ierr )

returns the energy of the last configuration calculated

Parameters
env_idid of the force_env that you want to update
e_potthe potential energy of the system
ierrwill return a number different from 0 if there was an error
Author
fawzi

Definition at line 1429 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_energy()

recursive subroutine, public f77_interface::calc_energy ( integer, intent(in) env_id,
real(kind=dp), dimension(1:n_el), intent(in) pos,
integer, intent(in) n_el,
real(kind=dp), intent(out) e_pot,
integer, intent(out) ierr )

returns the energy of the configuration given by the positions passed as argument

Parameters
env_idid of the force_env that you want to update
posarray with the positions
n_elnumber of elements in pos (3*natom)
e_potthe potential energy of the system
ierrwill return a number different from 0 if there was an error
Author
fawzi
Note
utility call

Definition at line 1456 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_force()

recursive subroutine, public f77_interface::calc_force ( integer, intent(in) env_id,
real(kind=dp), dimension(1:n_el_pos), intent(in) pos,
integer, intent(in) n_el_pos,
real(kind=dp), intent(out) e_pot,
real(kind=dp), dimension(1:n_el_force), intent(inout) force,
integer, intent(in) n_el_force,
integer, intent(out) ierr )

returns the energy of the configuration given by the positions passed as argument

Parameters
env_idid of the force_env that you want to update
posarray with the positions
n_el_posnumber of elements in pos (3*natom)
e_potthe potential energy of the system
forcearray that will contain the forces
n_el_forcenumber of elements in force (3*natom). If 0 the forces are not calculated
ierrwill return a number different from 0 if there was an error
Author
fawzi
Note
utility call, but actually it could be a better and more efficient interface to connect to other codes if cp2k would be deeply refactored

Definition at line 1486 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_input()

subroutine, public f77_interface::check_input ( type(section_type), pointer input_declaration,
character(len=*), intent(in) input_file_path,
character(len=*), intent(in) output_file_path,
logical, intent(in), optional echo_input,
type(mp_comm_type), intent(in), optional mpi_comm,
character(len=default_path_length), dimension(:, :), intent(in) initial_variables,
integer, intent(out) ierr )

performs a check of the input

Parameters
input_declaration...
input_file_paththe path of the input file to check
output_file_pathpath of the output file (to which it is appended) if it is "__STD_OUT__" the default_output_unit is used
echo_inputif the parsed input should be written out with all the defaults made explicit
mpi_commthe mpi communicator (if not given it uses the default one)
initial_variableskey-value list of initial preprocessor variables
ierrerror control, if different from 0 there was an error
Author
fawzi

Definition at line 1520 of file f77_interface.F.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ f_envs

type(f_env_p_type), dimension(:), pointer, save f77_interface::f_envs

Definition at line 183 of file f77_interface.F.

◆ default_para_env

type(mp_para_env_type), pointer, save, public f77_interface::default_para_env

Definition at line 184 of file f77_interface.F.