Hi Richard,
Richard Maine sent the following indented text:
>
> John Venier writes:
> > In translating some code we came across a presumably unusual
> > situation....
> > DOUBLE PRECISION, PARAMETER :: a(1024) = (/6.33795775455379D0, [...]
> [and bazillions of continuation lines needed]
>
> Not too incredibly unusual. I've seen the same thing asked several
> times before.
>
> Sounds like you've found the "usual" solutions. Either hope that the
> compiler will support enough continuation lines as an extension, break
> the array into a bunch of sub-arrays, which you then concatenate,
> or make the array into a variable instead of a parameter. If you
> make it a variable, you can then either use DATA statements or read
> it from a file. I think the option of reading from a file was the
> only one you didn't cover.
Thanks for mentioning that! I hadn't considered it, but I mostly
wanted to know if there were a better way to make it a parameter.
> Do note that for an array of that size, it is unlikely that the
> compiler is going to be particularly "smart" about optimizing
> a parameter array as opposed to a variable one. There may not
> be much difference in practice. I'd tend to go with just making
> it a variable, but I accept that the parameter option is also
> viable, if, as you have noted, a bit "less than elegant" in the
> hoops you have to jump through.
That's a good point, but optimization or no, I think it makes code
less prone to bugs when "read only" data are parameters; it gives the
compiler a shot at catching inadvertent modifications.
Anyway, the code is a highly magical, pretty accurate, but very fast
inverse of a Normal CDF, so the difference in optimization between a
large parameter array and regular array might be significant. I don't
know.
The original source code was written in C++ but could just as easily
have been written in C. It uses low-level trickery such as bit
manipulations. The guy who sent it to me supposed that it could not
be written in Fortran, due to its reliance on low-level C features. I
figured he just wasn't familiar with modern Fortran, and it would be
very useful anyway, so we started translating it, and ran up against
the source code limitations. C does not seem to have the same
limitations, but perhaps it does and everyone just ignores them.
Also, you don't need to count the number of elements in the array like
you do in Fortran, but that's another issue.
In any case, it struck me as odd, so I thought I'd see if I were
missing something obvious.
Thanks again for your help,
John
--
John Jeffrey Venier, M.Stat. Programmer Analyst III
Section of Computer Science Department of Biomathematics
The University of Texas M. D. Anderson Cancer Center, Houston, Texas
[log in to unmask] +1 713 792 2622
|