Skip to content

Commit 7bb0c9d

Browse files
committed
Added table of format codes
1 parent 4dab75c commit 7bb0c9d

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

chapters/Getting_your_toes_wet.tex

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,22 @@
6666
\item `\texttt{*}' is multiplication, `\texttt{**}' is exponentiation.
6767
\item The \keyword{print} statement on line 24 contains the format code\index{Fortran!format codes} \str{"(4I6)"}.
6868
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}
7085
\item Comments in Fortran start with `\texttt{!}' and last until the end of the line.
7186
\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.
7287
Multiplying by \texttt{1d0} on line 28 forces Fortran to do a double-precision floating-point calculation.
@@ -115,4 +130,4 @@
115130
Note that \texttt{./} specifies the \emph{path}, \ie, the location where to find the program.
116131
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).
117132

118-
%\lstinputlisting[float=h!,label=lst:myProg]{examples/myProg.f90}
133+
\lstinputlisting[float=h!,label=lst:myProg]{examples/myProg.f90}

0 commit comments

Comments
 (0)