Skip to content

Instantly share code, notes, and snippets.

@rsnemmen
Created April 4, 2016 23:02
Show Gist options
  • Select an option

  • Save rsnemmen/879cb5452effcf2d20a8f0041b8724e4 to your computer and use it in GitHub Desktop.

Select an option

Save rsnemmen/879cb5452effcf2d20a8f0041b8724e4 to your computer and use it in GitHub Desktop.
Generates array of random numbers. Saves it as an unformatted Fortran 90 binary file
! Generates arrays of random numbers. Saves them as binary
! unformatted files.
program test
implicit none
real, dimension(:,:), allocatable :: y
integer :: n
character(len=50) :: out
write(unit=*,fmt='(A,$)') 'Filename: '
read *, out
write(unit=*,fmt='(A,$)') 'Number of points: '
read *, n
! allocated arrays
allocate(y(n,n))
! generates random numbers
call random_number(y)
OPEN(UNIT=1000,FILE=out,STATUS='REPLACE',form='unformatted')
write(1000) y
CLOSE(1000)
!call writebin(10000,x,out)
!call writebin(2,y,out)
end program
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment