! This file: http://ftp.aset.psu.edu/pub/ger/fortran/hdk/dyn7.f90 ! !=== Example of Allocatable (DP 2-D) array. integer ierror, MB, na, nb double precision a allocatable a dimension a(:,:) print*, "How many MB to Allocate?" read(unit=*,fmt=*) na MB=1024**2 !---DOUBLE PRECISION array assumed to have 8-byte elements. nb=MB/8 allocate( a(na,nb), stat=ierror) if (ierror.ne.0) then print *, "?? Cannot allocate',na,'MB of virtual storage." print *, "At least this much free disk space for swap file", & " is needed." stop endif !---Initialize all elements of that array (for example's sake here). call anysub(a, na,nb) !---Deallocate the array and quit. deallocate( a) print *, "Double Presion Array of dimension (",na,",",nb,")" print *, "was succesfully allocated, used, and deallocated." end subroutine anysub(a, n1,n2) integer i,j,n1,n2 double precision a(n1,n2) !---Access the array in row major order - by columns - (least paging). do j=1,n2 do i=1,n1 a(i,j)=i+j end do end do end