萌新求助!看不懂源代码文件
本帖最后由 Karoline0099 于 2019-8-22 11:01 编辑我第一次接触Fortran,因为学业需求,当时前辈留下了一个写好的.f90,我试着在我电脑上运行了一下,提示出错,但是我自己完全不知道怎么回事
有没有大神可以帮忙看一下这个文件,怎么才能成功运行起来?
:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(:'(
!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
99end
本帖最后由 li913 于 2019-8-21 21:39 编辑
1、给错误提示。2、我试了一下,编译连接没问题,可以运行但缺少输入文件。
li913 发表于 2019-8-21 21:35
1、给错误提示。2、我试了一下,编译连接没问题,可以运行但缺少输入文件。
...
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的文件,是一年气象数据的合集
你是不是选错编译器了?用的什么编译器? 本帖最后由 li913 于 2019-8-23 15:21 编辑
第一句改为:integer,Parameter::line=364,sample=2048
原来的语句,sample是实型,gfortran不让它作为数组大小,ivf虽然会警告,但却不报错。
li913 发表于 2019-8-23 15:10
你是不是选错编译器了?用的什么编译器?
我没有用过啊,只是被告知要使用什么:'(
一个叫做mingw-64w的
页:
[1]