[Rd] Fortran coding standards
hin-tak.leung at cimr.cam.ac.uk
Wed Apr 11 15:55:07 CEST 2007
I am not familiar with fseries, nor the other routines you
mentioned, but can I make a few points:
(1) A good part of R's fortran code are "borrowed" from elsewhere.
When one is "borrowing", it is customary to keep deviation minimum
and strictly necessary i.e. bug-fixes only, and no re-indentation,
nor stylistic changes like many of those you outlined. All in all,
if you want to push for stylistic changes, you need to approach
the original writers.
(2) g77, gfortran are not the only fortran compilers out there!
"...it is standard Fortran 90 and is supported by g77", is just not
good enough - what do you mean by "...also conforms to later standards"?
Some piece of code is either fortran 77 conformant, or not
(i.e. *at least one* feature used are not).
(3) if it is not broken, don't try to fix it. It is possible to debate
on stylistic changes for eternity and not getting any real work done.
Vivek Rao wrote:
> I have some comments on the Fortran code in the
> fseries package in file 4A-GarchModelling.f ,
> especially the subroutine GARCHFIT and function
> I appended the code to the end of an earlier message,
> but it was rejected by some rule. Let me first say
> that I am grateful that packages for financial
> econometrics exist in R.
> Fortran 77 had PARAMETERs, and PARAMETERs equal to
> 99999 and 200 should have been defined instead of
> repeatedly using "magic numbers". More importantly,
> the code will fail if NN exceeds 99999, but the code
> does not check for this. I hope someone will fix this.
> In the code dsged the variables half, one, two should
> be made parameters, and instead of
> IMPLICIT DOUBLE PRECISION (A-H, O-Z)
> IMPLICIT NONE
> should be used and all variables declared. Although
> IMPLICIT NONE is not standard Fortran 77, it is
> standard Fortran 90 and is supported by g77.
> Experienced Fortranners know that IMPLICIT NONE
> catches errors. Another defect is the use of specific
> intrinsic functions such as DSQRT. There is no need to
> use this, since the SQRT function is generic, handling
> both single and double precision arguments.
> Maybe there should R coding standards to address such
> issues. I hope that eventually the Fortran code in R
> will use the modern features of Fortran 90 and later
> standards, using the gfortran compiler. However, with
> a little effort one can still write clean code in
> Fortran 77 that also conforms to later standards.
> Vivek Rao
> It's here! Your new message!
> Get new email alerts with the free Yahoo! Toolbar.
> R-devel at r-project.org mailing list
More information about the R-devel