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

what's the different between the variables in structure and global

newinteler
Beginner
241 Views
the first program:
!start of program
program justtest
real*8,dimension(:,:,:),allocatable :: q,qq

allocate(q(251,31,51),qq(251,31,51))
q=1d0
qq=q
deallocate(q,qq)

end program justtest
!end of program


the second program:
!start of program
program justtest

type type_test
real*8,dimension(:,:,:),allocatable :: q,qq
end type type_test

type(type_test) m

allocate(m%q(251,31,51),m%qq(251,31,51))
m%q=1d0
m%qq=m%q
deallocate(m%q,m%qq)

end program justtest
!end of program


The first program can run under visual fortran 6.6 with normal settings and the second can't. The only difference between these two programs is the position of allocatable variables. So, i'm just wondering whether the allocatable variables in structure could be optimized or not? I hope i could receive help about this problem here.
0 Kudos
2 Replies
durisinm
Novice
241 Views
What do you mean when you say that the second program can't run? Does it compile without errors? Does it compile and link successfully but crash during execution? What error messages are you seeing?

Mike
0 Kudos
newinteler
Beginner
241 Views
Thanks for your reply!
While, the second program cant run means it crash during execution, the error messages is stack overflow. And I know exactly that this is caused by the lack of stack allocations. So I could solve this problem by increasing the reserve of stack allocations in visual fortran compiler. But this fact shows that there is a big difference between the allocatable global variables and the structure variables in visual fortran compiler. So Im afraid that the using of structure variables in visual fortran program would really reduce the efficiency. If true, I want to know how much the efficiency could be reduced.
0 Kudos
Reply