- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We are planning to switch to Intel Fortran for Linux. Our product consists of more than 10,000 files, Fortran, C and C++. On each UNIX platform, we are using Fortran compiler options to avoid appending undersores to external names, subroutines, functions and common blocks, in order to have the same access to these names from C/C++ across platforms. Intel's compiler option -nus however only suppresses underscores in subroutine and function names while common block names are still having underscores. Is there a hidden option to suppress underscores in common block names ? Does anyone know if subsequent compiler releases will allow suppression of all underscores, or do I have to change hundreds of source files ?
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know of a command line option to do this. A colleague suggests:
"Consider the following example:
COMMON /MINE/ A,B,C
A = 3.0
END
If you compile this normally, ifc com.f90
you'll get a global symbol called mine_ that represents the COMMON block. As stated, compiling with -nus, does not change this. However, if we change the program and add:
COMMON /MINE/ A,B,C
!DIR$ATTRIBUTES C ::/MINE/
A = 3.0
END
then the global symbol emitted for the COMMON block is just mine.
This does involve changing source, but if the common block declaration is in an include file, as many people do, it's not too onerous. Otherwise, the directive would have to be inserted at each declaration of the common block."
If you feel that this is not sufficient, and a command line option is needed, I encourage you to submit a feature request to Intel Premier Support at https:premier.intel.com (one way to get an account, if you don't have one, is when you download an evaluation compiler). I can't say whether or not this would be accepted, but it seems like a reasonable suggestion/request to make.
Martyn
"Consider the following example:
COMMON /MINE/ A,B,C
A = 3.0
END
If you compile this normally, ifc com.f90
you'll get a global symbol called mine_ that represents the COMMON block. As stated, compiling with -nus, does not change this. However, if we change the program and add:
COMMON /MINE/ A,B,C
!DIR$ATTRIBUTES C ::/MINE/
A = 3.0
END
then the global symbol emitted for the COMMON block is just mine.
This does involve changing source, but if the common block declaration is in an include file, as many people do, it's not too onerous. Otherwise, the directive would have to be inserted at each declaration of the common block."
If you feel that this is not sufficient, and a command line option is needed, I encourage you to submit a feature request to Intel Premier Support at https:premier.intel.com (one way to get an account, if you don't have one, is when you download an evaluation compiler). I can't say whether or not this would be accepted, but it seems like a reasonable suggestion/request to make.
Martyn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oops, the syntax should be
!DEC$ATTRIBUTES C ::/MINE/
not
!DIR$ATTRIBUTES C ::/MINE/
The rule is !DIR$ for directives but !DEC$ for attributes
Martyn
!DEC$ATTRIBUTES C ::/MINE/
not
!DIR$ATTRIBUTES C ::/MINE/
The rule is !DIR$ for directives but !DEC$ for attributes
Martyn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you don't want to go through the code adding directives to the common block definitions, it is not that hard to define CPP macros in a common C header to modify names on the C side of the interface, assuming that all common block names are global names that don't conflict with other local names.
I quickly hacked together this example command-line to build CPP #defines from Fortran sources:
$ grep -i "^ *common */" *.f *.f90 *.inc | awk -F / '{print tolower($2)}' | sort | uniq | awk '{printf "#define %s %s_ ",$1,$1;}'
I quickly hacked together this example command-line to build CPP #defines from Fortran sources:
$ grep -i "^ *common */" *.f *.f90 *.inc | awk -F / '{print tolower($2)}' | sort | uniq | awk '{printf "#define %s %s_ ",$1,$1;}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
madmjcorden:
The rule is !DIR$ for directives but !DEC$ for attributes
This is an old thread resurrected, but the compiler treats !DIR$ and !DEC$ (and !MS$) identically. We document !DEC$ as the prefix but you can use the others if you like.

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