# Fortran playground with multiple compilers

**URL:** <https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183>\
**Category:** Announcements\
**Created:** [October 20, 2026, 6:44pm UTC](https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183 "2026-10-20T18:44:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [October 20, 2026, 6:44pm UTC](https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183/1 "2026-10-20T18:44:59Z")

</div>

I created a [Fortran playground](https://beliavsky.github.io/fortran-playground/) that can compile and run programs with gfortran, ifx, LLVM Flang, LFortran, and ofort. Code can checked with Fortitude and formatted with fprettify. You can choose the Fortran standard used. There are about 20 programs demonstrating the features of Fortran, some taken from FortranTip. It is powered by the same Modal service mentioned in [Python to Fortran transpiler is online](https://fortran-lang.discourse.group/t/python-to-fortran-transpiler-is-online/11157).

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [October 20, 2026, 7:06pm UTC](https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183/2 "2026-10-20T19:06:10Z")

</div>

With the earlier playground I was creating a web page where you could click on the name of the majority of the intrinsic procedure names and it would load the example from the fpm-man program.

[https://urbanjost.github.io/M\_intrinsics/playground.html](https://urbanjost.github.io/M_intrinsics/playground.html)

The site was non-responsive so often I never finished it other than making a script that given a directory made a page (the page above is automatically generated). It is easy to link codes to your page in a similar manner? I think that would be useful for Fortran Wiki articles and other Fortran resources where examples could be loaded from the web page with a click. It is not as easy to do with other sites I tried so I never implimented that with another playground like the Goldbolt Compiler Explorer site.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [October 20, 2026, 8:25pm UTC](https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183/3 "2026-10-20T20:25:58Z")

</div>

> [@urbanjost](#):
>
> majority of the intrinsic procedure names and it would load the example from the fpm-man program.
> 
> [https://urbanjost.github.io/M\_intrinsics/playground.html](https://urbanjost.github.io/M_intrinsics/playground.html)
> 
> The site was non-responsive so often I never finished it other than making a script that given a directory made a page (the page above is automatically generated). It is easy to link codes to your page in a similar manner?

Now you can do that, as explained [here](https://github.com/Beliavsky/fortran-playground#sharing-code-with-a-link).

---

<div class="post-metadata">

**Author:** ![Harper](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@Harper](https://fortran-lang.discourse.group/u/Harper)\
**Post date:** [October 20, 2026, 10:36pm UTC](https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183/4 "2026-10-20T22:36:00Z")

</div>

On trying the Fortran playground the LLVM Flang compiler rejected one of my own programs but I did not see the error message(s), so I can’t see what was wrong. I had tried the Compile and Run option.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [October 21, 2026, 12:57am UTC](https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183/5 "2026-10-21T00:57:10Z")

</div>

I changed the playground so that the Fortitude check pane only appears when the check button is pressed, using the extra space to expand the Program Output and Compilation panes. Using LLVM Flang on an invalid program, I do see error messages.

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [October 21, 2026, 1:21am UTC](https://fortran-lang.discourse.group/t/fortran-playground-with-multiple-compilers/11183/6 "2026-10-21T01:21:27Z")

</div>

Perfect! That would be really nice if Discourse automatically could do that if between lines like “```fortran-playground” and “'```”. So if someone puts a sample program in this forum it could automatically be placed in the playground with the click of a button,

## open [demo\_allocated.f90](https://beliavsky.github.io/fortran-playground/#code=program%20demo_allocated%0Ause%2Cintrinsic%20%3A%3A%20iso_fortran_env%2C%20only%20%3A%20dp%3D%3Ereal64%2Csp%3D%3Ereal32%0Aimplicit%20none%0Areal%28kind%3Dsp%29%2C%20allocatable%20%3A%3A%20x%28%3A%29%0Acharacter%28len%3D256%29%20%3A%3A%20message%0Ainteger%20%3A%3A%20istat%0A%0A%20%20%21%20basics%0A%20%20%20if%28%20allocated%28x%29%29%20then%0A%20%20%20%20%20%20%20write%28%2A%2C%2A%29%27already%20allocated%20%3F%3F%3F%3F%27%0A%20%20%20%20%20%20%20write%28%2A%2C%2A%29%27SIZE%28X%29%3D%27%2Csize%28x%29%0A%20%20%20else%0A%20%20%20%20%20%20%20write%28%2A%2C%2A%29%27not%20allocated%20so%20allocate%20it%27%0A%20%20%20%20%20%20%20allocate%28x%2810%29%29%0A%20%20%20endif%0A%0A%20%20%20%21%20how%20to%20test%20if%20already%20allocated%2C%20and%20deallocate%20if%20allocated%0A%20%20%20if%20%28%20allocated%28x%29%20%29%20then%0A%20%20%20%20%20%20write%28%2A%2C%2A%29%27%3Cwarning%3E%20already%20allocated%21%27%0A%20%20%20%20%20%20deallocate%28x%2CSTAT%3Distat%2C%20ERRMSG%3Dmessage%20%29%0A%20%20%20%20%20%20if%28istat.ne.0%29then%0A%20%20%20%20%20%20%20%20%20write%28%2A%2C%2A%29trim%28message%29%0A%20%20%20%20%20%20%20%20%20stop%0A%20%20%20%20%20%20endif%0A%20%20%20endif%0A%0A%20%20%20%21%20only%20if%20not%20allocated%2C%20allocate%0A%20%20%20if%20%28%20.not.%20allocated%28x%29%20%29%20allocate%28x%2820%29%29%0A%20%20%20write%28%2A%2C%2A%29%27size%20of%20x%28%29%20is%20now%2010%20or%2020%3F%20It%20is%20%27%2Csize%28x%29%0A%0A%20%20%21%20a%20little%20surprise%20is%20that%20there%20is%20no%20call%20to%20deallocate%0A%20%20%21%20in%20the%20INTENTOUT%283%29%20procedure%20but%20X%20will%20be%20deallocated%0A%20%20%21%20after%20this%20call%21%0A%20%20%20call%20intentout%28x%29%0A%20%20%20write%28%2A%2C%2A%29merge%28%27x%20is%20allocated%20%20%27%2C%27x%20is%20deallocated%27%2Callocated%28x%29%29%0A%0A%20%20%20contains%0A%0A%20%20%20subroutine%20intentout%28arr%29%0A%20%20%20%21%20note%20that%20if%20arr%20has%20intent%28out%29%20and%20is%20allocatable%2C%0A%20%20%20%21%20arr%20is%20deallocated%20on%20entry%0A%20%20%20real%28kind%3Dsp%29%2Cintent%28out%29%2Callocatable%20%3A%3A%20arr%28%3A%29%0A%20%20%20%20%20%20%20write%28%2A%2C%27%28a%29%27%29%20%26%0A%20%20%20%20%20%20%20%27note%20ARR%20might%20be%20allocated%20in%20calling%20program%20but%20because%27%2C%20%26%0A%20%20%20%20%20%20%20%27of%20intent%28out%29%20it%20will%20be%20deallocated%20on%20entry%20to%20this%27%2C%20%26%0A%20%20%20%20%20%20%20%27procedure%20automatically%27%0A%20%20%20end%20subroutine%20intentout%0A%0Aend%20program%20demo_allocated%0A) in Fortran Playground

```fortran
program demo_allocated
use,intrinsic :: iso_fortran_env, only : dp=>real64,sp=>real32
implicit none
real(kind=sp), allocatable :: x(:)
character(len=256) :: message
integer :: istat

  ! basics
   if( allocated(x)) then
       write(*,*)'already allocated ????'
       write(*,*)'SIZE(X)=',size(x)
   else
       write(*,*)'not allocated so allocate it'
       allocate(x(10))
   endif

   ! how to test if already allocated, and deallocate if allocated
   if ( allocated(x) ) then
      write(*,*)'<warning> already allocated!'
      deallocate(x,STAT=istat, ERRMSG=message )
      if(istat.ne.0)then
         write(*,*)trim(message)
         stop
      endif
   endif

   ! only if not allocated, allocate
   if ( .not. allocated(x) ) allocate(x(20))
   write(*,*)'size of x() is now 10 or 20? It is ',size(x)

  ! a little surprise is that there is no call to deallocate
  ! in the INTENTOUT(3) procedure but X will be deallocated
  ! after this call!
   call intentout(x)
   write(*,*)merge('x is allocated ','x is deallocated',allocated(x))

   contains

   subroutine intentout(arr)
   ! note that if arr has intent(out) and is allocatable,
   ! arr is deallocated on entry
   real(kind=sp),intent(out),allocatable :: arr(:)
       write(*,'(a)') &
       'note ARR might be allocated in calling program but because', &
       'of intent(out) it will be deallocated on entry to this', &
       'procedure automatically'
   end subroutine intentout

end program demo_allocated

```

I used a little Fortran filter (fpm package [apps/playground at main · urbanjost/apps · GitHub](https://github.com/urbanjost/apps/tree/main/playground)) but it just basically does what you illustrated with the javascript / python examples you provided.

I need to finish formatting it into a table or something nicer but your change let me make all the examples for the intrinsics import straight from the web page Nice!
