2. How to get started.

2.1 Using existing libraries

       For developing a new program, on the Alliant the following libraries
might need to be invoked:
         ifftlib         Fourier transform routines
         imlib           Routines for handling image format
         ccp4            Lower level routines invoked by imlib
         plot82          Graphics routines

Links have been set to these libraries, so the compile and linking command
would be:

 fortran -Og -uniproc -lifftlib -limlib -lccp4 -lplot82  progname

        On the VAX the following libraries might be needed:
         IFFTLIB         Fourier transform routines
         IMLIB           Image routines
         PLOT82          Graphics routines
         MODLIB          Lower level routines

The linking step after compilation would be:

 LINK PROGNAME,[PUBLIC.LIB]IFFTLIB/L,IMLIB/L,PLOT82/L,MODLIB/L

Commands IMLINK and PIMLINK followed by PROGNAME will carry out this
linking, respectively without or with the PLOT82 library.


2.2 UNIX implementation

       The standalone programs, while (mostly) written in standard
FORTRAN, call various subroutines which hopefully carry all the machine
specific subroutines.   For UNIX implementation, the following source
libraries will be needed, as discussed above (section 2.1):

                  ifftsub.for
                  imsubs.for
                  ccplib.for
                  plot82.for

     In addition ccp4 subroutines need the following lower level libraries:

                  library.c         Disk io routines written in C.

                  unix.for        | Select one of these or create
                  unix.m4         | a new one for the particular
                  unix_fx2800.for | computer involved.
                  unix_iris.for   |

2.3 Example program showing use of image routines

       Shown below is a simple example of a program to rotate an image
by 90 degrees.   Here only imlib and ccp4 would be needed on the Alliant
and IMLIB and MODLIB on the VAX.


C*ROTIM90.FOR***********************************************************
C     Example program to rotate image 90 degrees 
C     Input on logical stream IN, output on logical stream OUT
C
      DIMENSION ARRAY(1000000),TITLE(20),NXYZ(3),MXYZ(3),ALINE(1000),
     1 NXYZ1(3),MXYZ1(3),LABELS(20,10)
      CHARACTER DAT*24
      EQUIVALENCE (NX,NXYZ(1)),(NY,NXYZ(2)),(NZ,NXYZ(3))
C
      WRITE(6,1000)
1000  FORMAT('1',//'   ROTIM90 : Rotate image 90 degrees'//)
C     Open image stream 1 for input
      CALL IMOPEN(1,'IN','RO')
C     Read header block
      CALL IRDHDR(1,NXYZ,MXYZ,MODE,DMIN,DMAX,DMEAN)
C     Open image stream 2 for output
      CALL IMOPEN(2,'OUT','NEW')
C
C     Get date and time to include in new header label
      CALL FDATE(DAT)
      ENCODE(80,1100,TITLE) DAT
1100  FORMAT('  ROTIM90 : rotate image 90 degrees',A20)
C     Set new image dimensions, swapping x and y
      NXYZ1(1)=NXYZ(2)
      NXYZ1(2)=NXYZ(1)
      NXYZ1(3)=NXYZ(3)
      MXYZ1(1)=MXYZ(2)
      MXYZ1(2)=MXYZ(1)
      MXYZ1(3)=MXYZ(3)
C
C     Get labels from old image
      CALL IRTLAB(1,LABELS,NL)
C     Create new header, new dimensions, old MODE and LABELS
      CALL ICRHDR(2,NXYZ1,MXYZ1,MODE,LABELS,NL)
C     Write new header block adding label for this program step
      CALL IWRHDR(2,TITLE,1,DMIN,DMAX,DMEAN)
C
C     Loop over images in file - may be more than 1
      DO 300 IZ=1,NZ
C       Read an image, going to 99 if hit end of file
        CALL IRDSEC(1,ARRAY,*99)
C       Rotate 90 deg
        DO 200 JY=1,NX
          DO 210 JX=1,NY
            IND=(NY-JX)*NX+JY
210       ALINE(JX)=ARRAY(IND)
C         Write out new image a line at a time
          CALL IWRLIN(2,ALINE)
200     CONTINUE
300   CONTINUE
C
C     Close both image streams
      CALL IMCLOSE(1)
      CALL IMCLOSE(2)
      STOP
C     Here if end of file detected on reading
99    WRITE(6,1200)
1200  FORMAT(///'  End of file on stream 1')
      STOP
      END