Fortran-F90Namelist
view release on metacpan or search on metacpan
##
## End of generalities; here comes the real thing
##
@ARGV = ('-') unless(@ARGV);
my $nl = Fortran::F90Namelist->new();
foreach my $f (@ARGV) {
$nl->parse(file => $f, merge => 1)
or die "Couldn't parse file <$f>\n";
}
unless ($oneline) {
print <<"HERE";
;
; param.pro
;
; Set parameters from Pencil code namelist files (typically param.nml and
; param2.nml).
;
; This file is generated by nl2idl, so you will probably not want to edit
; it.
function $function
; Returns an anonymous structure with all slots set from the namelist
; data in @ARGV.
COMPILE_OPT HIDDEN
HERE
}
print $nl->output(format => 'idl',
name => 'par',
trim => $minimize,
oneline => $oneline,
maxslots => $maxtags,
double => $double);
unless ($oneline) {
print "\n return, par\n\nend\n";
} else {
print "\n";
}
# ---------------------------------------------------------------------- #
sub printopts {
# Print command line options
my $optsref = shift;
my %opts = %$optsref;
foreach my $opt (keys(%opts)) {
print STDERR "\$opts{$opt} = `$opts{$opt}'\n";
}
}
# ---------------------------------------------------------------------- #
sub usage {
# Extract description and usage information from this file's header.
my $thisfile = __FILE__;
local $/ = ''; # Read paragraphs
open(FILE, "<$thisfile") or die "Cannot open $thisfile\n";
while (<FILE>) {
# Paragraph _must_ contain `Description:' or `Usage:'
next unless /^\s*\#\s*(Description|Usage):/m;
# Drop `Author:', etc. (anything before `Description:' or `Usage:')
s/.*?\n(\s*\#\s*(Description|Usage):\s*\n.*)/$1/s;
# Don't print comment sign:
s/^\s*# ?//mg;
last; # ignore body
}
$_ or "<No usage information found>\n";
}
# ---------------------------------------------------------------------- #
sub version {
# Return CVS data and version info.
my $doll='\$'; # Need this to trick CVS
my $cmdname = (split('/', $0))[-1];
my $rev = '$Revision: 1.2 $';
my $date = '$Date: 2005/11/21 20:01:15 $';
$rev =~ s/${doll}Revision:\s*(\S+).*/$1/;
$date =~ s/${doll}Date:\s*(\S+).*/$1/;
"$cmdname version $rev ($date)\n";
}
# ---------------------------------------------------------------------- #
# End of file nl2idl
( run in 2.335 seconds using v1.01-cache-2.11-cpan-b301d465b3d )