以下部分代码在RECL< 2,147,483,647:
mult = imax*jmax*kmax*sizeofdouble
PRINT *,mult
OPEN (UNIT=2000, FILE=binaryFile, FORM='unformatted',access='direct',recl=mult)
READ (2000,rec=1) fromBinary
CLOSE (2000)
对于较大的值,即使 mult 打印正确( 是64位整数),我也会收到错误Fortran runtime error: RECL parameter is non-positive in OPEN statement
。显然,这是由于错误#44292。
除了使用其他编译器之外,您是否看到了重写上述代码的方法,以便我不需要为RECL使用大值?
答案 0 :(得分:2)
不能保证,但很可能您的文件也可以通过流访问来读取。特别是与gfortran。
gawk -v p=1 '
/^PATTERN2/ { # when we we see the 2nd marker:
# close the "write" end of the pipe to sort. Then sort will know it
# has all the data and it can begin sorting
close("sort", "to");
# then sort will print out the sorted results, so read and print that
while (("sort" |& getline line) >0) print line
# and turn the boolean back to true
p=1
}
p {print} # if p is true, print the line
!p {print |& "sort"} # if p is false, send the line to `sort`
/^PATTERN1/ {p=0} # when we see the first marker, turn off printing
' FILE
根据数组OPEN (UNIT=2000, FILE=binaryFile, FORM='unformatted',access='stream')
READ (2000) fromBinary
CLOSE (2000)
的大小,它将根据需要读取多个字节。
优点是没有处理器依赖性,并且所有编译器的流文件都相同。仍然应该像所有未格式化的文件一样谨慎使用字节序。