End of Record error when saving a variable

前端 未结 2 1583
梦谈多话
梦谈多话 2021-01-24 02:42

I\'m having a runtime error when I run a code that works without problems using a different computer.

I\'m wondering if the problem is the Fortran compiler of this machi

2条回答
  •  悲哀的现实
    2021-01-24 02:42

    One thing to be aware of, when you specify a list directed * write of a character string, the compiler always(?) adds an extra lead blank, so the effective length of the string you can write is one less than you might expect.

    To remedy that (and of course assuming you don't want the lead blank anyway ) use a string edit descriptor:

       write(sceneclass(i),'(a)')...
    

    Interestingly ifort (linux 11.1) actually allows you to overrun by one character:

     character*5 c
     write(c,*)'12345'  ! result: " 1234"
    

    which I would consider a bug. It seems they forgot to count the blank too.. ( gfortran throws the above error on this, and ifort balks if you add one more character )

    see here if you wonder why the blank.. Are Fortran control characters (carriage control) still implemented in compilers?

    and now I'm curious if some compiler somewhere didn't do that for an internal list write, or maybe your code was previously compiled with a flag to disable the "printer control" code

提交回复
热议问题