I recently got myself into a project involving FORTRAN. Here are some random FORTRAN FAQ that I’ve accumulated through working through code.
Q: What does 0d0
mean?
A: Double precision 0. First 0 is the value, D means x10 to the power of, second 0 is the exponent. (Reference)
Q: What does implicit double precision(a-h,o-z)
mean?
A: In FORTRAN, variables have default types based on their starting character. An implicit
statement overrides that. The code above means that any variable starting with a-h or o-z is a double precision real number. To undo this behavior in FORTRAN, use the statement implicit none
. (Reference)
Q: What are the default types for FORTRAN variables?
A: By default, variables starting with letters i-n or I-N are integer type, while those beginning with any other letter are real type. (Reference)
Q: What does the sign()
function do? Why does it take two arguments?
A: It is a sign copying function. sign(a,b)
returns the value of a
with the sign of b
. More specifically, if b
is greater than or equal to 0, sign(a,b)
returns the absolute value of a
; if not, it returns negative the absolute value of a
. (Reference)
Hi Kenneth,
Thanks for the post. I’m aware that a lot of statistical software from Stanford are written using the Mortran processor, e.g. glmnet and pcLasso. Have you considered writing a post on your experiences Mortran? 🙂
Thanks!
LikeLike
That’s definitely true. I’ll need to think about what I can write that will be helpful for the audience… I inherited my current workflow from another student, which involves an executable which does the MORTRAN-to-FORTRAN conversion, as well as some other scripts which produce the code that one needs to include if the mortran/fortran is going into an R package. I confess I’ve been using the workflow without giving much thought as to how/why it works… Perhaps (once I have the time and willpower!) I can describe the workflow and show a minimal example.
LikeLike
Thanks Kenneth. I think this would be important from a sustainability perspective – the likes of JHF can’t be around forever to maintain and develop software like this, and for community input there needs to be some kind of documentation. Perhaps the blog post can serve as a precursor for an additional vignette and/or extension to https://github.com/bnaras/SUtools?
LikeLike