Is it possible to determine which Fortran compiler generated a “.mod” file?

三世轮回 提交于 2021-02-04 13:46:06

问题


Say I have a package already installed on my machine and I want to figure out if I need to regenerate the module include files (.mod) to make them compatible with the rest of my compilation. Is there any way to do this?


回答1:


If the module is built using gfortran then using strings on the mod file (on Linux) will provide the compiler name and the version number. However, for Intel, the strings command will only show the compiler version number.




回答2:


I had a similar problem at some point with libraries and module files but no sources. Because it is easier to get the right compiler than to get the source code for recompiling in some cases, or to recompile only few things as mentioned by the OP, I found it useful to get the versioning of gfortran module somewhere on SO. Unfortunately, the information is not easy to find, so there is a need of reverse engineering and anyone is welcome to edit and add more.

I did a little bit of googling and here is the starting point: For gfortran the module versioning appeared at "gfortran 4.4" according to this page. It is important to say that the version number is for the module not for the compiler. I guess it changes when the format of the module file changes to account for some new features.

By combining information from this page, this pages, this one and the answer from matthieu-verstraete, I came up with this list of correspondence.

GCC version    module file version
-----------------------------------
up to 4.3.2    unversioned
4.4            0
4.5.1          4
4.6.3          6
4.7.0pre       8
4.7.1          9
4.8.[1-3]      10
4.9.2          12
5.1.0          14
8.1.0          15 
9              15
10             15
11             15

From version 4.8 on, the gfortran team includes a small message in the release notes when the module version changes. The message looks like

Module files: The version of the module files (.mod) has been incremented

as it can be read from this link. They do not give the version number, and it seems that when they say incremented, it is incremented by 2. The update of the module version in gfortran version 8 incremented by 1, and the [gfortran wiki] 5 does not say anything about it as of this writting. Thank you to matthieu-verstraete for digging it up.




回答3:


For recent gfortran versions:

  1. cp mymodule.mod test.mod.gz
  2. gunzip test.mod.gz
  3. read file test.mod - the first line will contain the module version, which is an internal counter for gfortran developers. See post above for a list of correspondences. For gfort 8.1.0 we are at version 15.


来源:https://stackoverflow.com/questions/37681248/is-it-possible-to-determine-which-fortran-compiler-generated-a-mod-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!