Fortran Coder

数据分类问题求助

查看数: 9674 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2015-2-6 13:44

正文摘要:

我有525个以站点命名的文件,每一个文件里是该站点从1961-2013年的数据,像下面的格式,第5列是年份:        50353        5143       12639 ...

回复

fcode 发表于 2015-2-7 10:26:39
[Fortran] 纯文本查看 复制代码
Program Www_fcode_cn
  Implicit None
  Character *5 Filename
  Character *4 Filename1
  Integer :: I, J
  Integer :: A(6)
  Open (10, File='D:\a\year.txt')
  Do J = 1961, 2013
    Read (10, *) Filename1
    Open (J, File='D:\c\'//Filename1//'.txt') !// 11 改为 j
  End Do
  Open (12, File='D:\a\tem.txt')
  Do I = 1, 525
    Read (12, *) Filename
    Open (13, File='D:\a\'//Filename//'.txt')
    Do J = 1961, 2013
      Read (13, *) A(:)
      Write (A(5), *) A(:)
    End Do
    Close (13)
  End Do
  Close (12)
  Do J = 1961, 2013
    Close (J)
  End Do
  Close (10)
End Program Www_fcode_cn
gercibee 发表于 2015-2-6 16:06:04
[Fortran] 纯文本查看 复制代码
program main
  implicit none
  character*5 filename
  character*4 filename1
  integer :: i,k,j,q
  integer :: a(6)
  
  do q = 1961, 2013
  open(10, file = "D:\a\year.txt")
      do i = 1, 53
          read(10, *) filename1 
          open(11, file = "D:\c\"//filename1//".txt")
          open(12, file = "D:\a\tem.txt")
          do j = 1, 525
              read(12, *) filename
              open(13, file = "D:\a\"//filename//".txt")
              do k = 1, 53
                  read (13, *) a(1:6)
                  if (a(5) == q) then
                      write(11,*) a(1:6)
                      exit
                  end if
              end do
          end do
          close(13)
          close(12)
      end do
      close(11)
      close(10)
  end do
end

     我这样写代码,然后就是不停的写,然后被替换,到最后只留下2013年的数据,这的哪里需要改一下呢?

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-11-23 06:07

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表