# Read out the content of a Fortran binary file based on the limited information given by its hexadecimal representation

**URL:** <https://fortran-lang.discourse.group/t/read-out-the-content-of-a-fortran-binary-file-based-on-the-limited-information-given-by-its-hexadecimal-representation/3000>\
**Category:** Help\
**Created:** [March 18, 2022, 2:19am UTC](https://fortran-lang.discourse.group/t/read-out-the-content-of-a-fortran-binary-file-based-on-the-limited-information-given-by-its-hexadecimal-representation/3000 "2022-03-18T02:19:10Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![mecej4](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/mecej4/32/855_2.png) [@mecej4](https://fortran-lang.discourse.group/u/mecej4)\
**Post date:** [March 19, 2022, 1:03pm UTC](https://fortran-lang.discourse.group/t/read-out-the-content-of-a-fortran-binary-file-based-on-the-limited-information-given-by-its-hexadecimal-representation/3000/15 "2022-03-19T13:03:08Z")

</div>

> [@Hongyi](#):
>
> As you can see below, each record has 9 fields with a headline denoting the space group name:
> 
> ```auto
> $ strings kLG_1.data | grep -v '^\?' | sed -re 's/\($//' | awk '!a[$0]++ {print $0, NF,NR}'
> 
> ```

Sorry, this line of reasoning / method of extracting information makes no sense at all. The Linux/Unix **string** utility displays printable characters when they occur consecutively in clumps of 4 or more. Everything else in the file is ignored! When a Fortran unformatted file is written, most of the bytes in the file correspond to “unprintable” characters, so by ignoring them you are discarding almost all the numerical information (integers, reals, etc.) and carrying on as if what is left is all that is important.

For instance, for the data file kLG\_1.data, your application of **strings** and **sed** leaves discards 90 percent of the content of the file.

The question is, do you have the Fortran program sources that produced every one of the unformatted data files that are of interest to you? Or, at least complete and precise documentation of the structure and content of the files? If not, you are simply inviting us to go with you for a walk in a minefield while wearing blindfolds.

---

_[View the full topic](https://fortran-lang.discourse.group/t/read-out-the-content-of-a-fortran-binary-file-based-on-the-limited-information-given-by-its-hexadecimal-representation/3000)._
