?
Solved

How to read single precision (REAL*4) FORTRAN 77 Binary data using Perl 5.6 and above

Posted on 2006-05-19
5
Medium Priority
?
475 Views
Last Modified: 2013-11-08
I'm trying to read unformatted fortran 77 data, specifically single precision real*4 data, using perl 5.6.  The reason for using perl for this problem is that I'm analyzing data, and I want the program to be as portable as possible.  The other part of this question is how to read the binary data created on a different bit machine i.e. created on a 32-bit SUN then read on a 64-bit SGI.  I know how to check for the "endian-ness" using perl, however I'm not sure how to read the binary data created by fortran.  Any response will be greatly appreciated.
0
Comment
Question by:jeffag04
2 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 16720341
you can use unpack"f" to unpack binary float data, but it is not portable, since it uses the native format
to be truely portable you may want to dump the float as a string, or if the format is not under your control, you may have to unpack it bit by bit to convert whatever format it is in.
0
 

Author Comment

by:jeffag04
ID: 16723428
I'm aware of the unpack/pack functions along with the different codes such as f,n,N, etc.  Using unpack "f" doesn't read the binary data correctly on its own.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question