Error when reading in float in Fortran

后端 未结 3 875
情深已故
情深已故 2021-01-20 16:48

This should be quite simple, but I can\'t manage to read in a floating point number in Fortran. My program test.f looks like this:

  PROGRAM TEST
  ope         


        
3条回答
  •  没有蜡笔的小新
    2021-01-20 17:05

    I would suggest reading/writing list formatted data, unless you have a very strong reason to do otherwise. assuming that you're reading in from a file with just a single float or integer in a single line, like this

    123.45
    11
    42
    

    then this should do the reading

    real*8 :: x,y,z
    open(1,file=filename)
    read(1,*)x
    read(1,*)y
    read(1,*)z
    close(1)
    

提交回复
热议问题