if (sliceCode < 1)
   {
    i = argTest( "-reg" );
    exit( 0 );
   };

if (sliceCode == 1)
   {
    float sR[size], sI[size];
    float fR[size], fI[size];
    float bR[size], bI[size];
    
    ix1    = 0.1*size;
    ix2    = 0.9*size; 

    if (argTest( "-reg" ))
       {
        ix1 = spec2pnt( fdata, CUR_XDIM, psX1 );
        ix2 = spec2pnt( fdata, CUR_XDIM, psX2 );
       };

    ix1 = integer( ix1 ) - 1;
    ix2 = integer( ix2 ) - 1;

    if (ix1 > ix2)
       {
        itemp = ix1;
        ix1   = ix2;
        ix2   = itemp;
       };

    if (ix1 < 0)        {ix1 = 0;};
    if (ix2 > size - 1) {ix2 = size - 1;};

    bestVal = -1e+16;
    bestP0  = 0.0;
    pFirst  = -180;
    pLast   =  180;

    nLeft  = 1 + ix2 - ix1;
    length = nLeft;

    (void) vvCopy( sR, rdata, size );
    (void) vvCopy( sI, idata, size );

    (void) vvCopyOff( bR, sR, nLeft, 0, ix1 );
    (void) vvCopyOff( bI, sI, nLeft, 0, ix1 );

    step = 10.0;

    for( iter = 0; iter < 3; iter++ )
       { 
    for( p0 = pFirst; p0 <= pLast; p0 += step )
       {
        (void) vvCopy( fR, bR, length );
        (void) vvCopy( fI, bI, length );
        (void) phase( fR, fI, length, p0, xP1 );
   
        (void) vCeiling( fR, length, 0.0 );
 
        thisVal = vSum( fR, length );
    
        if (thisVal > bestVal)
           {
            bestVal = thisVal;
            bestP0  = p0;
           };
       }

        pFirst = bestP0 - 0.75*step;
        pLast  = bestP0 + 0.75*step;

        step /= 10.0;
       }
   };

(void) phase( rdata, idata, size, bestP0, xP1 );
(void) printf( "%.3f\n", bestP0 );
