Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想使用Fortran 90将未知长度的文本从文件中读入类似向量的字符(len=1)a(3000)_Fortran_Fortran90 - Fatal编程技术网

我想使用Fortran 90将未知长度的文本从文件中读入类似向量的字符(len=1)a(3000)

我想使用Fortran 90将未知长度的文本从文件中读入类似向量的字符(len=1)a(3000),fortran,fortran90,Fortran,Fortran90,我想将未知长度的文本从文件中读入类似向量的字符(len=1)a(3000),但输入文件没有“文件结束标记” 我试过这样的方法: open(2,file=surnames.txt,status='old') read(2,15, IOSTAT=ios,END=20,ERR=20)(a(i),i=1,3000) isize=0 do while (ios == 0) isize=isize+1 read(2,15, ios

我想将未知长度的文本从文件中读入类似向量的字符(len=1)a(3000),但输入文件没有“文件结束标记”

我试过这样的方法:

     open(2,file=surnames.txt,status='old')
     read(2,15, IOSTAT=ios,END=20,ERR=20)(a(i),i=1,3000)

      isize=0
      do while (ios == 0)
        isize=isize+1
        read(2,15, iostat=ios, end=20) a(isize)
      end do

15    format(a1)
20    continue
但什么都不管用


感谢您的关注

请说出“无事可做”的含义。它没有说任何有用的话。它会崩溃吗?是否有任何错误消息?结果错了吗?错在哪里?请用更多信息回答您的问题。您可能应该使用
访问。我想将输入文件转换为字符向量,以便能够单独处理文件中的每个字符。我所说的“什么都不起作用”是指最后的向量a(I)是不正确的。谢谢现场IanH的答案在这种情况下非常有用。或者只做一个(LEN=3000),然后你就可以得到整条线的长度,不管它有多长。。。然后告诉你那条线有多长。。。