Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

LOC function on TYPE structures

drb
Beginner
546 Views
Hello,
We have recently upgraded our linux compilers to intel. I am currently attempting to compile our code, but I am running into runtime problems using the LOC intrinsic function. What I am experiencing is as follows:
the code is something like:
TYPE(BTYPE), POINTER :: MYPOINT
ALLOCATE(MYPOINT)
CALL MEMALLOC(MYPOINT) ! OUR MEM ALLOC ROUTINES
IP = LOC(MYPOINT%I)
The first time this occurs, the LOC stored in IP is a reasonable value. The pointer MYPOINT is purely local, so when I come back into this routine, I should be able to allocate another structure of type BTYPE. This, however, gives me Locations in IP which encompass those from the previous call so the program goes horribly wrong!
I have tried using the latest update, but found that GETARG doesnt work anymore, but the problem still exists. I tried this because the release text mentioned something about LOC not operating correctly. Is it possible to see the full text of problems fixed by the current version?
Thanks and sorry to have been longwinded !
Ben
Edit: I should add: using RedHat 7.3, kernel 2.4.18 using the latest intel fortran 8.0 .

Message Edited by drb on 04-26-2004 09:27 AM

0 Kudos
3 Replies
Steven_L_Intel1
Employee
546 Views
There's not enough information here to understand what the problem is, and I am not sure what you expect. Do you deallocate MYPOINT before leaving the routine? Is MYPOINT declared as SAVE? From what you've said here, I would expect the program to leak memory unless you deallocated MYPOINT.
You'll have to provide more details, such as perhaps a small but complete example, for people to look at.
What do you mean by "GETARG doesn't work anymore"?
0 Kudos
drb
Beginner
546 Views

Sorry to have been vague. I will try to create a small example of what I am doing and see if that has the same characteristics. I'll post this later.

I have posted a support issue for the GETARG, which I am dealing with via that route. It seems that with my compiler arguments and the new ifort compiler, GETARG doesnt work on my program anymore, ie I cannot get any arguments from the command line, including the program name.

Ben

0 Kudos
drb
Beginner
546 Views

I have now written a short program. As ever with small programs, this works! So at least that has shown me that the bug must be somewhere else in my code. I think the memory table is getting trashed, since I allocate one array, and get the LOC of it (from which I can work out the end LOC). Then, I allocate another (larger) array in the same subroutine. This LOC is marginally less than the first, and therefore is using the same memory locations as the first array!

I will test when I get the time, if this occurs on windows with the intel compiler also.

Thanks

Ben

Message Edited by drb on 04-27-2004 05:12 AM

0 Kudos
Reply