diff options
author | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-01-19 14:22:04 +0000 |
---|---|---|
committer | schnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2004-01-19 14:22:04 +0000 |
commit | a871263329e969b92a3835a06286df9ee2574e3d (patch) | |
tree | 173e1678f7e5cad0532c8c553aa0a004b35a9efe /lib/sbin/f_depend_modules.pl | |
parent | 539f0616473c60e35b88780ac7b96d4cba1ef6f9 (diff) |
Add (incomplete) Fortran 90 bindings for the flesh functions.
Also, detect Fortran 90 inter-module dependencies automatically.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@3524 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/f_depend_modules.pl')
-rwxr-xr-x | lib/sbin/f_depend_modules.pl | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/lib/sbin/f_depend_modules.pl b/lib/sbin/f_depend_modules.pl new file mode 100755 index 00000000..f226ae69 --- /dev/null +++ b/lib/sbin/f_depend_modules.pl @@ -0,0 +1,72 @@ +#!/usr/bin/perl -w +# $Header$ + +# Create dependencies for Fortran 90 "use" and "include" statements + +my $srcfile = $ARGV[0]; +my $dest = $ARGV[1]; +my $srcdir = $ARGV[2]; +my @otherdirs = @ARGV[3..$#ARGV]; + +my @suffixes = (".f77", ".f", ".f90", ".F77", ".F", ".F90"); + +print "$dest:"; + +my %modules; + +my $line = 0; +while (<STDIN>) { + ++ $line; + if (/^\s*#\s*(\d+)/) { + # line number directive from C preprocessor + $line = $1 - 1; + } elsif (/^\s*include\s*['"]([^'"]+)['"]/i) { + # include statement + my $name = $1; + print " \\\n $srcdir/$name"; + } elsif (/^\s*module\s+(\w+)/i) { + # begin of a module + my $name = $1; + $modules{$name} = 1; + } elsif (/^\s*use\s+(\w+)/i) { + # use statement + my $name = $1; + my $found = 0; + if (! $found) { + # reference to a module in this file? + if ($modules{$name}) { + $found = 1; + } + } + if (! $found) { + # reference to a module in this thorn? + loop: foreach my $suffix (@suffixes) { + if (-e "$srcdir/$name$suffix") { + $found = 1; + print " \\\n $name$suffix.o"; + last loop; + } + } + } + if (! $found) { + # reference to a module in another thorn? + loop: foreach my $dir (@otherdirs) { + # note: we could also use the SUBDIRS from the make.code.defn here + foreach my $subdir (".", "include") { + foreach my $suffix (@suffixes) { + if (-e "$dir/$subdir/$name$suffix.o") { + $found = 1; + print " \\\n $dir/$subdir/$name$suffix.o"; + last loop; + } + } + } + } + } + if (! $found) { + print STDERR "$srcfile:$line: Warning: While tracing module depencencies: Source file for module $name not found\n"; + } + } +} + +print "\n"; |