PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

present() intrinsic does not function properly

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Windscion



Joined: 27 Jul 2004
Posts: 1

PostPosted: Tue Dec 14, 2004 8:33 am    Post subject: present() intrinsic does not function properly Reply with quote

%begin code snippet
subroutine inter3z(fig)
...
logical, optional, intent(in) :: fig
...
if(present(fig)) then
...
%end code snippet

This code takes the branch for present(fig) = .true. even when no arguments were supplied!

I have verified this using pfg90 v5.2-4 with flags
-g -Mbounds -Mdclchk -Mchkfpstk
on RHEL3.0, Intel Pentium 4/Xeon.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5952
Location: The Portland Group Inc.

PostPosted: Tue Dec 14, 2004 1:53 pm    Post subject: Reply with quote

Hello,


The problem is that the optional argument is getting assigned a value. To fix, you need to add an interface so that the caller recognizes that fig is optional.

Example:
Code:

      program present_tester

! Comment out the interface to recreate the problem
      interface
         subroutine present_test(fig)
            character, optional, intent(in) :: fig
         end subroutine present_test
      end interface

      call present_test()
      call present_test('a')

      end program present_tester

      subroutine present_test(fig)
      character, optional, intent(in) :: fig
     
      if (present(fig)) then
         write(*,*) 'Is Present ', fig
      else
         write(*,*) 'Not Present'
      end if
      end subroutine present_test


Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
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 © phpBB Group