Fortran读取语句成功,但也调用了错误参数 - 为什么?

时间:2017-03-24 18:06:38

标签: fortran gfortran

我运行了一些fortran代码,看起来它正在工作,因为它读取了相应的行和值,但它也会在读取语句中跳过错误参数值。我无法弄清楚为什么会这样做。我已经修改了一段时间并在网上搜索了一天的答案。我唯一能想到的是它可能是编译器或系统架构问题。有人可以看看下面的代码的简化版本,并告诉我,如果他们发现问题?它正在阅读的文件也在下面。谢谢。

 PROGRAM read

  INTEGER   :: nkfobs

  integer    :: o_unit, my_task_id, KFNVOLA
  character(len=129)   :: o_file_name, o_head_format, o_body_format
  logical    there
  DATA KFNVOLA/71/


  my_task_id = 0
  write(o_file_name, '("obs_output", i5.5)') my_task_id
  o_head_format = '(i7)'
  o_body_format = '(3f13.5,i7,f13.5)'

  INQUIRE (file=trim(o_file_name), EXIST=there)
  if( there ) then
     print *, 'opening obs file from DART'
  OPEN(KFNVOLA,FILE=trim(o_file_name),FORM='FORMATTED',STATUS='OLD')
    else
      print *, 'Error: there are no DART obs files to open'
      return
   endif

  read(KFNVOLA,fmt=o_head_format,err=19) nkfobs
  print *, 'nkfobs = ', nkfobs
19    print *, 'Error in read in o_head of subroutine inenkfobs'

  close(KFNVOLA)

  END PROGRAM read

   9230
268.25000     33.64000     82.00000      1     -0.00000
268.25000     33.64000     82.00000      2      2.57222
268.25000     33.64000     82.00000      4    302.14999
268.25000     33.64000     82.00000      5      0.01677
266.39999     34.05000    106.00000      1     -2.22761
266.39999     34.05000    106.00000      2      1.28611
266.39999     34.05000    106.00000      4    303.14999
266.39999     34.05000    106.00000      5      0.01686
268.23001     38.13000    350.00000      1     -2.31475
268.23001     38.13000    350.00000      2      2.75861
268.23001     38.13000    350.00000      4    298.14999
268.23001     38.13000    350.00000      5      0.01433
267.70001     31.40000     34.00000      1     -0.62533
267.70001     31.40000     34.00000      2      3.54640
267.70001     31.40000     34.00000      4    302.14999
267.70001     31.40000     34.00000      5      0.01665
267.97000     32.52000     24.00000      1     -0.00000
267.97000     32.52000     24.00000      2      3.60111
267.97000     32.52000     24.00000      4    302.14999
267.97000     32.52000     24.00000      5      0.01663
263.73999     32.72000    145.00000      1     -3.08667
263.73999     32.72000    145.00000      2      5.34626
263.73999     32.72000    145.00000      4    304.14999
263.73999     32.72000    145.00000      5      0.01696

0 个答案:

没有答案