Errors during executing the program (Compaq Visual Fortran)

  • Comp Sci
  • Thread starter js6201
  • Start date
  • #1
7
0

Homework Statement


First of all, I used the Window xp & Compaq Visual Fortran 6.6 installed in VMware workstation.
In my case, there are no compile and link errors in source code, and excuting that program is also done.
But I want to generate 300 random numbers by using my program (Log-normally distributed).
In the case of j=1,2,3,...,117, there is no errors. but,
the case of j is larger than 117, the error is occured (no error messages in window console, but
no calculation.................The calculation step is not progressed...).
The source code is attached below.........

<Input Data>
3.93e-5,235421, 65889643, 15484354, 1235487, 4758, 85697, 2.9624, -14.5322

2. Homework Equations


Algorithms 712: Generate a normally distributed pseudo-random number.
The algorithm uses the ratio of uniforms method of A.J. Kinderman and J.F. Monahan augmented with quadratic bonding curves.

The Attempt at a Solution



In the first time, I see the message "image expended maximum...." So, I added the ignore terms in setting menu, (/ignore:4084).
Fortran:
Program Test

Implicit none

integer i, n0d, j

real xkbdot, m, lkbdot(310)

real seed1, seed2, a1, b11, c1, d1, sigma, mu

real X1, X2, S, T1, A, B, R1, R2, RANDN(310)

real u(310), v(310), q(310), kbdot(310)

real rand1(310), rand2(310), x(310), y(310)




open(unit=1, file="input", form="formatted", status="unknown")

read(1,*) xkbdot, SEED1, SEED2, A1, B11, C1, D1, sigma, mu




j=1




X1=MOD(A1*SEED1,B11)

X2=MOD(C1*SEED2,D1)

RAND1(j)=X1/B11

RAND2(j)=X2/D1

SEED1=X1

SEED2=X2




DO WHILE (j .le. 150)




X1=MOD(A1*SEED1,B11)

X2=MOD(C1*SEED2,D1)

RAND1(j)=X1/B11

RAND2(j)=X2/D1

SEED1=X1

SEED2=X2




C... Generate Log-normally Distributed Random Numbers..............C

S=0.449871

T1=-0.386595

A=0.19600

B=0.25472

R1=0.27597

R2=0.27846

C... Generate P=(u,v) uniform in rectangle enclosing acceptance region ..............C




  50 u(j)=RAND1(j)

v(j)=RAND2(j)

v(j)=1.7156*(v(j)-0.5)




C... Evaluate the quadratic form ..............C

X(j)=u(j)-S

Y(j)=ABS(v(j))-T1

Q(j)=X(j)**2+Y(j)*(A*Y(j)-B*Y(j))




C... Accept P if inside inner ellipse ..............C

IF (Q(j) .LT. R1) GO TO 100

C... Reject P if outside outer ellipse ..............C

IF (Q(j) .GT. R2) GO TO 50

C... Reject P if outside acceptance region ..............C

IF (v(j)**2 .GT. -4.0*LOG(u(j))*u(j)**2) GO TO 50

C... Return ratio of P's coordinate as the normal deviate ..............C

  100 RANDN(j)=v(j)/u(j)




C... Generate value of kbdot ..............C

LKBDOT(j)=RANDN(j)*sigma+mu




IF (LKBDOT(j) .gt. -2.30) then

KBDOT(j)=xkbdot

ELSE

KBDOT(j)=exp(LKBDOT(j))

END IF

write(*,*) j, KBDOT(j)




j=j+1

End do

End
 

Answers and Replies

  • #2
SteamKing
Staff Emeritus
Science Advisor
Homework Helper
12,796
1,668

Homework Statement


First of all, I used the Window xp & Compaq Visual Fortran 6.6 installed in VMware workstation.
In my case, there are no compile and link errors in source code, and excuting that program is also done.
But I want to generate 300 random numbers by using my program (Log-normally distributed).
In the case of j=1,2,3,...,117, there is no errors. but,
the case of j is larger than 117, the error is occured (no error messages in window console, but
no calculation.................The calculation step is not progressed...).
The source code is attached below.........

<Input Data>
3.93e-5,235421, 65889643, 15484354, 1235487, 4758, 85697, 2.9624, -14.5322

2. Homework Equations


Algorithms 712: Generate a normally distributed pseudo-random number.
The algorithm uses the ratio of uniforms method of A.J. Kinderman and J.F. Monahan augmented with quadratic bonding curves.

The Attempt at a Solution



In the first time, I see the message "image expended maximum...." So, I added the ignore terms in setting menu, (/ignore:4084).
You should be aware that reading in strings of digits as a REAL variable will only provide a certain number of floating point digits in the program's internal data storage.

For example, READing in "65889643" for SEED1 will probably result in the value of 65889600 being stored for use in further calculations. The REAL data type in Fortran will store about 6-7 of the most significant digits of an input. If you want to store more digits, the DOUBLE PRECISION data type must be used.

What effect the truncation of the input values of SEED1, SEED2, and A1 has on subsequent calculations is unknown, but since the program terminates without obvious error messages being issued, you should insert some WRITE statements into your code to display or print key values of the calculations for checking after the program terminates.
 
  • Like
Likes js6201
  • #3
7
0
You should be aware that reading in strings of digits as a REAL variable will only provide a certain number of floating point digits in the program's internal data storage.

For example, READing in "65889643" for SEED1 will probably result in the value of 65889600 being stored for use in further calculations. The REAL data type in Fortran will store about 6-7 of the most significant digits of an input. If you want to store more digits, the DOUBLE PRECISION data type must be used.

What effect the truncation of the input values of SEED1, SEED2, and A1 has on subsequent calculations is unknown, but since the program terminates without obvious error messages being issued, you should insert some WRITE statements into your code to display or print key values of the calculations for checking after the program terminates.
Dear StreamKing
I really appreciate your help for me! :) It is really helpful for me. But.. I change the variables from real to real*8(double precision) and get more results..
For example, before (real*4 or real) ---> only the calculation step is obtained to 117 and
after the revision , I have got the results the step to 530 but ........I want 6000th step becuase I perform the montecarlo simulation..
Why the calculation step is stopped and there are no messages....
In Console window, I check the error,
write(*,*) j, kbdot(j), but the error is not appeared...........
What can I do............
Thansk you so much in advance!
 
  • #4
BvU
Science Advisor
Homework Helper
2019 Award
13,601
3,288
Hi,

Use the debugger to see that after j = 117 you go into an infinite loop: Q(118) = 0.2798609 forever. > R2 hence goto 50 etcetera.
 
  • Like
Likes js6201
  • #5
7
0
Hi,

Use the debugger to see that after j = 117 you go into an infinite loop: Q(118) = 0.2798609 forever. > R2 hence goto 50 etcetera.
Oh my god !
It is really thank you T.T I am a starter of fortran........So It is really difficult to me...to find out the error............
I am very appreciate to BvU and StreamKing ! Have a good weekend!
 
  • #6
SteamKing
Staff Emeritus
Science Advisor
Homework Helper
12,796
1,668
Oh my god !
It is really thank you T.T I am a starter of fortran........So It is really difficult to me...to find out the error............
I am very appreciate to BvU and StreamKing ! Have a good weekend!
The handle is SteamKing, not StreamKing. You're welcome.
 

Related Threads on Errors during executing the program (Compaq Visual Fortran)

  • Last Post
Replies
5
Views
4K
Replies
3
Views
949
Replies
21
Views
2K
Replies
2
Views
2K
Replies
0
Views
1K
Replies
2
Views
910
Replies
5
Views
1K
Replies
5
Views
4K
Top