Topic: Can't open module file: No such file or directory

Hello Everybody,

This is almost certainly an "inexperienced user" problem, and the solution is probably very obvious, just not to me.

So, I've created a module, compiled and tested said module (let's call it modA) in a project (let's call it projA). I'm now working on another project (projB) in which I want to USE the module file. I have added the "module" and "build" directories of projA to the "Include/Module Directories" of projB (via Project Options > File Locations > Search Directories... > Add...). Every time I go to build projB, I get a

Fatal Error: Can't open module file 'modA.mod' for reading at (1): No such file or directory
compilation terminated.


The result is the same if I:

1) Try to copy modA.mod to projB's "Modules" directory

2) Add modA.mod to the project (from it's original directory or projB's "Modules" folder)

3) Add modA.o to the project from its original directory

4) Add modA source to the project from its original directory

The code DOES compile if:

1) I copy modA's source code to projB's directory and add it to the project

2) I copy modA.mod to projB "Modules" dir, copy modA.o to projB "Build" dir, and add modA.o to projB


Is this the intended way to use modules? I had thought that modules could be compiled, and than just referenced in situ in new projects.

Re: Can't open module file: No such file or directory

I think you're using it as expected.  I'll have to see if I can replicate the issue on my end.  Could you let me know what version of Simply Fortran you're using and what operating system you're on? 

After adding a search directory properly, it should be able to pick up modules from it.  I'm not sure why you're having the issue.

You could also try emailing the project files (just the .prj file, not any source code) and the makefiles for both projects to support@approximatrix.com.  I can have a look to see what's occurring.

Jeff Armstrong
Approximatrix, LLC

Re: Can't open module file: No such file or directory

Alright, will do! I made a pair of test projects just to demonstrate the issue. So I can post the source code of those projects if it would help.


Project A

-> Main Program

program mainA

use modA

implicit none
character (5) :: words
character (5) :: modout

words = 'help'
call foo(words, modout)
write(*,'(3a)') words,' = ',modout

words = 'why'
call foo(words, modout)
write(*,'(3a)') words,' = ',modout

words = modout
call foo(words, modout)
write(*,'(3a)') words,' = ',modout

words = 'this'
call foo(words, modout)
write(*,'(3a)') words,' = ',modout

end program

->ModA

module modA
implicit none
private
public :: foo

contains

subroutine foo(query, bar)
    character (5), intent (in) :: query
    character (5), intent (out):: bar
    
    select case (query)
        case ('help') 
            bar = 'no'
        case ('why')
            bar = 'who'
        case ('who')
            bar = 'why'
        case default
            bar = 'wuut?'
    end select
end subroutine foo

end module modA

ProjectB

-> Main Program

program mainB

use modA

implicit none
character (5) :: words
character (5) :: modout

words = 'test'
call foo(words, modout)
write(*,'(3a)') words,' = ',modout

end program

Re: Can't open module file: No such file or directory

I can't seem to replicate your issue.  My "Project B" is picking up the modA module correctly.

Could you first confirm that modA.mod exists in "Project A's" module directory using Windows Explorer?

If it does seem to be there, could you email the project files (ending in .prj) to support@approximatrix.com?

Jeff Armstrong
Approximatrix, LLC