Checking on data type matching in a subroutine call?

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

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.

     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



/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

This makes sense.
Thanks a lot! Mat

WRITE(*,‘A’) works with pgf90. Interesting… :)