开发者

using external modules in Fortran

开发者 https://www.devze.com 2023-03-11 14:46 出处:网络
I try to use two external Fortran module which are in same name (in this case mod_param). So, when i try to compile my code, the compiler gives the following error,

I try to use two external Fortran module which are in same name (in this case mod_param). So, when i try to compile my code, the compiler gives the following error,

mod_param.o: In function mod_param._': mod_param.f90:(.text+0x0): multiple definition ofmod_param._' mod_param.o:mod_param.F90:(.text+0x0): first defined here

is there any way to solve it without renaming the one of the module file and its name? I don't prefer the renaming because the external modules are maintained by someone else and i don't want to play with them. Is there any special use statement to do th开发者_开发问答at?


No. It is necessary to change the function name in the source code in at least one of the modules.

Since the code is being maintained by someone else, consider automating the renaming: perhaps the project Makefile can run a sed script which changes the function names. So that the dependencies are clear, be sure to make the output of the sed script a new file name which is used to be compiled—the virgin module would have a filename which is not compiled or linked into the project.

Even if it were somehow possible to link them both in with the same name, how would you control which was called with the name?


According to F2003 standard module names are global entities and must be unique in a program, with some exteptions for intrinsic modules.

So, that would be a no (Besides, how would you tell them apart were they of the same name?)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号