agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/languages/fortran/SKILL.md

fortran

Skill15 starsChanged 2 months agoMITView on GitHub

Expert modern Fortran (Fortran 90/2008/2018) assistance covering array operations, OpenMP, and numerical libraries. Use when writing scientific simulations, physics calculations, or high-performance linear algebra.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use Fortran's native array syntax for automatic vectorization:

    line 98
  2. Very specific:

    Always Declare implicit none: Eliminate dangerous legacy implicit typing by placing implicit none at the top of every module.

    line 119
  3. Very specific:

    Use Modern Fortran Standards (2008/2018/2023): Avoid obsolete fixed-format Fortran 77.

    line 120
  4. Very specific:

    Use intent(in), intent(out), and intent(inout): Explicitly document and enforce parameter passing semantics.

    line 122
  5. Very specific:

    Use common blocks (COMMON) or equivalence (EQUIVALENCE): Replace legacy shared memory with modern modules.

    line 126
  6. Very specific:

    Use fixed-form (column 7) syntax: Modern Fortran files should use .f90, .f08, or .f18 extensions with free-format layout.

    line 127

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Fortran

Modern Fortran is a high-performance compiled language engineered for numerical analysis, computational fluid dynamics, climate modeling, and large-scale parallel scientific computing (MPI/OpenMP).

When to Use

  • High-Performance Numerical & Scientific Computing: Weather forecasting, computational fluid dynamics (CFD), and physics simulations.
  • Supercomputing & HPC Clusters (MPI / OpenMP): Running petascale simulation workloads across thousands of distributed GPU/CPU nodes.
  • Linear Algebra BLAS/LAPACK Libraries: Maximizing raw floating-point computation speed on multidimensional matrix operations.
  • Legacy Aerospace & Nuclear Engineering: Maintaining and extending battle-tested mathematical modeling libraries.

Quick Start

program main
    implicit none
    integer, parameter :: dp = kind(1.0d0)
    real(dp) :: x = 2.0_dp, y = 3.0_dp, z

    z = x ** y
    print *, "Result of 2^3 is:", z
end program main

Core Concepts

Array Slicing & Pure Mathematical Syntax

Fortran treats multi-dimensional arrays as first-class primitives with native vector slicing:

program matrix_ops
  implicit none
  real, dimension(3, 3) :: A, B, C

  ! Initialize array
  A = 2.0
  B = 3.0

  ! Element-wise matrix multiplication in single line
  C = A * B + 1.0

  print *, "Result Matrix (1,1):", C(1, 1)
end program matrix_ops

Modern Fortran Modules (Fortran 2018/2023)

Encapsulates data, interfaces, and subroutines cleanly:

module physics_engine
  implicit none
  private
  public :: calculate_kinetic_energy

contains

  pure function calculate_kinetic_energy(mass, velocity) result(energy)
    real, intent(in) :: mass, velocity
    real :: energy
    energy = 0.5 * mass * (velocity ** 2)
  end function calculate_kinetic_energy

end module physics_engine

Coarray Parallelism for High-Performance Computing (HPC)

Built-in SPMD (Single Program, Multiple Data) parallel syntax without external MPI library calls:

program coarray_demo
  implicit none
  integer :: val[*]

  val = this_image() ! Each parallel CPU core assigns its own image ID
  sync all

  if (this_image() == 1) then
    print *, "Image 1 read from Image 2:", val[2]
  end if
end program coarray_demo

Common Patterns

Vectorized Array Operations and Slicing

Problem: Writing nested DO loops for large matrix calculations is slow and error-prone.

Solution: Use Fortran's native array syntax for automatic vectorization:

program matrix_math
    implicit none
    real, dimension(100, 100) :: A, B, C

    call random_number(A)
    call random_number(B)

    ! Array-level element-wise operation (vectorized)
    C = A * B + sin(A)

    print *, "Sum of C matrix:", sum(C)
end program matrix_math

Best Practices

Do:

  • Always Declare implicit none: Eliminate dangerous legacy implicit typing by placing implicit none at the top of every module.
  • Use Modern Fortran Standards (2008/2018/2023): Avoid obsolete fixed-format Fortran 77; write clean free-format code.
  • Mark Side-Effect-Free Functions as pure: Enable aggressive compiler parallelization and optimization.
  • Use intent(in), intent(out), and intent(inout): Explicitly document and enforce parameter passing semantics.

Don't:

  • Use common blocks (COMMON) or equivalence (EQUIVALENCE): Replace legacy shared memory with modern modules.
  • Use fixed-form (column 7) syntax: Modern Fortran files should use .f90, .f08, or .f18 extensions with free-format layout.
  • Ignore array bounds checking during development: Compile with -fcheck=all -Wall during debugging.

Troubleshooting

ErrorCauseSolution
Segmentation fault in array operationOut of bounds array indexing or stack exhaustion from large local arrays.Allocate large arrays on the heap using allocatable and compile with -fcheck=bounds.
Type mismatch in argument '...'Passing default real/integer to function expecting double precision.Specify explicit precision kind (e.g. 1.0_dp) on literals.
implicit none error: symbol has no IMPLICIT typeUndeclared variable used in program unit.Declare all variables explicitly with type and kind parameters.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.