FORTRAN 704 for VS Code

Edit a fixed-form FORTRAN 704 deck with syntax highlighting and snippets. Run the active file with F5, or use FORTRAN 704: Run current file in the Command Palette or the editor context menu. The command starts fortran704 as a VS Code task in the integrated terminal. Hollerith highlighting marks the count-and-H introducer; payload boundaries are not inferred by the grammar.

Install

The extension is supplied as source. From the repository root, open a VS Code Extension Development Host with this folder loaded:

code --extensionDevelopmentPath="$PWD/editors/vscode" .

Open tests/hello.f in that window, configure the executable below, then press F5. The extension is not published to the Marketplace and has no packaged VSIX. To run its command and grammar tests from the repository root:

node --test editors/vscode/tests/*.test.js

VS Code 1.75 or later is required. .f and .for files are associated with FORTRAN 704. Use Change Language Mode if another Fortran extension owns the file association.

A comment is a C or c in column 1. The statement text starts in column 7. Column 6 is the continuation column. The grammar follows that card, not free-form Fortran.

Set up the executable

Build fortran704 at the root of this repository (make). For a checkout opened as the workspace:

{
  "fortran704.compilerPath": "./fortran704",
  "fortran704.std": 2
}

fortran704.std is 0, 1, or 2. The task passes it as --std=N. A relative compiler path is resolved from the workspace folder that holds the source file. A bare name is looked up on PATH.

Running

  • Save new documents to disk before running. The command waits for a dirty file to save and stops if the save fails or is cancelled.

  • The task starts in the source file’s directory. In a multi-root workspace, settings come from the folder that contains the file. A file outside a workspace also runs.

  • F5 focuses the terminal. It does not start a debugger.

  • In Restricted Mode, highlighting and snippets remain available. Running a program requires Workspace Trust. A virtual document cannot be run.

Paths are passed literally. Do not put shell quotes, ~, environment variables, or ${workspaceFolder} in the settings.