Process Flow, C-Language Codes

The following is a description of the process flow for cmst.c, and any codes based on this master. This is the C version of bmst.f, and was named differently to allow both executables to be located in the same directory.

  1. The application prefix (4 characters) is written into character variable pid. You will want to edit this according to your new process name.
  2. Function “getparm”
    getparm(argc,argv,&iparm1. . .);   This function is located inline with every main program. You only need to modify the arguments starting with “iparm”. This is your interactive/command line input parameter function.
  3. Function “outlst”
    outlst(iparm1,fparm1,infile,pid,ofile,lstfile,h3);   This function (located inline with main program file) provides an echo check of the input parameters by writing to a listing file. Examining the listing file is sometimes useful when you wish to see what you have previously done. The listing file name is the same as the output data file name, but with a different suffix. Thus, if the ouput data file were named bfoobbar.seg, the listing file name would be, bfoobbar.lst.
  4. Function “in_chk“
    in_chk(&ntraces,&npts,&fsamin,hd,h1);   Checks the input file and outputs number of samples, sample interval, number of traces. Type:

    man in_chk

    for more on this subroutine.

  5. Function ”bargrid“
    bargrid(ntraces,&barr,&ibar,&invbar);   Computes the parameters for the real time progress bar drawn by exbar() to the screen.
  6. Then there is the trace loop. The for loop runs over the number of traces found in the in_chk() call. The sequence in bmst.c is:


    {vlist20}
          for (jrec=0;jrec<ntraces;jrec++)         //...trace loop
         {
            if(c_bsegin(jrec,s1,npts,&hd,h1)!=0)   //...read a trace
           {
            fprintf(stderr,"ABORT--c_bsegin");
            goto quit_it;
           }
    . . . . .     [ DO SOME COMPUTATIONS ON SIGNAL S1 ]
            if(c_bsegout(jrec,s2,npts,&hd,h2)!=0)  //...output a trace
           {
            fprintf(stderr,"ABORT--c_bsegout");
            goto quit_it;
           }
          exbar(ntraces,bar,ibar,invbar,jrec+1);   //...display progress bar
         } //  end trace loop-----------------------------
    
    vlist20

where c_bsegin reads a trace and c_bsegout writes a trace, and exbar writes the progress bar to the screen in real time. Again, you would insert your own code at the “do some computations” location in the trace loop. This is a simple example, and more complicated flows with multiple loops are possible. The other programs in the BSU package provide examples.