summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-11-24 19:57:21 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-11-24 19:57:21 +0000
commitd29c9698e567a3d72de56f1088fa40b2d6fe6df6 (patch)
tree3cef3b115d947027c6293756dc0fc64654522b2d /lib
parentdb54e98c4d21f26bded1add924813d76f59b3d60 (diff)
Merged in Erik's free-format f90 stuff. Until we have a standard
thorn with free-format f90 in it this is not guaranteed to work on all platforms. Thanks for doing this Erik. Tidied up the f_file_processor to some extent added grdoc stuff to it, and made the formatting consistent with the rest of the perl in the CCTK. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@1168 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib')
-rw-r--r--lib/make/make.config.rules.in72
-rw-r--r--lib/sbin/f_file_processor.pl263
2 files changed, 253 insertions, 82 deletions
diff --git a/lib/make/make.config.rules.in b/lib/make/make.config.rules.in
index d8eaeea2..80c9bfb7 100644
--- a/lib/make/make.config.rules.in
+++ b/lib/make/make.config.rules.in
@@ -56,6 +56,11 @@ define F_DEPENDENCIES
$(DEPENDENCY_FIXER)
endef
+define F90_DEPENDENCIES
+ $(F_DEPEND) $(INC_DIRS:%=-I%) $(EXTRA_DEFINES:%=-D%) -DFCODE $< $(F_DEPEND_OUT)
+ $(DEPENDENCY_FIXER)
+endef
+
#####################################################################
# Define how to do a C compilation
define PREPROCESS_C
@@ -93,28 +98,44 @@ endef
define POSTPROCESS_F77
endef
-# Define how to do a F90 compilation
+# Define how to do a fixed-format F90 compilation
+define PREPROCESS_F
+cat $< | sed 's.//.AUTOMATICALLY_GENERATED_CONCATONATION_PROTECTION_STRING.g' | $(CPP) $(CPPFLAGS) $(INC_DIRS:%=-I%) $(EXTRA_DEFINES:%=-D%) -DFCODE - | $(PERL) -p -e 's/__FORTRANFILE__/\"$(basename $(notdir $<)).F\"/g; s.AUTOMATICALLY_GENERATED_CONCATONATION_PROTECTION_STRING.//.g' - | $(PERL) $(F_FILE_PROCESSOR) > $(basename $(notdir $<)).f
+endef
+
+define COMPILE_F
+current_wd=`$(GET_WD)` ; cd $(SCRATCH_BUILD) ; $(F90) $(DEBUG_F90) $(F90FLAGS) $(FCOMPILEONLY)$(OPTIONSEP)$$current_wd$(DIRSEP)$@ $$current_wd$(DIRSEP)$(basename $(notdir $<)).f
+endef
+
+define POSTPROCESS_F
+endef
+
+# Define how to do a free-format F90 compilation
define PREPROCESS_F90
-cat $< | sed 's.//.AUTOMATICALLY_GENERATED_CONCATONATION_PROTECTION_STRING.g' | $(CPP) $(CPPFLAGS) $(INC_DIRS:%=-I%) $(EXTRA_DEFINES:%=-D%) -DFCODE - | $(PERL) -p -e 's/__FORTRANFILE__/\"$(basename $(notdir $<)).F\"/g ;s.AUTOMATICALLY_GENERATED_CONCATONATION_PROTECTION_STRING.//.g' | $(PERL) $(F_FILE_PROCESSOR) > $(basename $(notdir $<)).f
+cat $< | sed 's.//.AUTOMATICALLY_GENERATED_CONCATONATION_PROTECTION_STRING.g' | $(CPP) $(CPPFLAGS) $(INC_DIRS:%=-I%) $(EXTRA_DEFINES:%=-D%) -DFCODE - | $(PERL) -p -e 's/__FORTRANFILE__/\"$(basename $(notdir $<)).F\"/g; s.AUTOMATICALLY_GENERATED_CONCATONATION_PROTECTION_STRING.//.g' - | $(PERL) -s $(F_FILE_PROCESSOR) -free_format > $(basename $(notdir $<)).f90
endef
define COMPILE_F90
-current_wd=`$(GET_WD)` ; cd $(SCRATCH_BUILD) ; $(F90) $(DEBUG_F90) $(F90FLAGS) $(FCOMPILEONLY)$(OPTIONSEP)$$current_wd$(DIRSEP)$@ $$current_wd$(DIRSEP)$(basename $(notdir $<)).f
+current_wd=`$(GET_WD)` ; cd $(SCRATCH_BUILD) ; $(F90) $(DEBUG_F90) $(F90FLAGS) $(FCOMPILEONLY)$(OPTIONSEP)$$current_wd$(DIRSEP)$@ $$current_wd$(DIRSEP)$(basename $(notdir $<)).f90
endef
define POSTPROCESS_F90
endef
+# Define how to do a f77 compilation
+define PREPROCESS_f77
+cat $< > $(basename $(notdir $<)).f
+endef
+
# Define how to do a f compilation
define PREPROCESS_f
cat $< > $(basename $(notdir $<)).f
endef
-
-# Define how to do a f77 compilation
-define PREPROCESS_f77
-cat $< > $(basename $(notdir $<)).f
+# Define how to do a f90 compilation
+define PREPROCESS_f90
+cat $< > $(basename $(notdir $<)).f90
endef
@@ -129,7 +150,6 @@ endef
@echo Postprocessing $<
$(POSTPROCESS_C)
-
%.c.d: $(SRCDIR)/%.c
$(C_DEPENDENCIES)
@@ -212,26 +232,25 @@ endef
%.f77.d: $(SRCDIR)/%.f77
$(F77_DEPENDENCIES)
-
# Build rules for F90
%.F.o: $(SRCDIR)/%.F
@echo $(DIVIDER)
@echo Preprocessing $<
- $(PREPROCESS_F90)
+ $(PREPROCESS_F)
@echo Compiling $(DEBUG_F90) $<
- $(COMPILE_F90)
+ $(COMPILE_F)
@echo Postprocessing $<
- $(POSTPROCESS_F90)
+ $(POSTPROCESS_F)
%.f.o: $(SRCDIR)/%.f
@echo $(DIVIDER)
@echo Copying $<
$(PREPROCESS_f)
@echo Compiling $(DEBUG_F90) $<
- $(COMPILE_F90)
+ $(COMPILE_F)
@echo Postprocessing $<
- $(POSTPROCESS_F90)
+ $(POSTPROCESS_F)
%.F.d: $(SRCDIR)/%.F
$(F_DEPENDENCIES)
@@ -239,3 +258,28 @@ endef
%.f.d: $(SRCDIR)/%.f
$(F_DEPENDENCIES)
+# Build rules for free-format F90
+
+%.F90.o: $(SRCDIR)/%.F90
+ @echo $(DIVIDER)
+ @echo Preprocessing $<
+ $(PREPROCESS_F90)
+ @echo Compiling $(DEBUG_F90) $<
+ $(COMPILE_F90)
+ @echo Postprocessing $<
+ $(POSTPROCESS_F90)
+
+%.f90.o: $(SRCDIR)/%.f90
+ @echo $(DIVIDER)
+ @echo Copying $<
+ $(PREPROCESS_f90)
+ @echo Compiling $(DEBUG_F90) $<
+ $(COMPILE_F90)
+ @echo Postprocessing $<
+ $(POSTPROCESS_F90)
+
+%.F90.d: $(SRCDIR)/%.F90
+ $(F90_DEPENDENCIES)
+
+%.f90.d: $(SRCDIR)/%.f90
+ $(F90_DEPENDENCIES)
diff --git a/lib/sbin/f_file_processor.pl b/lib/sbin/f_file_processor.pl
index bbabbd2d..253ed5a9 100644
--- a/lib/sbin/f_file_processor.pl
+++ b/lib/sbin/f_file_processor.pl
@@ -1,83 +1,210 @@
-#!/usr/my/bin/perl
+#!/usr/bin/perl -s
+#/*@@
+# @file f_file_processor.pl
+# @date Jan 22 1995
+# @author Paul Walker
+# @desc
+# Postprocessor for Fortran files.
+#
+# Reads STDIN, writes to STDOUT.
#
-# Version: $Id$
-#
-# New BreakLines routine which is much cleaner
-#
-# Reads STDIN, writes to STDOUT.
-#
-# removes all comments
-# replaces && with newline and tab to col 7
-# replaces &! with newline at col 0
-# Breaks lines greater than 72 cols
-# Does this using multi-line matching!
-#
-# Paul, Jan 22 1995
-# Joan, Apr 21 1997: get rid of cC comments and handle ! comments properly
-# and fix it so now it is really 72 and we do not get
-# shitty breaks in the middle of fortran strings!
+# removes all comments
+# replaces && with newline and tab to col 7
+# replaces &! with newline at col 0
+# Breaks lines greater than 72 cols
+# Does this using multi-line matching!
+#
+# If run with -free_format, chooses free-format
+# line spleeting.
+#
+# @enddesc
+# @history
+# @hdate Wed Apr 21 1997 @hauthor Joan Masso
+# @hdesc get rid of cC comments and handle ! comments properly
+# and fix it so now it is really 72 and we do not get
+# breaks in the middle of fortran strings!
+# @hdate Wed Nov 24 12:17:43 1999 @hauthor Tom Goodale
+# @hdesc Added in Erik Schnetters free-format stuff
+# grdoc-ed
+# reformated as per rest of perl code in Cactus.
+# @endhistory
+# @version $Header$
+#@@*/
-$* = 1; # Multi-line is on!
+$* = 1; # Multi-line is on!
-while (<>) {
- next if (/^\s*$/); # Blanks slow down compilation, and cpp makes
- # lots and lots of them!
+# Pick the correct set of comments to remove.
+if ($free_format)
+{
+ $standard_comments = "[!]";
+}
+else
+{
+ $standard_comments = "[cC!]";
+}
- next if (/^\#/); # Remove any remaining # directives (e.g. line directives).
+# Loop over all lines.
+while (<>)
+{
+ next if (/^\s*$/); # Blanks slow down compilation, and cpp makes
+ # lots and lots of them!
+ next if (/^\#/); # Remove any remaining # directives (e.g. line directives).
- # Get rid of final \n
- chop;
+ # Get rid of final \n
+ chomp;
- # Get rid of any tabs
- s/\t/ /g;
-
- # Get rid of standard c C, or even ! comments
- s/^[cC!].*$/\n/g;
+ # Get rid of any tabs
+ s/\t/ /g;
+
+ # Get rid of standard c C, or even ! comments
+ s/^$standard_comments.*$/\n/g;
- # Get rid of ! comments : a bit tricky as ! may appear inside strings
- s/(.)![^'"]*$/\1\n/g;
-
- # OK, now put in the line breaks (&& or &!)
- s/\&\&\s*/\n /g;
- s/\&\!\s*/\n/g;
-
- # Get rid of lonesome semicolons
- s/\s*\;\s*$//;
-
- # And now we can fix the lines. This is actually a little complicated.
- # since there is a different case if the thing matches a newline
- # than if it doesn't.
- if (/\n/) {
- foreach $LINE (split('\n',$_)) {
- &splitline($LINE);
- }
- } else {
- &splitline($_);
+ # Get rid of ! comments : a bit tricky as ! may appear inside strings
+ s/(.)![^'"]*$/\1\n/g;
+
+ # OK, now put in the line breaks (&& or &!)
+ s/\&\&\s*/\n /g;
+ s/\&\!\s*/\n/g;
+
+ # Get rid of lonesome semicolons
+ s/\s*\;\s*$//;
+
+ # And now we can fix the lines. This is actually a little complicated.
+ # since there is a different case if the thing matches a newline
+ # than if it doesn't.
+ if (/\n/)
+ {
+ foreach $LINE (split('\n',$_))
+ {
+ &splitline($LINE);
}
+ }
+ else
+ {
+ &splitline($_);
+ }
+}
+
+#/*@@
+# @routine splitline
+# @date Wed Nov 24 12:14:55 1999
+# @author Tom Goodale
+# @desc
+# Chooses the correct routine to split lines.
+# @enddesc
+# @calls
+# @calledby
+# @history
+#
+# @endhistory
+#
+#@@*/
+sub splitline
+{
+ my ($line) = @_;
+
+ if($free_format)
+ {
+ &free_format_splitline($line);
+ }
+ else
+ {
+ &fixed_format_splitline($line);
+ }
+
}
-sub
-splitline
+#/*@@
+# @routine fixed_format_splitline
+# @date 1995
+# @author Paul Walker
+# @desc
+# Splits lines for F77 or fixed-format F90
+# @enddesc
+# @calls
+# @calledby
+# @history
+#
+# @endhistory
+#
+#@@*/
+sub fixed_format_splitline
{
- my ($LINE) = @_;
- # Remove ,, and , \) from blank thorns
- while ($LINE =~ s/,\s*,/,/) {}
- $LINE =~ s/,\s*\)/\)/;
-
- # Strip out leading spaces in favor of 7 spaces
- # $LINE =~ s/^\s+/ /;
- # Note the new treatement of comments with \S
- if ($LINE =~ /^([^\S].{71,71}).*/) {
- print "$1\n";
- $LINE =~ s/.{72,72}//;
- while ($LINE =~ /^(.{66,66}).*/) {
- print " &$1\n";
- $LINE =~ s/.{66,66}//;
- }
- print " &$LINE\n";
- } else {
- print "$LINE\n";
+ my ($LINE) = @_;
+
+ # Remove ,, and , \) from blank thorns
+ while ($LINE =~ s/,\s*,/,/) {};
+ $LINE =~ s/,\s*\)/\)/;
+
+ # Strip out leading spaces in favor of 7 spaces
+ # $LINE =~ s/^\s+/ /;
+ # Note the new treatement of comments with \S
+ if ($LINE =~ /^([^\S].{71,71}).*/)
+ {
+ print "$1\n";
+ $LINE =~ s/.{72,72}//;
+ while ($LINE =~ /^(.{66,66}).*/)
+ {
+ print " &$1\n";
+ $LINE =~ s/.{66,66}//;
}
+ print " &$LINE\n";
+ }
+ else
+ {
+ print "$LINE\n";
+ }
}
+
+#/*@@
+# @routine free_format_splitline
+# @date Thu Sep 30 12:05:36 1999
+# @author Erik Schnetter
+# @desc
+# Splits lines for freeformat fortran 90.
+# @enddesc
+# @calls
+# @calledby
+# @history
+#
+# @endhistory
+#
+#@@*/
+sub free_format_splitline
+{
+ my ($LINE) = @_;
+ my $OUT;
+
+ # Remove ,, and , \) from blank thorns
+ while ($LINE =~ s/,\s*,/,/) {};
+ $LINE =~ s/,\s*\)/\)/;
+
+ # Strip out leading spaces in favor of 3 spaces
+ # $LINE =~ s/^\s+/ /;
+ if ($LINE =~ /^(.{78,78})...*/) {
+ $OUT = $1;
+ print "$OUT";
+ # Check if the line already has a continuation mark.
+ print "&" if (! ($OUT =~ /\&[\s]*$/));
+ print "\n";
+ $LINE =~ s/.{78,78}//;
+ while ($LINE =~ /^(.{74,74}).*/)
+ {
+ $OUT = $1;
+ print "&" if (! ($OUT =~ /^[\s]*\&/));
+ print "$OUT";
+ print "&" if (! ($OUT =~ /\&[\s]*$/));
+ print "\n";
+ $LINE =~ s/.{74,74}//;
+ }
+ print "&" if (! ($LINE =~ /^[\s]*\&/));
+ print "$LINE\n";
+ }
+ else
+ {
+ print "$LINE\n";
+ }
+
+}