Fix suffix for Fortran 2003 source file - Intel Fortran compiler

I wrote a small piece of code trying to stick to the Fortran 2003 standard. The code is available on github .

This is my make file:

FC = gfortran FLGS = -g -pg -std=f2003 -I. -fbounds-check DEPS = camx.prm OBJ = unit-test-hadvppm.o hadvppm.o #linker macro %.o: %.f03 $(DEPS) $(FC) -c -o $@ $< $(FLGS) #build targets gnu-amd64-linux: $(OBJ) $(FC) -o $@ $^ $(FLGS) clean: gnu-amd64-linux rm *.o 

The code compiles without problems using the above makefile and gfortran .

However, if I try to compile it with iFort, simply using

 ifort -o ifort-amd64-linux unit-test-hadvppm.f03 hadvppm.f03 

it does not work, see output below. I believe this is due to the free .f03 file format. Is there a flag in iFort similar to the gfortran -std = f2003 flags? I tried to find this in the iFort documentation, should I look harder?

enter image description here

+6
source share
2 answers

There is nothing in the standard indicating a file suffix. Intel has always stated that they consider *.f90 as a suffix for the free source format, regardless of the standard version. This is just an agreement, not based on any standard document.

The f90 suffix may be a little regrettable, similar only to Fortran 90, but you should not hesitate to use it for each source file in free format.

Personally, I also don't like the practice of .f95 , .f03 , .f08 . Should I rename the source file just because I call some inline from a newer standard?

+12
source

You can specify the source form used in the source file using the -free and -fixed ifort command line options for free and fixed forms respectively.

As a separate issue, you can set the standard for diagnostics using the -stand [: xxx] option. This does not change the code generated by the compiler, it just changes the diagnostics that the compiler sets. This is equivalent to the gfortran option -std = xxx.

As another separate issue, you can point out that the compiler must change its behavior to comply with the Fortran standard using the -standard-semantics compiler parameter. This covers scenarios in which the compiler behavior has historically been different from that according to the Fortran standard, requiring or recommending.

As recommended in Vladimir’s comments and answer, the easiest option is to simply use .f90 for any free form source file (which will be considered as a free ifort form source in the absence of the -fixed command line option) no matter what standard he wrote.

+4
source

Source: https://habr.com/ru/post/958993/


All Articles