Ignore:
Timestamp:
01/26/09 16:33:10 (4 years ago)
Author:
awwalter
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PP/trunk/BAP/GENBAP_AWW_2.TXT

    r3777 r3778  
    732732 
    733733    // Padding parameters: 
    734     //      PADSEC(1 & 2) = length of the leading and trailing pad 
    735     //                      areas, in seconds. 
     734    //      PADSEC(1 & 2) = length of the leading and trailing pad areas, in seconds. 
    736735    public static double [] padsec = new double[2]; 
    737736 
    738737    //      TAPSEC(1 & 2) = taper length used with the datataper option. 
    739     //                Given as number of seconds in the taper. 
    740     //                Usually= 0.2. 
     738    //                      Given as number of seconds in the taper. Usually= 0.2. 
    741739    public static double [] tapsec = new double[2]; 
    742740 
    743     //      MTAPER(1 & 2) = tapering option, one for each end of the 
    744     //               time series.  Usually = 0. 
     741    //      MTAPER(1 & 2) = tapering option, one for each end of the time series. Usually = 0. 
    745742    //             = 0=> notaper, 
    746743    //             = 1=> zcross, 
     
    15681565      int ndamp = BapRSI.rsiDamping.length; 
    15691566      int nper = BapRSI.rsiPeriod.length; 
    1570       nwant6 = 2*nper + nper*ndamp; 
     1567      int nwant6 = 2*nper + nper*ndamp; 
    15711568 
    15721569      //nwant = Math.max(nwant0,nwant1,nwant2,nwant3,nwant4,nwant5,nwant6); 
     
    17961793         if (ndone<npandd) { 
    17971794            System.out.printf(lunmsg, 2001) npandd, ndone, lenwrk; 
    1798             warn("*"); 
     1795            BapUtil.warn("*"); 
    17991796            npandd = ndone; 
    18001797            if (ndone>npadl+ndata) { 
     
    19721969                  if (npadl!=0 || npadt!=0) { 
    19731970                     System.out.printf(lunmsg, 2004) npadl, npadt; 
    1974                      warn("*"); 
     1971                     BapUtil.warn("*"); 
    19751972                  } 
    19761973                  LINCOR(lunusr, lunmsg, rp.dptim1,dpdelt, 
     
    21102107// cccccccccccccccccccc (end of BAP2/BAP)cccccccccccccccccccccccccccccccccc 
    21112108 
    2112   WCOPY(work1,work2,npoint) { 
    2113       float work1(npoint), work2(npoint); 
    2114 //   WCOPY is called from BAP2 to copy the contents of WORK1() into WORK2(). 
    2115 //   Note that we would not need WCOPY or need to deal with 3 separate 
    2116 //         working arrays except that we may want to keep each array 
    2117 //         smaller than the 64K byte (=16K reals) segment limit in 
    2118 //         80x86 computers.  See comments in BAP.FOR for more info. 
    2119       do 100 i =1,npoint; 
    2120       work2(i)=work1(i); 
    2121   100 continue; 
     2109  //   WCOPY is called from BAP2 to copy the contents of WORK1() into WORK2(). 
     2110  //   Note that we would not need WCOPY or need to deal with 3 separate 
     2111  //         working arrays except that we may want to keep each array 
     2112  //         smaller than the 64K byte (=16K reals) segment limit in 
     2113  //         80x86 computers.  See comments in BAP.FOR for more info. 
     2114  WCOPY(float[] work1, float[] work2, npoint) { 
     2115      System.arraycopy(work1, 0, work2, 0, npoint); 
    21222116  } 
    21232117// cccccccccccccccccccc (end of WCOPY/BAP2/BAP) ccccccccccccccccccccccccccc 
    2124 // 
     2118 
     2119 
    21252120//   IDSTEP is called from BAP2 to write information about the current 
    21262121//          processing step to the run messages file and to the user 
     
    21762171                  sb.append("    Better to reduce the sampling rate in the DECIM step, which is done after the INSCOR step. ***"); 
    21772172                  System.out.println(sb.toString()); 
    2178                   warn("*"); 
     2173                  BapUtil.warn("*"); 
    21792174               else if (rp.spsnew>rp.spsin && rp.spsin>0.0 && (!rp.mdo[BapSteps.khicut]) ) { 
    21802175                  double x=rp.spsin/2.0; 
     
    21862181                  sb.append("    But the HICUT step was *not* requested in this run.  ***%n" 
    21872182                  System.out.printf(sb.toString(), x); 
    2188                   warn("*"); 
     2183                  BapUtil.warn("*"); 
    21892184               } 
    21902185            } else { 
    21912186               System.out.println("*** ERROR, INTERP step is only applicable for an unevenly-sampled time series.\n" + 
    21922187                 "    (This restriction may be removed in future versions.) Ending Run. ***"); 
    2193                warn("*"); 
     2188               BapUtil.warn("*"); 
    21942189            } 
    21952190         } 
     
    22682263            rp.jpad=1; 
    22692264            System.out.printf("*** WARNING: JPAD=0 invalid when decimation is requested; jpad reset to %2d ***", rp.jpad); 
    2270             warn("*"); 
     2265            BapUtil.warn("*"); 
    22712266 
    22722267         //  e) reset jpad if jpad = 4 is not required 
     
    22862281               if (jwas!=5) { 
    22872282                  System.out.printf("*** WARNING: jpad=%2d is invalid here, jpad reset to %2d ***%n", jwas, rp.jpad); 
    2288                   warn("*"); 
     2283                  BapUtil.warn("*"); 
    22892284               } 
    22902285            } 
     
    23522347       "sampling rate is genuinely required here.)  ***"); 
    23532348 
    2354                warn("*"); 
     2349               BapUtil.warn("*"); 
    23552350            } else if (rp.mdo[BapSteps.kintrp] ) { 
    23562351               StringBuffer sb = new StringBuffer(256); 
     
    23592354               sb.append("    But BOTH interpolations have been requested in this BAP run! ***"); 
    23602355               System.out.println(sb.toString()); 
    2361                warn("*"); 
     2356               BapUtil.warn("*"); 
    23622357            } 
    23632358         } else { 
     
    23672362               doit=false; 
    23682363               System.out.println("    ***    NO decimation performed when ndense < 2."); 
    2369                warn("*"); 
     2364               BapUtil.warn("*"); 
    23702365            } else { 
    23712366               x = outValue/outMode; 
     
    23812376              System.out.printf( "    Unless HICUT was previously applied or no frequencies are greater than %12.5g Hz,%n", x); 
    23822377              System.out.println("    the DECIMated time-series generated here will probably contain aliasing errors. ***"); 
    2383               warn("*"); 
     2378              BapUtil.warn("*"); 
    23842379         } 
    23852380 
     
    24152410               rp.velfit=false; 
    24162411               System.out.print("    *** WARNING: the VELFIT option does not apply when the LOCUT2 option is on. ***"); 
    2417                warn("*"); 
     2412               BapUtil.warn("*"); 
    24182413            } 
    24192414            if (rp.motion!=1 && rp.motion!=4) rp.locut2=false; 
     
    24242419                    "    *** WARNING: the LOCUT2 option does not apply when the LOCUT step is off or when MOTION is not = acc. ***" 
    24252420                ); 
    2426                warn("*"); 
     2421               BapUtil.warn("*"); 
    24272422            } 
    24282423         } else { 
     
    24702465                  System.out.printf(lunmsg, 2003); 
    24712466 2003 System.out.print(" *** WARNING: the VELFIT option should usually not be used when the LOCUT step is applied. ***"); 
    2472                   warn("*"); 
     2467                  BapUtil.warn("*"); 
    24732468               } 
    24742469            } 
     
    24892484// cccccccccccccccccccc (end of BAP/IDSTEP) ccccccccccccccccccccccccccccccc 
    24902485 
    2491   warn(onec, lunusr,lunmsg) { 
    2492       String onec; 
    2493  
    2494 //   WARN: warn user by rining terminal bell and/or stopping, depending 
    2495 //         on the value of IWARN (in BAPINOUT.INC). 
    2496 //         IWARN = 3 => ring bell, tell user how to change IWARN, 
    2497 //                      then stop 
    2498 //         IWARN = 2 => IWARN = 3 if ONEC="*", = IWARN=1 otherwise 
    2499 //         IWARN = 1 => ring bell and return 
    2500 //         IWARN = 0 => return. 
    2501  
    2502 //   On entry -- 
    2503 //     ONEC   = "+" or "*" to indicate how severe the warning is, 
    2504 //                with "*" being more severe than "+". 
    2505 //     LUNUSR = boolean unit number for the user terminal. 
    2506 //     LUNMSG =  "                  for the run messages file. 
    2507  
    2508       include "bapsteps.inc"; 
    2509       include "bapinout.inc"; 
    2510  
    2511       if (rp.iwarn!=0) bell(6); 
    2512       if (rp.iwarn>2 || (rp.iwarn==2 && onec=="*")) { 
    2513          System.out.printf(lunusr,1000); 
    2514          if (lunusr!=lunmsg) { 
    2515             System.out.printf(lunmsg,1001); 
    2516             System.out.printf(lunmsg,1000); 
    2517          } 
    2518          BapUtil.woe(-2); 
    2519       } 
    2520       return; 
    2521  
    2522  1000 System.out.print(5x,"WARN=STOP.  If you wish processing to proceed despite the above warning," 
    2523       /17x,"reset WARN=BELLS in the BAP run parameters list, then", " rerun." /17x,"Ending Run."); 
    2524  1001 System.out.print(" >>> 6 bells."); 
    2525   } 
    2526 // cccccccccccccccccccc (end of warn) cccccccccccccccccccccccccccccccccccc 
    2527  
    2528 //  SHOWZ: display info about the pad for DEBUG runs 
    2529   showz (npadl,ndata,npadt, workA, npandd) { 
    2530       float workA(npandd); 
    2531       int idebug; 
    2532       float debugr; 
    2533       equivalence (debugr, idebug); 
    2534  
    2535       nfar = 0; 
    2536       do 10 jjj=1,npadl; 
    2537       debugr = workA(jjj); 
    2538       if (idebug!=0) { 
    2539          print *, " first non-zero value: i, v=",jjj,debugr; 
    2540          nfar = npadl-jjj +300; 
    2541          if (jjj<300) nfar=npadl; 
    2542          goto 12; 
    2543       } 
    2544  10   continue; 
    2545          print *, " NO non-zero leading pad values!"; 
    2546          nfar = npadl; 
    2547  12   continue; 
    2548       print *, " "; 
    2549       do 20 jjj=npadl-nfar+1,npadl-nfar+600,50; 
    2550       if (jjj <=0 || jjj>npandd) goto 20; 
    2551       debugr = workA(jjj); 
    2552       System.out.printf(" Debug r&h= %7d %15.7e %10x", jjj,debugr,idebug); 
    2553    20 continue; 
    2554       print *, " "; 
    2555       do 30 jjj=npadl+ndata +nfar-1, 
    2556                      npadl+ndata +nfar-601, -50; 
    2557       if (jjj <=0 || jjj>npandd) goto 30; 
    2558       debugr = workA(jjj); 
    2559       System.out.printf(" Debug r&h= %7d %15.7e %10x", jjj,debugr,idebug); 
    2560    30 continue; 
    2561  
    2562   200 continue; 
    2563       print *, " "; 
    2564       print *, " SHOWZ: npadl, ndata, npadt",npadl,ndata,npadt; 
    2565       print *, "        npadl + ndata=", npadl+ndata; 
    2566       print *, " "; 
    2567       return; 
    2568   } 
    2569 // cccccccccccccccccccc (end of showz) ccccccccccccccccccccccccccccccccccccc 
     2486 
    25702487 
    25712488  BAPSET(lunans,lunusr, lundsk,lundat, luntmp,luntm2) { 
     
    51365053            n = min (130-27,ncout); 
    51375054            System.out.printf(lunmsg,1020) fmtout, filnam(1:n); 
    5138             warn("*"); 
     5055            BapUtil.warn("*"); 
    51395056         } 
    51405057      } 
     
    65296446// cccccccccccccccccccc (end of QLBL/HDRLBL/BANNER) cccccccccccccccccccccc 
    65306447 
    6531 //   BAPSPS:  Linearly interpolate the BAP input time series to SPSNEW 
    6532 //            samples per second. 
    6533 //            Note that this subroutine does *not* apply any high-cut 
    6534 //            filter to remove alias errors. 
     6448//   BAPSPS:  Linearly interpolate the BAP input time series to SPSNEW samples per second. 
     6449//            Note that this subroutine does *not* apply any high-cut filter to remove alias errors. 
    65356450//   On entry-- 
    65366451//     SPS      = input sample rate if workA() contains an evenly-sampled 
     
    65856500      // I also have not decided whether or not to just ignore back-stepping samples in an unevenly-sampled input time series. 
    65866501 
    6587       public static final boolean MOVET1=false; 
    6588       public static final boolean IGBACK =false; 
    6589  
    6590       //   Sanity checks: 
     6502      public static final boolean MOVET1 = false; 
     6503      public static final boolean IGBACK = false; 
     6504 
     6505      // Sanity checks: 
    65916506      if (BapConstants.small > rp.spsnew) BapUtil.woe(0); 
    65926507      if (BapConstants.small > Math.abs(rp.spsnew-sps)) BapUtil.woe(0); 
     
    66436558               } 
    66446559            } 
    6645             warn("*"); 
     6560            BapUtil.warn("*"); 
    66466561         } 
    66476562      } 
     
    66846599                 nwork -= 1; 
    66856600                 System.out.printf(" *** Truncating time series at %13.5e s due to array size. Length of the array =%8d. ***%n", time, lenwrk); 
    6686                  warn("*"); 
     6601                 BapUtil.warn("*"); 
    66876602                 break; 
    66886603              } 
     
    68156730      // Get the time interval at beginning and end of the t.s. in which to calculate mean value or llsqf line. 
    68166731 
    6817       for (int ii=0; ii==1; ii++) { 
     6732      for (int ii=0; ii<=1; ii++) { 
    68186733 
    68196734        ibeg = Math.min( Math.max(0, ifromt(tskew[0+ii])), ilast ); 
     
    68366751            xy0 =BapLLSQF.y0; 
    68376752 
    6838             for (int i=ibeg; i==iend; i++) { 
     6753            for (int i=ibeg; i<=iend; i++) { 
    68396754              workB[ib++] = (float) (worka[i] - xy0 - xslope*tfromi(i));    // B = A - (llsq fit line value)  
    68406755            } 
     
    68426757          } else { 
    68436758             // sum the values in the interval 
    6844              for (int i=ibeg; i==iend; i++) { 
     6759             for (int i=ibeg; i<=iend; i++) { 
    68456760               xy0 = xy0 + worka[i]; 
    68466761             } 
    68476762             xy0 = xy0/(iend-ibeg + 1); // mean value 
    68486763 
    6849              for (int i=ibeg; i==iend; i++) { 
     6764             for (int i=ibeg; i<=iend; i++) { 
    68506765               workB[ib++]= (float) (worka[i] - xy0); // B = A - (mean value)  
    68516766             } 
     
    68876802//   Find the first and last zero-crossings in the WORK() array. 
    68886803//   On entry -- 
    6889 //      SMIDGE, WORK(),NPTS 
     6804//      SMIDGE, WORK() 
    68906805//   On return -- 
    68916806//      IZC1 = first sample to retain w.r.t. first zero crossing 
     
    68956810  int izc1 = -1; 
    68966811  int izcn = -1; 
    6897   int npts = 0; 
    6898  
    6899   public void calcZeroCrossings(double smidge, float[] work, int npts) { 
     6812 
     6813  public void calcZeroCrossings(double smidge, float[] work) { 
     6814      calcZeroCrossings(smidge, work, 0, work.length-1); 
     6815  } 
     6816 
     6817  public void calcZeroCrossings(double smidge, float[] work, int idatan) { 
     6818      calcZeroCrossings(smidge, work, 0, idatan); 
     6819  } 
     6820 
     6821  public void calcZeroCrossings(double smidge, float[] work, int idata1, int idatan) { 
     6822 
    69006823      int j = 0; 
    6901       if (work[0]==0.f || Math.abs(work[0])<smidge) { 
    6902          izc1=0; 
    6903       } else if (npts>2) { 
    6904         for (int i=2; i<npts-1; i++) { 
    6905           if (work[i]*work[0] < 0.f) { 
    6906             izc1=0; 
     6824      double dx = Math.abs(smidge);  
     6825 
     6826      int ndata = idatan-idata1+1; 
     6827 
     6828      float data1 = work[idata1]; 
     6829      float datan = work[idatan]; 
     6830 
     6831      if ( Math.abs(data1) < dx) { 
     6832         izc1= idata1; 
     6833      } else if (ndata>2) { 
     6834        for (int i=idata1+1; i <= idatan-1; i++) { 
     6835          if (work[i]*data1 < 0.f) { 
     6836            izc1=idata1; 
    69076837            j=i; 
    69086838            if (Math.abs(work[i-1]) < Math.abs(work[i])) j=i-1; 
    6909             if (Math.abs(work[j]) < Math.abs(work[0])) izc1=i; 
     6839            if (Math.abs(work[j]) < Math.abs(data1)) izc1=i; 
    69106840            break; 
    69116841          } 
     
    69136843      } 
    69146844 
    6915       if (work[npts-1]==0.f || Math.abs(work[npts-1])<smidge) { 
    6916          izcn=npts-1; 
    6917       } else if (npts>2 && izc1 < npts-1) { 
    6918         for i= npts-2; i=Math.max(0, izc1-1), i--) { 
    6919           if (work[i]*work[npts-1] < 0.f) { 
    6920             izcn=npts-1; 
     6845      if (Math.abs(datan) < dx) { 
     6846         izcn=idatan; 
     6847      } else if (ndata>2 && izc1 < idatan) { 
     6848        for i= idatan-1; i >= Math.max(idata1, izc1-1), i--) { 
     6849          if (work[i]*datan < 0.f) { 
     6850            izcn=idatan; 
    69216851            j=i; 
    69226852            if (Math.abs(work[i+1]) < Math.abs(work[i])) j=i+1; 
    6923             if (Math.abs(work[j]) < Math.abs(work[npts-1])) izcn=i; 
     6853            if (Math.abs(work[j]) < Math.abs(datan)) izcn=i; 
    69246854            break; 
    69256855          } 
    69266856        } 
    69276857      } 
     6858 
    69286859  } 
    69296860// cccccccccccccccccccc (end of ZCROSS) ccccccccccccccccccccccccccccccccc 
     
    70116942         y0 = BapLLSQF.y0; 
    70126943      } else if (rp.mmean) {  // slope=0. and y0 is mean bias over fit interval 
    7013          for (int i = ibegf; i==iendf; i++) { 
     6944         for (int i = ibegf; i<=iendf; i++) { 
    70146945             y0 += worka[i]; 
    70156946         } 
     
    70196950      // Subtract the line 
    70206951      if (slope ==0.0) {  // Remove constant/bias value 
    7021         for (int i = ibegl; i==iendl; ii++) { 
     6952        for (int i = ibegl; i<=iendl; ii++) { 
    70226953            worka[i] = (float) (worka(i) - Y0); 
    70236954        } 
    70246955      } else { // remove line with slope 
    7025         for (int i = ibegl; i==iendl; ii++) { 
     6956        for (int i = ibegl; i<=iendl; ii++) { 
    70266957            worka[i] = (float) (worka[i] - Y0 - slope*(dptim1 + dpdelt*i)); 
    70276958        } 
     
    74247355         sb.append("    Leading/trailing pads truncated to %7d/%7d samples. ***%n"); 
    74257356         System.out.printf(sb.toString(), lenwrk, newpts, newz[0], newz[1]); 
    7426          warn("*"); // throw Exception ? 
     7357         BapUtil.warn("*"); // throw Exception ? 
    74277358      } else if (rp.jpad==4 || rp.jpad==5) { 
    74287359         nn = Math.round(newpts*ratio); 
     
    74407371            if (morez[1] <0) BapUtil.woe(0); 
    74417372            System.out.printf("    to %8d, " and %8d points. ***%n", morez[0], morez[1]); 
    7442             warn("*"); // throw Exception ? 
     7373            BapUtil.warn("*"); // throw Exception ? 
    74437374         } 
    74447375      } 
     
    74937424// cccccccccccccccccccc (end of PADLEN) ccccccccccccccccccccccccccccccccccc 
    74947425 
    7495   BAPPAD(lunusr,lunmsg,mtaper,tapsec, sps,work,morelz,newlz,ndata,newtz, doit2) { 
    7496       float    work(morelz+newlz+ndata+newtz); 
    7497       float    tapsec(2); 
    7498       int mtaper[1]; 
    7499       boolean doit2; 
    7500  
    75017426//   BAPPAD pads the time series in WORK() with leading and trailing 
    75027427//          zeros, then smooths the discontinuity between the data and 
    75037428//          the pad areas according to the tapering option, MTAPER. 
    7504  
    75057429//   On entry -- 
    7506 //     LUNMSG   = lun for run messages  = user terminal or disk file. 
    7507 //     LUNUSR   =   "                   = user terminal. 
    75087430//     MTAPER() = tapering option, one for each end of the time-series: 
    75097431//              = 0=> notaper 
    7510 //              = 1=> zcross    = reset to zero all values for samples 
    7511 //                                that occur before the first zero 
    7512 //                                crossing or after the last zero 
    7513 //                                crossing 
    7514 //              = 2=> datataper = apply a cosine taper at the end of 
    7515 //                                the time series. 
    7516 //     TAPSEC() = taper length used with the datataper option, in 
    7517 //                  seconds.  TAPSEC indicates the number of points to 
    7518 //                  be used in the taper, excluding the endpoints at 
    7519 //                  taper-factor = 0.0 and at taper-factor = 1.0. 
     7432//              = 1=> zcross    = reset to zero all sample values, before the first and after the last, zero crossing 
     7433//              = 2=> datataper = apply a cosine taper at the ends of the time series. 
     7434//     TAPSEC() = taper length used with the datataper option, in seconds. 
     7435//                TAPSEC determines the number of points to be used in the taper, excluding endpoints  
     7436//                taper-factor = 0.0 and at taper-factor = 1.0 (ie. ntaper = secs*sps-2). 
    75207437//     SPS      = sampling rate 
    7521 //     WORK()   = array containing a time-series plus free space for 
    7522 //                  padding.  The unpadded input time series is in 
    7523 //                  locations 1 thru NDATA. 
    7524 //     MORELZ   = empty space to be left at the beginning of the padded 
    7525 //                  time series.  (Will be used in the second padding 
    7526 //                  step) 
     7438//     WORK()   = array containing a time-series plus free space for padding. 
     7439//                The unpadded input time series is in locations 0 thru NDATA-1. 
     7440//     MORELZ   = empty space to be left at the beginning of the padded time series for a second padding step. 
    75277441//     NEWLZ    = number of zeros requested for the leading pad. 
    7528 //     NDATA    = number of samples (beginning at WORK(1)) in the 
    7529 //                  input time series. 
     7442//     NDATA    = number of samples (beginning at WORK[0]) in the input time series. 
    75307443//     NEWTZ    = number of zeros requested for the trailing pad. 
    7531  
    7532 //     NOTES: 
    7533 //       - Before calling BAPPAD, the caller must make certain that 
    7534 //         there is enough space in WORK() to contain NEWLZ+NDATA+NEWTZ 
    7535 //         samples. 
    7536 //       - NEWLZ and NEWTZ may =0 if tapering is wanted, without the 
    7537 //         padding.  (As might be appropriate when VELFIT=true) 
    7538  
     7444// 
     7445//       - Before calling BAPPAD, WORK array must be long enough to contain NEWLZ+NDATA+NEWTZ samples. 
     7446//       - NEWLZ and NEWTZ may =0 if tapering is wanted, without the padding. (As might be appropriate when VELFIT=true) 
    75397447//   On return -- 
    7540 //     WORK()   = contains the padded time series in locations MORELZ +1 
    7541 //                  thru MORELZ + newlz + NDATA + newtz. 
    7542 //     DOIT2    = false if there really was not any padding or tapering 
    7543 //                  applied to the time series. 
    7544  
    7545       include "bapconst.inc"; 
    7546       include "tempcs.inc"; 
    7547       public static final double pi =3.1415926535; 
    7548       float ntaper(2); 
    7549       boolean shift; 
    7550  
    7551       lztot = newlz+morelz; 
    7552       doit2 = true; 
     7448//     WORK  = contains the padded time series in index locations MORELZ thru MORELZ+newlz+NDATA+newtz-1. 
     7449 
     7450public class BapPad { 
     7451 
     7452  // Returns false if no padding or tapering was applied to the time series. 
     7453  public boolean pad(int[] mtaper, float[] tapsec, double sps, float[] work, int morelz, int newlz, int ndata, int newtz) { 
     7454 
     7455      // Input work(morelz+newlz+ndata+newtz); 
     7456 
     7457      boolean doit2 = true; 
     7458 
    75537459      if (newlz==0 && newtz==0) { 
    7554          if (rp.mtaper[0]==0 && rp.mtaper[1]==0) { 
    7555             System.out.printf(lunmsg,1000); 
    7556             if (lunusr!=lunmsg) System.out.printf(lunusr,1000); 
    7557          } 
    75587460         if (rp.mtaper[0]<=0 && rp.mtaper[1]<=0) { 
     7461            System.out.println("No padding requested (NEWLZ=NEWTZ=0)."); 
    75597462            doit2 = false; 
    7560             if (morelz<=0) return; 
    7561          } 
    7562       } 
    7563  
    7564       ntaper[0] = Math.max(0, Math.round(rp.tapsec[0]*sps) -2); 
    7565       ntaper[1] = Math.max(0, Math.round(rp.tapsec[1]*sps) -2); 
    7566  
    7567        data1 = work(1); 
    7568        datan = work(ndata); 
    7569       idata1 = lztot + 1; 
    7570       idatan = lztot + ndata; 
    7571  
    7572 //   Shift the time series forward in WORK(), to leave room for the 
    7573 //      leading pad. 
    7574  
    7575       shift  = true; 
    7576       if (lztot<=0) shift=false; 
    7577       smidge = 0.; 
    7578       do 120 i = idatan,idata1, -1; 
    7579       if (shift) work[i] = work(i-lztot); 
    7580       if (Math.abs(work[i]) > smidge) smidge = Math.abs(work[i]); 
    7581   120 continue; 
    7582       if (!doit2) return; 
     7463            if (morelz<=0) return false; // no taper and no extra zeroes requested for later padding so we're done 
     7464         } 
     7465      } 
     7466 
     7467      // If adding zeroes, shift the data time series forward (to right) in WORK array, leaving room for the leading pad. 
     7468      int lztot = newlz+morelz; 
     7469      idata1 = lztot; // first sample index 
     7470      idatan = lztot + ndata-1; // last sample index 
     7471      boolean shift = (lztot > 0) ? true : false; 
     7472 
     7473      double smidge = 0.; 
     7474      for (int i = idatan; i>=idata1; i--) { 
     7475        if (shift) work[i] = work[i-lztot]; 
     7476        if (Math.abs(work[i]) > smidge) smidge = Math.abs(work[i]); 
     7477      } 
     7478 
     7479      if (! doit2) return false; // no tapers and newlz=newtz=0 
     7480 
     7481      // Set smidge as a fractional part of the largest absolute data offset  
    75837482      smidge = BapConstants.small*smidge; 
    75847483 
    7585 //   If the "ZCROSS" taper option was specified, find the first and last 
    7586 //   zero-crossings in the time-series. 
    7587  
     7484      // If the "ZCROSS" taper option was specified, find the first and last zero-crossings in the time-series. 
     7485/* 
    75887486      izc1=-1; 
    75897487      izcn=-1; 
    7590       if (rp.mtaper[0]==1 || rp.mtaper[1]==1) { 
     7488      float data1 = work[idata1]; 
     7489      float datan = work[idatan]; 
     7490      if (rp.mtaper[0]==1 || rp.mtaper[1]==1) { // 1= ZCROSS 
    75917491         if (Math.abs(data1)<smidge) { 
    75927492            izc1=idata1; 
    75937493         } else if (ndata>2) { 
    7594             do 31 i=idata1+1, idatan-1; 
    7595             if (work[i]*data1<0.0) { 
    7596                izc1=idata1; 
    7597                j=i; 
    7598                if (Math.abs(work(i-1)) < Math.abs(work[i])) j=i-1; 
    7599                if (Math.abs(work(j)) < Math.abs(data1)) izc1=i; 
    7600                goto 32; 
     7494            for (i=idata1+1; i <= idatan-1; i++) { 
     7495              if (work[i]*data1<0.f) { 
     7496                izc1=idata1; 
     7497                j=i; 
     7498                if (Math.abs(work[i-1]) < Math.abs(work[i])) j=i-1; 
     7499                if (Math.abs(work[j]) < Math.abs(data1)) izc1=i; 
     7500                break; 
     7501              } 
    76017502            } 
    7602    31       continue; 
    7603    32       continue; 
    76047503         } 
    76057504         if (Math.abs(datan)<smidge) { 
    76067505            izcn=idatan; 
    76077506         } else if (ndata>2 && izc1 < idatan) { 
    7608             do 33 i= idatan-1, Math.max(idata1,izc1-1), -1; 
    7609             if (work[i]*datan<0.0) { 
    7610                izcn=idatan; 
    7611                j=i; 
    7612                if (Math.abs(work(i+1)) < Math.abs(work[i])) j=i+1; 
    7613                if (Math.abs(work(j)) < Math.abs(datan)) izcn=i; 
    7614                goto 34; 
     7507            for (int i= idatan-1; i >= Math.max(idata1, izc1-1); i--) { 
     7508              if (work[i]*datan<0.f) { 
     7509                 izcn=idatan; 
     7510                 j=i; 
     7511                 if (Math.abs(work[i+1]) < Math.abs(work[i])) j=i+1; 
     7512                 if (Math.abs(work[j]) < Math.abs(datan)) izcn=i; 
     7513                 break; 
     7514              } 
    76157515            } 
    7616   33        continue; 
    7617   34        continue; 
    7618          } 
    7619          if (izcn<=izc1 || izc1<0) { 
    7620             System.out.printf(lunmsg,1101); 
    7621             if (lunusr!=lunmsg) System.out.printf(lunusr,1101); 
    7622             warn("*"); 
    7623             if ((rp.mtaper[0]==1 && rp.mtaper[1]==1) || 
    7624                 (rp.mtaper[0]==1 && izc1==-1)     || 
    7625                 (rp.mtaper[1]==1 && izcn==-1)    ) { 
    7626 // +++          BapUtil.woe(2)  +++ do we want to continue here or croak? 
     7516         } 
     7517*/ 
     7518         BapZCross.calcZeroCrossings(smidge, work, idata1, idatan); 
     7519         izc1 = BapZcross.izc1; 
     7520         izcn = BapZcross.izcn; 
     7521 
     7522         if (izcn <= izc1 || izc1 < 0) { 
     7523            System.out.println(" *** The ZCROSS option should not be used with this data; it does not contain two zero crossings!***"); 
     7524            BapUtil.warn("*"); 
     7525            if ((rp.mtaper[0]==1 && rp.mtaper[1]==1) || (rp.mtaper[0]==1 && izc1==-1) || (rp.mtaper[1]==1 && izcn==-1)) { 
     7526               // BapUtil.woe(2)  +++ do we want to continue here or croak? 
    76277527               izc1 = idata1; 
    76287528               izcn = idatan; 
     
    76317531      } 
    76327532 
    7633 //   Begin Loop to pad and taper each end of the time-series. 
    7634  
    7635       do 500 ipad = 1,2; 
    7636       itap = rp.mtaper[ipad]; 
    7637       nzdata = 0; 
    7638       k2beg = 9; 
    7639       if (ipad==1) { 
    7640          tempcs(1:8) = "leading "; 
    7641          tempcs(9:13)= "first"; 
    7642          k2end  = 13; 
    7643          locbeg = 1; 
    7644          locend = lztot; 
    7645          npad   = newlz; 
    7646          ilow   = idata1; 
    7647          jdir   = -1; 
    7648          if (itap==1) { 
    7649             locend = izc1 -1; 
    7650             nzdata = locend - lztot; 
    7651          } 
    7652       } else { 
    7653          tempcs(1:8) = "trailing"; 
    7654          tempcs(9:12)= "last"; 
    7655          k2end  = 12; 
    7656          locbeg = 1     + idatan; 
    7657          locend = newtz + idatan; 
    7658          npad   = newtz; 
    7659          ilow   = idatan; 
    7660          jdir   = 1; 
    7661          if (itap==1) { 
    7662             locbeg = izcn +1; 
    7663             nzdata = idatan -izcn; 
    7664          } 
    7665       } 
    7666  
    7667 //   a) Pad with zeros and, if requested, extend the zeros into the 
    7668 //      data area, up to the first zero crossing. 
    7669  
    7670       if (locbeg<locend) { 
    7671          do 10 i= locbeg,locend; 
    7672          work[i]= 0.0f; 
    7673    10    continue; 
    7674          System.out.printf(lunmsg,1002) npad, tempcs(1:8); 
    7675          if (lunusr!=lunmsg) System.out.printf(lunusr,1002) npad, tempcs(1:8); 
    7676          if (itap==1 && nzdata>0) { 
    7677              System.out.printf(lunmsg,1030) tempcs(k2beg:k2end), nzdata; 
    7678              if (lunusr!=lunmsg) System.out.printf(lunusr,1030) tempcs(k2beg:k2end), nzdata; 
    7679          } 
    7680       } else { 
    7681          System.out.printf(lunmsg,1001) tempcs(1:8); 
    7682          if (lunusr!=lunmsg) System.out.printf(lunusr,1001) tempcs(1:8); 
    7683       } 
    7684  
    7685 //   b) If requested, apply a cosine taper at both ends of the data area. 
    7686 //        (Math.cos(0)=1.0; Math.cos(pi/2) =0.0; Math.cos(pi)=-1.0) 
    7687 //      Apply the taper so the lowest point in the taper (0.0) falls at 
    7688 //        the first point in the pad. 
    7689 //      Note that NNN counts the number of interior points in the 
    7690 //        taper, excluding the endpoints at F=1.0 and F=0.0.  The 
    7691 //        endpoint at f=1.0 is at sample number IHIGH, the endpoint 
    7692 //        at f=0.0 is the first point in the pad. 
    7693  
    7694       if (itap==2) { 
    7695          nnn= ntaper(ipad); 
    7696          if (nnn>=1) { 
    7697             System.out.printf(lunmsg,1010) tempcs(k2beg:k2end), nnn; 
    7698             if (lunusr!=lunmsg) System.out.printf(lunusr,1010) tempcs(k2beg:k2end), nnn; 
    7699             rstep = Math.PI/float(nnn+1); 
    7700             ihigh = ilow -jdir*(nnn); 
    7701             do 101 j=1,nnn; 
    7702                f = 0.5*(1.0+Math.cos(rstep*float(j))); 
    7703                i = ihigh + j*jdir; 
    7704                work[i] = (float) (work[i] * f); 
    7705   101       continue; 
    7706          } 
    7707       } 
    7708  
    7709 //   End of loop. 
    7710  
    7711   500 continue; 
    7712       return; 
    7713  
    7714  1000 System.out.print("No padding requested (MORELZ+NEWLZ=NEWTZ=0)."); 
    7715  1001 System.out.print("The time series has NOT been extended with %8s zeros."); 
    7716  1002 System.out.print("The time series has been extended with %8d %8s zeros."); 
    7717  1010 System.out.print("In addition, the %s %8d input samples were weighted with a cosine taper (values at the end approach zero)."); 
    7718  1030 System.out.print("In addition, the "%s %8d input samples were reset to zero." ); 
    7719  1101 System.out.print(" *** The ZCROSS option should not be used with this data; it does not contain two zero crossings!***"/); 
     7533      float[] ntaper = new int[2]; 
     7534      ntaper[0] = Math.max(0, Math.round(rp.tapsec[0]*sps)-2); 
     7535      ntaper[1] = Math.max(0, Math.round(rp.tapsec[1]*sps)-2); 
     7536 
     7537      String str1 = null; 
     7538      String str2 = null; 
     7539      // Begin Loop to pad and taper each end of the time-series. 
     7540      int nzdata = 0; 
     7541      int locbeg = 0; 
     7542      int locend = 0; 
     7543      int npad = 0; 
     7544      int ilow = 0; 
     7545      int jdir = 0; 
     7546 
     7547      for (int ipad = 0; ipad < 2; ipad++) { 
     7548        itap = rp.mtaper[ipad]; 
     7549        nzdata = 0; 
     7550        if (ipad==1) { 
     7551           str1 = "leading"; 
     7552           str2 =  "first"; 
     7553           locbeg = 0;       // first array index 
     7554           locend = lztot;   // total leading zeroes new+more in pad 
     7555           // npad   = newlz;   // requested zeroes for lead pad -aww changed to below: 
     7556           npad   = lztot;   // requested zeroes for lead pad plus secondary pad // added this -aww 
     7557           ilow   = idata1;  // first data sample index 
     7558           jdir   = -1; 
     7559           if (itap==1) { // zcross 
     7560              locend = izc1 - 1;        // out to 1st zero cross sample index - 1 
     7561              nzdata = locend - lztot;  // data to zero before lead pad 
     7562           } 
     7563        } else { 
     7564           str1 = "trailing"; 
     7565           str2 = "last"; 
     7566           locbeg = 1 + idatan;   // last data sample index +1 start of pad 
     7567           locend = newtz+idatan; // index at end of trailing pad 
     7568           npad   = newtz;        // requested zeroes for trailing pad 
     7569           ilow   = idatan;       // last data sample index 
     7570           jdir   = 1; 
     7571           if (itap==1) { 
     7572              locbeg = izcn + 1;      // from last zero crossing index + 1 
     7573              nzdata = idatan - izcn; // data to zero before trailing pad 
     7574           } 
     7575        } 
     7576 
     7577        // Pad with zeros and, if requested, extend the zeros into the data area, up to the first zero crossing. 
     7578        if (locbeg < locend) { 
     7579           for (int i = locbeg; i<=locend; i++) { 
     7580               work[i]= 0.f; 
     7581           }  
     7582           System.out.printf("The time series has been extended with %8d %8s zeros.%n", npad, str1); 
     7583           if (itap==1 && nzdata>0) { 
     7584               System.out.printf("In addition, the "%s %8d input samples were reset to zero.%n", str2, nzdata); 
     7585           } 
     7586        } else { 
     7587           System.out.printf("The time series has NOT been extended with %s zeros.%n", str1); 
     7588        } 
     7589 
     7590        // If requested, apply a cosine taper at both ends of the data area (cos(0)=1, cos(pi/2)=0, cos(pi)=-1). 
     7591        // Apply the taper so the lowest point in the taper (0.0) falls at the first point in the pad. 
     7592        // Note that NNN counts the number of interior points in the taper, excluding the endpoints at F=1.0 and F=0.0.  
     7593        // The endpoint at f=1.0 is at sample number IHIGH, the endpoint at f=0.0 is the FIRST point in the pad past the data. 
     7594        if (itap==2) { 
     7595           nnn = ntaper(ipad); 
     7596           if (nnn>=1) { 
     7597              System.out.printf("In addition, the %s %8d input samples are weighted with a cosine taper (endpoints approach zero).%n", str2, nnn); 
     7598              dw = Math.PI/float(nnn+1); // taper step 
     7599              ihigh = ilow - jdir*(nnn); // index of sample with highest taper value 
     7600 
     7601              int i = 0; 
     7602              for (int j=1; j<=nnn; j++) { // note endpoints excluded since values are 0. and 1. 
     7603                 i= ihigh+(j*jdir); 
     7604                 work[i] = (float) ( (.5 + .5*Math.cos(dw*j)) * work[i]); 
     7605              } 
     7606           } 
     7607        } 
     7608 
     7609 
     7610      } // End of loop. 
     7611 
     7612      return doit2; 
     7613 
    77207614  } 
    77217615// cccccccccccccccccccc (end of BAPPAD) ccccccccccccccccccccccccccccccccccc 
     
    77307624 
    77317625  BAPPD2(float[] work, int newlz, int npadl, int ndata, int npadt, int newtz) { 
    7732       // Input work length must be >= (newlz+npadl+ndata+npadt+newtz) 
    77337626 
    77347627      if (newlz<=0 && newtz<=0) { 
    77357628         System.out.println("No additional padding required."); 
    77367629         return; 
     7630      } 
     7631 
     7632      // Input work length must be >= (newlz+npadl+ndata+npadt+newtz) 
     7633      if (work.length < (newlz+npadl+ndata+npadt+newtz)) { 
     7634         System.out.println("BAPPD2 Error input work array length less than sum of data plus requested leading,trailing pads."); 
    77377635      } 
    77387636 
     
    77417639        float [] workB =  new float[npadl]; 
    77427640        System.arraycopy(work, newlz, workB, 0, workB.length); 
    7743         BapZCross.calcZeroCrossings(0., work(newlz), npadl); 
     7641        BapZCross.calcZeroCrossings(0., workB, npadl); 
     7642        //BapZCross.calcZeroCrossings(0., work, newlz, npadl); 
    77447643        izc = BapZCross.izc1; // should be zero if called b4  
    77457644      } 
     
    77637662        System.arraycopy(work, nbeg, workB, 0, workB.length); 
    77647663        BapZCross.calcZeroCrossings(0.0, workB, npadt); 
     7664        //BapZCross.calcZeroCrossings(0.0, workB, nbeg, npadt); 
    77657665        izc = BapZCross.izcn; 
    77667666      } 
     
    80907990         if (fh2 > 1.00001/(2*dpdelt) ) { 
    80917991            System.out.printf(lunmsg, 1001) fh2, 1.0/dpdelt; 
    8092             warn("*"); 
     7992            BapUtil.warn("*"); 
    80937993         } 
    80947994         if (fh1+1.999 >fh2) { 
    80957995            System.out.printf(lunmsg,1002) fh1, fh2; 
    8096             warn("*"); 
     7996            BapUtil.warn("*"); 
    80977997         } 
    80987998         if (pins > 1.0) { 
    80997999            System.out.printf(lunmsg,1003) pins; 
    8100             warn("*"); 
     8000            BapUtil.warn("*"); 
    81018001         } 
    81028002         if (minsc) { 
     
    81498049         if (fh1!= hitbeg || fh2!= hitend) { 
    81508050            System.out.printf(lunmsg, 1006) fh1, fh2; 
    8151             warn("*"); 
     8051            BapUtil.warn("*"); 
    81528052         } 
    81538053 
     
    83718271// ccccc (end of comments) ccccc 
    83728272 
    8373   BIhip(array,ndata,fcut,dt,nfs) { 
    8374       dimension array(ndata); 
    8375       double dt,fcut; 
    8376  
    83778273//   BIhip:  Bidirectional, high-pass Butterworth recursive filter. 
    8378  
    83798274//   On entry -- 
    83808275//     ARRAY()    contains the time series to be filtered. 
     
    83898284//     NFS      = rolloff parameter. 
    83908285//                rolloff = nfs*24 decibels/octave. 
    8391  
    83928286//   On return -- 
    83938287//     ARRAY()    contains filtered time-series. 
    8394  
    8395  
    83968288//   Subroutine History: 
    83978289//   ================== 
     
    84198311//     - removed array.inc and LARRAY. 
    84208312 
    8421       DOUBLE cs,  pi, temp, ts, wcp; 
    8422       DOUBLE f(11,3),a(11),b(11),c(11); 
    8423  
    8424       nfs1=nfs+1; 
    8425       if (nfs>11) BapUtil.woe(0); 
    8426       ts=dt; 
    8427       //pi=3.1415926535; 
    8428       wcp=Math.sin(fcut*Math.PI*ts)/Math.cos(fcut*Math.PI*ts); 
    8429       do 5 k=1,nfs; 
    8430       cs=Math.cos(float(2*(k+nfs)-1)*Math.PI/float(4*nfs)); 
    8431       a(k)=1./(1.+wcp*wcp-2.*wcp*cs); 
    8432       b(k)=2.*(wcp*wcp-1.)*a(k); 
    8433     5 c(k)=(1.+wcp*wcp+2.*wcp*cs)*a(k); 
    8434       // ...perform convolution in two directions 
    8435       do 30 ijk=1,2; 
    8436       do 6 i=1,nfs1; 
    8437       do 6 j=1,2; 
    8438     6 f(i,j)=0.; 
    8439       do 10 n=1,ndata; 
    8440       f(1,3)=array(n); 
    8441       do 14 i=1,nfs; 
    8442       temp=a(i)*(f(i,3)-2.*f(i,2)+f(i,1)); 
    8443    14 f(i+1,3)=temp-b(i)*f(i+1,2)-c(i)*f(i+1,1); 
    8444       do 16 i=1,nfs1; 
    8445       do 16 j=1,2; 
    8446    16 f(i,j)=f(i,j+1); 
    8447    10 array(n)=f(nfs1,3); 
    8448       nby2=int(float(ndata)/2.); 
    8449       do 20 n=1,nby2; 
    8450       num=ndata-n+1; 
    8451       temp=array(n); 
    8452       array(n)=array(num); 
    8453    20 array(num)=temp; 
    8454    30 continue; 
    8455   } 
     8313    float[] BIhip(float [] array, int ndata, double fcut, double dt, int nfs) { 
     8314 
     8315      int nfs1 = nfs+1; 
     8316 
     8317      double[][] f = new double [nfs1][3]; 
     8318      double[] a   = new double [nfs1]; 
     8319      double[] b   = new double [nfs1]; 
     8320      double[] c   = new double [nfs1]; 
     8321 
     8322      if (nfs1>11) BapUtil.woe(0); 
     8323 
     8324      double ts = dt; 
     8325      double wcp=Math.sin(Math.PI*ts*fcut)/Math.cos(Math.PI*ts*fcut); 
     8326      double cs = 0; 
     8327      for (int k=0; k<nfs; k++) { 
     8328         cs=Math.cos(float(2*(k+nfs)-1)*Math.PI/float(4*nfs)); 
     8329         a[k]=1./(1.+wcp*wcp-2.*wcp*cs); 
     8330         b[k]=2.*(wcp*wcp-1.)*a[k]; 
     8331         c[k]=(1.+wcp*wcp+2.*wcp*cs)*a[k]; 
     8332      } 
     8333 
     8334      double temp = 0.; 
     8335      int ijk = 1; 
     8336      while (ijk <= 2) { // ...perform convolution in two directions 
     8337        ijk++ 
     8338 
     8339        // zero out filter buffer 
     8340        for (int i=0; i<nfs1; i++) { 
     8341          for (int j=0, j<2; j++) { 
     8342            f[i][j] = 0.; 
     8343          } 
     8344        } 
     8345 
     8346        // Determine filtered sample value 
     8347        for (int n=0; n<ndata; n++) { 
     8348          f[0][2]=array[n]; 
     8349          for (int i=0; i<nfs; i++) { 
     8350            temp=a[i]*(f[i][2]-2.*f[i][1]+f[i][0]); 
     8351            f[i+1][2]=temp-b[i]*f[i+1][1]-c[i]*f[i+1][0]; 
     8352          } 
     8353 
     8354          for (int i=0; i<nfs1; i++) { 
     8355            for (int j=0; j<2; j++) { 
     8356              f[i][j]=f[i][j+1]; 
     8357            } 
     8358          } 
     8359 
     8360          array[n]=f[nfs1-1][2]; 
     8361        } 
     8362 
     8363        nby2=(int)(ndata/2); // what if ndata is not even ? 
     8364        // from mid-array+1 to end of array, swap elements 
     8365        for int n=0, n<nby2; n++) { 
     8366          num=ndata-n+1; 
     8367          temp=array[n]; 
     8368          array[n]=array[num]; 
     8369          array[num]=temp; 
     8370        } 
     8371      } // end of while 
     8372    } 
    84568373// CCCCCCCCCCCCCCCCCCCC (END OF bihip) CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 
    84578374 
    84588375// CCCCCCCCCCCCCCCCCCCC (Begin DataSeries) CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 
    84598376public class DataSeries { 
    8460     int ns = 0;  
    8461     double dx = 0.; 
    8462     float [] x = null;  
     8377    int ns = 0;          // number of samples  
     8378    double dx = 0.;      // interval 
     8379    float [] x = null;   // sample values  
    84638380 
    84648381    DataSeries(int ns) { 
     
    90488965// cccccccccccccccccccc (end of BapRSI) cccccccccccccccccccccccccccccc 
    90498966 
    9050 //   BapRSC = response-spectra calculating and reporting subroutine for 
    9051 //            program = BAP. 
    9052 //   BapRSI be called before BapRSC to create DAMP() and PERIOD() arrays. 
     8967//   BapRSC = response-spectra calculating and reporting subroutine for program. 
     8968//            call BapRSI before BapRSC to create DAMP() and PERIOD() arrays. 
    90538969//   On entry -- 
    90548970//     printResp = true for printing response-spectra values, or false not to print 
     
    95619477      for (int i = 1; i<=count; i++) System.out.print("\0007"); 
    95629478    } 
     9479 
     9480    // WARN: warn user by rining terminal bell and/or stopping, depending 
     9481    //        on the value of IWARN (in BAPINOUT.INC). 
     9482    //        IWARN = 3 => ring bell, tell user how to change IWARN, then stop 
     9483    //        IWARN = 2 => IWARN = 3 if ONEC="*", = IWARN=1 otherwise 
     9484    //        IWARN = 1 => beep and return 
     9485    //        IWARN = 0 => return. 
     9486    // On entry:  
     9487    //     ONEC   = "+" or "*" to indicate how severe the warning is, 
     9488    //                with "*" being more severe than "+". 
     9489    public void warn(String onec) { 
     9490      if (rp.iwarn != 0) BapUtil.beep(); 
     9491      if (rp.iwarn>2 || (rp.iwarn==2 && onec=="*")) { 
     9492        System.out.println("WARN=STOP. If you wish processing to proceed despite the above warning,"); 
     9493        System.out.println("reset WARN=BELLS in the run parameter properties, then rerun. Ending Run."); 
     9494        BapUtil.woe(-2); 
     9495      } 
     9496    } 
     9497 
     9498    //  SHOWZ: display info about the pad for DEBUG runs 
     9499    public void showz(int npadl, int ndata, int npadt, float[] workA, int npandd) { 
     9500 
     9501      if (workA.length < npandd) { 
     9502         System.out.printf("ERROR showz work length=%8d > %8d=npandd%n", workA.length, npandd); 
     9503         return; 
     9504      } 
     9505 
     9506      int nfar = npadl+ndata+npadt; 
     9507      if (nfar > npandd) { 
     9508         System.out.printf("ERROR showz (npadl+ndata+npadt)=%8d > %8d=npandd%n", nfar, npandd); 
     9509         return; 
     9510      } 
     9511 
     9512      int idebug = 0; 
     9513      float value = 0.f; 
     9514 
     9515      // Test leading 
     9516      boolean notZero = true; 
     9517      int icnt = 0; 
     9518      int lastZero = 0; 
     9519      for int j = 0; j<npadl; j++) { 
     9520        value = workA(j); 
     9521        if (value != 0.) { 
     9522          if (notZero) { 
     9523            System.out.printf("Showz: First non-zero leading pad value at index=%8d, npadl=%8d, value=%12.3g%n",j, npadl, value; 
     9524            notZero = false; 
     9525          } 
     9526          lastZero = j; 
     9527          icnt++ 
     9528        } 
     9529      } 
     9530      if (icnt > 0) System.out.printf("  non-zero leading pad value count=%8d, last zero index=%8d%n", icnt, lastZero); 
     9531      else System.out.println("Showz: leading pad values all zero!"); 
     9532 
     9533      // Test zero data 
     9534      notZero = true; 
     9535      icnt = 0; 
     9536      lastZero = 0; 
     9537      iend = npadl+ndata; 
     9538      for int j = npadl; j<iend; j++) { 
     9539        value = workA(j); 
     9540        if (value != 0.) { 
     9541          if (notZero) { 
     9542            System.out.printf("Showz: First non-zero data value starts at index=%8d, startoff=%8d, value=%12.3g%n",j, j-npadl, value; 
     9543            notZero = false; 
     9544            break; 
     9545          } 
     9546        } 
     9547      } 
     9548      notZero = true; 
     9549      icnt = 0; 
     9550      lastZero = 0; 
     9551      iend = npadl+ndata-1; 
     9552      for int j = iend; j>=ipadl; j--) { 
     9553        value = workA(j); 
     9554        if (value != 0.) { 
     9555          if (notZero) { 
     9556            System.out.printf("Showz: First non-zero data value from end is at index=%8d, endoff=%8d, value=%12.3g%n",j, iend-j, value; 
     9557            notZero = false; 
     9558            break; 
     9559          } 
     9560        } 
     9561      } 
     9562 
     9563      // Test trailing 
     9564      notZero = true; 
     9565      icnt = 0; 
     9566      lastZero = 0; 
     9567      iend = npadl+ndata+npadt;  
     9568      for int j = npadl+ndata; j<iend; j++) { 
     9569        value = workA(j); 
     9570        if (value != 0.) { 
     9571          if (notZero) { 
     9572            System.out.printf("Showz: first non-zero trailing pad value at index=%8d, npadl=%8d, value=%12.3g%n",j, npadt, value; 
     9573            notZero = false; 
     9574          } 
     9575          lastZero = j; 
     9576          icnt++ 
     9577        } 
     9578      } 
     9579      if (icnt > 0) System.out.printf("  non-zero trailing pad value count=%8d, last zero index=%8d%n", icnt, lastZero); 
     9580      else System.out.println("Showz: trailing pad values all zero!"); 
     9581 
     9582      return; 
     9583    } 
     9584// cccccccccccccccccccc (end of showz) ccccccccccccccccccccccccccccccccccccc 
    95639585} 
    95649586// cccccccccccccccccccc (end of BapUtil) cccccccccccccccccccccccccccccccc 
Note: See TracChangeset for help on using the changeset viewer.