XCODX |

Fortran Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Fortran

Fortran, from Formula Translation, was created by John Backus and his team at IBM in 1957 as the first widely used high-level language, built to turn mathematical formulas into fast machine code. It introduced array handling, loops, and subroutines that still shape numerical computing, and it has been modernized through Fortran 90, 2003, 2008, and 2018 with modules, dynamic arrays, coarrays for parallelism, and object-oriented features. It stays entrenched in high-performance computing: climate and weather models, computational fluid dynamics, quantum chemistry, and the LAPACK and BLAS routines that sit under much of scientific Python. On XCODX your code is compiled with gfortran (the version is shown in the badge) and run in a cloud sandbox, so you can test modern free-form Fortran without setting up a compiler. Its array-centric design lets the compiler vectorize numeric loops aggressively, which is a large part of why it stays competitive on number-crunching workloads.

Hello World in Fortran

program sum_demo
  implicit none
  integer :: i, total

  total = 0
  do i = 1, 10
     total = total + i
  end do

  print *, "Hello from Fortran!"
  print *, "Sum of 1 to 10 =", total
end program sum_demo

When to use Fortran

Fortran's strengths are first-class multidimensional arrays, mature optimizing compilers, and decades of tested numerical libraries, which make it fast for dense linear algebra and simulation. Choose it for CPU-bound scientific work - solving differential equations, physics and engineering simulations, or extending an existing HPC codebase - especially where every cycle of a tight numeric loop counts. It is a weak choice for string processing, web services, or general application code, where its text handling feels dated next to Python or C++. In this sandbox it suits practicing array operations, numeric algorithms, and the modern module syntax rather than large multi-file projects.

Common questions

How do I read input in Fortran with the READ statement?

List-directed input is the simplest form: declare your variables, then use read(*,*) x, y, where the first asterisk means standard input and the second means free-format parsing. On XCODX the program pauses at the read so you can type values into the live terminal separated by spaces or newlines, or supply them through the Stdin Box, and Ctrl+D signals end of input. The type of what you type must match the declared variable, or the run reports an error.

Can I use LAPACK, BLAS, or other Fortran libraries here?

No. The sandbox compiles a single source file with gfortran and has no package manager or network, so external libraries such as LAPACK, BLAS, or MPI are unavailable. Everything built into the language works, including array operations, math intrinsics like sqrt, sum, and matmul, and standard I/O. For library-based numerical work you would compile and link on your own machine.

What is the difference between fixed-form and free-form Fortran?

Fixed form is the old FORTRAN 77 layout with strict columns - statements start in column 7 and column 6 marks a continuation - typically in files ending .f. Free form, used by modern Fortran and files ending .f90, removes those column rules and lets you indent naturally and use longer lines. The examples here use free-form Fortran, which is what nearly all new code is written in.

Is Fortran still used in 2026?

Yes, mainly in high-performance and scientific computing. Weather forecasting, climate modeling, computational physics and chemistry, and engineering simulations run large Fortran codebases, and its numerical libraries sit beneath tools people use from other languages. It is not a general-purpose choice for apps or the web, but in its niche it stays actively developed and compiled.

Is Fortran faster than C for numerical code?

For dense array and linear-algebra work they are close, and Fortran can sometimes edge ahead because its arrays do not alias by default, which gives the optimizer more freedom to vectorize loops. C is more flexible for systems programming and pointer-heavy code. In practice the compiler, the algorithm, and memory layout matter more than the language name.

Why should I put implicit none in my Fortran program?

By historical default Fortran infers a variable's type from its first letter, so a typo can silently become a new variable and hide a bug. Writing implicit none at the top of a program or module turns that off and forces you to declare every variable, which is standard practice in modern Fortran. The example here uses it for exactly that reason.

How Fortran runs on XCODX

Sandbox filename
main.f90
Entry point
single main source file
Editor grammar
fortran
Reading stdin
read(*,*)
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

program hello
    implicit none
    print *, 'Hello from Fortran!'
    print *, 'Welcome to XCODX Online Compiler!'
end program hello