Documentation for module f77_interface

interface to use cp2k as library

source: f77_interface.F
Loading...

public Types:

f_env_type
...

public Subroutines/Functions:

SUBROUTINE RECURSIVE
calc_energy (env_id, pos, n_el, e_pot, ierr)
returns the energy of the configuration given by the positions passed as argument
SUBROUTINE RECURSIVE
calc_energy_force (env_id, calc_force, ierr)
updates the energy and the forces of given force_env
SUBROUTINE RECURSIVE
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
performs a check of the input
creates a new force environment using the given input, and writing the output to the given output unit
SUBROUTINE RECURSIVE
destroy_force_env (env_id, ierr, q_finalize)
deallocates the force_env with the given id
cleanup after you have finished using this interface
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
...
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
SUBROUTINE
get_cell (env_id, cell, per, ierr)
gets a cell
SUBROUTINE
get_energy (env_id, e_pot, ierr)
returns the energy of the last configuration calculated
SUBROUTINE
get_force (env_id, frc, n_el, ierr)
gets the forces of the particles
SUBROUTINE
get_natom (env_id, n_atom, ierr)
returns the number of atoms in the given force env
returns the number of particles in the given force env
SUBROUTINE
get_pos (env_id, pos, n_el, ierr)
gets the positions of the particles
gets a result from CP2K that is a real 1D array
gets the stress tensor
SUBROUTINE
init_cp2k (init_mpi, ierr)
initializes cp2k, needs to be called once before using any of the other functions when using cp2k as library
SUBROUTINE
set_cell (env_id, new_cell, ierr)
sets a new cell
SUBROUTINE
set_pos (env_id, new_pos, n_el, ierr)
sets the positions of the particles
SUBROUTINE
set_vel (env_id, new_vel, n_el, ierr)
sets the velocities of the particles

Module variables:

POINTER :: default_para_env

public Types:

TYPE :: f_env_type

...


INTEGER
:: id_nr ...
POINTER :: force_env ...
POINTER :: logger ...
POINTER :: timer_env ...
POINTER :: mp_perf_env ...
:: my_path ...
:: old_path ...

RECURSIVE SUBROUTINEcalc_energy(env_id, pos, n_el, e_pot, ierr)

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

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env that you want to update
REAL(dp),
INTENT(in)
:: pos(1:n_el) array with the positions
INTEGER,
INTENT(in)
:: n_el number of elements in pos (3*natom)
REAL(dp),
INTENT(out)
:: e_pot the potential energy of the system
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

RECURSIVE SUBROUTINEcalc_energy_force(env_id, calc_force, ierr)

updates the energy and the forces of given force_env

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env that you want to update
LOGICAL,
INTENT(in)
:: calc_force if the forces should be updated, if false the forces might be wrong.
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

RECURSIVE SUBROUTINEcalc_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

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env that you want to update
REAL(dp),
INTENT(in)
:: pos(1:n_el_pos) array with the positions
INTEGER,
INTENT(in)
:: n_el_pos number of elements in pos (3*natom)
REAL(dp),
INTENT(out)
:: e_pot the potential energy of the system
REAL(dp),
INTENT(inout)
:: force(1:n_el_force) array that will contain the forces
INTEGER,
INTENT(in)
:: n_el_force number of elements in force (3*natom). If 0 the forces are not calculated
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEcheck_input(input_declaration, input_file_path, output_file_path, echo_input, mpi_comm, ierr)

performs a check of the input

Arguments:
POINTER
:: input_declaration ...
CHARACTER(*),
INTENT(in)
:: input_file_path the path of the input file to check
CHARACTER(*),
INTENT(in)
:: output_file_path path of the output file (to which it is appended) if it is "__STD_OUT__" the default_output_unit is used
LOGICAL,
INTENT(in),
OPTIONAL
:: echo_input if the parsed input should be written out with all the defaults made explicit
INTEGER,
INTENT(in),
OPTIONAL
:: mpi_comm the mpi communicator (if not given it uses the default one)
INTEGER,
INTENT(out)
:: ierr error control, if different from 0 there was an error

RECURSIVE SUBROUTINEcreate_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

Arguments:
INTEGER,
INTENT(out)
:: new_env_id will contain the id of the newly created environment
POINTER
:: input_declaration ...
CHARACTER(*),
INTENT(in)
:: input_path where to read the input (if the input is given it can a virtual path)
CHARACTER(*),
INTENT(in),
OPTIONAL
:: output_path filename (or name of the unit) for the output
INTEGER,
INTENT(in),
OPTIONAL
:: mpi_comm the mpi communicator to be used for this environment it will not be freed when you get rid of the force_env
INTEGER,
INTENT(in),
OPTIONAL
:: output_unit if given it should be the unit for the output and no file is open(should be valid on the processor with rank 0)
LOGICAL,
INTENT(in),
OPTIONAL
:: owns_out_unit if the output unit should be closed upon destroing of the force_env (defaults to true if not default_output_unit)
OPTIONAL, POINTER
:: input the parsed input, if given and valid it is used instead of parsing from file
INTEGER,
INTENT(out),
OPTIONAL
:: ierr will return a number different from 0 if there was an error
CHARACTER(*),
INTENT(in),
OPTIONAL
:: work_dir ...
CHARACTER(*),
OPTIONAL
:: initial_variables(:,:) ...

RECURSIVE SUBROUTINEdestroy_force_env(env_id, ierr, q_finalize)

deallocates the force_env with the given id

Arguments:
INTEGER,
INTENT(in)
:: env_id the id of the force_env to remove
INTEGER,
INTENT(out)
:: ierr will contain a number different from 0 if
LOGICAL,
INTENT(in),
OPTIONAL
:: q_finalize ...

SUBROUTINEfinalize_cp2k(finalize_mpi, ierr)

cleanup after you have finished using this interface

Arguments:
LOGICAL,
INTENT(in)
:: finalize_mpi if the mpi environment should be finalized
INTEGER,
INTENT(out)
:: ierr returns a number different from 0 if there was an error

SUBROUTINEf_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

Arguments:
INTEGER,
INTENT(in)
:: f_env_id the f_env from where to take the defaults
TYPE(f_env_type),
POINTER
:: f_env will contain the f_env corresponding to f_env_id
INTEGER,
INTENT(out),
OPTIONAL
:: handle ...

SUBROUTINEf_env_get_from_id(f_env_id, f_env)

...

Arguments:
INTEGER,
INTENT(in)
:: f_env_id ...
TYPE(f_env_type),
POINTER
:: f_env ...

SUBROUTINEf_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

Arguments:
TYPE(f_env_type),
POINTER
:: f_env the f_env from where to take the defaults
INTEGER,
INTENT(out),
OPTIONAL
:: ierr variable that will be set to a number different from 0 if error contains an error (otherwise it will be set to 0)
INTEGER,
INTENT(in),
OPTIONAL
:: handle ...

SUBROUTINEget_cell(env_id, cell, per, ierr)

gets a cell

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
REAL(dp)
:: cell(3,3) the array with the cell matrix
INTEGER,
OPTIONAL
:: per(3) periodicity
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEget_energy(env_id, e_pot, ierr)

returns the energy of the last configuration calculated

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env that you want to update
REAL(dp),
INTENT(out)
:: e_pot the potential energy of the system
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEget_force(env_id, frc, n_el, ierr)

gets the forces of the particles

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
REAL(dp)
:: frc(1:n_el) the array where to write the forces
INTEGER,
INTENT(in)
:: n_el number of positions (3*nparticle) just to check
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEget_natom(env_id, n_atom, ierr)

returns the number of atoms in the given force env

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
INTEGER,
INTENT(out)
:: n_atom ...
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEget_nparticle(env_id, n_particle, ierr)

returns the number of particles in the given force env

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
INTEGER,
INTENT(out)
:: n_particle ...
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEget_pos(env_id, pos, n_el, ierr)

gets the positions of the particles

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
REAL(dp)
:: pos(1:n_el) the array where to write the positions
INTEGER,
INTENT(in)
:: n_el number of positions (3*nparticle) just to check
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEget_result_r1(env_id, description, n, result, res_exist, ierr)

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

Arguments:
INTEGER
:: env_id id of the force_env
:: description the tag of the result
INTEGER
:: n ...
REAL(dp)
:: result(1:n) ...
LOGICAL,
OPTIONAL
:: res_exist ...
INTEGER
:: ierr will return a number different from 0 if there was an error

SUBROUTINEget_stress_tensor(env_id, stress_tensor, ierr)

gets the stress tensor

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
REAL(dp),
INTENT(out)
:: stress_tensor(3,3) the array where to write the stress tensor
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEinit_cp2k(init_mpi, ierr)

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

Arguments:
LOGICAL,
INTENT(in)
:: init_mpi if the mpi environment should be initialized
INTEGER,
INTENT(out)
:: ierr returns a number different from 0 if there was an error

SUBROUTINEset_cell(env_id, new_cell, ierr)

sets a new cell

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
REAL(dp)
:: new_cell(3,3) the array with the cell matrix
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEset_pos(env_id, new_pos, n_el, ierr)

sets the positions of the particles

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
REAL(dp)
:: new_pos(1:n_el) the array with the new positions
INTEGER,
INTENT(in)
:: n_el number of positions (3*nparticle) just to check
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error

SUBROUTINEset_vel(env_id, new_vel, n_el, ierr)

sets the velocities of the particles

Arguments:
INTEGER,
INTENT(in)
:: env_id id of the force_env
REAL(dp)
:: new_vel(1:n_el) the array with the new velocities
INTEGER,
INTENT(in)
:: n_el number of velocities (3*nparticle) just to check
INTEGER,
INTENT(out)
:: ierr will return a number different from 0 if there was an error