next up previous print clean
Next: Restarting and combining Up: WRITING APPLICATIONS Previous: Serial

Distributing a dataset

The second example is taken from the SEPlib program Transf. It does a Fourier transform of a dataset and then distributes the data along the frequency axis. Again, only the portions relevant (and different from the previous example) will be shown.

In this case we want to know how many threads we are running on.

 nmpi=sep_num_thread()

By default, when converting to frequency inv=.false., we are going to create a dataset with nmpi sections, but we will allow the user to override this option. We are going to section the dataset along the last axis (ndimc) which in this case is the frequency axis.

  nsect=1; if(.not. inv) nsect=nmpi
  call from_param("nsect",nsect,nsect)
  if(nsect>1) then
    if(.not. inv)  then
      if(.not. sep3d_section_tag(output,ndimc,"BLOCK",nsect)) &
         call seperr("trouble sectioning tag")

Our input and our output could involve a sectioned dataset. Given our current window parameters (nc,fc,jc for output and nr,fr,and jr for our input), we need to know the size of the data with which we will be working. The sep_local_buffer_size gives the dimensions (number of samples by number of traces) of the local buffer size given the current window for a given dataset.

  if(.not. sep3d_local_buffer_size(output,n_c,nc,fc,jc) .or. &
        .not. sep3d_local_buffer_size(input,n_r,nr,fr,jr)) then
       call seperr("trouble getting local buffer sizes")
     end if

Once we have transformed the data, we need to pass it to the appropriate thread. We first describe the window that we want to pass sep3d_set_window and then distribute the data.

 call sep3d_set_window(space,nwind=nc,fwind=fc)
     if(.not. sep3d_transfer_data(input,space,blockc_in,blockc_out))&
       call seperr("trouble transfering data")

Everything else that is different from how you would conventionally program is the same as the first example.


next up previous print clean
Next: Restarting and combining Up: WRITING APPLICATIONS Previous: Serial
Stanford Exploration Project
5/23/2004