|
66 | 66 | \item `\texttt{*}' is multiplication, `\texttt{**}' is exponentiation. |
67 | 67 | \item The \keyword{print} statement on line 24 contains the format code\index{Fortran!format codes} \str{"(4I6)"}. |
68 | 68 | This tells Fortran to print 4 records of integer type, each having a width of 6 characters (including spaces), per line. |
69 | | - Format strings for other datatypes include \texttt{Ew.d} (real -- decimal form), \texttt{ESw.d} (real -- scientific form), \texttt{ENw.d} (real -- engineering form), \texttt{Lw} (logical), and \texttt{A} (characters). Here, \texttt{w} gives the width of a record and \texttt{d} gives the number of places right of the decimal. |
| 69 | + \Cref{tbl:format codes} gives the format codes for other intrinsic types. |
| 70 | + \begin{margintable} |
| 71 | + \begin{tabular}{ll} |
| 72 | + \toprule |
| 73 | + Format string & Meaning \\ |
| 74 | + \midrule |
| 75 | + \texttt{Iw} & integer \\ |
| 76 | + \texttt{Ew.d} & real (decimal form)\\ |
| 77 | + \texttt{ESw.d} & real (scientific form)\\ |
| 78 | + \texttt{ENw.d} & real (engineering form)\\ |
| 79 | + \texttt{Lw} & logical \\ |
| 80 | + \texttt{A} & character data\\ |
| 81 | + \bottomrule |
| 82 | + \end{tabular} |
| 83 | + \caption{\label{tbl:format codes}Format codes for intrinsic types. \texttt{w} gives the width of a record, and \texttt{d} gives the number of places to the right of the decimal.} |
| 84 | + \end{margintable} |
70 | 85 | \item Comments in Fortran start with `\texttt{!}' and last until the end of the line. |
71 | 86 | \item Dividing integers \textcolor{red}{\textbf{results in an integer}}\index{Fortran!integer division}, so \texttt{3 / 2 == 1} instead of 1.5 as you might expect. |
72 | 87 | Multiplying by \texttt{1d0} on line 28 forces Fortran to do a double-precision floating-point calculation. |
|
115 | 130 | Note that \texttt{./} specifies the \emph{path}, \ie, the location where to find the program. |
116 | 131 | The dot means the current directory (similarly, \texttt{..} refers to the parent directory), and the slash separates directories and file names (like the backslash in DOS and Windows). |
117 | 132 |
|
118 | | -%\lstinputlisting[float=h!,label=lst:myProg]{examples/myProg.f90} |
| 133 | +\lstinputlisting[float=h!,label=lst:myProg]{examples/myProg.f90} |
0 commit comments