program TestAllocate !=== Example of Allocating a 1G DP Array, filling it, and ! writing it unformatated. ! hdk - January 2007. integer :: AllocStatus, na, i, GB real(kind(1.D0)), allocatable, dimension(:) :: a GB=1024**3 ! 1073741824 bytes. !---DP array, a, is assumed to have 8-byte elements. na=GB/8 ! na is the number of DP array elements. print *, "Attempting to allocate ",na," DP elements." print *, " " ! Attempt to allocate exactly 1GB of array, allocate( a(na), stat=AllocStatus) if (AllocStatus /= 0) then print *, "Could not allocate ",na," DP elements." stop else print *, "Did allocate ",na," DP elements." print *, " " endif ! Intel compiler uses recordtype='stream'. ! Other compilers use access='transparent'. ! open(unit=60, file='/tmp/bigrec.out',status='unknown', & open(unit=60,file='bigrec.out',status='replace', & form='unformatted', action='write', & ! recordtype='stream') access='transparent') print *, "About to fill array, a" print *, " " do i=1,na a(i)=i end do print *, "Did fill array, a" print *, " " ! Write array, x as one logical record. print *,"About to write the array, a" print *," " write(60) na, a print *, "Successful write of array, a" print *, " " deallocate (a) end program