Skip to content

preliminary results from f2c #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

beachdweller
Copy link

@beachdweller beachdweller commented Jun 1, 2017

I managed to

  • find f2c
  • build on a virtual Linux box
  • run over slycot *.f files

Here are the preliminary results. (and I hope I do not make anyone unhappy)

I think

  • some tests are (more than) necessary : at least comparing results from gfortran with gcc or clang
  • may need to reorganize e.g. separating .c files from .f files into a separate folder

Let me know your opinion. Has anyone tried this before? (Please understand that I am not 100% familiar with Sli(y)cot, Linux, conda, ...)

@murrayrm
Copy link
Member

murrayrm commented Jun 1, 2017

A couple of thoughts:

  • I think having a C code version will be quite useful for people who don't have easy access to a FORTRAN compiler.

  • I would definitely suggest putting the C source code in a separate directory, perhaps something like f2c/.

  • I'm not sure I understand the logic of including the log file (f2c.log) in the repository.

  • Until we get some testing done, I would leave the FORTRAN version as the default.

  • Finally, so that we can keep the two distributions up to date, I wonder whether we shouldn't include the commands for creating the C version of the files in a Makefile at the top level (not sure about that).

@beachdweller
Copy link
Author

beachdweller commented Jun 1, 2017

Thanks for the comments.

  • Will move .c files to a separate folder.
  • Reason to add the log file was : there were some warning messages and I assumed that someone might want to check which files had which errors. (I have no problem removing the log file. If desired, I can prepare a new branch without the log file and git push --force)
  • I expect many new commits and tests should follow before any (important) decisions could be discussed.
  • What about closing this pull request for now and submit a new one (or re-open this pull request) when the c version (or python version) is more prepared? (e.g., when it can be built without much problem and pass the majority of the tests.)
  • Another possibility if I may suggest is to use a separate repository (for example the one I am using now) to develop the f2c version.

Hope this helps.

@roryyorke
Copy link
Collaborator

FWIW, the obvious (only?) platform where Fortran compilation is a problem is MS Windows. My guess of problem areas:

  • getting f2c to work with MSVC; it looks like this is possible [1].
  • linking against LAPACK and BLAS. When building for conda, this should link against the Conda-provided MKL.

Ideally the f2c step would be integrated as part of setup.py.

The original SLICOT distribution (see, e.g., [2]) included many examples, which could be used as the starting point for a test suite. It would be good anyway to have a thorough test set.

[1] https://medium.com/@chintanp/using-f2c-on-windows-to-convert-f77-files-to-c-33da825d5de0
[2] http://http.debian.net/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz

@beachdweller
Copy link
Author

beachdweller commented Jun 7, 2017

Thanks again for the comments.

  • I agree that gfortran is not difficult to install on Linux. I have not tried on macOS yet but I don't expect that it would be very different.
  • In the mean while, I could review several options for wrapping C codes in Python that I could find. I plan to see if I can automate the process.
  • Regarding LAPACK/BLAS subroutines that python-control calls, NumPy/SciPy already include majority of them. If I find no other idea, I might just locate the source code file and see if I could use the f2c again. (Somehow, Fortran starts feel like "Latin" to me; it is not an aged language but still decently influential.)
  • For the testing, I think this was one of good discussions.
  • I think that I should consider some additional measures to handle call-by-references in python

@slivingston
Copy link
Member

@Autodrive regarding your question

What about closing this pull request for now and submit a new one (or re-open this pull request) when the c version (or python version) is more prepared?

(quoted from above): I recommend that the PR is closed until it is ready for review or discussion (again). E.g., this is motivated because if you push new changes to the open PR, Travis CI will needlessly run tests against it.

@slivingston
Copy link
Member

for reference, the URL for Travis CI builds of Slycot on PRs: https://travis-ci.org/python-control/Slycot/pull_requests

@beachdweller
Copy link
Author

beachdweller commented Jan 16, 2018

A progress update:

  • I am currently working on a fork
  • Trying to setup an automate-able procedure. May need a plan B if it does not work on Windows.
  • Could find a discussion on f2c vs LAPACK >= 3.2 : LAPACK seemed to switch to Fortran 90 in 2008 but f2c is still more for Fortran 77. (I could see some error messages)
  • IMHO these are the important slycot functions : sb02md_, sb02mt_, sb03md_, tb04ad_, td04ad_, sg02ad_, sg03ad_, tb01pd_, ab09ad_, ab09md_, ab09nd_, sb01bd_, sb02od_, sb03od_, sb04md_, sb04qd_, sb10ad_, sb10hd_
  • These are the functions that I guess the above functions call but I could not locate .c version after f2c yet : dlamch_, dlamc3_, len_trim__
  • len_trim__ seems an intrinsic function of Fortran9x. Maybe I could prepare a separate .c file.
  • I could locate {dlamch_, dlamc3_} in the INSTALL folder.

Hope this helps.

KW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants