| New Reply |
Fortran 90 creating an array of unknown size |
Share Thread | Thread Tools |
| Feb21-12, 05:26 PM | #1 |
|
|
Fortran 90 creating an array of unknown size
I was given an assignment to create a program that solves the Josephus Problem ([URL="http://en.wikipedia.org/wiki/Josephus_problem"]. the program needs to work for n amount of people, and it must use an array.
Problem: I need to create a subroutine that will allow the user to read(*,*) n and create an array that is n big. Attempt: subroutine sub(n) implicit none integer :: n, i integer :: array(n) do i = 1, n array(i) = 0 end do end subroutine sub program arrays implicit none integer :: size, i write(*,*) "how big is your array" read(*,*) size call sub(size) end program arrays I am stuck, and dont know why this isnt working. |
| Feb23-12, 01:45 PM | #2 |
|
Mentor
|
|
| Feb24-12, 04:29 AM | #3 |
|
|
Summit like this:
Code:
subroutine(/arguments/) real,allocatable :: array(:) /code/ allocate ( array(x) ) /code/ deallocate ( array ) return |
| Mar15-12, 05:57 AM | #4 |
|
|
Fortran 90 creating an array of unknown sizeYou didn't print out anything after the value of "n" is typed. |
| New Reply |
| Thread Tools | |
Similar Threads for: Fortran 90 creating an array of unknown size
|
||||
| Thread | Forum | Replies | ||
| Fortran 77 help making an empty array (or blank list if they exist in fortran) | Programming & Comp Sci | 5 | ||
| FORTRAN 90 array problem | Programming & Comp Sci | 4 | ||
| Fortran: creating array containing characters | Programming & Comp Sci | 1 | ||
| Printing 1D array in Fortran as 2D array... | Programming & Comp Sci | 7 | ||
| Co-Array Fortran | Programming & Comp Sci | 2 | ||