This repository provides a comprehensive, hands-on learning path for scientists and engineers transitioning to Modern Fortran programming. It addresses the common challenge of learning Fortran through practical, executable examples that demonstrate real-world scientific computing concepts. The repository combines structured documentation with minimal, runnable code examples to create an effective learning environment that bridges theory and practice.
Fortran remains strategically important because it delivers unmatched performance and reliability for large-scale numerical computing. Its array-centric semantics, predictable memory model, and decades of compiler optimization yield superior vectorization and parallel efficiency (OpenMP, MPI, coarrays) with clear, maintainable code. The language is portable across supercomputers and platforms, backed by stable standards and mature toolchains. Modern Fortran adds modules, generics, allocatable arrays, and ISO C/Python interoperability, enabling teams to extend high-value legacy solvers while building new HPC components without performance regressions. For scientists and engineers, proficiency in Fortran unlocks a vast ecosystem of validated algorithms, ensures performance portability, and reduces total cost of ownership for mission-critical simulations—making it a prudent, forward-looking skill.
Our research demonstrates Fortran's power in solving complex optics problems, as evidenced by our comprehensive studies on Second Harmonic Generation (SHG) thermal effects, detailed in our articles and computational models available at the Second-Harmonic-Generation organization.
This tutorial is designed for:
- Scientists and Engineers: Researchers who need to work with legacy Fortran code or develop new scientific applications
- Graduate Students: Those pursuing degrees in physics, engineering, mathematics, or computational sciences
- Software Developers: Professionals transitioning from other languages to Fortran for high-performance computing
- Computational Researchers: Individuals working with numerical simulations, data analysis, or scientific modeling
By completing this tutorial, you will gain:
- Modern Fortran Fundamentals: Understanding of Fortran syntax and best practices
- Scientific Computing Skills: Practical experience with variables, arrays, loops, and file I/O operations
- Code Organization: How to structure Fortran programs for readability and maintainability
- Compiler Proficiency: Installing and working with Intel Fortran (ifort) compiler
- Best Practices: Following modern coding standards including implicit none, proper variable initialization, and clean code structure
- Basic understanding of programming concepts (variables, loops, conditionals)
- Familiarity with command-line operations
- Text editor with Fortran syntax highlighting
- Recommended starting point: Begin with the coding template tutorial and basic variable examples
- Understanding of legacy Fortran concepts
- Familiarity with compilation and execution processes
- Recommended starting point: Focus on the modern coding standards and template sections
- Basic computer literacy and file system navigation
- Willingness to learn command-line operations
- Recommended starting point: Start with the installation guide, then proceed through the tutorials in numerical order
- Additional resources: Consider basic programming tutorials if needed before diving into Fortran-specific concepts
Folder PATH listing
+---compiler installation <-- Intel Fortran compiler setup guide
│ ifort_Installation… <-- Detailed installation instructions
│
+---docs <-- Comprehensive tutorial documentation
│ 1_FORTRAN_Main-Com… <-- Essential Fortran commands
│ 2_FORTRAN_Coding-T… <-- Code structure templates
│ 3_FORTRAN_Run_a_Co… <-- Compilation and execution
│
│
+---src <-- Fortran source code examples
│ 1_FORTRAN_Coding_T… <-- Basic program structure
│ 2_Write-Read-Varia… <-- Variable types and I/O
│ 3_Readable_Code_St… <-- Code organization
│ 4_do-loop.f90 <-- Repetition structures
│ 5_If-then-else.f90 <-- Conditional statements
│ 6_open-file.f90 <-- File I/O operations
│ 7_Array.f90 <-- Array manipulation
│ Readme.md <-- Source code documentation
│
│ .gitignore <-- Git exclusions
│ LICENSE <-- License information
│ README.md <-- Project overview and documentation
- Operating System: Linux (Ubuntu 18.04+ recommended) or WSL2 on Windows
- Architecture: x86_64 (Intel/AMD 64-bit processors)
- Memory: Minimum 2GB RAM (4GB+ recommended for large computations)
- Storage: At least 10GB free space for Intel OneAPI installation
- Intel Fortran Compiler (ifort): Primary compiler for this tutorial
- Intel OneAPI Base Toolkit (2023.1.0 or later)
- Intel OneAPI HPC Toolkit (2023.1.0 or later)
- Git: Version control and repository management
- ZSH Shell: Enhanced shell with Oh My Zsh framework
- Text Editor: VS Code, Cursor, or any editor with Fortran syntax highlighting
- Terminal: Command-line interface for compilation and execution
- VS Code Extensions: Fortran language support, Intel OneAPI toolkit
- Terminal Configuration: ZSH with Oh My Zsh for enhanced productivity
- File Permissions: Ensure proper read/write permissions for source files
- Clone the Repository
git clone https://github.com/Max-Ghadri/Fortran-for-Science.git
cd Fortran-for-Science-
Install Intel Fortran Compiler Follow the detailed installation guide:
compiler installation/ifort_Installation-Guide.md -
Set Up Development Environment
- Open the project in Cursor/VS Code
- Navigate to the
src/directory to access Fortran source files - Review the documentation in the
docs/directory for learning materials
- Start Learning
- Read the tutorials in order:
docs/1_FORTRAN_Main-Commands_Tutorial.md- Essential Fortran commands and syntaxdocs/2_FORTRAN_Coding-Template_Tutorial.md- Code structure templates and best practicesdocs/3_FORTRAN_Run_a_Code_Tutorial.md- Compilation and execution guide
- Practice with examples in the
src/directory (seesrc/Readme.mdfor descriptions)
- Compile and Run
cd src/
ifort -o program_name program_name.f90
./program_name- Explore and Practice
- Work through examples in numerical order
- Modify examples to experiment with different concepts
- Use the coding template as a starting point for new programs
- Permission Denied: Use
sudofor installation commands - Environment Variables: Ensure Intel OneAPI paths are properly set
- Shell Configuration: Restart terminal after modifying
.zshrc
- Syntax Errors: Check Fortran syntax against documentation
- Missing Dependencies: Verify all required libraries are installed
- Memory Issues: Reduce array sizes or use dynamic allocation
- Segmentation Fault: Check array bounds and uninitialized variables
- File I/O Errors: Verify file permissions and paths
- Performance Issues: Use compiler optimization flags
- Documentation: Refer to
docs/directory for detailed explanations - Source Comments: Read inline comments in example files
After completing the basic setup:
- Master the Coding Template: Understand the 11-step structure
- Practice with Real Examples: Work through the scientific computing example
- Explore Advanced Topics: Arrays, file I/O, and optimization
- Build Your Own Projects: Apply learned concepts to your research
- Contribute: Share improvements and new examples with the community
Note: This tutorial is optimized for Linux environments. Windows users should use WSL2 for the best experience with Intel Fortran compiler and scientific computing workflows.
For questions not addressed in the resources above, please connect with Mostafa Rezaee on LinkedIn for personalized assistance.
