diff --git a/doc/src/Fortran.rst b/doc/src/Fortran.rst index 277170eefe..bda059432f 100644 --- a/doc/src/Fortran.rst +++ b/doc/src/Fortran.rst @@ -1517,7 +1517,7 @@ Procedures Bound to the :f:type:`lammps` Derived Type -------- -.. f:function:: find_pair_neighlist(style, exact, nsub, reqid) +.. f:function:: find_pair_neighlist(style[, exact][, nsub][, reqid]) Find index of a neighbor list requested by a pair style. @@ -1539,13 +1539,14 @@ Procedures Bound to the :f:type:`lammps` Derived Type lists and set the request ID to a value greater than zero. :p character(len=\*) style: String used to search for pair style instance. - :p exact: Flag to control whther style should match exactly or only a - regular expression/sub-string match is applied. - :ptype exact: logical - :p integer(c_int) nsub: Match *nsub*\ th hybrid sub-style instance of - the same style - :p integer(c_int) reqid: Request ID to identify the neighbor list in + :o exact: Flag to control whther style should match exactly or only a + regular expression/sub-string match is applied. Default: ``.TRUE.``. + :otype exact: logical + :o integer(c_int) nsub: Match *nsub*\ th hybrid sub-style instance of + the same style. Default: 0. + :o integer(c_int) reqid: Request ID to identify the neighbor list in case there are multiple requests from the same pair style instance. + Default: 0. :to: :cpp:func:`lammps_find_pair_neighlist` :r integer(c_int) index: Neighbor list index if found, otherwise :math:`-1`. diff --git a/fortran/lammps.f90 b/fortran/lammps.f90 index 3eb4f54762..ca065384b5 100644 --- a/fortran/lammps.f90 +++ b/fortran/lammps.f90 @@ -1857,19 +1857,30 @@ CONTAINS reqid) CLASS(lammps), INTENT(IN) :: self CHARACTER(LEN=*), INTENT(IN) :: style - LOGICAL, INTENT(IN) :: exact - INTEGER(c_int), INTENT(IN) :: nsub, reqid + LOGICAL, INTENT(IN), OPTIONAL :: exact + INTEGER(c_int), INTENT(IN), OPTIONAL :: nsub, reqid TYPE(c_ptr) :: Cstyle - INTEGER(c_int) :: Cexact + INTEGER(c_int) :: Cexact, Cnsub, Creqid - IF (exact) THEN - Cexact = 1_c_int + Cexact = 0_c_int + IF (PRESENT(exact)) THEN + IF (exact) THEN + Cexact = 1_c_int + END IF + END IF + IF (PRESENT(nsub)) THEN + Cnsub = nsub ELSE - Cexact = 0_c_int + Cnsub = 0_c_int + END IF + IF (PRESENT(reqid)) THEN + Creqid = reqid + ELSE + Creqid = 0_c_int END IF Cstyle = f2c_string(style) lmp_find_pair_neighlist = lammps_find_pair_neighlist(self%handle, Cstyle, & - Cexact, nsub, reqid) + Cexact, Cnsub, Creqid) IF (lmp_find_pair_neighlist < 0) THEN CALL lmp_error(self, LMP_ERROR_WARNING + LMP_ERROR_WORLD, & 'unable to find pair neighbor list [Fortran/find_pair_neighlist]')