PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Checking on data type matching in a subroutine call?

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



Joined: 07 Oct 2004
Posts: 2

PostPosted: Sun Oct 17, 2004 1:31 am    Post subject: Checking on data type matching in a subroutine call? Reply with quote

I compiled the following code using pgf90 5.2-4.
No warning message was given, while a complaint on
the mismatch of the data type was expected.
Should this kind of checking be done at compile time?

YY

! snip here
program testing

call sub1()

end program testing

subroutine sub1()
!character dummy

call sub2(dummy)

print *, dummy

end subroutine sub1

subroutine sub2(dummy)
character dummy

dummy='?'

end subroutine sub2
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Oct 18, 2004 10:31 am    Post subject: Valid Code Reply with quote

Hi YY,


Actually, this is valid Fortran 77 code since F77 does not type check subroutine calls. In Fortran 90 you can add an interface which will check for this type of error. Without the interface, however, F90 will revert to the F77 convention.

Code:
     program testing

      call sub1()

      end program testing

      subroutine sub1()
!     character dummy

      interface
         subroutine sub2(dummy)
            character, intent(in) :: dummy
         end subroutine
      end interface
      call sub2(dummy)

      print *, dummy
      write(*,'A') dummy

      end subroutine sub1

      subroutine sub2(dummy)
      character dummy

      dummy='?'

      end subroutine sub2


Code:
/tmp% pgf90 x.f
PGF90-S-0188-Argument number 1 to sub2: type mismatch (x.f: 15)
  0 inform,   0 warnings,   1 severes, 0 fatal for sub1


- Mat
Back to top
View user's profile
yysun



Joined: 07 Oct 2004
Posts: 2

PostPosted: Mon Oct 18, 2004 6:27 pm    Post subject: Reply with quote

This makes sense.
Thanks a lot! Mat

WRITE(*,'A') works with pgf90. Interesting... :)
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