Online Fortran Compiler
Compile and run Fortran online with GNU Fortran 16. Write free-form Fortran in main.f90, press Run, and gfortran builds and starts your program, with compiler errors and output shown beside your code. Programs can read input with read as they run.
How to run Fortran code online
- This page opens with Fortran selected, so you can start typing straight away.
- Write your code in the editor, or open files from your computer: single files, or a whole project as a .zip.
- Press Run, or Ctrl+Enter. The output appears in the panel beside the editor, and when the program asks for input you type it there and press Enter.
- Share a copy with a link, or save your files to your computer.
GNU Fortran 16 on Online IDE
- Your program is compiled with gfortran -O2 as free-form Fortran (Fortran 90 and later).
- Output is not buffered, so write (*, '(a)', advance='no') 'Enter: ' shows a prompt before read waits.
- read (*, *) reads values you type in the output panel, and iostat= catches input that is not a number.
- Put implicit none at the top of the program so that every variable has to be declared.
Example: a Fortran program that reads input
program main
implicit none
integer :: n, i, ios
write (*, '(a)', advance='no') 'Show squares and cubes up to: '
read (*, *, iostat=ios) n
if (ios /= 0) then
print '(a)', 'That is not a whole number.'
else
print '(a6, a10, a14)', 'n', 'n**2', 'n**3'
do i = 1, n
print '(i6, i10, i14)', i, i**2, i**3
end do
end if
end program main
Features of this tool
- Simple and fastA clean, lightweight editor that opens instantly.
- Powered by AceThe Ace code editor, with syntax highlighting, autocompletion and bracket matching.
- Interactive programsType input into the terminal while your program runs.
- Several filesWork in tabs, open files or a .zip from your computer, and save the project back to disk.
- Made for learningHelpful for beginners to learn and practice programs.
- Light and dark themesPlus 39 editor themes, a choice of coding fonts, and Vim, Emacs or VS Code keys.
- Keep your outputCopy or download the program output in one click.
- Share by linkSave your code in the cloud and open it anywhere.
Frequently asked questions
Which Fortran compiler does Online IDE use?
GNU Fortran (gfortran) 16 on Linux, compiling with -O2.
Can I run FORTRAN 77 code?
Fixed-form code needs small changes, because main.f90 is read as free-form source: start comments with ! instead of C or * in column 1, and end a line with & to continue it on the next.
How does a Fortran program read input?
With read (*, *), which waits for values you type in the output panel. Add iostat= to the read to handle input that is not a number.
How do I print a prompt on the same line as the input?
Use write (*, '(a)', advance='no') 'Enter: '. Output is not buffered, so the prompt shows before the program waits.
Contact us
For any feedback, queries or issues, please feel free to contact us or write to . We value your input and are committed to providing the best possible experience for our users.