      PROGRAM CNVFILE
c
c Program to convert RAW ASCII files to the ISAM format required
c   by VMS versions of GSAS
C
C Modified from the program of Von Dreele and Larson
c
      IMPLICIT none
      CHARACTER*80 INFILE,TEXT
      LOGICAL*4 IFOK,MORE
      INTEGER*4 IFILE,ierr      
      MORE = .TRUE.
      write(*,'(a)')'$Enter datafile to convert to GSAS format:'
      read(*,'(a)')INFILE
      DO WHILE ( MORE )
        OPEN(1,FILE=INFILE,STATUS='OLD')
        OPEN(2,FILE=INFILE,RECORDTYPE='FIXED',CARRIAGECONTROL='LIST',
     1      RECORDSIZE=80,FORM='FORMATTED',TYPE='NEW') 
        IERR = 0
        DO WHILE ( IERR.EQ.0 )
          READ(1,'(A)',IOSTAT=IERR) TEXT
          WRITE(2,'(A)') TEXT
        END DO
      
        CLOSE(1)
        CLOSE(2)               
        write(*,'(a)')'$Enter datafile to convert to GSAS format:'
        read(*,'(a)')INFILE
        IF ( INFILE .EQ. ' ' ) MORE = .FALSE.
      END DO
      STOP
      END
