After looking at this more closely, it seems there is something wrong
with this example. You are specifying the format statement "5f7.2"
which means 5 columns, and this is what you are getting. However, you
are passing an array that has 7 columns. I'm not sure how
write_matrix is supposed to behave in the case where you specify fewer
columns than your data actually has (or vice versa for that amtter).
Is this documented anywhere?
Here's how I would expect write_matrix to behave, using a slightly
nrows = 5
ncols = 7
ave = 0.0
std = 5.0
x = random_normal (ave, std, (/nrows,ncols/))
write_matrix (x, "7f7.2", False)
4.35 4.36 9.73 4.91 1.77 -0.63 -4.29
4.39 4.66 -5.84 4.59 3.68 -14.12 0.07
0.27 3.78 0.89 -3.09 5.08 -2.51 5.85
-3.35 -1.66 8.46 7.55 0.14 1.76 0.87
-6.90 4.06 10.39 4.56 -5.63 -1.40 8.65
The old write_matrix was not doing this properly, and neither
is the latest version.
Rick, I looked at the writematrix.f and writematrixW.c files before
your latest fixes, and I think I see the problem. The writematrixW.c
file is fine. However, you were passing nrow,ncol (in this order) to
the Fortran routine, and then redefining this as ncol,nrow on the
Fortran side. The nrow and ncol should stay in the same order. The
only thing that should change is that your data array "x" in the
Fortran routine should be defined x(ncol,nrow). Also, all the places
where you have "x(nr,nc)" have to now be changed to "x(nc,nr)".
This archive was generated by hypermail 2b29 : Wed Oct 29 2003 - 09:40:51 MST