      CHARACTER*5 SCHNAM
      CHARACTER*10 HMNAME
      INTEGER JB(2,3,30),XYZ(3,30),NPOS(30)
      INTEGER XYZWM(3,48),JAM(2,3,48)
      CHARACTER*1 MPOS(30),A
      Character*80 arg, GENERATORPath, WYCOFFPath
      Integer ISPG, NC

! For Watcom Fortran
!      If(nArgs() .le. 1) Then
! For g77
      If(IArgC() .lt. 1) Then
        Write(*, '(a)') ' ******  Fatal Error ******'
        Write(*, *) ' Index of Lattice System (1 - 230) must ',
     1               'be specified'
        Stop 9999
      EndIf
! For Watcom Fortran
!      Call GetArg(1, arg, iStat)
! For g77
      Call GetArg(1, arg)
      Read(arg,*) ISPG

      If(IArgC() .ge. 2) Then
        Call GetArg(2, GENERATORPath)
      Else
        GENERATORPath = 'generator'
      EndIf

      If(IArgC() .ge. 3) Then
        Call GetArg(3, WYCOFFPath)
      Else
        WYCOFFPath = 'wycoff'
      EndIf

      OPEN(3,FILE=GENERATORPath,IOSTAT=ISO,STATUS='OLD')
c      WRITE(6,*) 'generator: ISO=', ISO, ' should be 0.'
      IF(ISO.NE.0) STOP
      OPEN(4,FILE=WYCOFFPath,IOSTAT=ISO,STATUS='OLD')
c      WRITE(6,*) 'wycoff: ISO=', ISO, ' should be 0.'
      IF(ISO.NE.0) STOP

      CALL TSNTNM(ISPG,3,NC,SCHNAM,HMNAME)
      DO 2 IC=1,NC
        CALL TSPNGE(ISPG,IC,3)
        CALL TSWYRD(ISPG,IC,4,NUC,NPOS,MPOS,XYZ,JB)
        DO 3 IWP=1,NUC
          WRITE(6,600)  NPOS(IWP),MPOS(IWP)
     &             ,(XYZ(K,IWP),(JB(J,K,IWP),J=1,2),K=1,3)
  600     FORMAT(I5,A1,3(I4,I2,'/',I1))
          A=MPOS(IWP)
          CALL TSWYCF(A,NUC,NPOS,MPOS,XYZ,JB
     &           ,NSITE,XYZWM,JAM)
          DO 4 ISIT=1,NSITE
            WRITE(6,601) ISIT,(XYZWM(K,ISIT),
     &             (JAM(J,K,ISIT),J=1,2),K=1,3)
  601       FORMAT(I3,3(I4,I2,'/',I2))
    4     CONTINUE   
    3   CONTINUE
    2 CONTINUE

      CLOSE(3)
      CLOSE(4)
      END
