text:
c  f90-intrinsic-numeric.f
c
c Test Fortran 90 intrinsic numeric functions - Section 13.10.2 and 13.13
c     David Billinghurst <David.Billinghurst@riotinto.com>
c
c Notes:
c  * g77 does not fully comply with F90.  Noncompliances noted in comments.
c  * Section 13.12: Specific names for intrinsic functions tested in
c intrinsic77.f

      logical fail
      integer*2 j, j2, ja
      integer*1 k, k2, ka

      common /flags/ fail
      fail = .false.

c     ABS - Section 13.13.1
      j = -9
      ja = 9
      k = j
      ka = ja
      call c_i(ABS(-7),7,'ABS(integer)')
      call c_i2(ABS(j),ja,'ABS(integer*2)')
      call c_i1(ABS(k),ka,'ABS(integer*1)')
      call c_r(ABS(-7.),7.,'ABS(real)')
      call c_d(ABS(-7.d0),7.d0,'ABS(double)')
      call c_r(ABS((3.,-4.)),5.0,'ABS(complex)')
      call c_d(ABS((3.d0,-4.d0)),5.0d0,'ABS(double complex)')

c     AIMAG - Section 13.13.6
      call c_r(AIMAG((2.,-7.)),-7.,'AIMAG(complex)')
c     g77: AIMAG(double complex) does not comply with F90
c     call c_d(AIMAG((2.d0,-7.d0)),-7.d0,'AIMAG(double complex)')

c     AINT - Section 13.13.7
      call c_r(AINT(2.783),2.0,'AINT(real) 1')
      call c_r(AINT(-2.783),-2.0,'AINT(real) 2')
      call c_d(AINT(2.783d0),2.0d0,'AINT(double precision) 1')
      call c_d(AINT(-2.783d0),-2.0d0,'AINT(double precision) 2')
c     Note:  g77 does not support optional argument KIND

c     ANINT - Section 13.13.10
      call c_r(ANINT(2.783),3.0,'ANINT(real) 1')
      call c_r(ANINT(-2.783),-3.0,'ANINT(real) 2')
      call c_d(ANINT(2.783d0),3.0d0,'ANINT(double precision) 1')
      call c_d(ANINT(-2.783d0),-3.0d0,'ANINT(double precision) 2')
c     Note:  g77 does not support optional argument KIND

c     CEILING - Section 13.13.18
c     Not implemented

c     CMPLX - Section 13.13.20
      j = 1
      ja = 2
      k = 1
      ka = 2
      call c_c(CMPLX(1),(1.,0.),'CMPLX(integer)')
      call c_c(CMPLX(1,2),(1.,2.),'CMPLX(integer, integer)')
      call c_c(CMPLX(j),(1.,0.),'CMPLX(integer*2)')
      call c_c(CMPLX(j,ja),(1.,2.),'CMPLX(integer*2, integer*2)')
      call c_c(CMPLX(k),(1.,0.),'CMPLX(integer*1)')
      call c_c(CMPLX(k,ka),(1.,2.),'CMPLX(integer*1, integer*1)')
      call c_c(CMPLX(1.),(1.,0.),'CMPLX(real)')
      call c_c(CMPLX(1.d0),(1.,0.),'CMPLX(double)')
      call c_c(CMPLX(1.d0,2.d0),(1.,2.),'CMPLX(double,double)')
      call c_c(CMPLX(1.,2.),(1.,2.),'CMPLX(complex)')
      call c_c(CMPLX(1.d0,2.d0),(1.,2.),'CMPLX(double complex)')
c     NOTE: g77 does not support optional argument KIND

c     CONJG - Section 13.13.21
      call c_c(CONJG((2.,-7.)),(2.,7.),'CONJG(complex)')
      call c_z(CONJG((2.d0,-7.d0)),(2.d0,7.d0),'CONJG(double complex)')

c     DBLE - Section 13.13.27
      j = 5
      k = 5
      call c_d(DBLE(5),5.0d0,'DBLE(integer)')
      call c_d(DBLE(j),5.0d0,'DBLE(integer*2)')
      call c_d(DBLE(k),5.0d0,'DBLE(integer*1)')
      call c_d(DBLE(5.),5.0d0,'DBLE(real)')
      call c_d(DBLE(5.0d0),5.0d0,'DBLE(double)')
      call c_d(DBLE((5.0,0.5)),5.0d0,'DBLE(complex)')
      call c_d(DBLE((5.0d0,0.5d0)),5.0d0,'DBLE(double complex)')

c     DIM - Section 13.13.29
      j = -8
      j2 = -3
      ja = 0
      k = -8
      k2 = -3
      ka = 0
      call c_i(DIM(-8,-3),0,'DIM(integer)')
      call c_i2(DIM(j,j2),ja,'DIM(integer*2)')
      call c_i1(DIM(k,k2),ka,'DIM(integer*1)')
      call c_r(DIM(-8.,-3.),0.,'DIM(real,real)')
      call c_d(DIM(-8.d0,-3.d0),0.d0,'DIM(double,double)')

c     DPROD - Section 13.13.31
      call c_d(DPROD(-8.,-3.),24.d0,'DPROD(real,real)')

c     FLOOR - Section 13.13.36
c     Not implemented

c     INT - Section 13.13.47
      j = 5
      k = 5
      call c_i(INT(5),5,'INT(integer)')
      call c_i(INT(j),5,'INT(integer*2)')
      call c_i(INT(k),5,'INT(integer*1)')
      call c_i(INT(5.01),5,'INT(real)')
      call c_i(INT(5.01d0),5,'INT(double)')
c     Note: Does not accept optional second argument KIND

c     MAX - Section 13.13.63
      j = 1
      j2 = 2
      ja = 2
      k = 1
      k2 = 2
      ka = 2
      call c_i(MAX(1,2,3),3,'MAX(integer,integer,integer)')
      call c_i2(MAX(j,j2),ja,'MAX(integer*2,integer*2)')
      call c_i1(MAX(k,k2),ka,'MAX(integer*1,integer*1)')
      call c_r(MAX(1.,2.,3.),3.,'MAX(real,real,real)')
      call c_d(MAX(1.d0,2.d0,3.d0),3.d0,'MAX(double,double,double)')

c     MIN - Section 13.13.68
      j = 1
      j2 = 2
      ja = 1
      k = 1
      k2 = 2
      ka = 1
      call c_i(MIN(1,2,3),1,'MIN(integer,integer,integer)')
      call c_i2(MIN(j,j2),ja,'MIN(integer*2,integer*2)')
      call c_i1(MIN(k,k2),ka,'MIN(integer*1,integer*1)')
      call c_r(MIN(1.,2.,3.),1.,'MIN(real,real,real)')
      call c_d(MIN(1.d0,2.d0,3.d0),1.d0,'MIN(double,double,double)')

c     MOD - Section 13.13.72
      call c_i(MOD(8,5),3,'MOD(integer,integer) 1')
      call c_i(MOD(-8,5),-3,'MOD(integer,integer) 2')
      call c_i(MOD(8,-5),3,'MOD(integer,integer) 3')
      call c_i(MOD(-8,-5),-3,'MOD(integer,integer) 4')
      j = 8
      j2 = 5
      ja = 3
      call c_i2(MOD(j,j2),ja,'MOD(integer*2,integer*2) 1')
      call c_i2(MOD(-j,j2),-ja,'MOD(integer*2,integer*2) 2')
      call c_i2(MOD(j,-j2),ja,'MOD(integer*2,integer*2) 3')
      call c_i2(MOD(-j,-j2),-ja,'MOD(integer*2,integer*2) 4')
      k = 8
      k2 = 5
      ka = 3
      call c_i1(MOD(k,k2),ka,'MOD(integer*1,integer*1) 1')
      call c_i1(MOD(-k,k2),-ka,'MOD(integer*1,integer*1) 2')
      call c_i1(MOD(k,-k2),ka,'MOD(integer*1,integer*1) 3')
      call c_i1(MOD(-k,-k2),-ka,'MOD(integer*1,integer*1) 4')
      call c_r(MOD(8.,5.),3.,'MOD(real,real) 1')
      call c_r(MOD(-8.,5.),-3.,'MOD(real,real) 2')
      call c_r(MOD(8.,-5.),3.,'MOD(real,real) 3')
      call c_r(MOD(-8.,-5.),-3.,'MOD(real,real) 4')
      call c_d(MOD(8.d0,5.d0),3.d0,'MOD(double,double) 1')
      call c_d(MOD(-8.d0,5.d0),-3.d0,'MOD(double,double) 2')
      call c_d(MOD(8.d0,-5.d0),3.d0,'MOD(double,double) 3')
      call c_d(MOD(-8.d0,-5.d0),-3.d0,'MOD(double,double) 4')

c     MODULO - Section 13.13.73
c     Not implemented

c     NINT - Section 13.13.76
      call c_i(NINT(2.783),3,'NINT(real)')
      call c_i(NINT(2.783d0),3,'NINT(double)')
c     Optional second argument KIND not implemented

c     REAL - Section 13.13.86
      j = -2
      k = -2
      call c_r(REAL(-2),-2.0,'REAL(integer)')
      call c_r(REAL(j),-2.0,'REAL(integer*2)')
      call c_r(REAL(k),-2.0,'REAL(integer*1)')
      call c_r(REAL(-2.0),-2.0,'REAL(real)')
      call c_r(REAL(-2.0d0),-2.0,'REAL(double)')
      call c_r(REAL((-2.,9.)),-2.0,'REAL(complex)')
c     REAL(double complex) not implemented
c     call c_r(REAL((-2.d0,9.d0)),-2.0,'REAL(double complex)')

c     SIGN - Section 13.13.96
      j = -3
      j2 = 2
      ja = 3
      k = -3
      k2 = 2
      ka = 3
      call c_i(SIGN(-3,2),3,'SIGN(integer)')
      call c_i2(SIGN(j,j2),ja,'SIGN(integer*2)')
      call c_i1(SIGN(k,k2),ka,'SIGN(integer*1)')
      call c_r(SIGN(-3.0,2.),3.,'SIGN(real,real)')
      call c_d(SIGN(-3.d0,2.d0),3.d0,'SIGN(double,double)')

      if ( fail ) call abort()
      end

      subroutine failure(label)
c     Report failure and set flag
      character*(*) label
      logical fail
      common /flags/ fail
      write(6,'(a,a,a)') 'Test ',label,' FAILED'
      fail = .true.
      end

      subroutine c_i(i,j,label)
c     Check if INTEGER i equals j, and fail otherwise
      integer i,j
      character*(*) label
      if ( i .ne. j ) then
         call failure(label)
         write(6,*) 'Got ',i,' expected ', j
      end if
      end

      subroutine c_i2(i,j,label)
c     Check if INTEGER*2 i equals j, and fail otherwise
      integer*2 i,j
      character*(*) label
      if ( i .ne. j ) then
         call failure(label)
         write(6,*) 'Got ',i,' expected ', j
      end if
      end

      subroutine c_i1(i,j,label)
c     Check if INTEGER*1 i equals j, and fail otherwise
      integer*1 i,j
      character*(*) label
      if ( i .ne. j ) then
         call failure(label)
         write(6,*) 'Got ',i,' expected ', j
      end if
      end

      subroutine c_r(a,b,label)
c     Check if REAL a equals b, and fail otherwise
      real a, b
      character*(*) label
      if ( abs(a-b) .gt. 1.0e-5 ) then
         call failure(label)
         write(6,*) 'Got ',a,' expected ', b
      end if
      end

      subroutine c_d(a,b,label)
c     Check if DOUBLE PRECISION a equals b, and fail otherwise
      double precision a, b
      character*(*) label
      if ( abs(a-b) .gt. 1.0d-5 ) then
         call failure(label)
         write(6,*) 'Got ',a,' expected ', b
      end if
      end

      subroutine c_c(a,b,label)
c     Check if COMPLEX a equals b, and fail otherwise
      complex a, b
      character*(*) label
      if ( abs(a-b) .gt. 1.0e-5 ) then
         call failure(label)
         write(6,*) 'Got ',a,' expected ', b
      end if
      end

      subroutine c_z(a,b,label)
c     Check if COMPLEX a equals b, and fail otherwise
      double complex a, b
      character*(*) label
      if ( abs(a-b) .gt. 1.0d-5 ) then
         call failure(label)
         write(6,*) 'Got ',a,' expected ', b
      end if
      end

ext: f


text:
      SUBROUTINE SB01FY( DISCR, N, M, A, LDA, B, LDB, F, LDF, V, LDV,
     $                   INFO )
C
C     SLICOT RELEASE 5.5.
C
C     Copyright (c) 2002-2012 NICONET e.V.
C
C     PURPOSE
C
C     To compute the inner denominator of a right-coprime factorization
C     of a system of order N, where N is either 1 or 2. Specifically,
C     given the N-by-N unstable system state matrix A and the N-by-M
C     system input matrix B, an M-by-N state-feedback matrix F and
C     an M-by-M matrix V are constructed, such that the system
C     (A + B*F, B*V, F, V) is inner.
C
C     ARGUMENTS
C
C     Mode Parameters
C
C     DISCR   LOGICAL
C             Specifies the type of system as follows:
C             = .FALSE.:  continuous-time system;
C             = .TRUE. :  discrete-time system.
C
C     Input/Output Parameters
C
C     N       (input) INTEGER
C             The order of the matrix A and also the number of rows of
C             the matrix B and the number of columns of the matrix F.
C             N is either 1 or 2.
C
C     M       (input) INTEGER
C             The number of columns of the matrices B and V, and also
C             the number of rows of the matrix F.  M >= 0.
C
C     A       (input) DOUBLE PRECISION array, dimension (LDA,N)
C             The leading N-by-N part of this array must contain the
C             system state matrix A whose eigenvalues must have positive
C             real parts if DISCR = .FALSE. or moduli greater than unity
C             if DISCR = .TRUE..
C
C     LDA     INTEGER
C             The leading dimension of array A.  LDA >= N.
C
C     B       (input) DOUBLE PRECISION array, dimension (LDB,M)
C             The leading N-by-M part of this array must contain the
C             system input matrix B.
C
C     LDB     INTEGER
C             The leading dimension of array B.  LDB >= N.
C
C     F       (output) DOUBLE PRECISION array, dimension (LDF,N)
C             The leading M-by-N part of this array contains the state-
C             feedback matrix F which assigns one eigenvalue (if N = 1)
C             or two eigenvalues (if N = 2) of the matrix A + B*F in
C             symmetric positions with respect to the imaginary axis
C             (if DISCR = .FALSE.) or the unit circle (if
C             DISCR = .TRUE.).
C
C     LDF     INTEGER
C             The leading dimension of array F.  LDF >= MAX(1,M).
C
C     V       (output) DOUBLE PRECISION array, dimension (LDV,M)
C             The leading M-by-M upper triangular part of this array
C             contains the input/output matrix V of the resulting inner
C             system in upper triangular form.
C             If DISCR = .FALSE., the resulting V is an identity matrix.
C
C     LDV     INTEGER
C             The leading dimension of array V.  LDF >= MAX(1,M).
C
C     Error Indicator
C
C     INFO    INTEGER
C             = 0:  successful exit;
C             = 1:  if uncontrollability of the pair (A,B) is detected;
C             = 2:  if A is stable or at the stability limit;
C             = 3:  if N = 2 and A has a pair of real eigenvalues.
C
C     CONTRIBUTOR
C
C     A. Varga, German Aerospace Center,
C     DLR Oberpfaffenhofen, July 1998.
C     Based on the RASP routine RCFID2.
C
C     REVISIONS
C
C     Nov. 1998, V. Sima, Research Institute for Informatics, Bucharest.
C     Dec. 1998, V. Sima, Katholieke Univ. Leuven, Leuven.
C     Feb. 1999, A. Varga, DLR Oberpfaffenhofen.
C
C     KEYWORDS
C
C     Coprime factorization, eigenvalue, eigenvalue assignment,
C     feedback control, pole placement, state-space model.
C
C     ******************************************************************
C
C     .. Parameters ..
      DOUBLE PRECISION  ONE, TWO, ZERO
      PARAMETER         ( ONE = 1.0D0, TWO = 2.0D0, ZERO = 0.0D0 )
C     .. Scalar Arguments ..
      LOGICAL           DISCR
      INTEGER           INFO, LDA, LDB, LDF, LDV, M, N
C     .. Array Arguments ..
      DOUBLE PRECISION  A(LDA,*), B(LDB,*), F(LDF,*), V(LDV,*)
C     .. Local Scalars ..
      INTEGER           I
      DOUBLE PRECISION  CS, R11, R12, R22, SCALE, SN, TEMP
C     .. Local Arrays ..
      DOUBLE PRECISION  AT(2,2), DUMMY(2,2), U(2,2)
C     .. External Functions ..
      DOUBLE PRECISION  DLAPY2, DLAPY3
      EXTERNAL          DLAPY2, DLAPY3
C     .. External Subroutines ..
      EXTERNAL          DLARFG, DLASET, DLATZM, DROTG, DTRTRI, MA02AD,
     $                  MB04OX, SB03OY
C     .. Intrinsic Functions ..
      INTRINSIC         ABS, SQRT
C     .. Executable Statements ..
C
C     For efficiency reasons, the parameters are not checked.
C
      INFO = 0
C
C     Compute an N-by-N upper triangular R such that R'*R = B*B' and
C     find an upper triangular matrix U in the equation
C
C     A'*U'*U + U'*U*A = R'*R if DISCR = .FALSE. or
C     A'*U'*U*A - U'*U = R'*R if DISCR = .TRUE. .
C
      CALL MA02AD( 'Full', N, M, B, LDB, F, LDF )
C
      IF( N.EQ.1 ) THEN
C
C        The N = 1 case.
C
         IF( M.GT.1 )
     $      CALL DLARFG( M, F(1,1), F(2,1), 1, TEMP )
         R11 = ABS( F(1,1) )
C
C        Make sure A is unstable or divergent and find U.
C
         IF( DISCR ) THEN
            TEMP = ABS( A(1,1) )
            IF( TEMP.LE.ONE ) THEN
               INFO = 2
               RETURN
            ELSE
               TEMP = R11 / SQRT( ( TEMP - ONE )*( TEMP + ONE ) )
            END IF
         ELSE
            IF( A(1,1).LE.ZERO ) THEN
               INFO = 2
               RETURN
            ELSE
               TEMP = R11 / SQRT( ABS( TWO*A(1,1) ) )
            END IF
         END IF
         U(1,1) = TEMP
         SCALE  = ONE
      ELSE
C
C        The N = 2 case.
C
         IF( M.GT.1 ) THEN
            CALL DLARFG( M, F(1,1), F(2,1), 1, TEMP )
            CALL DLATZM( 'Left', M, N-1, F(2,1), 1, TEMP, F(1,2),
     $                   F(2,2), LDF, V )
         END IF
         R11 = F(1,1)
         R12 = F(1,2)
         IF( M.GT.2 )
     $      CALL DLARFG( M-1, F(2,2), F(3,2), 1, TEMP )
         IF( M.EQ.1 ) THEN
            R22 = ZERO
         ELSE
            R22 = F(2,2)
         END IF
         AT(1,1) = A(1,1)
         AT(1,2) = A(2,1)
         AT(2,1) = A(1,2)
         AT(2,2) = A(2,2)
         U(1,1)  = R11
         U(1,2)  = R12
         U(2,2)  = R22
         CALL SB03OY( DISCR, .FALSE., -1, AT, 2, U, 2, DUMMY, 2,
     $                SCALE, INFO )
         IF( INFO.NE.0 ) THEN
            IF( INFO.NE.4 ) THEN
               INFO = 2
            ELSE
               INFO = 3
            END IF
            RETURN
         END IF
      END IF
C
C     Check the controllability of the pair (A,B).
C
C     Warning. Only an exact controllability check is performed.
C              If the pair (A,B) is nearly uncontrollable, then
C              the computed results may be inaccurate.
C
      DO 10 I = 1, N
         IF( U(I,I).EQ.ZERO ) THEN
            INFO = 1
            RETURN
         END IF
   10 CONTINUE
C
C     Set V = I.
C
      CALL DLASET( 'Upper', M, M, ZERO, ONE, V, LDV )
C
      IF( DISCR ) THEN
C
C        Compute an upper triangular matrix V such that
C                                 -1
C        V*V' = (I+B'*inv(U'*U)*B)  .
C
C        First compute F = B'*inv(U) and the Cholesky factorization
C        of I + F*F'.
C
         DO 20 I = 1, M
            F(I,1) = B(1,I)/U(1,1)*SCALE
   20    CONTINUE
         IF( N.EQ.2 ) THEN
            DO 30 I = 1, M
               F(I,2) = ( B(2,I) - F(I,1)*U(1,2) )/U(2,2)*SCALE
   30       CONTINUE
            CALL MB04OX( M, V, LDV, F(1,2), 1 )
         END IF
         CALL MB04OX( M, V, LDV, F(1,1), 1 )
         CALL DTRTRI( 'Upper', 'NonUnit', M, V, LDV, INFO )
      END IF
C
C     Compute the feedback matrix F as:
C
C     1)   If DISCR = .FALSE.
C
C             F = -B'*inv(U'*U);
C
C     2)   If DISCR = .TRUE.
C                                -1
C             F = -B'*(U'*U+B*B')  *A.
C
      IF( N.EQ.1 ) THEN
         IF( DISCR ) THEN
            TEMP = -A(1,1)
            R11  = DLAPY2( U(1,1), R11 )
            DO 40 I = 1, M
               F(I,1) = ( ( B(1,I)/R11 )/R11 )*TEMP
   40       CONTINUE
         ELSE
            R11 = U(1,1)
            DO 50 I = 1, M
               F(I,1) = -( ( B(1,I)/R11 )/R11 )
   50       CONTINUE
         END IF
      ELSE
C
C        Set R = U  if DISCR = .FALSE. or compute the Cholesky
C        factorization of R'*R = U'*U+B*B' if DISCR = .TRUE..
C
         IF( DISCR ) THEN
            TEMP = U(1,1)
            CALL DROTG( R11, TEMP, CS, SN )
            TEMP = -SN*R12 + CS*U(1,2)
            R12  =  CS*R12 + SN*U(1,2)
            R22  = DLAPY3( R22, TEMP, U(2,2) )
         ELSE
            R11 = U(1,1)
            R12 = U(1,2)
            R22 = U(2,2)
         END IF
C
C        Compute F = -B'*inv(R'*R).
C
         DO 60 I = 1, M
            F(I,1) = -B(1,I)/R11
            F(I,2) = -( B(2,I) + F(I,1)*R12 )/R22
            F(I,2) =  F(I,2)/R22
            F(I,1) =  ( F(I,1) - F(I,2)*R12 )/R11
   60    CONTINUE
         IF( DISCR ) THEN
C
C           Compute F <-- F*A.
C
            DO 70 I = 1, M
               TEMP   = F(I,1)*A(1,1) + F(I,2)*A(2,1)
               F(I,2) = F(I,1)*A(1,2) + F(I,2)*A(2,2)
               F(I,1) = TEMP
   70       CONTINUE
         END IF
      END IF
C
      RETURN
C *** Last line of SB01FY ***
      END

max_stars_repo_name: bgin/MissileSimulation

max_issues_repo_name: bgin/MissileSimulation

max_forks_repo_name: bgin/MissileSimulation


text:
!***********************************************************************
!                                                                      *
      SUBROUTINE LDLBL1 (NAME)
!                                                                      *
!   Open, check and load data from the  .lsj.lbl   file of the         *
!   inital state.                                                      *
!                                                                      *
!   Call(s) to: [LIB92]: ALLOC.                                        *
!                                                                      *
!   Written by G. Gaigalas,                                            *
!   NIST                                                  May 2011     *
!                                                                      *
!***********************************************************************
!...Translated by Charlotte Froese Fischer
!                       Gediminas Gaigalas  10/05/17
!-----------------------------------------------
!   M o d u l e s
!-----------------------------------------------
      USE vast_kind_param, ONLY: DOUBLE
      USE memory_man
      USE jj2lsjbio_C
      IMPLICIT NONE
!-----------------------------------------------
!   D u m m y   A r g u m e n t s
!-----------------------------------------------
      CHARACTER(LEN=*), INTENT(IN) :: NAME
!-----------------------------------------------
!   L o c a l   V a r i a b l e s
!-----------------------------------------------
      REAL(DOUBLE) :: WEIGHTS
      CHARACTER    :: RECORD*15
      INTEGER      :: ICount, IOS, ITEST, J
!-----------------------------------------------
!
!   Check the first record of the file; if not as expected, try again
!
      J = INDEX(NAME,' ')
      OPEN (UNIT = 31,FILE=NAME(1:J-1)//'.lsj.lbl',FORM='FORMATTED',  &
           STATUS='OLD',IOSTAT = IOPEN_STATUS1)
      IF(IOPEN_STATUS1 == 0) THEN
         READ (31,'(1A15)',IOSTAT = IOS) RECORD
         IF (IOS /= 0) THEN
            PRINT *, 'Not a i *.lsj.lbl  File;'
            CLOSE (31)
            STOP
         ELSE
            CALL ALLOC (Lev_POS_1,  NVECTOTI,'Lev_POS_1',  'LDLBL1')
            CALL ALLOC (Lev_J_1,    NVECTOTI,'Lev_J_1',    'LDLBL1')
            CALL ALLOC (Lev_Par_1,  NVECTOTI,'Lev_Par_1',  'LDLBL1')
            CALL ALLOC (RLev_ENER_1,NVECTOTI,'RLev_ENER_1','LDLBL1')
!CPJ        CALL ALLOC (string_CSF1,NVECTOTI,'string_CSF1','LDLBL1')
            allocate(string_CSF1(NVECTOTI))
!
            ICount = 1
            READ (31,'(1X,I2,1X,A4,5X,A1,8X,F16.9)',IOSTAT = IOS)     &
              Lev_Pos_1(ICount),Lev_J_1(ICount),Lev_Par_1(ICount),    &
              RLev_ENER_1(ICount)
            IF (IOS .NE. 0) GO TO 1
!
            READ (31,'(7X,F12.8,17X,A)') WEIGHTS,string_CSF1(ICount)
!
    2       READ (31,'(1X,I2)',IOSTAT = IOS),ITEST
            IF (IOS .NE. 0) GO TO 1
            IF (ITEST .EQ. 0) GO TO 2
            BACKSPACE 31
            ICount = ICount + 1
            READ (31,'(1X,I2,1X,A4,5X,A1,8X,F16.9)',IOSTAT = IOS)     &
              Lev_Pos_1(ICount),Lev_J_1(ICount),Lev_Par_1(ICount),    &
              RLev_ENER_1(ICount)
            IF (IOS .NE. 0) GO TO 1
            READ (31,'(7X,F12.8,17X,A)') WEIGHTS,string_CSF1(ICount)
            GO TO 2
         ENDIF
      ENDIF
    1 CONTINUE
      CLOSE (31)
      RETURN
      END SUBROUTINE LDLBL1

max_stars_repo_name: CYChenFudan/grasp

max_issues_repo_name: CYChenFudan/grasp

max_forks_repo_name: CYChenFudan/grasp


text:
!#########################################################################
!# ***********************************************************************
!# <name> mapleio </name>
!# ***********************************************************************
!#
!# <purpose>
!# This module contains different routines for MAPLE export.
!# This feature can be used e.g. for debugging purposes to quickly analyse
!# situaltions inside of the program.
!#
!# The following routines can be found in this module:
!#
!# 1.) mapleio_writePointArray
!#     -> Writes a MAPLE command to an output channel for creating a
!#        point array
!#
!# 2.) mapleio_writePolygonPlot
!#     -> Writes a MAPLE PLOT command to an output channel for creating a
!#        polygon
!#
!# 3.) mapleio_writePointPlot
!#     -> Writes a MAPLE PLOT command to an output channel for creating a
!#        point set
!'
!# </purpose>
!#########################################################################

module mapleio

!$ use omp_lib
  use fsystem
  use storage
  use io
  use basicgeometry

  implicit none

  private

  interface mapleio_writePointPlot
    module procedure mapleio_writePointPlotSingle
    module procedure mapleio_writePointPlotMult
  end interface

  public :: mapleio_writePointArray
  public :: mapleio_writePolygonPlot
  public :: mapleio_writePointPlot

contains

  ! ***************************************************************************

!<subroutine>
  subroutine mapleio_writePointArray (ichannel,Dpoints,sname,iindex)

  !<description>
    ! Writes a MAPLE command to output channel ichannel which creates
    ! a MAPLE array containing the points in Dpoints. The MAPLE variable
    ! name will get the name 'sname'. If
    ! iindex is specified, the array gets the name 'sname(iindex)'.
  !</description>

  !<input>
    ! Output channel number where to write the MAPLE output to.
    integer, intent(in) :: ichannel

    ! Point set that should be written out. This is a list of (2D or 2D)
    ! point coordinates that form the polygon.
    real(DP), dimension(:,:), intent(in) :: Dpoints

    ! Name of the variable to be used by MAPLE.
    character(len=*), intent(in) :: sname

    ! OPTIONAL: Index of the variable (if sname should be treated as
    ! an array of polygons). If present, the variable gets the name
    ! 'sname(iindex)'.
    integer, intent(in), optional :: iindex
  !</input>

!</subroutine>

    integer :: ipoint,idim

    ! Create the first line
    if (.not. present(iindex)) then
      write (ichannel,'(A)') sname//':=['
    else
      write (ichannel,'(A)') sname//'('//trim(sys_siL(iindex,10))//'):=['
    end if

    ! Write the points
    do ipoint=1,ubound(Dpoints,2)

      write (ichannel,'(A)',ADVANCE='NO') &
        '     ['//trim(sys_sdL(Dpoints(1,ipoint),10))

      do idim=2,ubound(Dpoints,1)
        write (ichannel,'(A)',ADVANCE='NO') &
          ','//trim(sys_sdL(Dpoints(idim,ipoint),10))
      end do

      if (ipoint .eq. ubound(Dpoints,2)) then
        write (ichannel,'(A)',ADVANCE='NO') ']'
      else
        write (ichannel,'(A)',ADVANCE='YES') '],'
      end if

    end do

    write (ichannel,'(A)') '];';

  end subroutine

  ! ***************************************************************************

!<subroutine>
  subroutine mapleio_writePolygonPlot (ichannel,Dpoints,sname,iindex)

  !<description>
    ! Writes a MAPLE command to output channel ichannel which creates
    ! a MAPLE PLOT command for a polygon defined  by the points in Dpoints.
    ! The MAPLE variable name will get the name 'sname'. If
    ! iindex is specified, the variable gets the name 'sname(iindex)'.
  !</description>

  !<input>
    ! Output channel number where to write the MAPLE output to.
    integer, intent(in) :: ichannel

    ! Polygon that should be created. This is a list of (2D or 2D)
    ! point coordinates that form the polygon.
    real(DP), dimension(:,:), intent(in) :: Dpoints

    ! Name of the variable to be used by MAPLE.
    character(len=*), intent(in) :: sname

    ! OPTIONAL: Index of the variable (if sname should be treated as
    ! an array of polygons). If present, the variable gets the name
    ! 'sname(iindex)'.
    integer, intent(in), optional :: iindex
  !</input>

!</subroutine>

    integer :: ipoint,idim

    ! Create the first line
    if (.not. present(iindex)) then
      write (ichannel,'(A)') sname//':=polygonplot(['
    else
      write (ichannel,'(A)') sname//'('//trim(sys_siL(iindex,10))//&
        '):=polygonplot(['
    end if

    ! Write the points
    do ipoint=1,ubound(Dpoints,2)

      write (ichannel,'(A)',ADVANCE='NO') &
        '     ['//trim(sys_sdL(Dpoints(1,ipoint),10))

      do idim=2,ubound(Dpoints,1)
        write (ichannel,'(A)',ADVANCE='NO') &
          ','//trim(sys_sdL(Dpoints(idim,ipoint),10))
      end do

      if (ipoint .eq. ubound(Dpoints,2)) then
        write (ichannel,'(A)',ADVANCE='NO') ']'
      else
        write (ichannel,'(A)',ADVANCE='YES') '],'
      end if

    end do

    write (ichannel,'(A)')']);';

  end subroutine

  ! ***************************************************************************

!<subroutine>
  subroutine mapleio_writePointPlotSingle (ichannel,Dpoint,sname,iindex)

  !<description>
    ! Writes a MAPLE command to output channel ichannel which creates
    ! a MAPLE PLOT command for a point defined by Dpoint.
    ! The MAPLE variable name will get the name 'sname'. If
    ! iindex is specified, the variable gets the name 'sname(iindex)'.
  !</description>

  !<input>
    ! Output channel number where to write the MAPLE output to.
    integer, intent(in) :: ichannel

    ! Point that should be written out.
    real(DP), dimension(:), intent(in) :: Dpoint

    ! Name of the variable to be used by MAPLE.
    character(len=*), intent(in) :: sname

    ! OPTIONAL: Index of the variable (if sname should be treated as
    ! an array of polygons). If present, the variable gets the name
    ! 'sname(iindex)'.
    integer, intent(in), optional :: iindex
  !</input>

!</subroutine>

    integer :: idim

    ! Create the first line
    if (.not. present(iindex)) then
      write (ichannel,'(A)') sname//':=pointplot('
    else
      write (ichannel,'(A)') sname//'('//trim(sys_siL(iindex,10))//&
        '):=polygonplot('
    end if

    ! Write the points
    write (ichannel,'(A)',ADVANCE='NO') &
      '     ['//trim(sys_sdL(Dpoint(1),10))

    do idim=2,size(Dpoint)
      write (ichannel,'(A)',ADVANCE='NO') &
        ','//trim(sys_sdL(Dpoint(idim),10))
    end do

    write (ichannel,'(A)')']);';

  end subroutine

  ! ***************************************************************************

!<subroutine>
  subroutine mapleio_writePointPlotMult (ichannel,Dpoints,sname,iindex)

  !<description>
    ! Writes a MAPLE command to output channel ichannel which creates
    ! a MAPLE PLOT command for a point set defined  by the points in Dpoints.
    ! The MAPLE variable name will get the name 'sname'. If
    ! iindex is specified, the variable gets the name 'sname(iindex)'.
  !</description>

  !<input>
    ! Output channel number where to write the MAPLE output to.
    integer, intent(in) :: ichannel

    ! Polygon that should be created. This is a list of (2D or 2D)
    ! point coordinates that form the polygon.
    real(DP), dimension(:,:), intent(in) :: Dpoints

    ! Name of the variable to be used by MAPLE.
    character(len=*), intent(in) :: sname

    ! OPTIONAL: Index of the variable (if sname should be treated as
    ! an array of polygons). If present, the variable gets the name
    ! 'sname(iindex)'.
    integer, intent(in), optional :: iindex
  !</input>

!</subroutine>

    integer :: ipoint,idim

    ! Create the first line
    if (.not. present(iindex)) then
      write (ichannel,'(A)') sname//':=pointplot('
    else
      write (ichannel,'(A)') sname//'('//trim(sys_siL(iindex,10))//&
        '):=polygonplot(['
    end if

    ! Write the point
    write (ichannel,'(A)',ADVANCE='NO') &
      '     ['//sys_sd(Dpoints(1,ipoint),10)

    do idim=2,ubound(Dpoints,1)
      write (ichannel,'(A)',ADVANCE='NO') &
        ','//sys_sd(Dpoints(idim,ipoint),10)
    end do

    if (ipoint .eq. ubound(Dpoints,2)) then
      write (ichannel,'(A)',ADVANCE='YES') '],'
    else
      write (ichannel,'(A)',ADVANCE='NO') ']'
    end if

    write (ichannel,'(A)')');';

  end subroutine

end module

max_stars_repo_licenses: Intel Unlicense

max_issues_repo_licenses: Intel Unlicense

max_forks_repo_licenses: Intel Unlicense