Optional arguments for find_*_neighlist

This commit is contained in:
Karl Hammond
2022-10-28 21:01:12 -05:00
parent 73bf0334e4
commit d3ed99c7f8
2 changed files with 24 additions and 12 deletions

View File

@ -1553,7 +1553,7 @@ Procedures Bound to the :f:type:`lammps` Derived Type
-------- --------
.. f:function:: find_fix_neighlist() .. f:function:: find_fix_neighlist(id[, reqid])
Find index of a neighbor list requested by a fix. Find index of a neighbor list requested by a fix.
@ -1564,15 +1564,15 @@ Procedures Bound to the :f:type:`lammps` Derived Type
fixes with multiple neighbor list requests. fixes with multiple neighbor list requests.
:p character(len=\*) id: Identifier of fix instance :p character(len=\*) id: Identifier of fix instance
:p integer(c_int) reqid: request ID to identify the neighbor list in cases :o integer(c_int) reqid: request ID to identify the neighbor list in cases
in which there are multiple requests from the same fix. in which there are multiple requests from the same fix. Default: 0.
:to: :cpp:func:`lammps_find_fix_neighlist` :to: :cpp:func:`lammps_find_fix_neighlist`
:r index: neighbor list index if found, otherwise :math:`-1` :r index: neighbor list index if found, otherwise :math:`-1`
:rtype index: integer(c_int) :rtype index: integer(c_int)
-------- --------
.. f:function:: find_compute_neighlist() .. f:function:: find_compute_neighlist(id[, reqid])
Find index of a neighbor list requested by a compute. Find index of a neighbor list requested by a compute.
@ -1582,11 +1582,11 @@ Procedures Bound to the :f:type:`lammps` Derived Type
the request ID. The request ID is typically zero, but will be :math:`> 0` the request ID. The request ID is typically zero, but will be :math:`> 0`
in case a compute has multiple neighbor list requests. in case a compute has multiple neighbor list requests.
:p character(len=\*) id: Identifier of compute instance :p character(len=\*) id: Identifier of compute instance.
:p integer(c_int) reqid: request ID to identify the neighbor list in cases :o integer(c_int) reqid: request ID to identify the neighbor list in cases
in which there are multiple requests from the same compute in which there are multiple requests from the same compute. Default: 0.
:to: :cpp:func:`lammps_find_compute_neighlist` :to: :cpp:func:`lammps_find_compute_neighlist`
:r index: neighbor list index if found, otherwise :math:`-1` :r index: neighbor list index if found, otherwise :math:`-1`.
:rtype index: integer(c_int) :rtype index: integer(c_int)
-------- --------

View File

@ -1892,11 +1892,17 @@ CONTAINS
INTEGER(c_int) FUNCTION lmp_find_fix_neighlist(self, id, reqid) RESULT(idx) INTEGER(c_int) FUNCTION lmp_find_fix_neighlist(self, id, reqid) RESULT(idx)
CLASS(lammps), INTENT(IN) :: self CLASS(lammps), INTENT(IN) :: self
CHARACTER(LEN=*), INTENT(IN) :: id CHARACTER(LEN=*), INTENT(IN) :: id
INTEGER(c_int), INTENT(IN) :: reqid INTEGER(c_int), INTENT(IN), OPTIONAL :: reqid
TYPE(c_ptr) :: Cid TYPE(c_ptr) :: Cid
INTEGER(c_int) :: Creqid
IF (PRESENT(reqid)) THEN
Creqid = reqid
ELSE
Creqid = 0_c_int
END IF
Cid = f2c_string(id) Cid = f2c_string(id)
idx = lammps_find_fix_neighlist(self%handle, Cid, reqid) idx = lammps_find_fix_neighlist(self%handle, Cid, Creqid)
IF (idx < 0) THEN IF (idx < 0) THEN
CALL lmp_error(self, LMP_ERROR_WARNING + LMP_ERROR_WORLD, & CALL lmp_error(self, LMP_ERROR_WARNING + LMP_ERROR_WORLD, &
'neighbor list not found [Fortran/find_fix_neighlist]') 'neighbor list not found [Fortran/find_fix_neighlist]')
@ -1909,11 +1915,17 @@ CONTAINS
RESULT(idx) RESULT(idx)
CLASS(lammps), INTENT(IN) :: self CLASS(lammps), INTENT(IN) :: self
CHARACTER(LEN=*), INTENT(IN) :: id CHARACTER(LEN=*), INTENT(IN) :: id
INTEGER(c_int), INTENT(IN) :: reqid INTEGER(c_int), INTENT(IN), OPTIONAL :: reqid
TYPE(c_ptr) :: Cid TYPE(c_ptr) :: Cid
INTEGER(c_int) :: Creqid
IF (PRESENT(reqid)) THEN
Creqid = reqid
ELSE
Creqid = 0_c_int
END IF
Cid = f2c_string(id) Cid = f2c_string(id)
idx = lammps_find_compute_neighlist(self%handle, Cid, reqid) idx = lammps_find_compute_neighlist(self%handle, Cid, Creqid)
IF (idx < 0) THEN IF (idx < 0) THEN
CALL lmp_error(self, LMP_ERROR_WARNING + LMP_ERROR_WORLD, & CALL lmp_error(self, LMP_ERROR_WARNING + LMP_ERROR_WORLD, &
'neighbor list not found [Fortran/find_compute_neighlist]') 'neighbor list not found [Fortran/find_compute_neighlist]')