Anyway we've got a bit of a problem with F90 modules and
makefiles. Say you change something in module X. When you
make the program it should really recompile any source file
that USE that module to ensure consistency ( e.g. if the
change is in an interface block ). Now you could create
a whole load of dependencies in your makefile, but
that could get pretty hairy if there are multiple
levels of dependencies. Has any nice person out
there cooked up a nice tool to create these
dependency lists in advance ?
TIA
Ian
---
---------------------------------------------------------------------------
Full Name Dr Ian John Bush
JANET: I.J....@uk.ac.daresbury Phone: 0925 603652
JANETVAXMAIL: cbs%uk.ac.daresbury::I.J.Bush FAX: 0925 60????
Internet: I.J....@daresbury.ac.uk Address: DRAL
EARN/BITNET: I.J.Bush%daresbury.ac.uk@ukacrl Daresbury Laboratory
UUCP: I.J.Bush%daresbu...@ukc.uucp Warrington
EAN/X400: I.J....@daresbury.ac.uk WA4 4AD
--------------------------------------------------------------------------
The solution that seems to be working for me is to put any files
with modules first in the source list, e.g.,
SRCS = a.f90 b.f90 c.f90 ... (files without modules).
where all the modules are given in a.f90, b.f90, c.f90 only.
You would think that this might be quite inconvenient in some cases,
but it is o.k. for me at the moment.
Anyone have any other ways of dealing with this?
What is needed, of course, is exactly equivalent to the "makedepend"
program for C files---right down to its ability to recursively descend
the dependency graph...
I thought there was something available already, though---something
written in Perl. I haven't had too much of a need for it yet, so I
haven't sought it out. Sorry!
--
Michael C. Grant Information Systems Laboratory, Stanford University
mcg...@isl.stanford.edu <A HREF="http://www-isl.stanford.edu/~mcgrant">
------------------------------------------------------------------------------
"When you get right down to it, your "Long hair, short hair---what's
average pervert is really quite the difference once the head's
thoughtful." (David Letterman) blowed off?" (Nat'l Lampoon)
http://www.fortran.com/fortran/fm_new.html
under the February 21, 1995 listing. It does seem to have the
ability to trace the dependencies of modules.
>I thought there was something available already, though---something
>written in Perl. I haven't had too much of a need for it yet, so I
>haven't sought it out. Sorry!
I have one that works for NAG f90 and IBM xlf90, but not for Cray
f90. I will add some Cray stuff someday, but the current version is in
ftp://ahab.rutgers.edu/pub/perl/sfmakedepend
Note that this is a perl 5 script. It also finds dependencies such
as
include 'file'
#include "file"
Kate Hedstrom
I use the following in my Makfile, it's vanilla /bin/sh so should work
everywhere :-) It does rely on each module residing in a file of the same name,
i.e. "use fred" implies that the module fred lives in fred.f90. The source
files are supplied in the variable SRCS, and the depend rule should go at the
end of your Makefile.
--------------------------------- cut here -------------------------------
# Make header file dependencies, automatically generate a rule for every file
# (despite the rule above) so recompilation depends on included files too.
depend:
-@if [ `echo '\c' | wc -l` = '0' ]; then MN=''; SC='\c'; \
else MN='-n '; SC=''; fi; \
echo $$MN "Calculating include file dependencies...$$SC"; \
sed -n '1,/^## DO NOT DELETE THIS LINE/p' Makefile > Makefile.depend;\
for file in $(SRCS); do \
object=`echo $$file | sed 's/\.f90/\.o/'`; \
egrep '^ *use' $$file | sort -u | \
awk 'BEGIN { file="'$$object':"; line=file } {\
tmp=line " " $$2 ".o"; \
if (length(tmp) < 80) line=tmp; \
else { \
print line >> "Makefile.depend"; \
line=file " " $$2 ".o" \
} \
} END { print line >> "Makefile.depend" }'; \
done; \
mv Makefile Makefile.bak; \
mv Makefile.depend Makefile; \
echo 'Done.'
# Full include file dependency rules generated by make depend.
## DO NOT DELETE THIS LINE, it is needed by make depend.
--------------------------------- cut here -------------------------------
--
Dr Paul J Mitchell CChem MRSC | email: P.Mit...@surrey.ac.uk
Department of Chemistry, | www: http://www.chem.surrey.ac.uk/~chs1pm
University of Surrey, | Tel: (01483) 259580 Fax: (01483) 259514
Guildford, Surrey. GU2 5XH. UK. | (VFR750FJ CMA#36 MAG#65715 DoD#0145 Ogri)
I think the Right Thing is a) to generate dependencies on the
(system-dependent) locations of the *interface definitons* of used
modules (per Kate); b) ensure that these aren't outdated by
recompiling the module code unless they've actually changed (modules
win over include-file kluges).
The traditional (Kernighan/Pike?) Unix mechanism for b) is embodied in
the `move-if-change' script from GNU distributions, Norman Ramsey's
`cpif' etc. and could presumably be used in the referenced scripts.
Done directly it's this is the sort of thing, I think, assuming the
compiler puts interface info in .mod files:
foo.o: foo.f90 bar.m
f90 -c foo.f90
bar.o bar.m: bar.f90
f90 -c bar.f90
-cmp -s bar.mod bar.m || cp bar.mod bar.m