Software Archive
Read-only legacy content
17061 Discussions

Writing large array blows out stack

Intel_C_Intel
Employee
716 Views
Greetings,
I was wondering if anyone can help me with the following problem. I'm trying to write out a large array to disk using a single write statement but the call seems to blow out the stack. This did work in 6.0.B3 but seems to break since we upgraded to 6.5A. It seems that the write statement attempts to make a copy of the data on the stack before writing it. Does anyone know of a way around this? Sample code follows.

PROGRAM ftest2

IMPLICIT NONE

INTEGER(4), POINTER :: p (:)
INTEGER(4) :: ierr
INTEGER(4) :: size = (1024 * 1024 * 10) / 4

ALLOCATE( p ( 1 : size ) )

OPEN ( 69, FILE = 'test.bin', IOSTAT = ierr, status = 'REPLACE', FORM = 'BINARY' )

WRITE ( 69, '(B)', IOSTAT = ierr) p
CLOSE ( 69 )

END PROGRAM ftest2
0 Kudos
3 Replies
fela
Beginner
716 Views
Try the following:

WRITE ( 69, '(B)', IOSTAT = ierr) (p(I),I=1,SIZE)
0 Kudos
Intel_C_Intel
Employee
716 Views
Well, the program I gave is a little too simple. Actually, p is a structure with alot of different elements but totals in size close to 10 MB. How would I write out a structure that is 10 MB in size?
0 Kudos
Steven_L_Intel1
Employee
716 Views
I'm confused - you open the file as FORM='BINARY' and then use a formatted write statement? (And do you really mean (B) as the format?)

Please send an example of your actual code to us at vf-support@compaq.com and we'll take a look. It doesn't help to look at something that's not representative of your problem.

Steve
0 Kudos
Reply