(git:6a2e663)
f77_interface Module Reference

interface to use cp2k as library More...

Functions/Subroutines

subroutine, public init_cp2k (init_mpi, ierr)
 initializes cp2k, needs to be called once before using any of the other functions when using cp2k as library More...
 
subroutine, public finalize_cp2k (finalize_mpi, ierr)
 cleanup after you have finished using this interface More...
 
subroutine, public f_env_get_from_id (f_env_id, f_env)
 ... More...
 
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 More...
 
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 More...
 
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 More...
 
recursive subroutine, public destroy_force_env (env_id, ierr, q_finalize)
 deallocates the force_env with the given id More...
 
subroutine, public get_natom (env_id, n_atom, ierr)
 returns the number of atoms in the given force env More...
 
subroutine, public get_nparticle (env_id, n_particle, ierr)
 returns the number of particles in the given force env More...
 
subroutine, public get_cell (env_id, cell, per, ierr)
 gets a cell More...
 
subroutine, public get_qmmm_cell (env_id, cell, ierr)
 gets the qmmm cell More...
 
subroutine, public get_result_r1 (env_id, description, N, RESULT, res_exist, ierr)
 gets a result from CP2K that is a real 1D array More...
 
subroutine, public get_force (env_id, frc, n_el, ierr)
 gets the forces of the particles More...
 
subroutine, public get_stress_tensor (env_id, stress_tensor, ierr)
 gets the stress tensor More...
 
subroutine, public get_pos (env_id, pos, n_el, ierr)
 gets the positions of the particles More...
 
subroutine, public set_cell (env_id, new_cell, ierr)
 sets a new cell More...
 
subroutine, public set_pos (env_id, new_pos, n_el, ierr)
 sets the positions of the particles More...
 
subroutine, public set_vel (env_id, new_vel, n_el, ierr)
 sets the velocities of the particles More...
 
recursive subroutine, public calc_energy_force (env_id, calc_force, ierr)
 updates the energy and the forces of given force_env More...
 
subroutine, public get_energy (env_id, e_pot, ierr)
 returns the energy of the last configuration calculated More...
 
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 More...
 
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 More...
 
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 More...
 

Variables

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 
)

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
Author
fawzi

Definition at line 212 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 315 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 418 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 449 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 493 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 563 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 951 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 996 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 1019 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 1042 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 1070 of file f77_interface.F.

Here is the call 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 1101 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 1146 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 
)

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
Author
Ole Schuett

Definition at line 1168 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 1201 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 1247 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 1279 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 1306 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 1332 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 1357 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 1384 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 1414 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 1448 of file f77_interface.F.

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

Variable Documentation

◆ default_para_env

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

Definition at line 168 of file f77_interface.F.