Skip to main content

Online Fortran Compiler

Write Fortran, press run and read the output in seconds. Nothing to install and nothing to configure.

How it works

Free, no install, works on laptop and phone.

What is an online Fortran compiler?

An online Fortran compiler is a free tool that lets you write Fortran code in your browser and run it to see the output, with nothing to install. On Techsnap you can add input, run a program in seconds and use it on a laptop or a phone.

Updated December 2026

How to run Fortran code online

  1. Step 1

    Write your Fortran code

    Open the editor and type or paste your Fortran program. Syntax colours and indentation help you spot mistakes as you go.

  2. Step 2

    Press Run

    Your code is sent to a secure server that compiles and runs it. Add any input the program needs in the Input box first.

  3. Step 3

    Read the output

    Results and error messages appear below the editor within a few seconds. Fix, edit and run again as often as you like.

Everything you need to code in Fortran

Nothing to install

No Fortran setup, PATH or version problems. It works on a college lab PC or a phone.

Input support

Give your program input the same way a judge or exam platform does, then check the output.

Instant results

Most runs finish in a second or two, so you can try an idea and see what happens right away.

Free to start

Run code without paying. A free Techsnap account gives you more runs and saves your work.

Fortran code examples

Open the editor, paste one of these examples in and run it. Change a value and run it again to see what happens.

Hello World in Fortran

program hello
  print *, "Hello, Techsnap!"
end program hello

Variables and data types

program vars
  implicit none
  integer :: age = 21
  real :: marks = 87.5
  logical :: passed = .true.
  character(len=10) :: name = "Asha"

  print *, trim(name), age, marks, passed
end program vars

If, else if and else

program grade
  implicit none
  integer :: marks = 72

  if (marks >= 90) then
    print *, "Grade A"
  else if (marks >= 60) then
    print *, "Grade B"
  else
    print *, "Needs work"
  end if
end program grade

Do loops

program loops
  implicit none
  integer :: i, n

  do i = 1, 3
    print *, "do:", i
  end do

  n = 3
  do while (n > 0)
    print *, "while:", n
    n = n - 1
  end do
end program loops

Functions and subroutines

program funcs
  implicit none
  integer :: r

  print *, square(7)
  call add(5, 8, r)
  print *, r

contains

  integer function square(x)
    integer, intent(in) :: x
    square = x * x
  end function square

  subroutine add(a, b, total)
    integer, intent(in) :: a, b
    integer, intent(out) :: total
    total = a + b
  end subroutine add
end program funcs

Arrays

program arrays
  implicit none
  integer :: nums(5) = (/ 4, 9, 12, 15, 20 /)

  print *, "sum:", sum(nums)
  print *, "max:", maxval(nums)
  print *, "doubled:", nums * 2
end program arrays

Derived types

program types
  implicit none

  type :: student
    character(len=10) :: name
    integer :: marks
  end type student

  type(student) :: s
  s%name = "Ravi"
  s%marks = 78
  print *, trim(s%name), " scored", s%marks
end program types

Error handling with iostat

program errors
  implicit none
  integer :: value, status
  character(len=10) :: text = "twenty"

  read(text, *, iostat=status) value
  if (status /= 0) then
    print *, "Caught: not a valid number"
  else
    print *, value
  end if
end program errors

File reading and writing

program files
  implicit none
  character(len=20) :: line
  integer :: unit_id, ios

  open(newunit=unit_id, file="notes.txt", status="replace")
  write(unit_id, "(A)") "line one"
  write(unit_id, "(A)") "line two"
  close(unit_id)

  open(newunit=unit_id, file="notes.txt", status="old")
  do
    read(unit_id, "(A)", iostat=ios) line
    if (ios /= 0) exit
    print *, "read: ", trim(line)
  end do
  close(unit_id, status="delete")
end program files

Math with intrinsic functions

program maths
  implicit none
  real :: x = 2.0

  print *, "sqrt:", sqrt(x)
  print *, "power:", x ** 10
  print *, "mod:", mod(17, 5)
end program maths

How to take input in Fortran online

Fortran reads input with the read statement. read(*,*) takes values from standard input, one or more per line.

program input
  implicit none
  integer :: n, i
  integer :: nums(3), total

  read(*, *) n
  read(*, *) (nums(i), i = 1, 3)

  total = sum(nums)
  print *, "count:", n
  print *, "sum:", total
end program input

Common Fortran errors and how to fix them

Error: Symbol 'x' at (1) has no IMPLICIT type
You used a variable without declaring it. Declare every variable, and start with implicit none.
Error: Unclassifiable statement
Check the line for a typo in a keyword, a missing 'then' after an if, or a missing 'end' statement.
Fortran runtime error: End of file
The program tried to read more values than the Input box holds. Provide all the values it expects.

Who uses an online Fortran compiler

Students and learners

Practise Fortran for class assignments and exams without installing anything.

Teachers and mentors

Share a short program in a lesson and let students run and change it on their own devices.

Interview candidates

Rehearse Fortran questions in the same plain editor many online tests use.

Working developers

Check a snippet or an API behaviour in seconds without opening an IDE.

Writers and bloggers

Test code samples so the examples in your tutorials really run.

Teams

Paste a reproducible example into a ticket or chat so everyone sees the same result.

Online compiler vs local Fortran setup

Techsnap online compilerLocal setup
Setup timeNone, open the pageInstall Fortran, set PATH, pick a version
Works on any deviceYes, any modern browserOnly the machine you set up
Best forPractice, quick tests, learningLarge projects and long-running work
Extra librariesStandard library onlyAnything you can install

About Fortran

What is Fortran?

Fortran is one of the oldest programming languages and is still heavily used for numerical computing. Its name comes from Formula Translation, and it is designed to make array maths fast.

What is Fortran used for?

Weather and climate models, physics simulations, engineering analysis and supercomputing. Large legacy scientific codes are written in it and still maintained.

Fortran for beginners

Begin every program with program and implicit none, declare your variables, then use print and read. Arrays and loops are very natural in Fortran and indexing starts at 1.

Fortran vs other languages

For number crunching on arrays, Fortran compilers produce very fast code, often matching C. It is less suited to general applications, text processing or web work.

Why use an online Fortran compiler?

Setting up gfortran on Windows takes some effort. An online runner lets you compile and run a program straight away.

Fortran career opportunities

Roles exist in scientific computing, weather services, space research and national laboratories. Knowing Fortran alongside Python or C++ is valued there.

Explore more online compilers

Frequently asked questions

Is this online Fortran compiler free?

Yes. Write and run Fortran code in your browser for free, with nothing to install. A free Techsnap account gives you more runs and saves your work.

Which Fortran standard is used?

Modern free-form Fortran (Fortran 90 and later) compiled with gfortran. The examples use the .f90 style.

How do I take input in Fortran online?

Fill the Input box and read it with read(*,*), as in the example on this page.

Can I run Fortran on my phone?

Yes. The editor, input and output work in a mobile browser, so you can practise without a laptop.

Ready to write Fortran code?

Open the editor and run your first program in under a minute.