FORTRAN90 allocatable arrays
Declaration:
INTEGER, DIMENSION(:), ALLOCATABLE :: ages ! 1D REAL, DIMENSION(:,:), ALLOCATABLE :: speed ! 2D
- Allocation:
READ*, isize ALLOCATE(ages(isize), STAT=ierr) IF (ierr /= 0) PRINT*, "ages : Allocation failed" ALLOCATE(speed(0:isize-1,10),STAT=ierr) IF (ierr /= 0) PRINT*, "speed : Allocation failed"
- the optional STAT= field reports on the success of the storage request. If the INTEGER variable ierr is zero the request was successful otherwise it failed.
Deallocating Arrays
IF (ALLOCATED(ages)) DEALLOCATE(ages,STAT=ierr) Note: this ALLOCATED() is an intrinic function return a logic value reporting the status of the array
评论
发表评论