From 48241b292362885d9f096c3e15868ff15ca67ce5 Mon Sep 17 00:00:00 2001 From: hinder Date: Mon, 11 Apr 2011 20:46:57 +0000 Subject: f_file_processor.pl: Fix handling of continuation lines with OpenMP OpenMP requires continuation lines in Fortran 90 (and possibly Fortran 77 as well though I have not checked that) to start with the OMP sentinel (https://computing.llnl.gov/tutorials/openMP/#Directives). This patch ensures that a sentinel OMP or HPF is repeated when a line starting with that sentinel is broken to limit its length to 132 characters. It also adds a case-insensitive flag to the check for "!" like comments and adds extra backslashes to the standard_comments regex to properly match $OMP after all metacharacters have been handled. Tested with LoopControl's Fortran interface on gcc 4.5,Intel 11.1 and PGI. (Patch by Roland Haas) git-svn-id: http://svn.cactuscode.org/flesh/trunk@4697 17b73243-c579-4c4c-a9d2-2d5706c11dac --- lib/sbin/f_file_processor.pl | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/sbin/f_file_processor.pl b/lib/sbin/f_file_processor.pl index f65082a0..437fbcd7 100644 --- a/lib/sbin/f_file_processor.pl +++ b/lib/sbin/f_file_processor.pl @@ -33,11 +33,11 @@ $line_directives = $line_directives eq 'yes'; # Pick the correct set of comments to remove. if ($free_format) { - $standard_comments = "^\\s*!(?!\$(omp|hpf))"; + $standard_comments = "^\\s*!(?!\\\$(omp|hpf))"; } else { - $standard_comments = "^[c!*](?!\$(omp|hpf))"; + $standard_comments = "^[c!*](?!\\\$(omp|hpf))"; } # Maximum line length for free form Fortran @@ -108,7 +108,7 @@ while (<>) # the following code by Fokke Dijkstra also checks for comments # on a line with a string # Search for possible comment - if (/!(?!\$(omp|hpf))/) + if (/!(?!\$(omp|hpf))/i) { # find all ! " and ' and check for strings or comments $string = 0; @@ -237,10 +237,17 @@ sub free_format_splitline my $maxlen1 = $max_line_length - 1; my $maxlen1i = $max_line_length - $indentation - 1; my $maxlen2i = $max_line_length - $indentation - 2; + my $sentinel = ""; if ($LINE =~ /^(.{$maxlen1,$maxlen1})../m) { $OUT = $1; + if ($OUT =~ /^\s*(!\$(omp|hpf))/mi) + { + $sentinel = $1; + $maxlen1i = $maxlen1i - length($sentinel); + $maxlen2i = $maxlen2i - length($sentinel); + } # Check if the line already has a continuation mark. $OUT = "$OUT&" if (! ($OUT =~ /\&\s*$/m)); &printline ($OUT); @@ -250,7 +257,7 @@ sub free_format_splitline { $LINE =~ /^(.{$maxlen2i,$maxlen2i})/m; $OUT = $1; - $OUT = "$indent&$OUT" if (! ($OUT =~ /^\s*\&/m)); + $OUT = "$indent$sentinel&$OUT" if (! ($OUT =~ /^\s*\&/m)); $OUT = "$OUT&" if (! ($OUT =~ /\&\s*$/m)); &printline ($OUT); $LINE =~ s/.{$maxlen2i,$maxlen2i}//m; @@ -258,16 +265,16 @@ sub free_format_splitline if ($LINE =~ /^\&\s*$/m) { - &printline ("$indent& $LINE"); + &printline ("$indent$sentinel& $LINE"); } elsif ($LINE =~ /^\s*\&\s*$/m) { - &printline ("$indent&$LINE"); + &printline ("$indent$sentinel&$LINE"); } else { $OUT = $LINE; - $OUT = "$indent&$OUT" if (! ($LINE =~ /^\s*\&/m)); + $OUT = "$indent$sentinel&$OUT" if (! ($LINE =~ /^\s*\&/m)); &printline ($OUT); } } -- cgit v1.2.3