Hello, World
program hello
print *, "Hello, World!"
end program helloTap Run to execute
main.f90 · output appears here
Press Run to execute
Output streams here as your program runs.
Fortran is one of the oldest high-level programming languages, originally created for numerical and scientific computing, and it remains a mainstay of high-performance and engineering codes. It offers native multidimensional arrays, strong support for floating-point math, and modern features from array slicing to modules and procedures. CompileBytes compiles Fortran with gfortran, the GNU Fortran compiler; the reported version 10.2.0 reflects the GCC toolchain.
Modern Fortran (Fortran 90 and later) replaced fixed-form punched-card layout with free-form source, modules for encapsulation, and powerful array operations that let you express whole-array computations concisely. Programs begin with a program block and end with end program. Thanks to mature optimizing compilers and decades of tuned numerical libraries, Fortran continues to power simulations in physics, climate modeling, and computational engineering.
main.f90 is the entry point for each run.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
program hello
print *, "Hello, World!"
end program helloprogram main
implicit none
print *, square(7)
contains
integer function square(n)
integer, intent(in) :: n
square = n * n
end function square
end program mainprogram loop
implicit none
integer :: i
do i = 1, 5
print *, i, i * i
end do
end program loopprogram arrays
implicit none
integer :: a(5) = [1, 2, 3, 4, 5]
integer :: b(5)
b = a * a
print *, "squares:", b
print *, "sum:", sum(a)
end program arraysprogram grade
implicit none
integer :: score = 75
if (score >= 90) then
print *, "A"
else if (score >= 70) then
print *, "B"
else
print *, "C"
end if
end program gradeprogram readinput
implicit none
integer :: n
print *, "Enter a number:"
read *, n
print *, "Doubled:", n * 2
end program readinputprogram main
implicit none
integer :: result
call add(3, 4, result)
print *, "sum:", result
contains
subroutine add(a, b, c)
integer, intent(in) :: a, b
integer, intent(out) :: c
c = a + b
end subroutine add
end program mainprogram main
implicit none
print *, factorial(5)
contains
recursive function factorial(n) result(f)
integer, intent(in) :: n
integer :: f
if (n <= 1) then
f = 1
else
f = n * factorial(n - 1)
end if
end function factorial
end program mainprogram fmt
implicit none
real :: pi = 3.14159265
integer :: count = 42
write(*, '(A, F6.3)') "pi = ", pi
write(*, '(A, I4)') "count = ", count
end program fmtThe editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
Fortran is one of 46 single-file compiler scratchpads. Each run submits only main.f90; local sibling-file imports are not enabled.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme.
Download file exports the active Fortran source file.