Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

How to automatically pick linux ifort or windows cvf intrinsic modules?

whistles28
Beginner
989 Views
Hi,

I am compiling my code sometimes in Linux Intel Fortran, sometimes in Windows Compaq Visual Fortran.

The problem is that I use an intrinsic module (for some time/date functions such as TIMEF, FDATE, DATE, CLOCK and ETIME) which is common both compilers except that it has a different name for each compiler (DFPORT in Win CVF and IFPORT in Linux Intel Fortran).

Presently, when switching compilers I have to manually write "USE DFPORT" instead of "USE IFPORT" or vice-versa in all the subroutines using the module. This rather inconvenient.

Is there an automatic way of doing it, without having to manually change the text when swiching compilers? This would render the code platform independent (at least for the two platforms I am testing).

Thanks,
Francisco
0 Kudos
4 Replies
TimP
Honored Contributor III
989 Views
Did you notice the .pdf documentation for ifort recommends the standard Fortran intrinsic DATE_AND_TIME in preference to a majority of those, or ETIME could usually be replaced by CPU_TIME?
Besides, you might make an ifport.f90 which USEs dfport.f90 so as to make CVF resemble ifort in this respect. According to the doc, not all the functions you mentioned are declared there.
0 Kudos
Kevin_D_Intel
Employee
989 Views

You can consider using the Intel Compiler predefine (__INTEL_COMPILER) and -fpp.

Compile the sample below on Linux with ifort using:

ifort -fpp sample.f

Compile the sample on Windows with CVF using:

cvf -fpp sample.f

sample.f
=======
[cpp]program sample

#ifdef __INTEL_COMPILER
  USE IFPORT
#else
  USE DFPORT
#endif

end[/cpp]
0 Kudos
whistles28
Beginner
989 Views
Quoting - tim18
Did you notice the .pdf documentation for ifort recommends the standard Fortran intrinsic DATE_AND_TIME in preference to a majority of those, or ETIME could usually be replaced by CPU_TIME?
Besides, you might make an ifport.f90 which USEs dfport.f90 so as to make CVF resemble ifort in this respect. According to the doc, not all the functions you mentioned are declared there.


When I composed the code I did not find those intrinsic procedures, only the DFPORT module's ones. I am convinced it will not be difficult to adapt my code with it.

Thanks for the tip!

Francisco
0 Kudos
whistles28
Beginner
989 Views

You can consider using the Intel Compiler predefine (__INTEL_COMPILER) and -fpp.

Compile the sample below on Linux with ifort using:

ifort -fpp sample.f

Compile the sample on Windows with CVF using:

cvf -fpp sample.f

sample.f
=======
[cpp]program sample

#ifdef __INTEL_COMPILER
USE IFPORT
#else
USE DFPORT
#endif

end[/cpp]

It worked! Thanks!

When I'll have the time, I will also try Tim18's tip of switching to standard Fortran procedures.

Francisco
0 Kudos
Reply