/************************************************************************/ /* This is the HDF 4 example gr_ex1.c. */ /************************************************************************/ #include "hdf.h" #include "mfgr.h" #define X_LENGTH 5 #define Y_LENGTH 10 main( )
{
int32 gr_id, ri_id, file_id, status; int32 dimsizes[2], ncomp, il; /* Create and open the file. */
file_id = Hopen("Example1.hdf", DFACC_CREATE, 0);
/* Initiate the GR interface. */ gr_id = GRstart(file_id); /* Define the number of components and dimensions of the image. */ ncomp = 2; il = MFGR_INTERLACE_PIXEL; dimsizes[0] = X_LENGTH; dimsizes[1] = Y_LENGTH; /* Create the image array. */ ri_id = GRcreate(gr_id, "Image_array_1", ncomp, DFNT_INT16, il, dimsizes); /* Terminate access to the image array. */ status = GRendaccess(gr_id); /* Terminate access to the GR interface and close the file */ status = GRend(ri_id); /* Close the file. */ status = Hclose(file_id); } |
Instrumented for Runtime Tracing
/************************************************************************/ /* This is the HDF 4 example gr_ex1.c. */ /* It has been instrumented for Pablo Runtime Tracing. */ /************************************************************************/ #include "hdf.h" #include "mfgr.h" #define X_LENGTH 5 #define Y_LENGTH 10 #include "ProcTrace.h" /* Pablo header file. */ main( )
{
int32 gr_id, ri_id, file_id, status;
int32 dimsizes[2], ncomp, il;
/****************************************************************/
/* Initialize Pablo tracing. */
/* The output file is named gr_ex1.rt. */
/* All HDF callse will be traced. */
/* The Runtime Tracing option has been selected. */
/****************************************************************/
HDFinitTrace("gr_ex1.rt",ID_ALLHDF,RUNTIME_TRACE);
/* Create and open the file. */
file_id = Hopen("Example1.hdf", DFACC_CREATE, 0);
/* Initiate the GR interface. */ gr_id = GRstart(file_id); /* Define the number of components and dimensions of the image. */ ncomp = 2; il = MFGR_INTERLACE_PIXEL; dimsizes[0] = X_LENGTH; dimsizes[1] = Y_LENGTH; /* Create the image array. */ ri_id = GRcreate(gr_id, "Image_array_1", ncomp, DFNT_INT16, il, dimsizes); /* Terminate access to the image array. */ status = GRendaccess(gr_id); /* Terminate access to the GR interface and close the file */ status = GRend(ri_id); /* Close the file. */ status = Hclose(file_id); /****************************************************************/ /* Terminate Pablo Tracing. */ /****************************************************************/ HDFendTrace(); } |
Instrumented for Summary Tracing
/************************************************************************/ /* This is the HDF 4 example gr_ex1.c. */ /* It has been instrumented for Pablo Summary Tracing. */ /************************************************************************/ #include "hdf.h" #include "mfgr.h" #define X_LENGTH 5 #define Y_LENGTH 10 #include "ProcTrace.h" /* Pablo header file. */ main( )
{
int32 gr_id, ri_id, file_id, status;
int32 dimsizes[2], ncomp, il;
/****************************************************************/
/* Initialize Pablo tracing. */
/* The output file is named gr_ex1.rt. */
/* All HDF callse will be traced. */
/* The Summary Tracing option has been selected. */
/****************************************************************/
HDFinitTrace("gr_ex1.sum",ID_ALLHDF,SUMMARY_TRACE);
/* Create and open the file. */
file_id = Hopen("Example1.hdf", DFACC_CREATE, 0);
/* Initiate the GR interface. */ gr_id = GRstart(file_id); /* Define the number of components and dimensions of the image. */ ncomp = 2; il = MFGR_INTERLACE_PIXEL; dimsizes[0] = X_LENGTH; dimsizes[1] = Y_LENGTH; /* Create the image array. */ ri_id = GRcreate(gr_id, "Image_array_1", ncomp, DFNT_INT16, il, dimsizes); /* Terminate access to the image array. */ status = GRendaccess(gr_id); /* Terminate access to the GR interface and close the file */ status = GRend(ri_id); /* Close the file. */ status = Hclose(file_id); /****************************************************************/ /* Terminate Pablo Tracing. */ /****************************************************************/ HDFendTrace(); } |
Suppose the Pablo software is installed in the directory <PabloDir> and the instrumented HDF software is installed in the directory <HDF4Dir>.
To compile the code, use the following command:
cc -c gr_ex1.c -I<PabloDir>/include -I<HDF4Dir>/include
To link the code, use the following command:
cc -o myEXE gr_ex1.o -L<PabloDir>/lib -L<HDF4Dir>/lib -ldf-inst -lmfhdf-inst -lPabloTrace -lPabloTraceExt [other libraries as necessary]
To execute the code, use the following command:
myEXE
For run-time tracing, this will produce a trace output file named gr_ex1.rt. For summary tracing, this will produce a trace file gr_ex1.sum.
Click on the name below to download the binary files produced for the runtime and summary tracing described above. See the Trace Output Files section below for the steps necessary to convert these files to ascii.
The trace output files are in binary format and are generally best processed in that format. Sometimes it is convenient, however, to convert the file to ASCII to read its contents. To convert a binary trace file to ASCII, use the command SDDFconverter. The following is the session used to convert gr_ex1.rt from a binary format to the ASCII file gr_ex1.rt.ascii. User responses are in bold. Click to download the converted trace output file User responses are in bold. Click to download the converted trace output file gr_ex1.rt.ascii.
% SDDFconverter
Please enter name of the input SDDF file: gr_ex1.rt
File is in SDDF Non-Native Binary format
Output in Ascii, Binary or Converted (reverse byte order) format [A, B, C]: A
Please entery name of the output SDDF file: gr_ex1.rt.ascii
Do you want diagnostic messages printed [Y or N}: N
Issue the command CreateHDFRecords gr_ex1.rt to produce the new binary trace file gr_ex1.rt.rec, which summarizes the Unix I/O and HDF activity within each HDF procedure call. Click to download the file gr_ex1.rt.rec.
Issue the command HDFStatsTables gr_ex1.rt.rec to produce the report on the screen. Note that the output is 132 columns wide.
Issue the command HDFStatsTables gr_ex1.sum to produce the report on the screen. Note that the output is 132 columns wide.