11
$\begingroup$

I understand that FORTRAN might be faster in terms of computation time, but I don't understand why it is always recommended by people in the field. Everyone tends to avoid MATLAB for astrodynamics; is there a solid reason behind this, or is it just the preference of the majority?

MATLAB offers a lot of features not found in FORTRAN (such as visualizations or linking with other software).

$\endgroup$
17
  • 1
    $\begingroup$ Can you give some examples of these recommendations? $\endgroup$ Dec 30, 2019 at 19:23
  • 1
    $\begingroup$ Isn’t the recommendation “use a validated code”, many of which happen to be written in FORTRAN because they’re old and experienced? $\endgroup$ Dec 30, 2019 at 21:14
  • 1
    $\begingroup$ @uhoh ah this makes sense, basically FORTRAN is used because its a lower level of programming. I am currently "literally right now" writing some code for orbital analysis and I decided to write the libraries both in MATLAB and FORTRAN since I am still convinced with MATLAB but the astrodynamic society does FORTRAN only :) $\endgroup$
    – John
    Dec 30, 2019 at 21:40
  • 4
    $\begingroup$ This comment thread makes me happy since my simulation engineering years were using FORTRAN. I chuckled at the 'lower level' comment, remembering assembly language routines! $\endgroup$ Dec 30, 2019 at 22:31
  • 5
    $\begingroup$ I can't answer specifically on FORTRAN except for the use of legacy code (which is already mentioned in the comments) but I personally use C for my astrodynamics applications. Numerical integration is a pretty intensive task and C or FORTRAN are much better at performing it quickly than MatLab. I've previously linked an atmospheric model (JB2008) written in FORTRAN to my propagator in C because there was no implementation of it in C already. Write your core in FORTRAN or C and use MEX to call it from MatLab and process your results there. Nobody wants to plot anything from FORTRAN or C. $\endgroup$ Dec 31, 2019 at 14:16

1 Answer 1

10
$\begingroup$

As many of the comments have already mentioned, there are several different reasons people might recommend the use of Fortran over Matlab. One of the most straightforward answers is that a lot of legacy (read: validated) code is written in Fortran, and depending on your job function, learning to use Fortran might make you more productive - for instance, if you have to use, maintain, and extend these tools.

Another reason (also mentioned in the comments) is, basically, performance. Well-written Fortran code is about as performant as you're going to get, and Fortran has the added benefit of being a farily straightforward language in which to write scientific code. Solving differential equations is computationally intensive, and since that is a core task of most astrodynamics code (orbit propagation), it makes sense to stick with a language that can give you good performance. Modern astrodynamics work often requires solving these differential equations many times over (e.g. for Monte Carlo simulations or optimization tasks), making performance even more critical. Of course, one could write performance-critical code in Fortran or C and link to the libraries in Matlab, but often it's easier to be consistent and stay in a single environment, particularly for students with limited time to learn multiple languages (although this is mostly a matter of preference).

Finally, Matlab has several design flaws (which I won't elaborate on here) that make it a poor choice for implementing a large, complex codebase (although, of course, many large codebases have been written in Matlab). Astrodynamics code in particular has a tendency to get complicated quickly for even basic tasks - for example, you may want to "just" propagate an orbit, so you need a flexible ODE solver, but you also need to simulate various perturbations, handle reference frame transformations and different time systems, etc. A flexible astrodynamics codebase can be sprawling, and I know from experience that it gets extremely messy in Matlab. Fortran is well-suited to this type of code. It's worth noting that it's not required to use Fortran for performant, well-structured codebases - the Julia language is one example of a "high-level" language that does not have the deficiencies of Matlab.

$\endgroup$
1
  • 7
    $\begingroup$ Good answer -- I want to point out though, that people should not take away from this that Fortran is intrinsically faster than any other compiled language. In fact, the Gnu compiler suite convert Fortran and C to the same intermediate language before compiling, and the Gnu Fortran runtime is written in C. Institutional momentum, not wanting to reinvent the wheel, and reuse of validated code are the biggest reasons. That Fortran is not slower than alternatives, and that it has a defined interoperability standard with C, helps maintain its status. $\endgroup$
    – Tristan
    Jan 2, 2020 at 17:03

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.