Moving code to individual subroutines
Moving the existing code to within individual subroutines. No
change in functionality (just moving code around).
#!/usr/bin/perl
use strict;
-my $rundir = shift;
-
+# Remove duplicate decomposition files in "dirname"
+sub rem_dup_decomp_files
+{
+ my($dirname) = @_;
# Find files in current directory that are
# named *piodecomp* - these are the pio
# decomposition files
-opendir(F,$rundir);
+ opendir(F,$dirname);
my @decompfiles = grep(/^piodecomp/,readdir(F));
closedir(F);
my $rmfile=0;
@@ -43,9 +45,14 @@ for(my $i=0; $i< $#decompfiles; $i++){
}
}
}
+}
+# Decode the stack traces in the pio decomposition files
+sub decode_stack_traces
+{
+ my($dirname) = @_;
# Decode/Translate the stack trace for CESM runs
-opendir(F,$rundir);
+ opendir(F,$dirname);
my @decompfiles = grep(/^piodecomp/,readdir(F));
closedir(F);
for(my $i=0; $i<= $#decompfiles; $i++){
@@ -68,4 +75,11 @@ for(my $i=0; $i<= $#decompfiles; $i++){
}
close(F1);
}
+}
+
+# Main program
+my $rundir = shift;
+&rem_dup_decomp_files($rundir);
+&decode_stack_traces($rundir);
+
