In the realm of programming, particularly in the field of scientific computing, Fortran remains a powerful and widely-used language. One of its fundamental aspects is the ability to output data, which is achieved through print statements. Let's delve into the world of Fortran print statements, exploring their syntax, various formats, and providing practical examples.

Before we dive into the specifics, it's essential to understand that Fortran print statements are used to display output on the console or a file. They are a crucial component in debugging, data visualization, and communicating results to users.

Understanding Fortran Print Statements
At the heart of Fortran print statements lies the WRITE statement. It's the primary tool for outputting data. The basic syntax of a Fortran print statement is as follows:

WRITE (unit, fmt) var
Here, 'unit' represents the output destination (like 6 for the standard output, or a file unit), 'fmt' is the format string that controls the output's appearance, and 'var' is the variable you want to print.

Format Strings in Fortran Print Statements
Format strings are pivotal in determining how your output looks. They consist of a combination of explicit and implied format specifications. Explicit format specifications start with an 'I', 'F', or 'E' for integer, real, or exponential format, respectively. Implied format specifications, on the other hand, are based on the type of the variable being printed.
Let's explore this with an example. Consider the following Fortran code snippet:

PROGRAM PrintExample
REAL :: x = 3.14159
WRITE(*,*) 'The value of Pi is: ', x
END PROGRAM
In this example, '*' is the default format for real numbers, so 'x' will be printed in its default format. The '*' also indicates that the output will be written to the standard output (unit 6).
Control Specifiers in Fortran Print Statements

Control specifiers are used to control the output's appearance further. They include 'T' for tab, 'X' for space, and '+' for sign. For instance, the following code:
PROGRAM PrintExample
INTEGER :: i = 123
WRITE(*, '(I3)') i
END PROGRAM




















will print '123' with a width of 3 characters, padding with spaces if necessary.
Advanced Fortran Print Statements
Fortran print statements can also handle arrays and complex numbers. For arrays, you can use the '(' and ')' to specify the range of elements to print. For complex numbers, Fortran automatically prints the real and imaginary parts.
Printing Arrays in Fortran
To print an array, you can use the following syntax:
WRITE(*,*) arr(1:5)
This will print the first five elements of the array 'arr'.
Printing Complex Numbers in Fortran
When printing a complex number, Fortran automatically prints the real and imaginary parts. Here's an example:
PROGRAM PrintExample
COMPLEX :: c = (1.0, 2.0)
WRITE(*,*) c
END PROGRAM
This will output '1.000000 2.000000', showing both the real and imaginary parts.
In conclusion, Fortran print statements are a powerful tool for outputting data in a controlled and formatted manner. Whether you're printing a single variable or an array of complex numbers, Fortran's WRITE statement, combined with format strings and control specifiers, provides the flexibility to meet your output needs. Happy coding!