Want more features on Pastebin? Sign Up, it's FREE!
Guest

fortran spread code

By: a guest on Sep 12th, 2013  |  syntax: Fortran  |  size: 0.46 KB  |  views: 88  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. program sandbox
  2.     implicit none
  3.     real, dimension(2, 2) :: p
  4.     real, dimension(:, :), allocatable :: q
  5.     integer i, n
  6.  
  7.     n = 3
  8.     allocate(q(2, 2*n))
  9.  
  10.     print *, "p"
  11.     p = reshape([1, 3, 2, 4], shape(p))
  12.     do i=1, 2
  13.         print *, p(i, :)
  14.     end do
  15.  
  16.     print *, "spread"
  17.     q = reshape(spread(transpose(p), 2, n), [2, 2*n], order=[2, 1])
  18.     do i=1, 2
  19.         print *, q(i, :)
  20.     end do
  21.     deallocate(q)
  22. end program sandbox
clone this paste RAW Paste Data