"Turning off" compiler extensions

"Turning off" compiler extensions

I am trying to replace old Fortran language extensions in a large program with the corresponding featuresfrom the new Fortran 2003 standard (e.g. using DATE_AND_TIME instead of GETDAT or GETTIM from IFPORT). However, I am suprised to see that aprogram without the "USE IFPORT" statement still compiles and works properly with GETDAT or GETTIM procedures.I was expecting to see a complier error stating GETDAT or GETTIM procedures are not found.Is there a way to actually force IVF to produce such an error? I am relying onthese compiler errors to locatethese language extensions.

I am using IVF 11.1.067 with VS 2005 Professional.

Thanks for any help in advance,

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Those you cited aren't actually compiler extensions. They do rely on ifport library, so you might turn them into link errors by appending /link /nodefaultlib:libifport.lib to your link step.
By the way, date_and_time has been in the standard since f90.

When you use any functions or subroutines that are not intrinsic, providing interfaces (through USE statements or explicitly) allows the compiler to check that the subroutines/functions are called with the correct number and types of arguments.

The following program, written under the mistaken assumption that GETDAT and GETTIM return strings in the format mm:dd:yyyy and hh:mm:ss.uu rather than a set of integer arguments, fails to compile when the IFPORT module is USEd, because the compiler can detect that the arguments are incorrect.

program tst
  use IFPORT
  character*11 :: date1,time1
  call getdat(date1)
  call gettim(time1)
10 format(' Date : ',A,/,' Time : ',A)
end program tst

Without the USE IFPORT line, the program will be compiled and, depending on whether or not the misused routines are to be found in the default libraries, linked without error messages. However, the resulting program will abort with an access violation.

As Tim has already pointed out, using external functions and subroutines, whether provided by the user or the compiler vendor, does not constitute a "language extension", because the Fortran standard prescribes the rules for writing and using such functions and subroutines.

Check if you have any of the following set to "Yes":

  • Fortran/Libraries/Use Portlib library (/4Yportlib)
  • Fortran/Compatibility/Use PowerStation compatibility library (/fpscomp:libs)

To get warnings for language extensions (in the narrow sense), set:

  • Fortran/Diagnostics/Warn For Non-Standard Fortran to f95 or f2003 (/stand:f95, /stand:f03)

There is no way you can pick a subset of extensions selectively, though.

While you could use gloabal find in files to find the occurances of GETDATand GETTIM, if you are preparing a library for use by others, you would like to give them a reminder that they should fix there code.

I imaging, that when you have such a library, you also require a

USE YourLibrary

In there you could declare an interface to GETDAT and GETTIM

integer ::notUsed

subroutine GETDAT(msg)
type(USE_DATE_AND_TIME) :: msg
end subroutine GETDAT
end interface

When they USE YourLibrary they will error out should they continue to use GETDAT...

Jim Dempsey

Leave a Comment

Please sign in to add a comment. Not a member? Join today