!***********************************************************************
! ISPACK FORTRAN SUBROUTINE LIBRARY FOR SCIENTIFIC COMPUTING
! Copyright (C) 1998--2019 Keiichi Ishioka <ishioka@gfd-dennou.org>
!
! This library is free software; you can redistribute it and/or
! modify it under the terms of the GNU Lesser General Public
! License as published by the Free Software Foundation; either
! version 2.1 of the License, or (at your option) any later version.
!
! This library is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
! Lesser General Public License for more details.
! 
! You should have received a copy of the GNU Lesser General Public
! License along with this library; if not, write to the Free Software
! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
! 02110-1301 USA.
!***********************************************************************
SUBROUTINE SXNMML(NN,N,M,L,MI)

  IMPLICIT NONE
  INTEGER(8) :: NN,N,M,L,MI,MA,K

  MA=ABS(M)
  K=MA/MI

  IF(M.EQ.0) THEN
     L=N+1
  ELSE IF(M.GT.0) THEN
     L=K*(2*(NN+1)-(K-1)*MI)+1+2*(N-M)
  ELSE
     L=K*(2*(NN+1)-(K-1)*MI)+1+2*(N+M)+1
  END IF

END SUBROUTINE SXNMML
