3 Writing reusable code with functions and subroutines
This chapter covers
- What procedures are and why we use them
- How procedures break down into two kinds: functions and subroutines
- Writing procedures that don’t cause side effects
- Writing procedures that work on both scalars and arrays
In the previous chapter, you learned about the core elements of Fortran: declaration of scalar and array variables, do
loops to iterate parts of the code a desired number of times, and arithmetic expressions and assignments. We used them to write a simple simulator that predicts the motion of an object in space and time due to background flow. As we learn new Fortran features, we’ll continuously expand and improve our app to produce more realistic simulations. ...
Get Modern Fortran now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.