- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The compiler flag -fpp prepends /tmp to the search path for include files.
Steps to reproduce:
1. Consider the test program hw.f90 and the include file msg.h:
$ cat hw.f90
program hello
implicit none
include 'msg.h'
print *,msg
end program hello
$ cat msg.h
! -*- f90 -*-
character(len=16) :: msg = 'Hello World!'
2. The program compiles ok, with or without -fpp:
$ ifort -o hw hw.f90
$ ./hw
Hello World!
$ ifort -fpp -o hw hw.f90
$ ./hw
Hello World!
3. Now create a file msg.h in /tmp:
$ echo 'This is no valid Fortran' > /tmp/msg.h
4. The program still compiles ok without -fpp:
$ ifort -o hw hw.f90
5. But with -fpp it does not work anymore:
$ ifort -fpp -o hw hw.f90
/tmp/msg.h(1): error #5082: Syntax error, found IDENTIFIER 'IS' when expecting one of: ( % : . = =>
This is no valid Fortran
-----^
hw.f90(7): error #6404: This name does not have a type, and must have an explicit type. [MSG]
print *,msg
----------^
compilation aborted for hw.f90 (code 1)
Conclusion
With -fpp, the wrong file /tmp/msg.h gets included, even though the right one is in the cwd.
Version
$ ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091012 Package ID: l_cprof_p_11.1.059
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
My OS is SLES 11
Steps to reproduce:
1. Consider the test program hw.f90 and the include file msg.h:
$ cat hw.f90
program hello
implicit none
include 'msg.h'
print *,msg
end program hello
$ cat msg.h
! -*- f90 -*-
character(len=16) :: msg = 'Hello World!'
2. The program compiles ok, with or without -fpp:
$ ifort -o hw hw.f90
$ ./hw
Hello World!
$ ifort -fpp -o hw hw.f90
$ ./hw
Hello World!
3. Now create a file msg.h in /tmp:
$ echo 'This is no valid Fortran' > /tmp/msg.h
4. The program still compiles ok without -fpp:
$ ifort -o hw hw.f90
5. But with -fpp it does not work anymore:
$ ifort -fpp -o hw hw.f90
/tmp/msg.h(1): error #5082: Syntax error, found IDENTIFIER 'IS' when expecting one of: ( % : . = =>
This is no valid Fortran
-----^
hw.f90(7): error #6404: This name does not have a type, and must have an explicit type. [MSG]
print *,msg
----------^
compilation aborted for hw.f90 (code 1)
Conclusion
With -fpp, the wrong file /tmp/msg.h gets included, even though the right one is in the cwd.
Version
$ ifort -V
Intel Fortran Intel 64 Compiler Professional for applications running on Intel 64, Version 11.1 Build 20091012 Package ID: l_cprof_p_11.1.059
Copyright (C) 1985-2009 Intel Corporation. All rights reserved.
My OS is SLES 11
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suppose this relates to the default usage of /tmp/ for the pre-processed files required by -fpp option. I believe you could change that (e.g. to a subdirectory of /tmp/ which you create for your project) if you knew the sequence of environment variables used by that compiler to make the determination.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure. Indeed, setting the environment variable TMP to some safe directory works around this issue.
Once you are aware of the problem, you can even more easily work around it, just by deleting the offending file in /tmp. But if you are not aware of it, it can take you hours of debugging before you figure out why your edits in the include file fail to have any effect. Note that if the offending file contains valid Fortran source, you wont get any notice about it being included in the place of your include file.
That is why i suggest this is a bug worth being fixed and tht's why i'm posting it here. Suggested fix:
1. Use mkdtemp(3) to create a unique temporary directory for the intermediate files.
2. Include compiler generated intermediate files by absolute path name rather then modifying the include path.
Once you are aware of the problem, you can even more easily work around it, just by deleting the offending file in /tmp. But if you are not aware of it, it can take you hours of debugging before you figure out why your edits in the include file fail to have any effect. Note that if the offending file contains valid Fortran source, you wont get any notice about it being included in the place of your include file.
That is why i suggest this is a bug worth being fixed and tht's why i'm posting it here. Suggested fix:
1. Use mkdtemp(3) to create a unique temporary directory for the intermediate files.
2. Include compiler generated intermediate files by absolute path name rather then modifying the include path.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for raising this issue.
FPP shouldn't be a factor here. It handles #include. The Fortran Front-end handles the INCLUDE statement so throwing -fpp has an unintended side-effect.
I will re-create your test case, test the latest release, and direct to Development if not resolved and update the post when I know more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is reproducible with our upcoming release too. It spans all OSes. On Windows the TEMP setting is typically user unique but the behavior is the same when headers are placed in the TEMP location.
I directed this to Development(see internal tracking id below) and will update as I learn more.
(Internal tracking id: DPD200162585)
I directed this to Development(see internal tracking id below) and will update as I learn more.
(Internal tracking id: DPD200162585)
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