Fortran

Guide To Learn

Standard input, output, and error

If you’ve done any programming before picking up this book, you’ve likely heard of standard input (stdin), output (stdout), and error (stderr). They’re collectively known as standard streams and were introduced in the early days of the Unix operating system to allow easier interaction with the local file system and hardware, such as keyboards, printers, and, later, screens. […]

Reading and writing multiple variables at once

While implementing a simple echo program in the previous subsection, we accidentally stumbled on list-directed I/O, which allows you to read or write multiple variables on the same line. It’s called list-directed because of its functionality to consume and emit an arbitrary list of variables. For example, if you input a character string, an integer, and a […]

Your first I/O: Input from the keyboard and output to the screen

So far, we’ve read data and written it to screen and/or files in almost every chapter in this book. For brevity, and to stay focused on other features of the language, I only briefly mentioned what we did and why, so I haven’t explained in much detail about how it works. Before we jump into […]

Exercise 3: Calculating moving average and standard deviation

You can implement the moving average by iterating over each element of the input array, slicing that array over a subrange determined by the input window parameter, and applying the general average function to that slice, as shown in the following listing. Listing 5.19 Calculating moving average of a real array x over window w ❶ Result array with […]

Exercise 1: Convenience (de)allocator subroutines

Start with the allocator subroutine alloc. For the key functionality to work, our subroutine needs to do the following: The following listing demonstrates the implementation. Listing 5.16 Allocating an array with error handling ❶ Array to allocate ❷ Array size ❸ Integer status code ❹ Character string to store the error message ❺ Free if already allocated ❻ Allocates with error handling […]

Scroll to top