Hi, Maurice and others
I had written:
... when I installed 2.1, I couldn't get it to compile! I get the message djgpp.ver: No such file or directory (ENOENT)
Maurice wrote:
djgpp.ver comes with gcc2953b In this version it is contained in the base directory %DJDIR%\lib , while in new versions (gcc303) it is contained in a subdirectory %DJDIR%\lib\gcc-lib\djgpp\3.03 Thus this file must also be borrowed from gcc2953b.zip, in addition to the files contained in %DJDIR%\lib\gcc-lib\djgpp\2.953 as was indicated in the doc. I missed this point up to now.
Thanks: that was it. I ended up having to copy all the old stuff from djgpp/lib (about 10 small files), PLUS the <many \ > libgcc.a, into the new djgpp directory. Now the compiler works fine.
This leaves me only with the original problem, which is still there on the new compiler as well!
Maurice also wrote:
FSize := 8 * sqr(nx); {making a cube. *8 is for "real"}
It is a square not a cube ? try 8 * nx pow 3
In addition you should write SizeOf(Real) instead of 8 to make this portable
No: I'm allocating one square for each "slice" of the cube. If the cube is 100^3, then I allocate 100 squares. The reason for this is that I'm working near my memory limit (around 400^3), and the program derives information on a huge cube of reals, then transfers it to a huge cube of integers. I can't hold both cubes in memory at the same time, so I allocate an integer slice, transfer a slice's worth of information, deallocate the real slice, then move to the next slice. At least that's what I want to do.
Yes, SizeOf() is more general; thanks for mentioning that.
The problem appears to be in how reals are *written*. Now I get a Page Fault, and the call traceback says: in function free+77 in function _p_dispose+37 in function _p_write_real+154 in function _p_write+437
The revised code is below.
regards, Toby -------------------------------------------------------------------- program testmem;
const Xmax = 25;
type Fieldary = array[1..2] of real; FPary = array[0..Xmax] of ^Fieldary;
var Field : FPary; FSize, i,j, k, nx : integer;
begin writeln; write('Enter the size: '); {I used 5} readln(nx); FSize := SizeOf(Real) * sqr(nx); {making a cube.} for i := 0 to nx do GetMem(Field[i], FSize); writeln('Memory allocated OK'); for i := 0 to nx do for j := 1 to nx do for k := 1 to nx do Field[i]^[j+(nx*k)] := 1.0 * i * j * k; writeln('Done assigning. Writing...'); for i := 0 to nx do for j := 1 to nx do begin for k := 1 to nx do write(Field[i]^[j+(nx*k)]:8:1, ' '); {<== CRASHES HERE} writeln; end; writeln('Freeing memory...'); for i := 0 to nx do if (Field[i] <> Nil) then FreeMem(Field[i]); end.