forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Allocatable Vs Pointer

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
narayanamoorthy_k



Joined: 19 Jun 2014
Posts: 142
Location: Chennai, IN

PostPosted: Tue Aug 05, 2014 8:12 am    Post subject: Allocatable Vs Pointer Reply with quote

Hello
Whether "Allocatable" and "Pointer" can be mutually used. I understand Pointer denotes to the memory address only, but Allocatable allocates the physical memory to contain the values. WIth pointer definition, where the contents (user_defined values) goes.

I also noticed that there no difference between these two under the following situation. In

Code:

Module M1

contains
subroutine passtoSub(s)
real, pointer :: s(:)

s(1) = 10.0
!assign values here
end subroutine passtoSub

end module

program main
use M1
real , allocatable,save :: myarray(:)

allocate myarray(10)

call passtoSub(myarray)

print*, (myarray(I),I=1,ubound(myarray,1))

end program main


This works fine, but how the datas of myarray in Main and Subroutine handled as this code serves the purpose. Just want to understand more on this.
_________________
Thanks and Regards
Moorthy
Back to top
View user's profile Send private message
narayanamoorthy_k



Joined: 19 Jun 2014
Posts: 142
Location: Chennai, IN

PostPosted: Tue Aug 05, 2014 10:04 am    Post subject: Reply with quote

In addition, are they use the same memory locations and addresses in both cases? Like Main allocates a different memory while pass it on to Subroutine, Subroutine pointer takes a different memory but the lifespan of the pointer only at Subroutine level, once control comes back to Main, it released?

Appreciate for clarifications..

Thank you
_________________
Thanks and Regards
Moorthy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group