Redian新闻
>
How to read binary(data) file generated by Fortran in C/C++ (转载)
avatar
How to read binary(data) file generated by Fortran in C/C++ (转载)# Programming - 葵花宝典
M*n
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
avatar
P*e
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.

avatar
q*2
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.

avatar
e*e
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.

avatar
M*n
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

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。