| View previous topic :: View next topic |
| Author |
Message |
yysun
Joined: 07 Oct 2004 Posts: 2
|
Posted: Sun Oct 17, 2004 1:31 am Post subject: 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 |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Mon Oct 18, 2004 10:31 am Post subject: Valid Code |
|
|
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 |
|
 |
yysun
Joined: 07 Oct 2004 Posts: 2
|
Posted: Mon Oct 18, 2004 6:27 pm Post subject: |
|
|
This makes sense.
Thanks a lot! Mat
WRITE(*,'A') works with pgf90. Interesting... :) |
|
| Back to top |
|
 |
|