楚香饭 发表于 2016-4-16 07:13 谢谢回答,非常感谢!!!! |
|
除了 Compaq Visual Fortran,除了 Powerstation,除了 g77 ,除了 NPD Fortran ,除了这些已经死了的编译器 但凡还在更新维护中的编译器,都可以使用。 |
楚香饭 发表于 2016-4-14 21:33 Read( 16 , pos = 32+lngTDT*4+1 ) Inquire( 12 , Pos = i ) 这种语句要在哪种版本才能使用? |
楚香饭 发表于 2016-4-14 21:33 谢谢你的回答,还没有运行,我将去学习你的代码和相关知识 |
|
1. 这里没有学计算机专业的。 2. 你的数据文件格式还是比较简单的。 3. 对于二进制文件来说,有一种很方便的东西,叫 stream,本站有介绍文章 4. 我写了一个简单的代码,也做了注释,应该比较易懂。 [Fortran] 查看源码 复制源码 Program www_fcode_cn
use , Intrinsic :: ISO_C_Binding
Implicit None
character(len=1) :: yn !//问询
character(len=30) :: myHead !//头部
integer(kind=C_SHORT) :: lngTDT !//数据大小
Integer(kind=C_Int) , allocatable :: spcin(:) !//数据
Character(len=1) , allocatable :: tail(:) !//尾部
integer :: n !//大小
Open( 16 , File = '6.dat' , access="stream" , form="unformatted" )
Open( 12 , File = 'ca.chn' , access="stream" , form="unformatted" )
Open( 11 , File = '1.txt' )
Inquire( 16 , size = n ) !//查询文件大小
Read( 16 ) myHead , lngTDT !//读前头部32字节
n = n - 32 - lngTDT*4 !//算出尾部大小
If ( n > 0 ) then !//如果有尾部
Allocate( tail(n) ) !//分配尾部
Read( 16 , pos = 32+lngTDT*4+1 ) tail !//读取尾部
End If
Write(*,*)'1024 CH ?(Y/N)'
Read(*,*) yn
If( YN == 'Y' .OR. YN == 'y' ) then
LngTDT=1024
Else
LngTDT=4096
EndIf
Allocate( spcin(LngTDT) ) !//分配数据
Write( 12 ) myHead , LngTDT !//写入头部32字节
read(11,*) !//跳过第一行<<DATA>>
read(11,*) spcin !//读取数据
write( 12 ) spcin !//写入数据
If(n>0) write(12) tail !//写入尾部
Deallocate( spcin )
If(n>0) Deallocate( tail )
close( 16 )
close( 12 )
close( 11 )
End Program www_fcode_cn |
捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )
GMT+8, 2025-11-24 23:51