/***/
/* zri.M: convert X=Complex Y=Real Z=Real -> X=Real Y=Real Z=Complex.  
/***/

/***/
/* Definitions taken from "fdatap.h":
/***/

if (sliceCode == CODE_INIT)
   {
    FDQUADFLAG =  106;  
    NDQUADFLAG = 1007;
    FD_COMPLEX = 0;
    FD_REAL    = 1;
    NULL_DIM   = 0;

    (void) setParm( fdata, FDQUADFLAG, FD_REAL,    NULL_DIM );
    (void) setParm( fdata, NDQUADFLAG, FD_REAL,    CUR_XDIM );
    (void) setParm( fdata, NDQUADFLAG, FD_COMPLEX, CUR_ZDIM );
    (void) setParm( fdata, NDSIZE,     zSize*2,    CUR_ZDIM );
   };

if (sliceCode < 1)
   {
    exit( 0 );
   };

/***/
/* For each 2D complex plane in the data stream:
/*  Read the plane.
/*  Seperate its real and imaginary parts.
/*  Write the real plane.
/*  Write the imaginary plane.
/***/

if (yLoc != 1)
   {
    exit( 0 );
   };

float riBuff[xSize*ySize*2], rBuff[xSize*ySize], iBuff[xSize*ySize];

(void) dReadB( inUnit, riBuff, wordLen*xSize*ySize*2 );

rOff  = 0;
iOff  = 0;
riOff = 0;

for( iy = 0; iy < ySize; iy++ )
   {
    (void) vvCopyOff( rBuff, riBuff, xSize, rOff, riOff );

    riOff += xSize;

    (void) vvCopyOff( iBuff, riBuff, xSize, iOff, riOff );

    riOff += xSize;
    rOff  += xSize;
    iOff  += xSize;
   }

(void) dWrite( outUnit, rBuff, wordLen*xSize*ySize );
(void) dWrite( outUnit, iBuff, wordLen*xSize*ySize ); 
