tianrui 发表于 2022-5-8 12:46:18

write格式输出中g0是什么格式

网站课程语法之文件读写上中有这样一个程序
Program www_fcode_cn
Use DFile_Mod
Implicit None
Real , allocatable :: a(:,:)
Character(len=512) :: cStr
Real    :: r
integer :: FILE_IN , i , nRow , nCol
Open( NewUnit = FILE_IN , File = "text.txt" )
nRow = GetFileN( FILE_IN ) - 2 !//获得文件行数
Read( FILE_IN , * ) !//跳过第一行
Read( FILE_IN , * ) !//跳过第二行
Read( FILE_IN , '(a512)' ) cStr!//读取第三行
nCol = GetDataN( cStr ) - 1 !//获得第三行有多少列
write( *, '("Row:",g0," Col: ",g0)' ) nRow , nCol
Allocate( a( nCol , nRow ) )
Backspace( FILE_IN ) !//退回到第三行
Do i = 1 , nRow
    Read( FILE_IN , * ) r , a( : , i )
    write( * , * ) a(:,i)
End Do
Deallocate( a )
Close( FILE_IN )
End Program www_fcode_cn
请问其中write( *, '("Row:",g0," Col: ",g0)' ) nRow , nCol中g0是什么输出格式,我找到format中与之对应的格式是Gw.d其中d不能省略,我把g0改成g1之后报错了,所以不明白g0是什么输出格式
希望大家能为我这个新人答疑解惑

fcode 发表于 2022-5-8 13:13:44

g0 就是让编译器自动选择使用合适的宽度,两侧不会有多余的空格(特别适合于想紧凑的输出内容时)。
页: [1]
查看完整版本: write格式输出中g0是什么格式