M**********n 发帖数: 432 | 1 【 以下文字转载自 Computation 讨论区 】
发信人: ManshengChen (像琼瑶一样老去), 信区: Computation
标 题: How to read binary(data) file generated by Fortran in C/C++?
发信站: BBS 未名空间站 (Sat Oct 13 19:28:21 2007)
How to read binary(data) file generated by Fortran in C/C++?
Is it possible? If possible how to realize it?
The binary file generated by Fortran is a double precision data file.
I have tried to use read binary file in C++, but have problem. The following
is my C++
code.
double temp=0.0;
ifstream File("bin.data",i | P********e 发帖数: 2610 | 2 c++的 double size可能和Fortran不一样
and be aware of header
following
【在 M**********n 的大作中提到】 : 【 以下文字转载自 Computation 讨论区 】 : 发信人: ManshengChen (像琼瑶一样老去), 信区: Computation : 标 题: How to read binary(data) file generated by Fortran in C/C++? : 发信站: BBS 未名空间站 (Sat Oct 13 19:28:21 2007) : How to read binary(data) file generated by Fortran in C/C++? : Is it possible? If possible how to realize it? : The binary file generated by Fortran is a double precision data file. : I have tried to use read binary file in C++, but have problem. The following : is my C++ : code.
| q****2 发帖数: 7 | 3 Two links
http://cires.colorado.edu/~knowlesk/programming/fortranio.html
http://local.wasp.uwa.edu.au/~pbourke/dataformats/fortran/
following
【在 M**********n 的大作中提到】 : 【 以下文字转载自 Computation 讨论区 】 : 发信人: ManshengChen (像琼瑶一样老去), 信区: Computation : 标 题: How to read binary(data) file generated by Fortran in C/C++? : 发信站: BBS 未名空间站 (Sat Oct 13 19:28:21 2007) : How to read binary(data) file generated by Fortran in C/C++? : Is it possible? If possible how to realize it? : The binary file generated by Fortran is a double precision data file. : I have tried to use read binary file in C++, but have problem. The following : is my C++ : code.
| e**e 发帖数: 3 | 4 Did the Fortran program use "direct access" or "sequential access" to
write the binary file?
If "sequential access", each write statement will produce one record
in the data file, and the record is prefixed and postfixed with the
integer value that is the length of that record. For example
open(unit=..., file="...", access="sequential", form="unformatted")
write(unit=...)1.23d0
will write the four-byte integer "8", the eight-byte double "1.23d0",
and again the four-byte integer "8". The "8
【在 M**********n 的大作中提到】 : 【 以下文字转载自 Computation 讨论区 】 : 发信人: ManshengChen (像琼瑶一样老去), 信区: Computation : 标 题: How to read binary(data) file generated by Fortran in C/C++? : 发信站: BBS 未名空间站 (Sat Oct 13 19:28:21 2007) : How to read binary(data) file generated by Fortran in C/C++? : Is it possible? If possible how to realize it? : The binary file generated by Fortran is a double precision data file. : I have tried to use read binary file in C++, but have problem. The following : is my C++ : code.
| M**********n 发帖数: 432 | 5 This works.
Thank you very much!
【在 e**e 的大作中提到】 : Did the Fortran program use "direct access" or "sequential access" to : write the binary file? : If "sequential access", each write statement will produce one record : in the data file, and the record is prefixed and postfixed with the : integer value that is the length of that record. For example : open(unit=..., file="...", access="sequential", form="unformatted") : write(unit=...)1.23d0 : will write the four-byte integer "8", the eight-byte double "1.23d0", : and again the four-byte integer "8". The "8
|
|