fortran-lang / stdlib

Fortran Standard Library
https://stdlib.fortran-lang.org
MIT License
1.03k stars 163 forks source link

Inappropriate version comparison of Intel Fortran in CMakeLists.txt #443

Open degawa opened 3 years ago

degawa commented 3 years ago

To switch a compiler option for specifying the Fortran standard, CMake processes the following statements:

  add_compile_options(-warn declarations,general,usage,interfaces,unused)
  if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 18.0)
    add_compile_options(-stand f15)
  else()
    add_compile_options(-stand f18)
  endif()

The version comparison operator VERSION_LESS used here corresponds to <, so -stand f18 is specified for Intel Fortran 18.0 and later. However, Intel Fortran 18 does not have the keyword f18 for -stand option. It can be confirmed from references:

I found a version comparison operator VERSION_LESS_EQUAL corresponding to <=. It would be better to use it instead of VERSION_LESS.

  add_compile_options(-warn declarations,general,usage,interfaces,unused)
  if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS_EQUAL 18.0)
    add_compile_options(-stand f15)
  else()
    add_compile_options(-stand f18)
  endif()
awvwgk commented 3 years ago

Good catch, thanks. Would you mind opening a pull request for this?

nncarlson commented 3 years ago

Note that when CMake compares version strings it uses the full version, including the fourth tweak field, which for Intel is the numeric build date. And when you compare against "18.0" it is padded with 0's to "18.0.0.0". So even with VERSION_LESS_EQUAL, any 18.0 version compiler -- including 18.0.0 because of the build date for the tweak field -- will fall into the else clause. This needs to be VERSION_LESS 18.1 if 18.1 is the first to support -stand f18. Actually I think they went straight from 18.0 to 19.0, so VERSION_LESS 19.0 works.

Romendakil commented 3 years ago

Recently there was the discussion in favor of not support gfortran 7 and 8 any longer because they are no longer maintained by gcc/gfortran. With the same reasoning, shouldn't we abandon Intel 18 and 19 as well as they are no longer supported (AFAIK). Intel 20 and 21 are the only actively maintained versions.

nncarlson commented 3 years ago

I wouldn't object too strongly to dropping support for at least Intel 18 -- it's pretty old now. Though it is still used in some HPC centers where they tend to keep their OS/software stack unchanged for a long time. I'm not aware of any 20 or 21 version. They seemed to have jumped from 19.1 to 2021 in their new oneAPI branding.

awvwgk commented 3 years ago

Well, stdlib doesn't compile with Intel 18 and lower anyway, so support is not really given right now for those versions (see https://github.com/fortran-lang/stdlib/issues/299).

degawa commented 3 years ago

Would the following be a summary of the discussion here?

awvwgk commented 3 years ago

I found only one Intel 18 version that works (18.0.5 20180823), but I think going forward we will just drop support for 18 and earlier. Therefore, there is indeed no need to fix this issue.