# Getting started ## Build A POSIX host, GCC or Clang with C11 and `__int128`, and Make are required. The tests use Python 3.12+. Run these commands from the repository root: ```sh make ./fortran704 tests/hello.f ``` The default compiler is GCC. To use Clang, add `CC=clang` to each Make command, including `make CC=clang test` and `make CC=clang test-oracle-strict`. Run `make clean` before changing compilers in an existing checkout. The output is `HELLO, WORLD`, preceded by a printer-control blank. `STOP 0` is written separately to standard error. ## Write a card deck Keep the six leading spaces on statements. A label occupies columns 1-5; column 6 is blank for a new statement, and the statement occupies columns 7-72. A `C` in column 1 starts a comment. ```fortran C A SMALL FORTRAN II PROGRAM A=1.25 PRINT 10,A 10 FORMAT(1H ,F6.2) STOP END ``` Save this as `example.f`, then run `./fortran704 example.f`. It prints `1.25`. The default is FORTRAN II. Choose `--std=1` for FORTRAN I or `--std=0` for the 1954 proposal. Each mode has its own accepted syntax and storage rules; consult [FORTRAN II](../dialect/fortran2.md), [FORTRAN I](../dialect/fortran1.md) or [FORTRAN 0](../dialect/fortran0-deviations.md). Card input comes from standard input, independently of source: ```sh ./fortran704 tests/read.f < tests/read.in ``` `--ss=UUUUUU` sets the six sense switches; use `D` for a down switch. See [debugging and media](debug-media.md) for scripted stops and persistent tape/drum state, or [SAP/BSS](sap-bss.md) for object subprograms. ## Jupyter Build the executable first, then install the kernel into a Python 3.12+ environment: ```sh python3 -m venv .venv . .venv/bin/activate python3 -m pip install -e . jupyterlab fortran704kernel-install --sys-prefix jupyter lab ``` Select **FORTRAN 704**. A cell containing `END` runs as a standalone program; it does not append earlier cells. Other source cells accumulate cards. To finish an accumulated deck, put its remaining cards in a cell with `%run` and omit `END`; the kernel supplies the terminator. For example, enter this first cell: ```fortran I=4 ``` Then run the accumulated deck from a second cell: ```text PRINT 1,I 1 FORMAT(1H ,I4) STOP %run ``` Cards stay in the deck after `%run`. To rerun it unchanged, use `%run` alone. `%new` clears the cards, `%list` shows them, and `%reset` also restores the dialect and sense switches and clears pending input. `%std 0|1|2` and `%ss UUUUUU` persist for the session. Magics start with `%` in column 1; a `%` in column 6 remains a continuation marker. `%deck` starts card input and `%enddeck` ends it. A card `READ` without a supplied deck prompts for input when the notebook frontend permits it. Use `%deck` when prompts are unavailable. Source cards and input decks use ASCII. `%timeout SECONDS` sets a run limit from 1 to 86400 seconds (30 by default). `FORTRAN704_TIMEOUT` sets the initial value when the kernel starts; an invalid value stops startup with an error. The kernel captures at most 1 MiB of raw bytes from each child output pipe per run. Exceeding that limit terminates the child and reports `OutputLimitError`. The kernel's own status and error messages are separate from this limit. Captured output is retained on both output-limit and timeout errors. Time spent answering the synchronous `READ` prompt is excluded. EOF at a prompt closes stdin and resumes the run timer. An interrupt terminates the child and reports `KeyboardInterrupt`. An input-channel failure reports `OSError` and terminates the child. The prompt uses an idle-output heuristic because the batch executable has no input-request protocol. Each run starts a new process, so variables do not persist between runs. The installer records an existing in-tree executable in `kernel.json` under `env.FORTRAN704`. To use an external binary, find that file with `jupyter kernelspec list` and set `env.FORTRAN704` to its absolute path. That field overrides the shell's `FORTRAN704`; the shell value is used only when the field is absent. Reinstall the kernel specification if you move the tree. ## VS Code The [extension guide](../editors/vscode/README.md) covers fixed-form highlighting, snippets and the run command. It is a source extension; there is no Marketplace release. Running a deck requires a trusted workspace and a local executable. ## Verify a build ```sh make test make test-oracle make test-oracle-strict ``` These checks use captured reference outputs and work offline. Rebuilding the original-compiler captures is a separate, optional procedure in the [corpus guide](../tests/oracle/README.md).