Re: Memory Leak Problem
- From: e p chandler <epc8@xxxxxxxx>
- Date: Thu, 19 Jun 2008 05:27:00 -0700 (PDT)
On Jun 18, 4:06 pm, babak...@xxxxxxxxx wrote:
Hey Guys,
Just to start off, this is my first time on this forum, so I aplogize
in advance.
Before I get into my problem, I'm not a programmer, I'm a stats
masters student and have to write some code to
carry out my research, hence the poor programming structure.
That being said, I have, what I believe to be a memory leak problem. I
think I have located the problem, but Im not sure how to fix it.
I have an iterative process that carries one for about a 1000 times.
And each iteration I generated about 700000 random numbers. I have
used the ALLOCATE() function before the iterative techniques, but when
I have tried using the DEALLOCATE() function I get a segmentation
fault. The variable that contains these random numbers is a pointer,
and I have named it "rout." The random numbers come from a subroutine
too. I have given a link to the code (which is not very long at all),
and if someone has any suggestions I am truly greatful, as this
problem has frustrated me for too long now!
http://www.uoguelph.ca/~bhabibza/epidemic.f ; <- main code
http://www.uoguelph.ca/~bhabibza/subrng.f ; <- subroutine to
produce random numbers
Thanks in advance,
Babak
1. Using .f seems odd for free-format source.
2. Variable P has default type of REAL. This causes a problem with my
compiler (g95) which does not allow REAL valued array indexes. Perhaps
P was meant to be declared INTEGER. Adding IMPLICIT NONE would have
helped here.
3. ALLOCATE(rout(n)) in the main program, where N has no defined
value, has already been mentioned.
4. Suggest INTEGER,PARAMETER for the "magic number" 21.
5. seed=aint(harvest*2.0e0**31) Why not the simpler 2**31?
6. Why the call to RNG in the main program when none of the 700,000
values generated are used?
7. Arrays vp_names and vp are unchanged as the program runs.
Initializing vp inside a loop does not make sense. Why not use DATA
instead?
8. Variables a & b are REAL but are really used as INTEGERS. Assigning
an INTEGER to a REAL variable is actually allowed.
9. Suggest SELECT CASE instead of IFs when dealing with individuals(i)
%status. (status = 0, 1 or 2 or ?)
10. When testing %status and %dummy_status near the end of the
program, all of the actions taken in the three cases are the same.
Suggest a compound conditional here
IF ( ( .AND. ) .OR. ( .AND. ) .OR
( .AND. ) ) ....
11. You are generating 700,000 random numbers at one time. How many do
you actually use?
12. [I don't understand POINTER in Fortran very well.] Is it standard
to use rout, which has a pointer attribute, as an argument and then
ALLOCATE it inside your subroutine? Why not a fixed size array? I see
no advantage in your program to making ROUT come and go.
- e
.
- Follow-Ups:
- Re: Memory Leak Problem
- From: Richard Maine
- Re: Memory Leak Problem
- From: glen herrmannsfeldt
- Re: Memory Leak Problem
- References:
- Memory Leak Problem
- From: babakh99
- Memory Leak Problem
- Prev by Date: PGI wierdness with .EQV.
- Next by Date: Re: a problem in subroutine
- Previous by thread: Re: Memory Leak Problem
- Next by thread: Re: Memory Leak Problem
- Index(es):
Relevant Pages
|
|