Discussion:
[Scons-users] Fortran dependency in a higher directory
GUEZ Lionel
2018-04-05 16:01:32 UTC
Permalink
Hello. Consider the following test files.

$ cat foo.f
module foo_m
implicit none
integer i
contains
subroutine foo
i = 3
end subroutine foo
end module foo_m

$ cat Subdir/bar.f
module bar_m
implicit none
contains
subroutine bar
use foo_m, only: i
print *, "bar"
print *, "i = ", i
end subroutine bar
end module bar_m

$ cat SConstruct
Object(["Subdir/bar.f", "foo.f"], FORTRANFLAGS = "-ffree-form")

So I have a Fortran file bar.f in directory Subdir which depends on a
Fortran file in the directory above Subdir. Now I try to compile this:

$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gfortran -o Subdir/bar.o -c -ffree-form Subdir/bar.f
Subdir/bar.f:5:8:

use foo_m, only: i
1
Fatal Error: Can't open module file 'foo_m.mod' for reading at (1): No
such file or directory
compilation terminated.
scons: *** [Subdir/bar.o] Error 1
scons: building terminated because of errors.

Scons has not figured out the dependency. It has not begun with the
compilation of foo.f, as it should have. What is the simplest way to
make this work?
--
Lionel GUEZ
Laboratoire de météorologie dynamique
École normale supérieure
24 rue Lhomond
75005 Paris
Bill Deegan
2018-04-05 17:36:09 UTC
Permalink
Take a look at:
http://scons.org/doc/production/HTML/scons-man.html#cv-FORTRANPATH
Post by GUEZ Lionel
Hello. Consider the following test files.
$ cat foo.f
module foo_m
implicit none
integer i
contains
subroutine foo
i = 3
end subroutine foo
end module foo_m
$ cat Subdir/bar.f
module bar_m
implicit none
contains
subroutine bar
use foo_m, only: i
print *, "bar"
print *, "i = ", i
end subroutine bar
end module bar_m
$ cat SConstruct
Object(["Subdir/bar.f", "foo.f"], FORTRANFLAGS = "-ffree-form")
So I have a Fortran file bar.f in directory Subdir which depends on a
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gfortran -o Subdir/bar.o -c -ffree-form Subdir/bar.f
use foo_m, only: i
1
Fatal Error: Can't open module file 'foo_m.mod' for reading at (1): No
such file or directory
compilation terminated.
scons: *** [Subdir/bar.o] Error 1
scons: building terminated because of errors.
Scons has not figured out the dependency. It has not begun with the
compilation of foo.f, as it should have. What is the simplest way to
make this work?
--
Lionel GUEZ
Laboratoire de météorologie dynamique
École normale supérieure
24 rue Lhomond
75005 Paris
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
GUEZ Lionel
2018-04-06 11:51:34 UTC
Permalink
On Thu, 5 Apr 2018 10:36:09 -0700
Post by Bill Deegan
http://scons.org/doc/production/HTML/scons-man.html#cv-FORTRANPATH
Thank you. This documentation is misleading, isn't it?

"The Fortran implicit dependency scanner will search these directories
for include files (but not module files since they are autogenerated
and, as such, may not actually exist at the time the scan takes place)."

Precisely, we are trying to make the dependency scanner look for module
files in the higher directory.
--
Lionel GUEZ
Laboratoire de météorologie dynamique
École normale supérieure
24 rue Lhomond
75005 Paris
Bill Deegan
2018-04-06 16:07:36 UTC
Permalink
I'm not sure what you mean by misleading?
What do you think it means?

Perhaps you're looking for:
http://scons.org/doc/production/HTML/scons-man.html#cv-FORTRANMODDIR
There are a number of other FORTRAN* variables which affect fortran
compilations in the manpage as well
Post by GUEZ Lionel
On Thu, 5 Apr 2018 10:36:09 -0700
Post by Bill Deegan
http://scons.org/doc/production/HTML/scons-man.html#cv-FORTRANPATH
Thank you. This documentation is misleading, isn't it?
"The Fortran implicit dependency scanner will search these directories
for include files (but not module files since they are autogenerated
and, as such, may not actually exist at the time the scan takes place)."
Precisely, we are trying to make the dependency scanner look for module
files in the higher directory.
--
Lionel GUEZ
Laboratoire de météorologie dynamique
École normale supérieure
24 rue Lhomond
75005 Paris
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
GUEZ Lionel
2018-04-09 08:30:40 UTC
Permalink
On Fri, 6 Apr 2018 09:07:36 -0700
Post by Bill Deegan
I'm not sure what you mean by misleading?
What do you think it means?
Well, the documentation on FORTRANPATH says the dependency scanner will
not search the directories in FORTRANPATH for module files and you are
telling me the contrary: that I should use FORTRANPATH to tell the
dependency scanner to take into account module files.
--
Lionel GUEZ
Laboratoire de météorologie dynamique
École normale supérieure
24 rue Lhomond
75005 Paris
Bill Deegan
2018-04-09 14:48:40 UTC
Permalink
It's been a LONG time since I've worked with fortran.
I'm pointing you at the variables listed in the docs for you to figure it
out yourself.
I'm not in anyway contradicting what's in the docs..
Post by GUEZ Lionel
On Fri, 6 Apr 2018 09:07:36 -0700
Post by Bill Deegan
I'm not sure what you mean by misleading?
What do you think it means?
Well, the documentation on FORTRANPATH says the dependency scanner will
not search the directories in FORTRANPATH for module files and you are
telling me the contrary: that I should use FORTRANPATH to tell the
dependency scanner to take into account module files.
--
Lionel GUEZ
Laboratoire de météorologie dynamique
École normale supérieure
24 rue Lhomond
75005 Paris
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
GUEZ Lionel
2018-04-10 15:53:48 UTC
Permalink
On Mon, 9 Apr 2018 10:48:40 -0400
Post by Bill Deegan
It's been a LONG time since I've worked with fortran.
I'm pointing you at the variables listed in the docs for you to
figure it out yourself.
I'm not in anyway contradicting what's in the docs..
I am not ignoring what you say: I read the description of all
Fortran variables in the doc (and I read the SCons 3.0.1 user guide
completely down to chapter 15).

I will try to be more precise. It is ambiguous to refer to "module
files". "Module file" could mean a compiled module interface (with
usually a .mod suffix) or it could mean a source Fortran file
containing one or more modules. The compilation system must be able to
search for compiled module interfaces (.mod files) in a set of
directories, without corresponding source files: this happens when a
program uses a Fortran library. And the compilation system must be able
to search for source module files, to be compiled, in another set of
directories, in order to figure out the order of compilation.

Now the documentation on FORTRANPATH says:

"The list of directories that the Fortran compiler will search for
include files and (for some compilers) module files."

I guess that, here, "module files" means compiled module interfaces. So
I would propose that you amend this sentence to:

"The list of directories that the Fortran compiler will search for
include files and (for some compilers) compiled module interfaces
(files with suffix $FORTRANMODSUFFIX)."

Then the documentation on FORTRANPATH says:

"The Fortran implicit dependency scanner will search these directories
for include files (but not module files since they are autogenerated
and, as such, may not actually exist at the time the scan takes place)."

Here I guess that "module files" also means compiled module interfaces.
But there misses the information that the dependency scanner
WILL search these directories for source module files.

Thus, I would propose that you amend this sentence to:

"The Fortran implicit dependency scanner will search these directories
for include files and source module files (but not compiled module
interfaces (files with suffix $FORTRANMODSUFFIX) since they are
autogenerated and, as such, may not actually exist at the time the scan
takes place)."
--
Lionel GUEZ
Laboratoire de météorologie dynamique
École normale supérieure
24 rue Lhomond
75005 Paris
Loading...