×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

What can go wrong with deallocate?

What can go wrong with deallocate?

What can go wrong with deallocate?

(OP)
I have rewritten legacy code to use allocatable arrays
I am defining these in the Subroutine that calls the ode solver
DOUBLE PRECISION, dimension(:), ALLOCATABLE :: ATOL ,RTOL
DOUBLE PRECISION, dimension(:), ALLOCATABLE :: WORK
integer, DIMENSION(:), allocatable :: IWORK
allocate (RTOL(NEQ ), stat=iaLLOCATEstatus)
if (IALLOCATEstatUS /= 0) then
write(6,*)'ERROR trying to allocate rtol in solve0U0'
stop 1
end if
allocate (ATOL(NEQ ), stat=iaLLOCATEstatus)
if (IALLOCATEstatUS /= 0) then
write(6,*)'ERROR trying to allocate atol in solve0U0'
stop 1
end if




allocate (WORK(NRWRKRAD), stat=iaLLOCATEstatus)
if (IALLOCATEstatUS /= 0) then
write(6,*)'ERROR trying to allocate WORK in solveOU0'
stop 1
end if
allocate (IWORK(NIWRKRAD), stat=iaLLOCATEstatus)
if (IALLOCATEstatUS /= 0) then
write(6,*)'ERROR trying to allocate IWORK in solve0U0'
stop 1
end if
.......
22 CALL RADAU5( NEQ,FCN,T,Y,TOUT,H,
& RTOL,ATOL,ITOL,
& DJAC,
& IJAC,MLJAC,MUJAC, DUMMAS,
z IMAS,MLMAS,MUMAS,
c ok thus far
& SOLOUT,0,
z LDATIMES,NSUP,URESUR,URESUI,
& WORK,NRWRKRAD,
z IWORK,NIWRKRAD,RPAR,IPAR, IDID)
c radau5 has rtol, atol and work, iwork, dimensioned to their allocated dimensions
....................
deallocate (IWORK , stat=IALLOCATEstatus)
deallocate ( WORK , stat=IALLOCATEstatus)
deallocate (ATOL, stat=IALLOCATEstatus)
if(allocated(rtol)) deallocate (RTOL, stat=IALLOCATEstatus) !!! this is line 31134

I get an error (whether or not I check for allocated(rtol))

free(): invalid pointer

Program received signal SIGABRT: Process abort signal.

Backtrace for this error:
#0 0x7f99d22cad01 in ???
#1 0x7f99d22c9ed5 in ???
#2 0x7f99d1f9420f in ???
#3 0x7f99d1f9418b in ???
#4 0x7f99d1f73858 in ???
#5 0x7f99d1fde3ed in ???
#6 0x7f99d1fe647b in ???
#7 0x7f99d1fe7cab in ???
#8 0x55a74f9ee098 in stiffr_
at /home/me/DEVELOPMENT/HLINEARRADAUtst/ft185.f:31134

gdb complains about a missing raise.c file

free(): invalid pointer

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) l
45 in ../sysdeps/unix/sysv/linux/raise.c

Any ideas???

RE: What can go wrong with deallocate?

Could you try allocating and deallocating in the same routine? That way you won't have to check if something has been allocated.

RE: What can go wrong with deallocate?

(OP)
It is being done in the same routine. Between allocating and deallocating I'm only calling
a routine with the allocated arrays and their dimensions as arguments. This routine does not change the array dimensions, so I am really puzzled.

RE: What can go wrong with deallocate?

Is this on the first or second time the code is invoked? Are the allocatable arrays passed in or are they local to the routine? I can see this happening, the second time it is invoked if the allocatable arrays are passed in.

RE: What can go wrong with deallocate?

(OP)
This is the first time the code is invoked, but the S/R to which the allocated arrays are passed as arguments along with their dimensions is called multiple times(330 times). Interestingly enough it's on the last time the crash occurs...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close