!***********************************************************************
! 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 SXINM1(MM,NM,IM,IT,T,R,MI)

  IMPLICIT NONE
  INTEGER(8) :: MM,NM,IM,IE,MI,K,M
  INTEGER(8) :: N1,M1,MN
  INTEGER(8) :: IT(IM/2)  
  REAL(8) :: T(IM*3/2)
  REAL(8) :: R(5*(MM/MI+1)*(2*NM-MM/MI*MI)/4+MM/MI+1)
  INTEGER(8) :: NPMAX  

  CALL FXRINI(IM,IT,T)    
  CALL LXINIR(NM,0_8,R)

  N1=MM/MI+1
  M1=N1*MI
  MN=N1
  IF(MM/MI-M1/MI.GE.0) THEN
     MN=MN+1
  END IF

  CALL MXGOMP(NPMAX)  

  !$omp parallel private(K,M,IE) num_threads(NPMAX)
  !$omp do schedule(dynamic) 
  DO K=0,MN-1
     IE=5*K*(2*NM-MI*(K-1))/4+K+1 ! サイズを変えたのでこうなる
     M=K*MI
     CALL LXINIR(NM,M,R(IE))       
  END DO
!$omp end do
!$omp end parallel  

END SUBROUTINE SXINM1
