Fortran routine returns an error that I cannot interpret
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Fortran routine returns an error that I cannot interpret
Hello Everyone!
This was the first time I had to program in Fortran (77). I need to implement an Unequal Error Protection piece where a double integral is present. I am using a provided DBLIN (IMSL library) routine for the integral itself and pass all the necessary arguments into it (like the function of two variables, the integration limits and etc.).
Most probably, there is a problem in my program, but I cannot find any idea on how to resolve it...
The error I get is:
Code:
*** TERMINAL ERROR (IER = 133) FROM IMSL ROUTINE DBLIN
*** TERMINAL ERROR (IER = 133) FROM IMSL ROUTINE DBLIN
The DBLIN function description says that this error indicates:
Quote:
C IER = 133 INDICATES THAT AERR.LE.0.0
What could exactly be causing it?
The code of my program is:
Code:
PROGRAM MAIN
implicit DOUBLE PRECISION (a-h,o-z)
common sig,d1,r1,Ms
open(13,file='C.dat')
c INTEGER IRULE, NOUT
c REAL A, B, ERRABS, ERREST, ERRREL, F, G, H, RESULT
do 10 isnrdb=1,15
c d0 = 0.8944D0
c r0 = 0.4472D0
d1 = 0.4472D0
r1 = 0.8944D0
A = -7.0
B = 7.0
ERRABS = 0.0
ERRREL = 0.01
IRULE = 6
mm = 4D0
Ms = 2D0**mm
pm = 1D0
snr = 10.D0**(DBLE(isnrdb)/10.D0)
sig = (pm/snr)/2.D0
c write(*,*) 'The value of temp is: ',temp(2.D0,3.D0,0.D0,0.D0)
write(*,*) 'The finsum:',finsum(2.D0,3.D0)
MM = dblin(finsum,A,B,G,H,ERRABS,ERROR,IER)
write(*,*) 'AA:',dblin(finsum,A,B,G,H,ERRABS,ERROR,IER)
c write(13,*) isnrdb, sngl(C)
10 continue
END
c ----------------------------------------------
c This function performs the final summation
c before the integration of the two sums.
c Param: aa-bb,cc-dd are the two intervals for
c the performance of the summatioon function.
function finsum(rre,rim)
implicit double precision (a-h,o-z)
common sig,d1,r1,Ms
aa=0.D0
bb=0.D0
cc=6.D0
dd=6.D0
finsum = 0.D0
finsum = finsum+temp(rre,rim,aa,bb)
finsum = finsum+temp(rre,rim,cc,dd)
return
end
c This function performs an intermediate step in
c the capacity calculation process.
c Param: aa-bb,cc-dd are the two intervals for
c the performance of the summatioon function.
function temp(rre,rim,aa,bb)
implicit double precision (a-h,o-z)
common sig,d1,r1,Ms
temp = 0.D0
bot = psum(rre,rim,aa,bb)+psum(rre,rim,cc,dd)
c write(*,*) 'The value of BOT is: ', bot
do 180 i=aa,bb
sir=DBLE(-r1+(i/5)*d1)
sii=DBLE(-r1+MOD(i,5)*d1)
int1111 = qpdf(rre,rim,sir,sii)/bot
int111 = dlog(DBLE(int1111))/dlog(2.D0)
int111 = int111+dlog(DBLE(Ms/8))/dlog(2.D0)
c int11 = int111*qpdf(rre,rim,sir,sii)
c write(*,*) 'The valueis: ', int111*qpdf(rre,rim,sir,sii)
temp = temp+int111*qpdf(rre,rim,sir,sii)
180 continue
c do 190 i=cc,dd
c sir=DBLE(-r1+(i/5)*d1)
c sii=DBLE(-r1+MOD(i,5)*d1)
c
c int1111 = qpdf(rre,rim,sir,sii)/bot
c int111 = dlog(DBLE(int1111))/dlog(2.D0)
c int111 = int111+dlog(DBLE(Ms/8))/dlog(2.D0)
c int11 = int111*qpdf(rre,rim,sir,sii)
c temp = temp + int11
c 190 continue
c temp = temp/1.D0
c write(*,*) 'inter1:', temp/1.D0
return
end
c This function performs a summation of probability
c density function from a to b, with individual
c spacing for each of the constellation points.
c Param: [a;b] is the summation interval.
c Internally only the qpdf is used.
c
c DBLE converts value to a double precision real.
c Functionality compared to MATLAB
function psum(rre,rim,a,b)
implicit double precision (a-h,o-z)
common sig,d1,r1,Ms
psum = 0.D0
do 200 i=a,b
sir=DBLE(-r1+(i/5)*d1)
sii=DBLE(-r1+MOD(i,5)*d1)
c write(*,*) 'The value of arg is: ',arg
c write(*,*) 'The value of sir is: ', sir
psum = psum + qpdf(rre,rim,sir,sii)
200 continue
psum = psum
return
end
c This function defines a 2-dimensional pdf for further
c mapping of the QAM constellation points.
c Functionality compared to MATLAB
function qpdf(r_r, r_i, si_r, si_i)
implicit double precision (a-h,o-z)
common sig,d1,r1,Ms
PI=3.141592654D0
t=(1.D0/(2.D0*PI*sig)) * dexp(-(r_i-si_i)**2/(2.D0*sig))
qpdf = t * dexp(-(r_r-si_r)**2/(2.D0*sig))
return
end
c The following two functions define the inner limits
REAL FUNCTION G (X)
REAL X
G = -7.0
RETURN
END
REAL FUNCTION H (X)
REAL X
H = 7.0
RETURN
END
The routine for double integral I use is available at this location.
You are passing in a desired absolute error of 0 (your parameter ERRABS) to dblin. This would mean it would have to do a numerical integration over an infinite number of points. So dblin returns an error instead.
--
"I'm livin' in the 70's
I feel like I lost my keys
Got the right day but I got the wrong week
And I get paid for just bein' a freak"
Last edited by neonsignal; 09-01-2009 at 01:20 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.