C************************************************************************
C* This is the program gr_ex1f.f from the HDF 4 Examples. *
C************************************************************************
PROGRAM CREATE IMAGE ARRAY
implicit none integer*4 gr_id, ri_id, file_id, dimsizes(2), ncomp, il
integer mgstart, mgcreat, mgendac, mgend, hopen, hclose
integer*4 X_LENGTH, Y_LENGTH, status, MFGR_INTERLACE_PIXEL
parameter (X_LENGTH = 5, Y_LENGTH = 10,
+ MFGR_INTERLACE_PIXEL = 0)
C DFACC_CREATE and DFNT_INT16 are defined in hdf.h.
integer*4 DFACC_CREATE, DFNT_INT16
parameter (DFACC_CREATE = 4, DFNT_INT16 = 22)
C Create and open the file.
file_id = hopen("Example1.hdf", DFACC_CREATE, 0)
C Initiate the GR interface.
gr_id = mgstart(file_id)
C Define the number of components and dimensions of the image array.
ncomp = 2
il = MFGR_INTERLACE_PIXEL
dimsizes(1) = Y_LENGTH
dimsizes(2) = X_LENGTH
C Create the image array.
ri_id = mgcreat(gr_id, 'Ex_array_1', ncomp, DFNT_INT16, il,
+ dimsizes)
C Terminate access to the image array.
status = mgendac(ri_id)
C Terminate access to the GR interface and close the file.
status = mgend(gr_id)
C Close the file.
status = hclose(file_id)
end
|
An instrumented Version of HDF4 FORTRAN Code
C************************************************************************
C* This is the program gr_ex1f.f from the HDF 4 Examples. *
C* It has been instrumented for Pablo Runtime tracing of selected *
C* routines. *
C************************************************************************
PROGRAM CREATE IMAGE ARRAY
implicit none
C************************************************************************
C* Pablo include file and array used to specify the routines to be *
C* traced. *
C************************************************************************
include 'ProcTrace.inc'
integer TraceIDs(3), nIDs
integer*4 gr_id, ri_id, file_id, dimsizes(2), ncomp, il
integer mgstart, mgcreat, mgendac, mgend, hopen, hclose
integer*4 X_LENGTH, Y_LENGTH, status, MFGR_INTERLACE_PIXEL
parameter (X_LENGTH = 5, Y_LENGTH = 10,
+ MFGR_INTERLACE_PIXEL = 0)
C DFACC_CREATE and DFNT_INT16 are defined in hdf.h.
integer*4 DFACC_CREATE, DFNT_INT16
parameter (DFACC_CREATE = 4, DFNT_INT16 = 22)
C************************************************************************
C* Trace all routines in the HDF 4 source file mfgr.c plus the *
C* routines hwrite and hopen. *
C************************************************************************
TraceIDs(1) = idmfgrc
TraceIDs(2) = idhwrite
TraceIDs(3) = idhopen
nIDs = 3
C************************************************************************
C* Initialize Palbo tracing. Output goes to the trace file *
C* gr_ex1f.rt. The routines to be traces are specified by the *
C* contents of the array TraceIDs and the number of entries in *
C* TraceIDs is specified by nIDs. *
C* Runtime Tracing is performed. *
C************************************************************************
call HDFinitTracef("gr_ex1f.rt",TraceIDs,nIDs,RUNTIMETRACE)
C Create and open the file.
file_id = hopen("Example1.hdf", DFACC_CREATE, 0)
C Initiate the GR interface.
gr_id = mgstart(file_id)
C Define the number of components and dimensions of the image array.
ncomp = 2
il = MFGR_INTERLACE_PIXEL
dimsizes(1) = Y_LENGTH
dimsizes(2) = X_LENGTH
C Create the image array.
ri_id = mgcreat(gr_id, 'Ex_array_1', ncomp, DFNT_INT16, il,
+ dimsizes)
C Terminate access to the image array.
status = mgendac(ri_id)
C Terminate access to the GR interface and close the file.
status = mgend(gr_id)
C Close the file.
status = hclose(file_id)
C************************************************************************
C* End HDF tracing. *
C************************************************************************
call HDFendTracef()
end
|
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:
f77 -c gr_ex1f.f -I<PabloDir>/include -I<HDF4Dir>/include
To link the code, use the following command:
f77 -o myEXE gr_ex1f.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
This will produce a trace output file named gr_ex1f.rt.
Click on the name below to download the binary files produced for the runtime 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 gr_ex1.rt.ascii.
% SDDFconverter
Please enter name of the input SDDF file: gr_ex1f.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_ex1f.rt.ascii
Do you want diagnostic messages printed [Y or N}: N
Runtime
Issue the command CreateHDFRecords gr_ex1f.rt to produce the new binary trace file gr_ex1f.rt.rec, which summarizes the Unix I/O and HDF activity within each HDF procedure call. Click to download the file gr_ex1f.rt.rec.
Issue the command HDFStatsTables gr_ex1f.rt.rec to produce the report on the screen. Note that the output is 132 columns wide.
Summary
- Follow the steps outlined for HDF4 Summary tracing of C codes to generate reports on HDF4 FORTRAN codes.