Date: Tue, 13 Jul 1993 17:46:51 -0400 (EDT)
From: HARALAAG@UCBEH.SAN.UC.EDU
Subject: Re: Import of SIEMENS data in GSAS
To: VONDREELE@figaro.lansce.lanl.GOV
Message-id: <01H0I2LUWHC28WZ22S@UCBEH.SAN.UC.EDU>
X-VMS-To: IN%"VONDREELE@figaro.lansce.lanl.GOV"
MIME-version: 1.0
Content-type: TEXT/PLAIN; CHARSET=US-ASCII
Content-transfer-encoding: 7BIT

Hello Dr. Vondreele:

This is my short explanation for UXD files (SIEMENS_UXD.DOC) and FORTRAN source
(SIEM_UXD.FOR) for transfer of Siemens UXD files to GSAS RAW files. It's tested
only for the output from our diffractometer, and I don't expect need for major
changes, but you never know  8-)

I don't know how GSAS control the end of the RAW file (on zero value or on
number of steps) thats why I left one extra line with zeros in the output file,
but this can be cleaned easily. If you have any comments or you need more
information on UXD files let me know.

Regards
	Alex Haralampiev

P.S. BTW I still don't know why both version of GSAS that we have installed,
don't like my data (in particular GENLES) and crash with the error messages 
that I had sended to Dr. Larson some time ago. I'll appreciate your suggestions
on this problem, because now it's easy to transfer SIEMENS files to GSAS  8-)
but I still cannot start refinement of my tourmalines structures. 

-------------------------------------------------------  
SIEMENS_UXD.DOC
------------------------------------------------------- 
The following is an example of SIEMENS .UXD data file with 201 data points.
This type of files are produced by SIEMENS software package DIFFRAC AT ver.3.1
and earlier, which support D500 and D5000 diffractometers.  This is the only 
possible export ASCII form from DIFFRAC AT and the SIEMENS_D.EXE routine 
transfer .UXD files to the format of GSAS .RAW files. The original SIEMENS .RAW 
files are binary (i.e. AGH083.RAW) and only SIEMENS know how they are organized.
I know only that SIEMENS_D work for my data collected on the diffractometer at 
Geology Department of University of Cincinnati. For all other hardware setups
it is possible to have additional fields and/or different numbers in them, but 
after checking your DIFFRAC AT manual, you will figure it out. Also this version
of the program will work only with single range data files.

If you want to use the following sample for testing purposes, 
cut (every_line.LE.the_dotted_line)

Happy hacking

	Alex Haralampiev
	haralaag@ucbeh.san.uc.edu
.......................................................................
; AGH083.RAW   Converted to UXD format by XCH Version 1
_FILEVERSION=' '
_SAMPLE='S-19-2 T-0;0;100 34-36 DEG'
_+SAMPLE='Old file structure - converted by XCH'
_DATEMEASURED='05-Jul-1993 13:52:00'
_WL1= 1.54060
_WL2= 1.54443
_WL3= 1.39222
_WLRATIO= 0.51400
_ANODE=Cu
; Range  1
_DRIVE='COUPLED'
_STEPTIME=  3.0
_STEPSIZE= 0.01000
_STEPMODE=S 
_START=  34.000
_2THETA=  34.000
_THETA=  17.000
_KHI=   0.000
_PHI=   0.000
_STEPCOUNT=  201
_COUNTS
     92.     79.     93.     98.    107.     87.     77.     78.
     82.    111.     93.     99.     80.     82.     95.    106.
    116.    113.    108.    102.    153.    144.    129.    164.
    155.    156.    189.    178.    186.    222.    233.    211.
    264.    264.    270.    302.    307.    386.    405.    454.
    491.    473.    630.    687.    759.    954.   1120.   1256.
   1528.   1629.   2036.   2430.   2793.   3063.   3356.   3273.
   3049.   2718.   2284.   2009.   1857.   1817.   1809.   1893.
   1673.   1476.   1209.    912.    685.    528.    434.    382.
    350.    330.    268.    290.    275.    248.    197.    215.
    198.    170.    172.    159.    139.    141.    139.    142.
    144.    117.    147.    106.    107.    112.    112.    137.
    110.    109.    102.    132.    106.    117.    134.    139.
    127.    137.    133.    159.    156.    175.    190.    235.
    198.    223.    244.    282.    305.    325.    402.    376.
    430.    372.    368.    303.    284.    260.    263.    257.
    253.    298.    228.    200.    169.    151.    132.    122.
    114.    115.    110.    106.     89.     98.    109.     97.
     93.     98.    101.     89.    116.    112.     99.    124.
    113.    129.    133.    136.    157.    134.    140.    149.
    159.    196.    155.    185.    191.    166.    159.    179.
    155.    135.    147.    137.    117.    111.    139.    117.
    136.    113.     99.    114.     95.    100.     94.     80.
     79.     90.     88.     98.     88.     83.     92.    102.
    106.    102.     94.    117.    127.    134.    131.    127.
    118.
--------------------------------------------------- 
SIEM_UXD.FOR
--------------------------------------------------- 
        PROGRAM SIEM_UXD
!Program to take Siemens UXD-format ASCII data files and convert them
!to GSAS raw powder files. For more on UXD format see SIEMENS_UXD.DOC file.
!
! Based on [GSAS.CODES]*.FOR programs
!
! Date: July-1993      Hacked: Alex Haralampiev - HARALAAG@UCBEH.SAN.UC.EDU

        REAL*4          START           !Start 2-theta
        REAL*4          FINISH          !End 2-theta (no point here)
        REAL*4          STEP            !2-theta steps
        INTEGER*4       NSTEPS          !Number of 2-theta steps
        INTEGER*4       OUTREC          !Number of output records
        INTEGER*4       PATTERN(10000)  !This number is big enough
                                        !for the number of all 2-theta
                                        !steps in my scans
        INTEGER*4       IUIN,IUOUT      !Input and output unit nos.
        CHARACTER*80    INNAME,OUTNAME  !Input & output file names
        CHARACTER*80    TITLE           !Data string                   

        DATA    IUIN,IUOUT/10,11/

!Open files

        TYPE *,' Enter Siemens UXD-format data file name'
        ACCEPT '(A)',INNAME
        IEND = INDEX(INNAME,' ')-1
        IDOT = INDEX(INNAME,'.')
        IF (IDOT.EQ.0) INNAME = INNAME(1:IEND)//'.UXD'
        OPEN(IUIN,FILE=INNAME,STATUS='OLD',ACCESS='SEQUENTIAL')
        TYPE *,' Enter GSAS output data file name'
        ACCEPT '(A)',OUTNAME
        OPEN(IUOUT,FILE=OUTNAME,STATUS='UNKNOWN',ACCESS='SEQUENTIAL',
     +       RECORDTYPE='FIXED',RECL=80,FORM='FORMATTED',
     +       CARRIAGECONTROL='LIST')

!Read header

        TITLE = ' '
        READ(IUIN,'(2X,A13)') TITLE(1:13)       !Original SIEMENS file name
        READ(IUIN,'(/,9X,A31)') TITLE(14:44)    !Sample information
        READ(IUIN,'(/,15X,A17)') TITLE(45:66)   !Date and time measured
        WRITE (IUOUT, '(A)') TITLE
        TYPE 1,TITLE(1:66)
1       FORMAT(' Title: ',A)
       
        TITLE = ' '
!
! Search of header for some of the UXD field labels
!
        DO WHILE (TITLE(2:4).NE.'COU')             !field w/label _COUNTS
            READ(IUIN,'(A)') TITLE
            IF (TITLE(2:6).EQ.'STEPT') THEN        !field w/label _STEPTIME=
              READ(TITLE,'(10X,F5.1)') TIME 
              CONTINUE
            ELSE IF (TITLE(2:6).EQ.'STEPS') THEN   !field w/label _STEPSIZE=
              READ(TITLE,'(10X,F8.5)') STEP
              CONTINUE
            ELSE IF (TITLE(2:6).EQ.'STEPC') THEN   !field w/label _STEPCOUNT=
              READ(TITLE,'(11X,I5)') NSTEPS
              CONTINUE
            ELSE IF (TITLE(2:4).EQ.'STA') THEN     !field w/label _START=
              READ(TITLE,'(8X,F7.3)') START
              CONTINUE
            END IF
        END DO
        FINISH = START + (NSTEPS - 1) * STEP
        TYPE 3,START,FINISH,STEP
3       FORMAT(' Starting 2-theta = ',F10.2,' ending 2-theta = ',F10.2,
     +               ' step = ',F6.4)
        OUTREC = (NSTEPS - 1) / 10 + 1
        TYPE 4,NSTEPS,OUTREC
4       FORMAT(' Number of data = ',I6,
     +         ' number of output records = ',I5)
        TITLE = ' '
        WRITE (TITLE, 10) 'BANK 1',NSTEPS,OUTREC,'CONST',START*100.,
     +         STEP*100.,TIME
10      FORMAT(A,2I8,1X,A,3F10.1,22X)
        WRITE (IUOUT, '(A)') TITLE

!Process data

!Read UXD data counts to END-OF-FILE

        READ(IUIN,*,END=55) PATTERN

!Output of data                   

55      J = 0
        I = 0
        DO NREC=1,(OUTREC + 1)       !" + 1" is for padding of the output
                                     !     file with one row of "0" values

            WRITE (IUOUT, 6) (PATTERN(J + I), I=1,10)
6           FORMAT(10I8)
            J = J + 10
        END DO

!Finished

        CLOSE (IUIN)
        CLOSE (IUOUT)
        STOP 'All done'
        END
