Fortran Coder

查看: 15130|回复: 5
打印 上一主题 下一主题

[求助] 萌新求助!看不懂源代码文件

[复制链接]

4

帖子

1

主题

0

精华

新人

F 币
30 元
贡献
10 点
跳转到指定楼层
楼主
发表于 2019-8-21 17:11:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Karoline0099 于 2019-8-22 11:01 编辑

我第一次接触Fortran,因为学业需求,当时前辈留下了一个写好的.f90,我试着在我电脑上运行了一下,提示出错,但是我自己完全不知道怎么回事
有没有大神可以帮忙看一下这个文件,怎么才能成功运行起来?
:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(


[Fortran] 纯文本查看 复制代码
!  This program is for extracting reflectance at four wavelength
    Parameter(line=364,sample=2048)
        real NIESraw(line, sample),d1(line,sample),d2(line,sample)
        real NIESwave(line,sample),NIESt(line)
        real NIES(line, sample), ref(line,sample),waveNISE
    character filename*20, filename2*100, dum*10
        open(unit=22, file='filename.prn', status='old')
    do 1 idate=1,2000
        read(22,*,end=99) filename 
        filename2=filename                    !'Z:\kiryuT\spectro\data\UT_30m\'//filename
    open(unit=20, file=filename2, status='old')
          open(unit=30, file='refrectance.dat',status='unknown')        
!!! discard the first 8 lines !!!!丂丂
        do j=1,3
        read(20,*)
        end do
    read(20,*) dum,(NIESt(i),i=2,line) 
    do j=1,4
        read(20,*)
        end do
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        do j=1,sample
        read(20,*) (d1(i,j),i=1,line) 
        end do
        do j=1,sample-5
         do i=2,line
  !    if(NIESt(i).eq.5.0) then       !NIES_20m bag correction
  !    NIESwave(i,j)=d1(1,j+5)        !
  !    else                           !
          NIESwave(i,j)=d1(1,j)
!          end if                         !
          NIESraw(i,j)=d1(i,j)/NIESt(i)     
          end do    
    end do
    do i=2,line
        !open(unit=23, file='factors3.csv', status='old')
        do k=1,157
    sumNIES=0.0
        NNIES=0
        wave=300.+float(k)*5.
      do j=1,sample-5
      if((NIESwave(i,j).ge.wave-2.5).and.(NIESwave(i,j).le.wave+2.5)) then
          sumNIES=sumNIES+NIESraw(i,j)
          NNIES=NNIES+1
          end if
      end do
    NIES(i,k)=sumNIES/float(NNIES)    !average
        !read(23,*) f1 !f2,f3
        !REF(i,k)=(UT(i,k))/(NIES(i,k)*f1)
        end do
        end do
        do ll=1,35
        time=(float(ll)/(6*24))*24.
        write(30,100) filename, time
        end do
        do l=2,(line+6)/5
        do k=1,157
          REF(l,k)=NIES(5*(l-2)+3,k)/((NIES(5*(l-2)+2,k)+NIES(5*(l-2)+4,k))/2)
    end do
        !close(23)
        time=(float(l-2)/(6*24)+0.25)*24.
        write(30,100) filename,time,ref(l,46),ref(l,54),ref(l,76),ref(l,100),ref(l,90),ref(l,81),ref(l,120),ref(l,134)
    write(*,100) filename,time,ref(l,46),ref(l,54),ref(l,76),ref(l,100),ref(l,90),ref(l,81),ref(l,120),ref(l,134)
100 format(A20,1x,10f14.8)
        end do
        do ll=1,36
        time=(float(ll)/(6*24)+0.75)*24.
        write(30,100) filename, time
        end do
1   continue
99  end

   
分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

798

帖子

2

主题

0

精华

大宗师

F 币
3793 元
贡献
2268 点
沙发
发表于 2019-8-21 21:35:07 | 只看该作者
本帖最后由 li913 于 2019-8-21 21:39 编辑

1、给错误提示。2、我试了一下,编译连接没问题,可以运行但缺少输入文件。

4

帖子

1

主题

0

精华

新人

F 币
30 元
贡献
10 点
板凳
 楼主| 发表于 2019-8-22 10:55:58 | 只看该作者
li913 发表于 2019-8-21 21:35
1、给错误提示。2、我试了一下,编译连接没问题,可以运行但缺少输入文件。
...

[Fortran] 纯文本查看 复制代码
 real NIESraw(line, sample),d1(line,sample),d2(line,sample)
                          1
Error: Bad array specification for an explicitly shaped array at (1)
SPECTRO.F90:4:26:

  real NIESwave(line,sample),NIESt(line)
                          1
Error: Bad array specification for an explicitly shaped array at (1)
SPECTRO.F90:5:23:

  real NIES(line, sample), ref(line,sample),waveNISE
                       1
Error: Bad array specification for an explicitly shaped array at (1)
SPECTRO.F90:17:19:

     read(20,*) dum,(NIESt(i),i=2,line)
                   1
Error: Expected variable in READ statement at (1)
SPECTRO.F90:23:11:

  read(20,*) (d1(i,j),i=1,line)
           1
Error: Expected variable in READ statement at (1)
SPECTRO.F90:22:8:

  do j=1,sample
        1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
SPECTRO.F90:30:3:

    NIESwave(i,j)=d1(1,j)
   1
Error: The function result on the lhs of the assignment at (1) must have the pointer attribute.
SPECTRO.F90:32:3:

    NIESraw(i,j)=d1(i,j)/NIESt(i)
   1
Error: The function result on the lhs of the assignment at (1) must have the pointer attribute.
SPECTRO.F90:25:8:

  do j=1,sample-5
        1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
SPECTRO.F90:41:13:

       do j=1,sample-5
             1
Warning: Deleted feature: End expression in DO loop at (1) must be integer
SPECTRO.F90:47:4:

     NIES(i,k)=sumNIES/float(NNIES)    !average
    1
Error: The function result on the lhs of the assignment at (1) must have the pointer attribute.
SPECTRO.F90:58:3:

    REF(l,k)=NIES(5*(l-2)+3,k)/((NIES(5*(l-2)+2,k)+NIES(5*(l-2)+4,k))/2)
   1
Error: The function result on the lhs of the assignment at (1) must have the pointer attribute.





输入文件是一个.prn的文件,是一年气象数据的合集

798

帖子

2

主题

0

精华

大宗师

F 币
3793 元
贡献
2268 点
地板
发表于 2019-8-23 15:10:36 | 只看该作者
你是不是选错编译器了?用的什么编译器?

798

帖子

2

主题

0

精华

大宗师

F 币
3793 元
贡献
2268 点
5#
发表于 2019-8-23 15:18:14 | 只看该作者
本帖最后由 li913 于 2019-8-23 15:21 编辑

第一句改为:integer,Parameter::line=364,sample=2048
原来的语句,sample是实型,gfortran不让它作为数组大小,ivf虽然会警告,但却不报错。

4

帖子

1

主题

0

精华

新人

F 币
30 元
贡献
10 点
6#
 楼主| 发表于 2019-8-24 18:55:10 | 只看该作者
li913 发表于 2019-8-23 15:10
你是不是选错编译器了?用的什么编译器?

我没有用过啊,只是被告知要使用什么
一个叫做mingw-64w的
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

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

GMT+8, 2024-5-3 16:12

Powered by Tencent X3.4

© 2013-2024 Tencent

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