- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Today I was surprised that gfortran diagnoses a simple error but neither ifort nor ifx do.
Consider the following code:
REAL a1,a2
CALL sub1(a1)
CALL sub1(a1,a2)
END
SUBROUTINE sub1(a)
REAL a
END
Here, the first call to sub1 employs 1 argument, the second employs 2. I was expecting the compiler to throw an error. GFORTRAN does:
3 | CALL sub1(a1,a2)
| 1
Error: More actual than formal arguments in procedure call at (1)
but ifort version 2021.12.0 and ifx version 2024.1.0 don't flag this. Tried the -stand and -check options but that doesn't change anything.
What am I overlooking?
Thanks, Kay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are assuming that the main program knows about the interface to sub1 but sub1 is external there is no interface provided either by having sub1 in a module or having an explicit interface given in the main program. a2 could in fact be defined as an optional argument in sub1. If you compile that with interface checking switched on (/warn:interfaces) you should get a warning/error
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are assuming that the main program knows about the interface to sub1 but sub1 is external there is no interface provided either by having sub1 in a module or having an explicit interface given in the main program. a2 could in fact be defined as an optional argument in sub1. If you compile that with interface checking switched on (/warn:interfaces) you should get a warning/error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You should have tried -warn.
D:\Projects>ifx -warn:interface t.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.1.0 Build 20240308
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
t.f90(5): error #6784: The number of actual arguments cannot be greater than the number of dummy arguments. [SUB1]
CALL sub1(a1,a2)
-----------^
compilation aborted for t.f90 (code 1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Andrew and Steve,
thanks for pointing this out! I thought -warn is the default but I was wrong. Will remember this!
Best wishes,
Kay

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page