Is there any way to alter fortran compiler options by file extension? For example, I may want to enable more diagnostic checking on files that end with .f90 compared to those that end with .for. Since we are in the process of updating our fortran code and converting from very old-school fixed format and style to the more updated free-form and object-oriented style, this would be a very useful option.
It is incorrect to infer Fortran language level with file format. You can write Fortran 66 in a free-format file, and you can write Fortran 2008 code in a fixed format file. Some people even enjoy writing code that is equally valid when regarded as fixed format or free format.
If you wish to associate fixed format with old code that needs different compiler options, one way to do so would be to use a makefile, with one rule for compiling *.f files and another for *.f90 files:
ifort /check /Od /c $<
ifort /O2 /c $<
Thanks for the reply. You're right about inferring language level from file format. As we are making updates to our code we are converting as many things as we can from the older format/style to the newer format/style and we make this distinction by changing the .for to .f90. As a result, it would be great to have the compiler use different options based on file extension. Unfortunately, we are tied to Visual Studio and I don't know if there is a way to incorporate your makefile suggestion. Do you know if this can be done via the Visual Studio options without having to explicitly set compiler options on each file?
How about creating separate projects? You can set the options on a project and if you collect the revised files in their own project, you canset them independently of the non-revised ones.
Nick Russ wrote:
Unfortunately, we are tied to Visual Studio and I don't know if there is a way to incorporate your makefile suggestion.
That is a self-inflicted predicament. You need not be tied to Visual Studio the IDE. The VS toolchain includes Nmake.
If you are converting a project made of, say, a hundred files, the conversion process should be short-lived. Once you have converted the old files to free format and run tests for correct results with the new files, you don't need to have a mix of old and new file formats in your future projects.
For conversion projects, I would not use VS at all, but I concede that people follow their own tastes.