Clicky

Fortran Wiki
allocate_coin_toss

Originally posted to comp.lang.fortran.

program allocate_coin_toss
  implicit none
  real, dimension(:,:), allocatable :: a
  real :: u

  call random_number(u)

  if (u < 0.5) then
     allocate(a(5,8))
  else
     allocate(a(7,4))
  end if

  print *, shape(a)

  deallocate(a)
end program allocate_coin_toss

category: code