Prev: C interop to popen
Next: transfer from real to logical
From: Terence on 2 Dec 2009 17:20 On Dec 3, 7:18 am, dpb <n...(a)non.net> wrote: > kis wrote: > > Hello Experts, > > > I have a binary file created by FORTRAN program. I need to modify its > > content. Unfortunately, I don't have any manual that explains the > > format of this binary file. Is there a way to find the format in which > > this binary file is written? > > There's no Fortran Standard definition, but... > > An unformatted file is a sequence of unformatted records. An unformatted > record is a sequence of values. The number of records and the content > of each record is determined by the function of the program, of course. Er, There's more than just one kind of "BINARY" file produced by Fortran programa. The common variations are:- 1) Opened as UNFORMATTED SEQUENTIAL, which has a structure of prefixed and postfixed byte counters to the enclosed record; 2) Opened as BINARY SEQUENTIAL, with no added structure and is a file of bytes, "stream files"; 3) Opened as DIRECT ACCESS, which has a fixed record length of byte- based records. The meaning of the data "sections" if any (none for BINARY) is defined by the user. Without any previous information of the content, you can only "resonably guess" at the use of the files. Text data, confined (usually and especially for english) to the byte values #20 to #7e can fairly easily be identified and a tentative assignment of a field can be made to these strings. Next you try to divide other sections into 4-byte words unless you happen to know that integer*2 vaues may be present. Smallish integers would have trailing #00 bytes among 4-byte divisions; floating point values tend to have a lead byte value around #40 and most probably fairly random other bytes, except when repesenting signed integer values as floating point coding. And yes, as suggested, a binary text editor is very useful. I'll supply one if you ask; but there must be lots "out there".
From: Luka Djigas on 2 Dec 2009 17:23 On Wed, 02 Dec 2009 20:54:18 +0100, Sjouke Burry <burrynulnulfour(a)ppllaanneett.nnll> wrote: > >Last resort: hunt down the writer of that program and beat the >documentation/code out of him/her. >/ That last approach always reminds me somehow of http://xkcd.com/538/ :) pp, Luka
From: dpb on 2 Dec 2009 17:35 Terence wrote: .... > Er, There's more than just one kind of "BINARY" file produced by > Fortran programa. .... If you hadn't stopped and snipped there, you would have seen I went thru the two in the Standard (and came back and added "stream" later)... --
From: Richard Maine on 2 Dec 2009 18:03 dpb <none(a)non.net> wrote: > Terence wrote: > ... > > Er, There's more than just one kind of "BINARY" file produced by > > Fortran programa. > ... > If you hadn't stopped and snipped there, you would have seen I went thru > the two in the Standard (and came back and added "stream" later)... And you actually gave accurate descriptions, as I'd expect. :-) -- Richard Maine | Good judgment comes from experience; email: last name at domain . net | experience comes from bad judgment. domain: summertriangle | -- Mark Twain
From: Sjouke Burry on 2 Dec 2009 21:24
Luka Djigas wrote: > On Wed, 02 Dec 2009 20:54:18 +0100, Sjouke Burry > <burrynulnulfour(a)ppllaanneett.nnll> wrote: > >> Last resort: hunt down the writer of that program and beat the >> documentation/code out of him/her. >> / > > That last approach always reminds me somehow of > http://xkcd.com/538/ Now you did it... Wasted a precious hour with those silly cartoons.... |