ESM4714
Scientific Visual Data Analysis and Multimedia
Exercise #3: Compiling C and Fortran programs for data conversion
Objectives:
Learn how to create (H)ierarchical (D)ata (F)ormat (HDF) and other binary files
by compiling, linking HDF libraries, and executing C and Fortran data conversion
programs.
Procedure: NOTE: Highlighted italic text denotes user response.
Use C program to create a new ascii format and then use the Fortran program to
create the HDF file.
NOTE: Here you can work exclusively on your optical disk just like your home directory.
- Start by finding the file brown.ascii.start.Z in the brown directory and uncompress it.
- % cd /rmdisk/rmdisk0/ESM4714/examples/brown (if you have an optical disk mounted on planet-name.smvc.vt.edu)
- % cd ~username/ESM4714/examples/brown (the users home directory on planet-name.smvc.vt.edu)
- % uncompress brown.ascii.start.Z
- Move a copy of brown.ascii.start to the make_bin directory.
- % cp brown.ascii.start make_bin
- Go into the make_bin directory from the brown directory.
- % cd make_bin
- Create the binary file brown.bin from brown.ascii.start but first create the
executable file atoi.x from the C-program atoi.c ((A)lphanumeric (TO) binary
(I)nteger).
- % cc atoi.c -o atoi.x
- % atoi.x < brown.ascii.start > brown.bin or
- % cat brown.ascii.start | atoi.x > brown.bin will also work
- Move a copy of brown.bin into the direcory make_ascii and then go into that directory.
- % cp brown.bin ../make_ascii
- % cd ../make_ascii
- Create the file brown.ascii from the file brown.bin but first create the
executable file itoa.x from the C-program itoa.c (binary (I)integer (TO)
(A)lphanumeric).
- % cc itoa.c -o itoa.x
- % itoa.x < brown.bin > brown.ascii or
- % cat brown.bin | itoa.x > brown.ascii will also work
- NOTE: The brown.ascii.start is different then brown.ascii. The file
brown.ascii.start was written with 64 integers per line and brown.ascii was
created with 20 integers per line with a leading space. The file brown.ascii is
in the correct format to be converted by the Fortran program into a HDF file.
- Move a copy of brown.ascii file to the directory make_hdf and then go into that directory.
- % cp brown.ascii ../make_hdf
- % cd ../make_hdf
- Create a 3D (S)cientific (D)ata (S)et "SDS_HDF" file brown.hdf from the
brown.ascii file but first create the executable m_sds_hdf.x from the fortran
program m_sds_hdf.f . You can adjust the dimensions for other data sets by
editing the dimension statement for the appropiate array size in the various C
and fortran programs. There are a number of different ways you can organize
these arrays to affect a specific visual image orientation. Controling the
initial view of data by array manipulation is unnecessary since many of the
visual software applications can adjust the display of the data once the data set
is loaded into the application.
- % f77 m_sds_hdf.f -o m_sds_hdf.x -L/apps/hdf/lib -ldf -lz
- NOTE: if /apps/hdf/lib has already been defined by setenv LD_LIBRARY_PATH
in your .tcshrc file then use ...
- % f77 m_sds_hdf.f -o m_sds_hdf.x -ldf -lz
- % m_sds_hdf.x (creates the brown.hdf file)
- NOTE: The file brown.hdf is now readable by: 1) PV-Wave or NCSA's xds on
the SMVC workstations or 2) SpyGlass (Dicer, Transform, Format) software
installed on the MacIntosh G3s. The NCSA xds has been installed in your ~bin
directory. SpyGlass Dicer can also read
the original brown.bin or brown.ascii.start or brown.ascii files but you must
provided the dimensions. Perhaps you perfer the later. Most users prefer the
former by using HDF format, because the array dimensions are included in the
HDF file.
Recommendation:
The C-data-conversion programs atoi.c and itoa.c are only two of the many
programs you may want to use. Review the other C-data-conversion programs on
you optical disk directory "data_con" and the class notes "Data Types and
Conversions" that will be passed out in class. You will be introduce you to
a variety of other conversion programs, mostly C, in the class lecture on
data-types. You may also want review Chapters 1-5 of the text "The Data
Handbook", by Brand Fortner, published by SpyGlass Inc. Copies of these books
will be loaned out to interested students.
Click image to return to Visualization home page.
R.D. Kriz
Virginia Tech
College of Engineering
Revised 01/10/03
http://www.sv.vt.edu/classes/ESM4714/exercises/exer3/exer3.html