关于Fortran 90程序外部子程序文件关联结构可视化的技术咨询
Visualizing Fortran 90 Program File Dependencies
Absolutely! Figuring out the relationships between your scattered Fortran 90 subprograms doesn’t have to be a headache—there are several reliable tools and methods to visualize these connections clearly. Here are my top recommendations:
Dedicated Fortran Dependency Tools
fortran-dependency-graph: This lightweight, purpose-built tool scans your Fortran source files to pick up module uses, subroutine calls, and other inter-file dependencies. It outputs a Graphviz-compatible.dotfile, which you can convert into a readable image or PDF with Graphviz’sdotcommand. Example workflow:# Generate the dependency dot file fortran-dependency-graph -o dependencies.dot *.f90 # Convert to a PNG image dot -Tpng dependencies.dot -o dependency-graph.pngfpt(Fortran Program Translator): A more feature-rich option,fptdoesn’t just generate dependency graphs—it also offers code analysis, refactoring, and validation tools. It can produce interactive dependency visualizations or export Graphviz-formatted files, making it ideal for larger, more complex Fortran projects.
General Static Analysis + Graphviz
If you prefer a more customizable approach, you can pair general static analysis with Graphviz:
- Write a simple script (e.g., in Python) to scan your
.f90files for key patterns likeuse :: module_nameorcall subroutine_name(). Use regular expressions to extract these relationships, then output them in Graphviz’s node-edge format. This gives you full control over which dependencies you include and how the graph is structured. - Some multi-language static analyzers (like
cppcheck, with Fortran support enabled) can also parse dependency data that you can feed into Graphviz for visualization.
IDE-Integrated Solutions
For a seamless workflow during development:
- Visual Studio Code: Install a Fortran-focused extension (like Fortran IntelliSense) that includes dependency navigation features. Many of these extensions can display a tree view of module references or generate basic dependency graphs directly within the editor.
- Intel Parallel Studio: The Intel Fortran Compiler’s配套 IDE includes built-in code navigation and dependency visualization tools, perfect for quickly exploring relationships between files while you work.
Quick Tips for Better Visualizations
- Clean up your code first: Ensure consistent naming for modules and subroutines—this makes the generated graphs much easier to parse.
- Break down large projects: If your codebase is huge, generate sub-graphs for individual modules or components, then combine them to avoid an overly cluttered single graph.
内容的提问来源于stack exchange,提问作者Joseph Flores Cuba
相关产品推荐
相关产品推荐

