Error copying Fortran module

Hello everyone,

I keep getting this error

Error copying Fortran module "src/modules/elemental.mod".  Tried "src/modules/ELEMENTAL.mod" and "src/modules/elemental.mod"

while compiling with either gfortran or ifort intel compiler on UNIX OS.

Can anyone please suggest what might be a possible source of such strange error?

PS. The same code compiles and runs fine on Windows using Intel compilers.

Thanks!

That message did not come from a compiler - it almost certainly came from a script or makefile. You’ll need to examine the command you used to “compile” and see what it is really doing.

1 Like

Could it be a problem related to case sensitivity in UNIX OS?
OK, it tried ELEMENTAL.mod and elemental.mod, but it could also be for example Elemental.mod

You could search the file containing the error message with grep.

@sblionel thanks for the clarification. I had indeed thought about the build system. I checked all the related files over and over, yet I could not see the mistake myself. That being said, since it is unfortunately CMake (which I never liked), it might be that I am missing the spot.

@vmagnin thanks for the hint, I knew UNIX OSes are case sensitive and tried to be very careful on that matter. Nonetheless, the problem is more complicated I guess, cause no module elemental exists in the first place…

I see that among the generated make build files, there is a src/CMakeFiles/BsaLib.dir/depend.make file in which I some rule patterns like:

<cmake_dir>/<a_file_path>.F90.o.provides.build: <cmake_dir>/elemental.mod.stamp
<cmake_dir>/elemental.mod.stamp: <cmake_dir>/<a_file_path>.F90.o
   $(CMAKE_COMMAND) -E cmake_copy_mod src/modules/elemental.mod src/modules/elemental.mod.stamp GNU 

A similar pattern is present for a “pure.mod”, same as elemental.mod.

I don’t deal with Makefiles very often, so I don’t really know from where this might come from.

A missing dependency?

Possibly related…? (the error pattern seems very similar with the following Q/A)

If so, Cmake might be considering something like module elemental function foo() as a module name?

Another pattern might be this, but not very sure…

2 Likes

Thanks @septc , glad you came back after a long time helping me solving this issue ! Perfect timing :laughing:

So, the signature module elemental/pure function/subroutine proc_name() is non-standard ?

1 Like

It’s standards conforming, just appears to confuse CMake’s Fortran parser. The simple workaround is probably to just swap the keywords. I.e.

elemental module subroutine proc_name()
1 Like