gcc - Ambiguous reference to variable -
so doing 2 modules linking main program. first 1 has variables defined in , second 1 functions.
module1:
module zmienne implicit none integer, parameter :: ngauss = 8 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 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) :: r, u, r6, tempred, f, r2, r1, calka,beta real(10) :: inte real :: start, finish integer:: i,j,irange real(10),dimension(ngauss)::x,w,integrand end module zmienne
module2
module in implicit none contains real(10) function inte(y,beta,r2,r1) 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) inte=-1.0d0 else inte=exp(-u)-1.d0 endif inte=r*r*inte end function end module in
and while im calling them that:
use zmienne; use in
i getting following error:
name 'inte' @ (1) ambiguous reference 'inte' module 'zmienne'
i've deleted "inte" in module1 getting following error:
irange=inte(intrange/division) 1 error: missing actual argument argument 'beta' @ (1)
the main program code is:
program wykres use zmienne; use in 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') ! gaussian points (xx) , weights (ww) [-1,1] interval ! [0,1] interval have (vector instr.) x=0.5d0*(xx+1.0d0) w=0.5d0*ww ! plots tempred = 1.0 call cpu_time(start) 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 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 i=1,ngauss r=(r2-r1)*x(i)+r1 r6=(1.0/r)**6 u=beta*r6*(r6-1.0d0) ! check underflows if (u>100.d0) f=-1.0d0 else f=exp(-u)-1.d0 endif ! array integrand introduced in order 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 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 , analytical result write(*,*)sum(integrand*w*(r2-r1)),-(0.5**3)/3.0 !************************************************************** ! tot_calka - sum of integrals integration ranges ! dividion initial length of integration intervals ! tot_old - compare results fro 2 consecutive divisions. ! @ beginning assume big number ! blad - difference between 2 consecutive integrations, ! @ beginning assume big number ! error - assumed precission, parameter, necassary ! performing do-while loop total_calka=0.0 division=0.5 tot_old=10000.0 blad=10000.0 while (blad>error) ! intrange - upper integration limit, should estimated ! analysing plot of mayer function. here - 7. ! irange = number of subintegrals have calculate irange=inte(intrange/division) total_calka=-(0.5**3)/3.0 ! analytical result integration range [0,0.5] ! loop on intervals, each of them calculate ! lower , upper limits, r1 , r2 j=1,irange r1=0.5+(j-1)*division r2=r1+division calka=0.0 ! integral given interval 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 , new integrals write(*,*) irange,division,tot_old,total_calka division=division/2.0 blad=abs(tot_old-total_calka) tot_old=total_calka ! , final error write(*,*) blad enddo open(1,file='calka.dat', access='append') ! secod viarial coefficient=constant*total_calka, ! constant omitted here write(1,*)tempred,total_calka close(1) end program wykres
the inte
declared in both modules.
upd. inte(y,beta,r2,r1)
function defined in module in
, , used in main program. function requires 4 arguments, call
irange=inte(intrange/division)
provides 1 argument. i'm not sure if function should used in case. try use long meaningful names variables , functions avoid similar issues.
Comments
Post a Comment