From 5c50ce8765d834601fd8906b8ee29b50ae5cb54c Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Thu, 22 Jul 2021 13:58:05 -0400 Subject: [PATCH] Add first/last flag --- src/opt_delete.f90 | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/opt_delete.f90 b/src/opt_delete.f90 index c111b90..f631693 100644 --- a/src/opt_delete.f90 +++ b/src/opt_delete.f90 @@ -8,6 +8,7 @@ module opt_delete implicit none real(kind=dp) :: rc_off + logical :: first public contains @@ -34,6 +35,7 @@ module opt_delete character(len=100) :: textholder arg_pos = arg_pos + 1 + first = .true. call get_command_argument(arg_pos, textholder, arg_len) if(arg_len==0) stop "Missing argument to delete command" @@ -49,6 +51,24 @@ module opt_delete end select arg_pos = arg_pos + 1 + + do while(.true.) + if(arg_pos > command_argument_count()) exit + !Pull out the next argument which should either be a keyword or an option + arg_pos=arg_pos+1 + call get_command_argument(arg_pos, textholder) + textholder=adjustl(textholder) + + select case(trim(textholder)) + case('first') + first=.true. + case('last') + first=.false. + case default + !if it isn't an available option to opt_group then we just exit + exit + end select + end do end subroutine parse_delete subroutine delete_overlap @@ -99,7 +119,11 @@ module opt_delete if (norm2(r_atom(:,nei)-r_atom(:,i)) < rc_off) then delete_num = delete_num + 1 - for_delete(delete_num) = max(i,nei) + if(first) then + for_delete(delete_num) = min(i,nei) + else + for_delete(delete_num) = max(i,nei) + end if !Now zero out the larger index if(i < nei) then