get_properties_api Subroutine

public subroutine get_properties_api(verror, vmol, vdisp, c_cn, c_charges, c_c6, c_alpha) bind(C, name=namespace//"get_properties")

Calculate dispersion

Arguments

Type IntentOptional Attributes Name
type(c_ptr), value :: verror
type(c_ptr), value :: vmol
type(c_ptr), value :: vdisp
real(kind=c_double), intent(out), optional :: c_cn(*)
real(kind=c_double), intent(out), optional :: c_charges(*)
real(kind=c_double), intent(out), optional :: c_c6(*)
real(kind=c_double), intent(out), optional :: c_alpha(*)

Source Code

subroutine get_properties_api(verror, vmol, vdisp, &
      & c_cn, c_charges, c_c6, c_alpha) &
      & bind(C, name=namespace//"get_properties")
   !DEC$ ATTRIBUTES DLLEXPORT :: get_properties_api
   type(c_ptr), value :: verror
   type(vp_error), pointer :: error
   type(c_ptr), value :: vmol
   type(vp_structure), pointer :: mol
   type(c_ptr), value :: vdisp
   type(vp_model), pointer :: disp
   real(c_double), intent(out), optional :: c_cn(*)
   real(wp), allocatable :: cn(:)
   real(c_double), intent(out), optional :: c_charges(*)
   real(wp), allocatable :: charges(:)
   real(c_double), intent(out), optional :: c_c6(*)
   real(wp), allocatable :: c6(:, :)
   real(c_double), intent(out), optional :: c_alpha(*)
   real(wp), allocatable :: alpha(:)

   if (debug) print'("[Info]",1x, a)', "get_properties"

   if (.not.c_associated(verror)) return
   call c_f_pointer(verror, error)

   if (.not.c_associated(vmol)) then
      call fatal_error(error%ptr, "Molecular structure data is missing")
      return
   end if
   call c_f_pointer(vmol, mol)

   if (.not.c_associated(vdisp)) then
      call fatal_error(error%ptr, "Dispersion model is missing")
      return
   end if
   call c_f_pointer(vdisp, disp)

   allocate(cn(mol%ptr%nat), charges(mol%ptr%nat), alpha(mol%ptr%nat), &
      & c6(mol%ptr%nat, mol%ptr%nat))
   call get_properties(mol%ptr, disp%ptr, realspace_cutoff(), cn, charges, c6, alpha)

   if (present(c_cn)) then
      c_cn(:size(cn)) = cn
   end if

   if (present(c_charges)) then
      c_charges(:size(charges)) = charges
   end if

   if (present(c_c6)) then
      c_c6(:size(c6)) = reshape(c6, [size(c6)])
   end if

   if (present(c_alpha)) then
      c_alpha(:size(alpha)) = alpha
   end if

end subroutine get_properties_api