|
1 | 1 | \Chapter{Getting your toes wet}{with Fortran and Linux} |
2 | 2 | \label{chap:Getting your toes wet} |
3 | 3 | \begin{quote}\small |
4 | | - \emph{``1957: John Backus and IBM create FORTRAN. There's nothing funny about IBM or FORTRAN. It is a syntax error to write FORTRAN while not wearing a blue tie.''} \\ \hspace*{\fill}---James Iry |
| 4 | + \emph{``1957: John Backus and IBM create FORTRAN\@. There's nothing funny about IBM or FORTRAN\@. It is a syntax error to write FORTRAN while not wearing a blue tie.''} \\ \hspace*{\fill}---James Iry |
5 | 5 | \end{quote} |
6 | 6 |
|
7 | 7 | For this course we recommend using the GNU Fortran compiler, as it is free and of reasonably high quality.\footnote{You're welcome to use the Intel Fortran compiler, which is free on Linux, but remember to change the compiler flags, since they differ from \texttt{gfortran}.} |
|
16 | 16 | $ sudo apt-get install gfortran gfortran-doc |
17 | 17 | \end{lstlisting} |
18 | 18 | \emph{Note that anything you type in the console is case-sensitive!} |
19 | | -This command grants \texttt{aptitude} privileges to search for and then install the \texttt{gfortran} package and its documentation. |
| 19 | +This command grants the package manager (\texttt{aptitude}) privileges to search for and then install the \texttt{gfortran} package and its documentation. |
20 | 20 | You may also find it useful to install the \LaTeX\ typesetting system for writing reports. |
21 | | -You can install it with another call to \texttt{aptitude}: |
| 21 | +You can install it with another call to \texttt{apt-get}: |
22 | 22 | \begin{lstlisting}[style=prompt, nolol, breaklines=false] |
23 | 23 | $ sudo apt-get install texlive # or texlive-full for a complete installation |
24 | 24 | \end{lstlisting} |
|
29 | 29 | \begin{lstlisting}[style=prompt, nolol, linewidth=30cm] |
30 | 30 | $ ls # display the contents of the current directory |
31 | 31 | $ ls -l # display contents with extra details |
32 | | - $ cp file path # copy 'file' to 'path' |
33 | | - $ mv file path # move 'file' to 'path' |
34 | | - $ rm file # remove 'file' |
35 | | - $ mkdir dir # create a new directory called 'dir' |
36 | | - $ cd dir # change current directory to 'dir' |
37 | | - $ rmdir dir # remove directory 'dir' (only if it's empty) |
38 | | - $ rm -r dir # remove directory 'dir' (even if it's not empty) |
39 | | - $ man cmd # provide documentation on 'cmd' |
| 32 | + $ cp file path # copy `file' to `path' |
| 33 | + $ mv file path # move `file' to `path' |
| 34 | + $ rm file # remove `file' |
| 35 | + $ mkdir dir # create a new directory called `dir' |
| 36 | + $ cd dir # change current directory to `dir' |
| 37 | + $ rmdir dir # remove directory `dir' (only if it's empty) |
| 38 | + $ rm -r dir # remove directory `dir' (even if it's not empty) |
| 39 | + $ man cmd # provide documentation on `cmd' |
40 | 40 | \end{lstlisting} |
41 | 41 |
|
42 | 42 | For your first program, open a terminal, create a directory for ICCP files and open your first Fortran file by typing |
43 | | -\marginnote[-0.5cm]{Modern terminal emulators all have a feature called |
44 | | - \emph{tab completion}\index{Tab completion}; hit the \texttt{TAB} key after you've entered part of a command and the terminal will attempt to fill in the rest of the command for you.} |
| 43 | +\marginnote[-0.5cm]{Modern shells all have a feature called |
| 44 | + \emph{tab completion}\index{Tab completion}; hit the \texttt{TAB} key after you've entered part of a command and the shell will attempt to fill in the rest of the command for you.} |
45 | 45 | \begin{lstlisting}[style=prompt, nolol, linewidth=30cm] |
46 | 46 | $ mkdir iccp # create a new directory called 'iccp' |
47 | 47 | $ cd iccp # move to the new directory |
|
62 | 62 | For double-precision numbers, use \texttt{d} instead of \texttt{e} in scientific notation, \eg, \texttt{1d-1}. |
63 | 63 | It is also possible to specify the precision as a suffix: \texttt{1.0\_4} for single and \texttt{1.0\_8} for double precision. |
64 | 64 | This also works for integers. |
65 | | - \item \texttt{\keyword{integer} :: fibonacci(N)} allocates an array of 20 |
66 | | - integers, with the array\index{Fortran!arrays} index\footnote{Array indices can start at any integer by replacing \texttt{N} with a lower and upper bound separated with a colon. Thus, \lstinline$real :: myArray(-312:74)$ means \texttt{myArray} starts at index -312 and runs through index 74.} running from 1 to 20. |
| 65 | + \item \texttt{\keyword{integer} :: fibonacci(N)} allocates an array of 20 integers, with the array\index{Fortran!arrays} index\footnote{Array indices can start at any integer by replacing \texttt{N} with a lower and upper bound separated with a colon. Thus, \lstinline$real :: myArray(-312:74)$ means \texttt{myArray} starts at index -312 and runs through index 74.} running from 1 to 20. |
67 | 66 | \item `\texttt{*}' is multiplication, `\texttt{**}' is exponentiation. |
68 | 67 | \item The \keyword{print} statement on line 24 contains the format code\index{Fortran!format codes} \str{"(4I6)"}. |
69 | 68 | This tells Fortran to print 4 records of integer type, each having a width of 6 characters (including spaces), per line. |
|
116 | 115 | Note that \texttt{./} specifies the \emph{path}, \ie, the location where to find the program. |
117 | 116 | 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). |
118 | 117 |
|
119 | | -\lstinputlisting[float=h!,label=lst:myProg]{examples/myProg.f90} |
| 118 | +%\lstinputlisting[float=h!,label=lst:myProg]{examples/myProg.f90} |
0 commit comments