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 

System exception 0x40010008: FormatMessage failed
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
narayanamoorthy_k



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

PostPosted: Thu Feb 08, 2018 1:12 pm    Post subject: Re: Reply with quote

JohnCampbell wrote:
Generic routines provide a single call, BUT you still need to write separate routines for all possible type/rank combinations.
It is just a verbose way of doing argument checking, which /CHECK can also do.
Not a fan of long winded verbose structures in F03/08. Just more opportunities to miss-type and provide coding errors.

John


Hi John
In pursuing our earlier discussion, I have done the parts of my program, which is working perfectly. My Special thanks to you too in helping that out.

However, it has a closing error, as I mentioned in other post.

http://forums.silverfrost.com/viewtopic.php?t=3707&start=0&postdays=0&postorder=asc&highlight=

It says, DEALLOCATING the dangling FORTRAN pointers. The respective array is in allocated state, but unable to deallocate it.

I oblige your views in this regard. Please advise.

Thanks in advance
_________________
Thanks and Regards
Moorthy
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2551
Location: Sydney

PostPosted: Thu Feb 08, 2018 1:19 pm    Post subject: Reply with quote

You could try:
If ( allocated(xx) ) then
deallocate ( xx, stat=stat )
if ( stat /= 0 ) write (*,*) 'unexpected error in deallocate XX, stat=',stat
end if

or try:
deallocate ( xx, stat=stat ) ! try to deallocate and ignore error if occurs

I have no idea what a dangling pointer is. Could be you have already deallocated the target array the pointer is pointing to.

Should you be using ASSOCIATED test or NULLIFY the pointer ?
I expect you should only deallocate pointers that have been allocated.

I wouldn't write this type of code.
Back to top
View user's profile Send private message
narayanamoorthy_k



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

PostPosted: Thu Feb 08, 2018 1:34 pm    Post subject: Reply with quote

Yes I remember, you mentioned this earlier.

When I use this code, it shows the other error as stated in this thread-heading.

Perhaps, i can try the NULLIFY..

But here the BS array is a ALLOCATABLE Array, which is valid at the time of executing this "DEALLOCATE" command. I also noticed that the previous "DEALLOCATE" command was executed for the "unassigned" arrays with no error. but here the BS is in ASSIGNED state, but showing up this error.
_________________
Thanks and Regards
Moorthy
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1884

PostPosted: Thu Feb 08, 2018 1:59 pm    Post subject: Reply with quote

If at all possible, avoid using Fortran variables with the POINTER attribute in your programs. Use allocatable types instead.

Here is a program to illustrate how a pointer may get demoted to a dangling pointer.

Code:
program dangling_pointer
   implicit none
   integer, pointer, dimension(:) :: iptr => NULL()
   allocate(iptr(3))
   iptr = (/ 123, 321, 222/)
   call sub(iptr)
   print *,iptr

contains
   subroutine sub(ipt)   
      implicit none
      integer, pointer, dimension(:) :: ipt
      ipt(2) = (ipt(1)+ipt(3))/2
      if(ipt(2) < 300)deallocate(ipt)
      return
   end subroutine sub
end program dangling_pointer
Back to top
View user's profile Send private message
narayanamoorthy_k



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

PostPosted: Fri Feb 09, 2018 5:51 am    Post subject: Reply with quote

Thank mecej4,

I also observe and agree with you. Many of our expert group here, are with the same views on Pointers.
Having arrived at a logic to resolve the challenging problem, while we face such a mistakes due to compiler, it is really painful. However, these pointer concepts are good in C++ and other object oriented programming. But there, I recall, the object references are taken at the address levels separately, but not as an alias to reference, as we do here. If that is the case, I think our FTN95 will not face such issues further. I am sure, this POINTER has to improve further still in our FTN95.
_________________
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 -> Support All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
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