What could be the cause of "output statement overflows record, unit -5, file Internal Formatted Write"error?

huangapple go评论121阅读模式
英文:

What could be the cause of "output statement overflows record, unit -5, file Internal Formatted Write"error?

问题

尊敬的Stack Overflow社区,

我正在使用KPP处理器运行一个简单的模拟,但在输出的第9个.dat文件(共150个)后,模拟终止,并显示以下错误信息:

forrtl: severe (66): output statement overflows record, unit -5, file Internal Formatted Write

所使用的编译器是:Intel Fortran Compiler 2022.2.1。

可能涉及到的Fortran代码部分如下:

* OPEN( unit=10, file="dyno_"//ex_no(1)//ex_no(2)//ex_no(3)//".dat")

......

INTEGER i

WRITE(10,999) (TIME-TSTART)/3600.D0,  &
               (C(LOOKAT(i))/CFACTOR, i=1,NLOOKAT)
999 FORMAT(E24.16,100(1X,E24.16))*

希望您能提供帮助。

提前感谢您。

我尝试检查Fortran Integrator.f90脚本中的WRITE语句,但在代码中没有找到足够的资源来确切查找问题所在。

英文:

Dear Stack over flow community,
I am running a simple simulation with KPP processor and after the 9th output .dat file (out of 150) the simulation terminates with the following error message:

forrtl: severe (66): output statement overflows record, unit -5, file Internal Formatted Write

Compiler used: Intel Fortran Compiler 2022.2.1 .

This might be the part of the Fortran code involved:

 * OPEN( unit=10, file="dyno_"//ex_no(1)//ex_no(2)//ex_no(3)//".dat")

......
......

  INTEGER i

      WRITE(10,999) (TIME-TSTART)/3600.D0,  &
                   (C(LOOKAT(i))/CFACTOR, i=1,NLOOKAT)
999   FORMAT(E24.16,100(1X,E24.16))*

I hope you can help with that.

Thank you in advance.

I tried checking the WRITE statement in the Fortran Integrator.f90 script but I did not find enough resources inline to check exactly what the problem was.


Maybe this longer description helps:

After successfully compiling a Makefile, with Intel Fortran Compiler 2022.2.1, with the options suggested by chw21, I get an executable file called dynho.exe.

In order to get the desired output I execute dynho.exe with the ./ command.
The output should be made of 150 .dat files, because the simulation uses 150 different sets of initial conditions.

The simulation runs but terminated after producing only 9 out of 150 expected .dat files.

The execution of the dynho.exe has been made submitting the salloc script in bwunicluster:

#!/bin/bash  
#SBATCH   --nodes=1
#SBATCH   --cpus-per-task=5
#SBATCH   --mem=600mb
#SBATCH   --time=27:00:00           
#SBATCH   -J  test_bwbatch               # Specify job name
#SBATCH   --mail-user=blablabla@kit.edu
#SBATCH   --mail-type=BEGIN,END,FAIL

echo "Start kpp script execution at $(date)"

./dynho.exe

which produces a .out file. This is the part where the forrtl error is mentioned:

forrtl: severe (66): output statement overflows record, unit -5, file Internal Formatted Write
Image              PC                Routine            Line        Source
dynho.exe          0000000000455A3A  Unknown               Unknown  Unknown
dynho.exe          0000000000454737  Unknown               Unknown  Unknown
dynho.exe          0000000000408629  dynho_util_mp_ini          66  dynho_Util.f90
dynho.exe          0000000000430EE6  MAIN__                     82  dynho_Main.f90
dynho.exe          000000000040385D  Unknown               Unknown  Unknown
libc-2.28.so       000014B9B1F6D493  __libc_start_main     Unknown  Unknown
dynho.exe          000000000040377E  Unknown               Unknown  Unknown

============================= JOB FEEDBACK =============================

NodeName=uc2n501
Job ID: 21896960
Cluster: uc2
User/Group: ii5664/imk-tro
State: FAILED (exit code 66)
Nodes: 1
Cores per node: 6
CPU Utilized: 00:12:52
CPU Efficiency: 9.02% of 02:22:36 core-walltime
Job Wall-clock time: 00:23:46
Memory Utilized: 5.89 MB
Memory Efficiency: 0.98% of 600.00 MB

I could post the dynho_Util.f90 and dynho_Main.f90 routines but I would not to overwhelm the post.

This is part of the dynho_Util.f90 :

     SUBROUTINE InitSaveData (j)

      USE dynho_Parameters
      INTEGER    :: j
      CHARACTER  :: ex_no(3)

      ex_no(1:2) = '000'

   
       IF(j.lt.10) then
          WRITE(ex_no(3),4) j
4         FORMAT(i1) 
       ELSEIF (j.ge.10.and.j.lt.100) then          
          WRITE(ex_no(2:3),5) j     !! This is line 66  !!
5         FORMAT(i2) 
       ELSE
          WRITE(ex_no(:),6) j
6         FORMAT(i3)
       END IF

      OPEN( unit=10, file="dynho_"//ex_no(1)//ex_no(2)//ex_no(3)//".dat")
    !  open(10, file='dynho.dat')

      END SUBROUTINE InitSaveData

This dynho_Util.f90 routine is a bit longer but I guess the relevant part should be this one.

答案1

得分: 2

内部写操作是在变量的一部分进行写入

character :: ex_no(3)

这是一个字符数组,长度为3,长度为1。在内部写入中

write(ex_no(1:2), '(I2)') 10

我们正在指向内部文件中的两个_记录_,ex_no(1)ex_no(2)1 然而,写入只涉及一个记录,所以只传输到 ex_no(1)。但是,ex_no(1) 是长度为1的字符,将两个字符("10")写入其中太多了。

这就是错误的原因。

纠正这个问题需要完全重写逻辑,因为你应该使用长度为3的标量字符,并且使用像 (I3.3) 这样的格式,而不是那些复杂的条件语句。你可以在另一个问题及其答案中了解到生成这种文件的正确方法。


1 在内部文件中使用数组时,数组的每个元素是传输操作中的一个独立记录。

英文:

The internal write is writing to part of the variable

character :: ex_no(3)

This is a character array, extent 3, length 1. In the internal write

write(ex_no(1:2), '(I2)') 10

we are pointing to two records in the internal file, ex_no(1) and ex_no(2).<sup>1</sup> The write, though, is writing just one record, so transfers to just ex_no(1). But, ex_no(1) is a character of length 1 and writing two characters to that (&quot;10&quot;) is too many.

This is the reason for the fault.

Correcting this involves a complete rewrite of the logic, as you should be using a scalar character of length 3, and using a format like (I3.3) instead of those convoluted conditionals. You can read about the correct way to generate files like this in another question and its answers.


<sup>1</sup> When using an array in an internal file, each element of the array is one distinct record in the transfer operation.

答案2

得分: 1

我同意Vladimir的观点,你应该提供更多信息。我不认为你提供的那行(或几行)包含错误。在上一行中,你在第10单元写入了一个文件,但错误信息指向了第-5单元的内部写入。

通常情况下,这种情况发生是因为你试图将内容写入一个字符串变量,但要写入的内容太大,类似这样:

program overflow
    implicit none
    character(len=10) :: some_string
    write(some_string, *) "一些比", 10, "个字符还长的内容"
end program overflow

我最近在这样的情况下遇到过:

character(len=256) :: fullname
character(len=200) :: dirpath, filename

write(fullname, "(A, A1, A)") trim(dirpath), "/", filename

因为filename没有修剪,fullname只剩下dirpath变量的前55个字符,然后是filename的一百多个尾随空格,这样就太长了,fullname无法处理。当目录的路径少于56个字符时,这个过程是正常的,但当它是59个字符时突然就出错了。

我建议使用以下编译选项:-O0 -g -traceback,这样会显示出错误发生的具体行数。

英文:

I agree with Vladimir, you should give more information. I don't think that the line(s) you presented contain the error. In the line above you write to a file on unit 10, but the error references an internal write on unit -5.

This usually happens when you try to write to a string variable, but the content to be written is too large, something like this:

program overflow
    implicit none
    character(len=10) :: some_string
    write(some_string, *) &quot;Some content longer than&quot;, 10, &quot;characters&quot;
end program overflow

I have encountered that recently in such a situation:

character(len=256) :: fullname
character(len=200) :: dirpath, filename

write(fullname, &quot;(A, A1, A)&quot;) trim(dirpath), &quot;/&quot;, filename

Because filename wasn't trimmed, only 55 characters of the dirpath variable remained before the hundred-plus trailing spaces of filename became too long for fullname to handle. This went fine while the path to the directory contained less than 56 characters, but suddenly broke when it was 59.

I would suggest compiling with the options: -O0 -g -traceback which will give you the specific line where this happens.

huangapple
  • 本文由 发表于 2023年3月9日 18:20:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75683250.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定