concept side effect in category fortran

appears as: side effects, side effect
Modern Fortran: Building efficient parallel applications

This is an excerpt from Manning's book Modern Fortran: Building efficient parallel applications.

Each layer of abstraction introduces a benefit and a cost. The benefit usually boils down to having to write less boilerplate code, especially when programming repetitive tasks. The cost is that abstractions hide not only the implementation details, but also meaning and side effects if they’re not used conservatively and with care. I’ll warn you each time we come across a new abstraction in this book. Consider each abstraction carefully, and use them only if the benefits outweigh the perceived costs.

For short and simple applications, using only the main program does the job. Once you start repeating code, it may be time to define it in a function and call it from the main program. Functions are powerful because you can use them in expressions, and they’re especially well suited for writing pure, side effect-free code. Subroutines are appropriate when side effects are inevitable, for example, for I/O or when working with shared, globally accessible data. Figure 3.6 illustrates how you can define and call functions and subroutines in the main program.