Re: Save an array to memory for another program to read it



Hello,

Whoops, I got it backwards. <sigh>

Dan Nagle wrote:
Hello,

Nektarios - Greece wrote:
I run a program and suppose it creates an array A.
I need the program to store into memory this array, end itself and when immediately runs again to load this array again from the memory.

H O W ?

One way is something like this

test to see if a file exists, named, say, array_a.dat

if it exists, read it

if not, compute A and write it to a file named array_a.dat

(You can choose any name you want for the file,
I chose array_a.dat for illustration.)

I am new in Fortran. So, please help me.

Thus,

program ...

real(...), dimension(...) :: a

inquire( file='array_a.dat', exists= file_exists)

if( file_exists )then

open( unit= a_unit, file= 'array_a.dat', form= 'unformatted', &
access= 'sequential', status= 'old')

call compute_array_a( a)

write( unit= a_unit) a

else

open( unit= a_unit, file= 'array_a.dat', form= 'unformatted', &
access= 'sequential', status= 'new')

read( unit= a_unit) a

endif

end program ...

I left out a bunch of stuff, but that's one general way
to solve my understanding of your problem.

HTH



--
Cheers!

Dan Nagle
Purple Sage Computing Solutions, Inc.
.



Relevant Pages

  • Re: Storing large number of values in 2D array
    ... array.How can I store them and retrieve them later? ... around 32 000 bytes for the 2D array. ... But that was a memory efficient solution, ... I have seen proposals to add to C ...
    (comp.lang.c)
  • Re: A challenging file to parse
    ... algorithm problem and found a Orun-time and Omemory solution, ... Do the same thing, but when storing in an array, store it at ...
    (comp.lang.c)
  • Re: Database in memory
    ... > I have a large amount of information which I store in memory. ... > this information as array of structures using CPtrArray. ... > several tables completely in memory and query it with SQL? ...
    (microsoft.public.vc.mfc)
  • Database in memory
    ... I have a large amount of information which I store in memory. ... this information as array of structures using CPtrArray. ... several tables completely in memory and query it with SQL? ...
    (microsoft.public.vc.mfc)
  • Database in memory
    ... I have a large amount of information which I store in memory. ... this information as array of structures using CPtrArray. ... several tables completely in memory and query it with SQL? ...
    (microsoft.public.vc.mfc)