# Error copying Fortran module

**URL:** https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549
**Category:** Help
**Created:** [March 6, 2024, 3:40pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549 "2024-03-06T15:40:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mEm](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mEm](https://fortran-lang.discourse.group/u/mEm)
#### Post date: [March 6, 2024, 3:40pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/1 "2024-03-06T15:40:50Z")

</div>

Hello everyone,

I keep getting this error

```auto
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!

---

<div class="post-metadata">

### Author: ![sblionel](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/sblionel/32/853_2.png) [@sblionel](https://fortran-lang.discourse.group/u/sblionel)
#### Post date: [March 6, 2024, 5:26pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/2 "2024-03-06T17:26:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)
#### Post date: [March 6, 2024, 5:59pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/3 "2024-03-06T17:59:19Z")

</div>

> [@mEm](#):
>
> PS. The same code compiles and runs fine on Windows using Intel compilers.

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.

---

<div class="post-metadata">

### Author: ![mEm](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mEm](https://fortran-lang.discourse.group/u/mEm)
#### Post date: [March 6, 2024, 7:19pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/4 "2024-03-06T19:19:47Z")

</div>

@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:

```auto
<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.

---

<div class="post-metadata">

### Author: ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)
#### Post date: [March 6, 2024, 7:45pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/5 "2024-03-06T19:45:07Z")

</div>

> [@mEm](#):
>
> no `module elemental` exists in the first place…
> 
> `depend.make`

A missing dependency?

---

<div class="post-metadata">

### Author: ![septc](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/septc/32/77_2.png) [@septc](https://fortran-lang.discourse.group/u/septc)
#### Post date: [March 6, 2024, 11:56pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/6 "2024-03-06T23:56:59Z")

</div>

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

> **[Sorry about the formatting](https://community.intel.com/t5/Intel-Fortran-Compiler/recursive-mod-problem/m-p/1173503)**
>
> Sorry about the formatting

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…

> **[Makefiles: Fortran module dependency named via preprocessor DEFINE variable...](https://gitlab.kitware.com/cmake/cmake/-/issues/25380)**
>
> Here is a simple example to show the problem. This is possibly related to

---

<div class="post-metadata">

### Author: ![mEm](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@mEm](https://fortran-lang.discourse.group/u/mEm)
#### Post date: [March 7, 2024, 10:23am UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/7 "2024-03-07T10:23:21Z")

</div>

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

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

---

<div class="post-metadata">

### Author: ![everythingfunctional](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/everythingfunctional/32/176_2.png) [@everythingfunctional](https://fortran-lang.discourse.group/u/everythingfunctional)
#### Post date: [March 7, 2024, 3:55pm UTC](https://fortran-lang.discourse.group/t/error-copying-fortran-module/7549/8 "2024-03-07T15:55:24Z")

</div>

> [@mEm](#):
>
> So, the signature `module elemental/pure function/subroutine proc_name()` is non-standard ?

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

```auto
elemental module subroutine proc_name()

```
