Rule
0 installs · 0 said it worked
Cursor rules for writing modern Fortran scientific code
Cursor rules guiding modern Fortran code: explicit module interfaces, kind parameters, intent on arguments, allocatable memory practices, and numerical testing.
People use this for
- fortran scientific code rules
- modern fortran coding guidelines
- fortran kind parameters module
- cursor rules fortran numerical code
- write fortran code with explicit interfaces
- Name
cursor-rules-for-writing-modern-fortran-scientific-code- Works with
- Cursor
- License
- CC0(as observed at the source)
- Version
- v1 · updated Nov 29, 2026
Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.
Are you the author?Claim this profileRequest removal
Use this rule
$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/cursor-rules-for-writing-modern-fortran-scientific-code-39ws/export/mdc" -o .cursor/rules/cursor-rules-for-writing-modern-fortran-scientific-code.mdcThen open a new session; Cursor picks it up from .cursor/rules/.
Manual install
Save cursor-rules-for-writing-modern-fortran-scientific-code.mdc as .cursor/rules/cursor-rules-for-writing-modern-fortran-scientific-code.mdc for this project or ~/.cursor/rules/cursor-rules-for-writing-modern-fortran-scientific-code.mdc for every project, then start a new session.
Rule
description: Modern Fortran rules for scientific computing, modules, explicit interfaces, kind parameters, memory safety, and testing globs: ["/*.f", "/.f90", "**/.f95", "/*.f03", "/.f08", "**/.for", "**/.ftn", "CMakeLists.txt", ".cmake", "Makefile"] alwaysApply: false
Fortran Programming Guidelines
Basic Principles
- Use modern Fortran standards such as Fortran 2003, 2008, or newer.
- Use
implicit nonein every program unit. - Put procedures in modules to provide explicit interfaces.
- Keep modules focused and place each major module in its own file.
- Prefer clear, structured code over clever language tricks.
- Avoid obsolete features such as COMMON blocks, GOTO-heavy control flow, and numeric labels.
Kinds and Types
- Define numeric kind parameters in one shared module, such as
kind_mod. - Use
real(kind=dp)or the project-approved real kind for floating point values. - Use
integer(kind=i4)or the project-approved integer kind for integer values. - Define constants such as pi explicitly.
- Include units in comments for physical quantities.
- Use derived types to group related data instead of passing many primitive arguments.
Naming and Style
- Use lowercase for language keywords and most identifiers.
- Use underscores for multi-word names.
- Avoid names that differ only by case.
- Use descriptive names for procedures and state.
- Repeat the procedure or module name after
endstatements. - Keep indentation consistent in
do,if,select case, and module blocks.
Procedures
- Keep subroutines and functions short and single-purpose.
- Use
intent(in),intent(out), orintent(inout)for every dummy argument. - Keep functions free of side effects whenever possible.
- Prefer early validation and clear returns over deep nesting.
- Use
use, only:when importing from modules.
Memory and Arrays
- Prefer allocatable arrays over pointers unless pointer semantics are required.
- Check allocation state and array sizes before use.
- Deallocate allocatable arrays when their lifetime is not naturally scoped.
- Specify array bounds clearly when they matter.
- Avoid unnecessary dynamic allocation in hot loops.
Testing and Build
- Use CMake, fpm, Make, or the project-standard build system consistently.
- Compile with warnings enabled and treat important warnings as failures in CI.
- Add unit tests for public procedures and integration tests for numerical workflows.
- Test boundary conditions, invalid inputs, and representative scientific cases.
- Verify numerical tolerances explicitly rather than relying on exact floating point equality.
Common Mistakes
- Do not declare variables after executable code unless using a block construct.
- Do not assume
random_numberis a function; it is a subroutine. - Do not write to stdout from pure procedures.
- Do not declare the same variable twice in the same scope.
- Do not assume pi, dp, or project kinds already exist without importing or defining them.
No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.
Tried it
Reports from people who added this rule to their editor. They roll up into the badges above.
No one has filed a report yet. Try the prompt and be the first.
Related rules
- Agent that writes, runs, and repairs tests after code changes
A system prompt defining a test-writer-fixer agent that writes unit, integration, and end-to-end tests, runs suites, analyzes failures, and repairs tests without weakening them.
Coding · @ersinyilmaz
- Cursor rules for writing and testing Xian smart contracts in Python
A Cursor rules file that guides the assistant through writing Xian blockchain smart contracts in Python, covering naming, state, context variables, events, error handling, and unittest-based testing with security checks.
Coding · @patrickjs
- Quality engineering agent role for risk-based test strategy and CI quality gates
A senior quality engineering role prompt that guides an assistant through risk-based test strategy, test automation architecture, CI/CD quality gates, edge-case analysis, and defect management, writing results to a TODO checklist file.
Coding · @wkaandemir
- Cursor rules enforcing clean, readable, maintainable code practices
A Cursor .mdc rule file that guides the assistant toward clean code: named constants, meaningful names, sparing comments, single-purpose functions, DRY, language style standards, extracted conditionals, continuous refactoring, and version control.
Coding · @patrickjs
- Python docstring coverage and drift checker for code review
A skill-style system prompt that makes the assistant measure Python docstring coverage via AST analysis, flag stale or missing docstrings, and plan a CI-gated documentation fix.
Coding · @f
License: CC0v1 · published Nov 29, 2026
Comments
No comments yet. If you tried this prompt, say how it went.