登 录
註 冊
论坛
微波仿真网
注册
登录论坛可查看更多信息
微波仿真论坛
>
程序
>
g77 及gfrotran 中二进制文件的问题
发帖
回复
2712
阅读
0
回复
[
讨论
]
g77 及gfrotran 中二进制文件的问题
离线
febi
UID :2537
注册:
2007-05-11
登录:
2016-05-05
发帖:
123
等级:
退休版主
0楼
发表于: 2008-03-30 10:14:00
w,SOvbAxX2
A question about g77's OPEN & WRITE
skh6L!6*<
a9j f7r1
F-R4S^eV
--------------------------------------------------------------------------------
\l?\%aqm
"EQ`Q=8
Zhong Wang wrote:
g>12!2}
^GQ+,0Yy
> I am using g77 for programing now. But I found that
.}&bE1
> g77 is somewhat
%E}f7GT4
> different to Visual Fortran in I/O.
Jt\?,~,
>
c/DB"_}!a
> In visual fortran, the following code is legal:
iOkRB[hi
>
3Wa^:8N
> REAL a(10)
0UB)FK,9
> OPEN(10,file='aaa.dat',form='binary')
|a%&7-;
> WRITE(10)a
8L`J](y
> CLOSE(10)
-|\V'
> <<<<<
7;:R\d6iL
> You can see that in file aaa.dat there's not
@]uvpI!h
> anything between the integer
=H%c/Jty
> and real numbers.
vR.=o*!%
> But in g77, if I use:
F.i*'x0u
>
^# B`GV
> REAL a(10)
FloCR=^H
> OPEN(10,file='aaa.dat',form='unformatted')
qPDe;$J)
> WRITE(10)a
Cp`)*P2
> CLOSE(10)
{U?/u93~
> <<<<<
Eyv%"+>
> With "hexedit aaa.dat", you can find there's a
xa5^h]o
> length value before and after
"#\\p~D/<
> each record. You know, sometimes we have to make more
87l(a,#J
> efforts to deal with
rV*9=
> those length values when we use other softwares to
w[}5qAI5*f
> open these data files. For
&\#If:
> example, when I use matlab to open the file, I have to
pyhC%EZU
> read off those length
a'u:1C^\
> values. It's very convinient.
~,3+]ts='\
>
fQ33J>
> Can you recommend me a possible method with g77 to
*`&4<>=n
> generate data file which
\CNv,HUm3
> contains no extra bytes in it? Or can the developers
|l'BNuiU
> add some new features
LfOXgn\
> like form='direct' to g77?
1vk&;
1O3"W;SR<:
No, there's no method to get rid of the record lenghts in an unformatted
EVZuwbO)|
file when using g77. However, if all the records in your file are the
L9ECF;)
same length, you could write a "direct access" file, by doing the writes
bHZXMUewC
thusly:
i eQQ{iGJH
21Mr2-#z
REAL A(10)
M6l S2
OPEN(...,ACCESS='DIRECT',RECL=....)
luXcr H+w
DO I = 1, N
{_T?0L
... fill A
g\^7 Q
..
Teh _
~3bH2,{L[
未注册仅能浏览
部分内容
,查看
全部内容及附件
请先
登录
或
注册
共
条评分
磁砖
发帖
回复