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

can i write the allocatable array like this?

Wang_J_
Beginner
902 Views

type fracShp
      real*8,allocatable::s(:) 
end type

type(fracShp),allocatable:: abc(:)

allocate(abc(5))

allocate(abc%s(5))

Is the above codes right? The array 'abc' is allocatable, and the array 's' in 'abc' is also allocatable.  Can the compiler get the right address of all the two arrays?

0 Kudos
9 Replies
IanH
Honored Contributor III
902 Views

You need to allocate the array component in each element of abc separately.

[fortran]allocate(abc(5))

allocate(abc(1)%s(5))

allocate(abc(2)%s(22))

...

allocate(abc(5)%s(66))[/fortran]

0 Kudos
Wang_J_
Beginner
902 Views

if I allocate it as you did, is everything  legal?   I am afraid that the system can not find the right address of the inner allocatable variable 's'.

IanH wrote:

You need to allocate the array component in each element of abc separately.

allocate(abc(5)) allocate(abc(1)%s(5)) allocate(abc(2)%s(22)) ... allocate(abc(5)%s(66))

0 Kudos
Anonymous66
Valued Contributor I
902 Views

If you allocate as Ian describes, it is legal. When you say your "system can not find the right address," what happens? It would be helpful to see the exact text of the error message.

0 Kudos
Wang_J_
Beginner
902 Views

Annalee (Intel) wrote:

If you allocate as Ian describes, it is legal. When you say your "system can not find the right address," what happens? It would be helpful to see the exact text of the error message.

In my program there are some access violation without error message. It just displayed in the assemble language. So i can not find where it happened.  i doubt if there are some address confusion.  Moreover,  the memory occupied by my program became more and more large. I have checked the allocatable variables and  pointers, and deallocated them. But the problem was still not be solved. The program is too long to paste out. So is there any advice to solve this problem?

0 Kudos
Anonymous66
Valued Contributor I
902 Views

I would suggest using the /traceback option. This will show you where the access violation occurs in your program.

0 Kudos
Wang_J_
Beginner
902 Views

Annalee (Intel) wrote:

I would suggest using the /traceback option. This will show you where the access violation occurs in your program.

where is the /traceback option? Is it still work in the 'Release'  mode or just work in the 'Debug' mode?

thank you!

0 Kudos
Anonymous66
Valued Contributor I
902 Views

Traceback is under   Properties > Fortran > Run-time > Generate Traceback Information. This works in both release and debug mode.

 

 

0 Kudos
Wang_J_
Beginner
902 Views

Annalee (Intel) wrote:

Traceback is under   Properties > Fortran > Run-time > Generate Traceback Information. This works in both release and debug mode.

 

 

OK, Thank you!  But if i still can not solve the problem, can you help me to solve it?  If you can give some help, please give me an individual email address. i could sent the program to you. Thank you very much for your advice.

0 Kudos
Anonymous66
Valued Contributor I
902 Views

Hi Wang,

If you can not share your program on this forum, the best option is to submit an issue through Premier Support.

 

0 Kudos
Reply