       SUBROUTINE LINTOMM(X,Y)
C
C----------------------------------------------------------------------
C
C.IDENTIFICATION: Subroutine LINTOMM 
C.LIBRARY:        FOTLIB
C.AUTHOR:         L.Chiappetti - IFCTR Milano
C.VERSIONS:       0.0 - 25 Aug 97 - original version
C.PURPOSE:        convert (linearized) pixels to mm
C.METHOD:         plain scaling
C.SYNTAX:         CALL  LINTOMM(X,Y)
C.PARAMETERS:     REAL*8 X,Y  are x,y  pixels (in) and mm (out)
C.RESTRICTIONS:
C.NOTES:          calls instrument specific parameter loading
C.FILES:
C.REFERENCES
C
C----------------------------------------------------------------------
C
       DOUBLE PRECISION X,Y,IRX,IRY,A(10)
       REAL HALF,SIZE
       CHARACTER INSTR*4
       INCLUDE 'pixcommon.inc'
       CALL GET_GLOBAL_DEFAULT('INSTRUMENT','NONE',INSTR)
C
C-->   need to load current pixsize
C-->   natural pixsize (i.e. 0.5*(A3+A4) )
C-->   and "half" i.e. 128* natural pixsize
       IF(INSTR.EQ.'mecs')THEN
         CALL INIT_CORRECT_ME_FAST(A,HALF,SIZE)
       ELSE
        WRITE(*,*)' not yet supported for instrument ',INSTR
        CALL Z_EXIT(99)
       ENDIF
*      write(*,*)'half',half
C
C      mm to nexpixels of origin (0,0 mm) (A1,A2 raw pix)
       IRX=(0.0+HALF)/PIXSIZE
       IRY=(0.0+HALF)/PIXSIZE
*      write(*,*)'irxy',irx,iry
C
C      distance from centre in mm
       X=(X-IRX)*pixsize
       Y=(Y-IRY)*pixsize
       RETURN
       END
