17
$\begingroup$

I've spent the last couple of months on coding a Fortran program for solving a particular PDE system (describes fluid flow/combustion). I tryed to use latest-standard Fortran and the new OOP capabilites modern Fortran has. I am working on my own and have no Fortran guru beside me to ask questions, so a nataral way to learn for me would be to look at other libraries/solvers that use modern Fortran.

Unfortunately all the Fortran libraries out there seem to be written in pretty old Fortran, Fortran90 tops. Therefore I had to think through the class-design and interaction myself. And I am not at all certian that I did it right, especially if one looks from a preformance perspective. But perhaps I have missed something and there are modern scientific packages written if Fortran and using OOP?

There are a lot of good C++ libraries to learn from (OpenFOAM, deal.II and more) and also Python libraries. Those languages have a bigger community in general as well. Is it perhaps better to drop Fortran and switch language if I want to learn by example?

$\endgroup$
3
  • $\begingroup$ Jack, it seems like your comment was too large: "(The rest of this comment is to meet the length requirement.)". That rises hope within me, so please edit it so everyone can read it :D. $\endgroup$
    – tiam
    Commented May 24, 2012 at 17:35
  • 2
    $\begingroup$ Sorry, my comment was misleading, as I was answering your last question. I mean that, if you want to learn modern OOP by example from full-fledged libraries, C++ is the way to go. Sorry; I am not aware of any open source best-of-breed modern Fortran libraries. $\endgroup$ Commented May 24, 2012 at 17:39
  • 6
    $\begingroup$ I would caution that C++ is already somewhat of a twisted incarnation of object orientation, and many libraries further misuse it (true for any language). I agree that it's important to look beyond Fortran, but it's important to also look beyond C++. Learning how to express concepts in languages of several different kinds (object-oriented, generic, and functional; static and dynamic) is will worth it even if you come back to a simple language like C for your "real" work. $\endgroup$
    – Jed Brown
    Commented May 24, 2012 at 20:27

6 Answers 6

14
$\begingroup$

There are modern CFD codes which you can look into. For example ...

Fluidity: General purpose multiphase CFD (FE) code; Even does fully unstructured AMR

WRF: Next-generation numerical model weather prediction system from NCAR

Code Saturne: General purpose CFD (FV) code; Some features listed on Wikipedia

There are similar modern Fortran codes for structural analysis.

But they may not use full F2003 capabilities due to lack of widespread compiler support. Most new compilers do support large parts of F2003 (see the ACM SIGPLAN Fortran Forum papers) but it takes time to have a wide user base. Debian stable for example has GCC 4.4.5 so generally speaking you should not expect your users to have anything better (i.e., 4.5/4.6/4.7).

When F2003 compilers become widespread you will see libs/code that use the F2003 capabilities.

For now you can look at this book by Damian Rouson on how to use the OOP capabilities.

$\endgroup$
3
  • $\begingroup$ That's right, F2003 is just recently catching up (for my own library I decided to stick with F95 for maximum portability). We will see more code written in F2003 or even F2008 soon. $\endgroup$ Commented May 24, 2012 at 22:38
  • $\begingroup$ Very good point. I hope we'll see more new-standard code in the coming years. $\endgroup$
    – tiam
    Commented May 25, 2012 at 12:26
  • $\begingroup$ Damian Rouson works on the ForTrillinos, which is a modern fortran interface to the Trillinos Project. $\endgroup$ Commented May 27, 2012 at 23:29
7
$\begingroup$

If you want to learn by example I would recommend rosettacode, a programming chrestomathy site. There you can find many example problems comparatively written in quite a few different languages.

Maybe even more interesting for you would be Fortran wiki, and here is a section on OOP in Fortran which might be useful.

Fortan is doing just fine - let's not give up on it!

$\endgroup$
2
  • $\begingroup$ I like Fortran myself :). I know the wiki website, Matcalds books are also very good as well as PGI's tutorials. But seeing some real material would be nice! $\endgroup$
    – tiam
    Commented May 24, 2012 at 18:53
  • $\begingroup$ Coding style of dolfyn CFD code is really comprehensive and "modern Fortran literate". There you can find examples of some data structures like linked lists etc. which might be informative, and little bit of OOP if I remember correctly. $\endgroup$ Commented May 24, 2012 at 19:14
4
$\begingroup$

I agree with the comment by @JackPoulson. I am not aware of any open source libraries written in modern Fortran. So the answer to your specific question about needing to switch to C++ to learn by example is an unfortunate "yes." But, to be clear, I do know that at least one library exists that was written almost exclusively in modern Fortran with an eye towards OOP, so it is possible (and worthwhile). This library is not open source, though, so it will not help you achieve your learning goal.

However, you are also likely to be reluctant to throw away what you have already completed. If you are still interested in pursuing Fortran for this and have specific development questions, I'd encourage you to ask them on StackOverflow. There are a few highly skilled Fortran developers active there that are more than happy to help.

$\endgroup$
3
$\begingroup$

I'm a little late on this one, but you should have a look at version 3 of the parallel linear algebra library PSBLAS, which takes full advantage of the modern Fortran features such as inheritance and polymorphism. There's also a paper here where they compared the performance of that version with their older versions, which stuck to F90/F95. Surprisingly enough, the speed difference was negligible overall.

$\endgroup$
2
$\begingroup$

I don't know which Fortran dialect it's written in, but there is William Mitchell's PHAML code that is a general purpose Fortran FEM code.

I will admit that I'm not impartial in the discussion of Fortran vs C++ but I do like to point out that you difficulty in finding a modern Fortran-based FEM code while at the same time finding a whole lot of C++-based codes tells something of what the community as a whole thinks is the way to go. There is of course nothing wrong with trying to build your own code in a language you like and are familiar with, but your brief survey already shows you that you're building an island. You may want to take that into account.

$\endgroup$
-1
$\begingroup$

There is the open source fortran library forDat by ffr Engineering which uses oop 2003 features

$\endgroup$
1
  • 1
    $\begingroup$ Welcome to SciComp! Your answer is not really helpful since you don't describe a) what forDat does and b) which OOP features forDat uses. You're also missing an opportunity here, since as forDat's developer (which you should disclose, by the way, see scicomp.stackexchange.com/help/behavior), you could also mention why forDat is using those features. $\endgroup$ Commented Jul 22, 2014 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.