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
Gcc Fortran中(1)处的不可分类语句_Gcc_Fortran_Fortran90_Gfortran - Fatal编程技术网

Gcc Fortran中(1)处的不可分类语句

Gcc Fortran中(1)处的不可分类语句,gcc,fortran,fortran90,gfortran,Gcc,Fortran,Fortran90,Gfortran,我对fortran非常陌生,我真的不知道为什么会出现这个错误 integrand(i)=inte(x(i),beta,r2,r1) 1 Error: Unclassifiable statement at (1) calka11.f95:97.6: 我已经将所有变量制作成一个模块文件,然后使用 use 当我再次将这些变量放入代码文件时,它会再次流畅地工作 module zmienne real(10) :: r, u, r6, tempred, f, r2,

我对fortran非常陌生,我真的不知道为什么会出现这个错误

integrand(i)=inte(x(i),beta,r2,r1)
      1 Error: Unclassifiable statement at (1) calka11.f95:97.6:
我已经将所有变量制作成一个模块文件,然后使用

use 
当我再次将这些变量放入代码文件时,它会再次流畅地工作

    module zmienne
     real(10) :: r, u, r6, tempred, f, r2, r1, calka,beta
     real(10) :: inte
     real :: start, finish
     integer:: i
     integer, parameter :: Ngauss = 8
     real(10),dimension(ngauss),parameter::xx=(/-0.9602898565d0,&
     -0.7966664774d0,-0.5255324099d0,-0.1834346425d0,&
     0.1834346425d0,0.5255324099d0,0.7966664774d0,0.9602898565d0/)
     real(10),Dimension(ngauss),parameter::ww=(/0.1012285363d0,&
     0.2223810345d0,0.3137066459d0,0.3626837834d0,&
     0.3626837834d0,0.3137066459d0,0.2223810345d0,0.1012285363d0/)
     real(10),dimension(ngauss)::x,w,integrand
     integer, parameter :: out_unit=1000
     integer, parameter :: out_unit1=1001
     integer, parameter :: out_unit2=1002, out_unit3=1003
     real(10), parameter :: error=0.000001
     real(10):: total_calka, division,tot_old,blad
     real(10),parameter:: intrange=7.0
     integer::j,irange
   end module zmienne
使用该模块的主程序:

program wykres
 use zmienne
 implicit none
 open(unit=out_unit, file='wykresik.dat', action='write', status='replace')
 open(unit=out_unit1, file='wykresik1.dat', action='write')
 open(unit=out_unit2, file='wykresik2.dat', action='write')
 open(out_unit3, file='wykresik3.dat', action='write')

! the gaussian points (xx) and weights (ww) are for the [-1,1] interval
! for [0,1] interval we have (vector instr.)
     x=0.5d0*(xx+1.0d0)
     w=0.5d0*ww
! plots 
   tempred = 1.0
   beta=4.d0/tempred
   call cpu_time(start)
 do i=1,1000
    r=float(i)*0.01
    r6=(1.0/r)**6
    u=beta*r6*(r6-1.0)
    f=exp(-u/tempred)-1.0
    write(out_unit,*) r, u
    write(out_unit1,*)r, f
    write(out_unit2,*)r, r*r*f
end do
   call cpu_time(finish)
 print '("Time = ",f6.3," seconds.")',finish-start
! end of plots
! integration  1
 calka=0.0
 r1=0.0
 r2=0.5
    do i=1,ngauss
    r=(r2-r1)*x(i)+r1
    r6=(1.0/r)**6
    u=beta*r6*(r6-1.0d0)
! check for underflows
    if (u>100.d0) then 
    f=-1.0d0 
    else
    f=exp(-u)-1.d0 
    endif
! the array integrand is introduced in order to perform vector calculations below
    integrand(i)=r*r*f
    calka=calka+integrand(i)*w(i)
    enddo
    calka=calka*(r2-r1)

    write(*,*)calka
! end of integration    

! integration 2
  calka=0.0    
     do i=1,ngauss
     integrand(i)=inte(x(i),beta,r2,r1)
     calka=calka+integrand(i)*w(i)
     enddo
     calka=calka*(r2-r1)
! end of integration 2    
    write(*,*)calka

! vector integration  and analytical result  
    write(*,*)sum(integrand*w*(r2-r1)),-(0.5**3)/3.0

!**************************************************************



! tot_calka - the sum of integrals all integration ranges    
! dividion the initial length of the integration intervals    
!  tot_old - we will compare the results fro two consecutive divisions.
! at the beginning we assume any big number
!  blad - the difference between two consecutive integrations,
! at the beginning we assume any big number
! error - assumed precission, parameter, it is necassary for
! performing do-while loop 
    total_calka=0.0
    division=0.5
    tot_old=10000.0
    blad=10000.0
    do while (blad>error)
! intrange - the upper integration limit, it should be estimated
!  analysing the plot of the Mayer function. Here - 7.
! irange = the number of subintegrals we have to calculate
    irange=int(intrange/division)
    total_calka=-(0.5**3)/3.0
!   the analytical result for the integration range [0,0.5]

! the loop over all the intervals, for each of them we calculate 
! lower and upper limits, r1 and r2
    do j=1,irange
    r1=0.5+(j-1)*division
    r2=r1+division
    calka=0.0
! the integral for a given interval   
    do i=1,ngauss
      integrand(i)=inte(x(i),beta,r2,r1)
     calka=calka+integrand(i)*w(i) 
    enddo
    total_calka=total_calka+calka*(r2-r1)
    enddo
! aux. output: number of subintervals, old and new integrals
        write(*,*) irange,division,tot_old,total_calka
    division=division/2.0
    blad=abs(tot_old-total_calka)
    tot_old=total_calka
! and the final error
       write(*,*) blad
    enddo

   open(1,file='calka.dat', access='append')
! the secod viarial coefficient=CONSTANT*total_calka, 
! CONSTANT is omitted here
   write(1,*)tempred,total_calka
   close(1)
end program wykres
我还对这个实函数进行了外部处理,它为模块中的每个变量提供了一个错误。例如,看起来是这样的

undefined reference to `__zmienne_MOD_total_calka'
Inte是一个实定义变量,这对我计算这个积分是必要的

integrand(i)=inte(x(i),beta,r2,r1)
为什么它在另一个文件中时不工作,而它在另一个文件中时工作。真奇怪

这是原始代码:

program wykres
 implicit none

 real(10) :: r, u, r6, tempred, f, r2, r1, calka,beta
! beta - an auxiliary variable
 real(10) :: inte
! inte - the function defined below
 real :: start, finish
 integer:: i
 integer, parameter :: Ngauss = 8
 real(10),dimension(ngauss),parameter::xx=(/-0.9602898565d0,&
 -0.7966664774d0,-0.5255324099d0,-0.1834346425d0,&
 0.1834346425d0,0.5255324099d0,0.7966664774d0,0.9602898565d0/)
 real(10),Dimension(ngauss),parameter::ww=(/0.1012285363d0,&
 0.2223810345d0,0.3137066459d0,0.3626837834d0,&
 0.3626837834d0,0.3137066459d0,0.2223810345d0,0.1012285363d0/)
 real(10),dimension(ngauss)::x,w,integrand
 integer, parameter :: out_unit=1000
 integer, parameter :: out_unit1=1001
 integer, parameter :: out_unit2=1002, out_unit3=1003
 real(10), parameter :: error=0.000001
 real(10):: total_calka, division,tot_old,blad
 real(10),parameter:: intrange=7.0
 integer::j,irange

 open(unit=out_unit, file='wykresik.dat', action='write', status='replace')
 open(unit=out_unit1, file='wykresik1.dat', action='write')
 open(unit=out_unit2, file='wykresik2.dat', action='write')
 open(out_unit3, file='wykresik3.dat', action='write')

! the gaussian points (xx) and weights (ww) are for the [-1,1] interval
! for [0,1] interval we have (vector instr.)
     x=0.5d0*(xx+1.0d0)
     w=0.5d0*ww

! plots 
   tempred = 1.0
   call cpu_time(start)
 do i=1,1000
    r=float(i)*0.01
    r6=(1.0/r)**6
    u=4.0d0*r6*(r6-1.0)
    f=exp(-u/tempred)-1.0
    write(out_unit,*) r, u
    write(out_unit1,*)r, f
    write(out_unit2,*)r, r*r*f
end do
   call cpu_time(finish)
 print '("Time = ",f6.3," seconds.")',finish-start
! end of plots

! integration  1
 calka=0.0
 r1=0.0
 r2=0.5
! auxiliary variable
 beta=4.d0/tempred
    do i=1,ngauss
    r=(r2-r1)*x(i)+r1
    r6=(1.0/r)**6
    u=beta*r6*(r6-1.0d0)
! check for underflows
    if (u>100.d0) then 
    f=-1.0d0 
    else
    f=exp(-u)-1.d0 
    endif
! the array integrand is introduced in order to perform vector calculations below
    integrand(i)=r*r*f
    calka=calka+integrand(i)*w(i)
    enddo
    calka=calka*(r2-r1)
    write(*,*)calka
! end of integration    

! integration 2
  calka=0.0    
     do i=1,ngauss
     integrand(i)=inte(x(i),beta,r2,r1)
     calka=calka+integrand(i)*w(i)
     enddo
     calka=calka*(r2-r1)
! end of integration 2    
    write(*,*)calka

! vector integration  and analytical result  
    write(*,*)sum(integrand*w*(r2-r1)),-(0.5**3)/3.0

!**************************************************************



! tot_calka - the sum of integrals all integration ranges    
! dividion the initial length of the integration intervals    
!  tot_old - we will compare the results fro two consecutive divisions.
! at the beginning we assume any big number
!  blad - the difference between two consecutive integrations,
! at the beginning we assume any big number
! error - assumed precission, parameter, it is necassary for
! performing do-while loop 
    total_calka=0.0
    division=0.5
    tot_old=10000.0
    blad=10000.0
    do while (blad>error)
! intrange - the upper integration limit, it should be estimated
!  analysing the plot of the Mayer function. Here - 7.
! irange = the number of subintegrals we have to calculate
    irange=int(intrange/division)
    total_calka=-(0.5**3)/3.0
!   the analytical result for the integration range [0,0.5]

! the loop over all the intervals, for each of them we calculate 
! lower and upper limits, r1 and r2
    do j=1,irange
    r1=0.5+(j-1)*division
    r2=r1+division
    calka=0.0
! the integral for a given interval   
    do i=1,ngauss
      integrand(i)=inte(x(i),beta,r2,r1)
     calka=calka+integrand(i)*w(i) 
    enddo
    total_calka=total_calka+calka*(r2-r1)
    enddo
! aux. output: number of subintervals, old and new integrals
        write(*,*) irange,division,tot_old,total_calka
    division=division/2.0
    blad=abs(tot_old-total_calka)
    tot_old=total_calka
! and the final error
       write(*,*) blad
    enddo

   open(1,file='calka.dat', access='append')
! the secod viarial coefficient=CONSTANT*total_calka, 
! CONSTANT is omitted here
   write(1,*)tempred,total_calka
   close(1)
end program wykres
耶稣基督,在结束程序下面有一个代码。。。线程现在可能已关闭。谢谢大家

real(kind=10) function inte(y,beta,r2,r1)
     implicit none

     real(kind=10)::r,beta,r6,r2,r1,u,y

     r=(r2-r1)*y+r1
     r6=(1.0/r)**6
     u=beta*r6*(r6-1.0d0)
         if (u>100.d0) then 
    inte=-1.0d0 
    else
    inte=exp(-u)-1.d0 
    endif
    inte=r*r*inte
    end
它不仅仅是一个类型为10的实标量变量,不管这种类型对编译器意味着什么。(对于gfortran类10,它是x87扩展精度,对于许多其他编译器,它是无效的。)

当你这样做的时候

integrand(i)=inte(x(i),beta,r2,r1)
索引标量是没有意义的

如果
inte
是一个返回类型为10的实数的外部函数,则应将其声明为

real(10), external :: inte

或者最好为它编写一个完整的接口块。

inte
是一个标量,不能接受任何参数或数组索引。这条冒犯的线到底应该做什么?@RaulLaasner,
inte
是一个10
real
s的数组。它是在第3行的
zmienne
模块中定义的。我对使用OP提供的
zmienne
模块的这一行代码没有任何问题。因此,我要求calka11.f95提供更多的上下文和源代码。只需注意:请尽量避免扩展*.f95、*.f03等表示您使用的Fortran标准。无论语言版本如何,最好对所有自由格式源代码使用*.f90。@Wildcat
real(10)::inte
不是大小为10的数组,而是类型为10的实标量,但为什么它在单个源文件中工作,而在OP将代码分解为模块时不工作?因为在单个文件中,当调用在范围内时,它被正确地解释为外部函数。
real(10), external :: inte