# Hybrid Fortran is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public License # along with Hybrid Fortran. If not, see <http://www.gnu.org/licenses/>. import pstats, sys from optparse import OptionParser from tools.commons import setupDeferredLogging from tools.filesystem import dirEntries import logging parser = OptionParser() parser.add_option("-i", "--inputDirectory", dest="inputDir", help="read files from DIR", metavar="DIR") parser.add_option("-o", "--output", dest="output", help="output combined statistics to FILENAME", metavar="FILENAME") (options, args) = parser.parse_args() setupDeferredLogging('preprocessor.log', logging.INFO) if not options.inputDir or not options.output: logging.error("please see --help on how to use this program") sys.exit(1) statFiles = dirEntries(str(options.inputDir), False, 'cprof') logging.debug("combining %s" %(str(statFiles))) statistics = pstats.Stats(*statFiles) statistics.dump_stats(options.output)
setupDeferredLogging('preprocessor.log', logging.DEBUG if options.debug else logging.INFO) if (not options.sourceDir): logging.error( "sourceDirectory option is mandatory. Use '--help' for informations on how to use this module" ) sys.exit(1) #prepare xml output doc = Document() callGraphRoot = doc.createElement("callGraph") doc.appendChild(callGraphRoot) filesInDir = dirEntries(str(options.sourceDir), True, 'h90') #first pass: loop through all h90 files (hybrid fortran 90) in the current directory # and build the basic callgraph based on subprocedures and calls. Also parse @-directives for annotations. progressIndicatorReset(sys.stderr) for fileNum, fileInDir in enumerate(filesInDir): parser = H90XMLCallGraphGenerator(doc) parser.processFile(fileInDir) logging.debug("Callgraph generated for " + fileInDir + "") printProgressIndicator(sys.stderr, fileInDir, fileNum + 1, len(filesInDir), "Callgraph parsing") #second pass: moved to generateP90Codebase.py since we need symbol analysis already if (options.pretty): sys.stdout.write(doc.toprettyxml())
parser.add_option("-p", "--pretty", action="store_true", dest="pretty", help="make xml output pretty") (options, args) = parser.parse_args() setupDeferredLogging('preprocessor.log', logging.DEBUG if options.debug else logging.INFO) if (not options.sourceDir): logging.error("sourceDirectory option is mandatory. Use '--help' for informations on how to use this module") sys.exit(1) #prepare xml output doc = Document() callGraphRoot = doc.createElement("callGraph") doc.appendChild(callGraphRoot) filesInDir = dirEntries(str(options.sourceDir), True, 'h90') #first pass: loop through all h90 files (hybrid fortran 90) in the current directory # and build the basic callgraph based on subprocedures and calls. Also parse @-directives for annotations. progressIndicatorReset(sys.stderr) for fileNum, fileInDir in enumerate(filesInDir): parser = H90XMLCallGraphGenerator(doc) parser.processFile(fileInDir) logging.debug("Callgraph generated for " + fileInDir + "") printProgressIndicator(sys.stderr, fileInDir, fileNum + 1, len(filesInDir), "Callgraph parsing") #second pass: moved to generateP90Codebase.py since we need symbol analysis already if (options.pretty): sys.stdout.write(doc.toprettyxml()) else: