Error when reading in float in Fortran

后端 未结 3 879
情深已故
情深已故 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:29

    Your variable line is implicitly defined as integer. This doesn't work with thef edit descriptor. If you want to read an integer use i edit descriptor (i3 for example). Otherwise declare line as real to math the "f" descriptor.

    Note beside: the .0 is not a problem, because if Fortran gets a number with decimal point the .0 part in the descriptor is ignored. It is only used when an number without a decimal is entered and then it uses the number behind the decimal point in the desciptor to add a decimal point into the right place. For with F8.5, 123456789 is read as 123.45678. More ont this here http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/lin/compiler_f/lref_for/source_files/pghredf.htm .

提交回复
热议问题