0% found this document useful (0 votes)
17 views5 pages

Notes 31 35

Uploaded by

briley.boede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views5 pages

Notes 31 35

Uploaded by

briley.boede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

1.8.

UNIX 31

• ls -lrt This lists the elements contained within the working directory in detailed
form, also giving the ordering by files most recently modified.

• rm file This removes the file named file from the directory.

• cp file1 file2 This copies the file named file1 into the file named file2. If file2 already
exists, it is overwritten by file1.

• mv file1 file2 This 1) moves the file named file1 into the file named file2, and 2) removes
the file named file1. If file2 already exists, it is overwritten by file1.

• mkdir directory This creates the directory named directory within the working direc-
tory.

• rmdir directory This removes the directory named directory. The directory must be
empty in order to remove it.

• cat file Concatenate (i.e. print to the screen) the contents of file.

• more file Print to the screen the contents of file one screen at a time and use the space
bar to move down in the file.

• less file Like more except one can use arrows or j, k keys to navigate up and down
in file.

• UNIX command & Execute the process UNIX command in the background so as to
keep the terminal window available for user input.

• UNIX shortcut * a wildcard character which stands in for arbitrary characters.

One should note that other operating systems such as OS-X or Microsoft Windows have
file system devices such as OS-X’s “Finder” which give a WYSIWYG view of the UNIX tree
structure of organizing files. The two approaches are entirely compatible, and in fact can be
applied to arrange the same files. One is simply more visual than the other.
A file can be identified by its local address as long as the user resides in the proper
directory. For example to view the file helloworld.f90, one first insures it lives within the
present directory, and then executes

[powers@darrow2-p ame.20214]$ cat helloworld.f90

If the user resides in a different directory and still wishes to view the same file without first
navigating to that directory, one can used the absolute address, for example

[powers@darrow2-p ame.20214]$ cat /afs/nd.edu/users/powers/www/ame.20214/helloworld.f90

CC BY-NC-ND. 29 April 2021, J. M. Powers.


32 CHAPTER 1. OVERVIEW

A highly useful feature of most modern UNIX implementations is the arrow keys’ ability
to recall previous commands and edit them. It is difficult to display this without an actual
demonstration.
Here we illustrate some of the power of UNIX commands. The user may want to copy all
of the sample Fortran programs from the course home space to the user’s personal home
space. Since at Notre Dame both the course home space and the user’s home space are all
within AFS, and because the course home space is a public directory, copying is easy and can
be done in a few simple commands. The sequence of commands is described as follows:

1. Sign onto a UNIX-based machine.

2. Create a new directory within your home space.

3. Change directories into that new directory.

4. Copy all files with an .f90 extension into your new directory.

5. List those files to make sure they are present.

A sample set of UNIX commands which achieves this is as follows:

[powers@darrow2-p ~]$ mkdir programs


[powers@darrow2-p ~]$ cd programs
[powers@darrow2-p ~/programs]$ ls
[powers@darrow2-p ~/programs]$ cp ~powers/www/ame.20214/2e/*.f90 .
[powers@darrow2-p ~/programs]$ ls -lrt
total 10
-rw-r--r-- 1 powers campus 65 Sep 16 12:41 ch15a.f90
-rw-r--r-- 1 powers campus 894 Sep 16 12:41 ch13d.f90
-rw-r--r-- 1 powers campus 269 Sep 16 12:41 ch13c.f90
-rw-r--r-- 1 powers campus 213 Sep 16 12:41 ch13b.f90
-rw-r--r-- 1 powers campus 210 Sep 16 12:41 ch13a.f90
-rw-r--r-- 1 powers campus 156 Sep 16 12:41 ch12g.f90
-rw-r--r-- 1 powers campus 202 Sep 16 12:41 ch12f.f90
-rw-r--r-- 1 powers campus 217 Sep 16 12:41 ch12e.f90
-rw-r--r-- 1 powers campus 152 Sep 16 12:41 ch12d.f90
-rw-r--r-- 1 powers campus 152 Sep 16 12:41 ch12c.f90
[powers@darrow2-p ~/programs]$

Here mkdir made the new directory programs. We then moved into the directory programs,
via the cd command. We then listed the files within programs and found that it was empty.
We then copied all files with the .f90 extension into the existing directory, indicated by
the “dot”, [.], shorthand for the existing directory. We then re-listed the programs in the
directory and found ten new programs listed.

CC BY-NC-ND. 29 April 2021, J. M. Powers.


1.9. ONLINE COMPILERS 33

1.9 Online compilers


There exist a variety of open-source web-based compilers of a variety of languages, including
Fortran. These can be useful for editing and debugging, mainly because the user interface
is more intuitive than UNIX. There may be challenges in porting input and output files,
depending on the web interface chosen. An example interface is found at
http://www.tutorialspoint.com/compile fortran online.php.
A screen shot of this web browser-based interface is shown in Fig. 1.8.

Figure 1.8: Screen shot of a web browser-based Fortran interface.

CC BY-NC-ND. 29 April 2021, J. M. Powers.


34 CHAPTER 1. OVERVIEW

CC BY-NC-ND. 29 April 2021, J. M. Powers.


Chapter 2

Introduction to problem solving

Read C&S, Chapter 2.

Here, we summarize a few of the key concepts of this chapter. Problems are often formu-
lated in words, which can be ambiguous. Some problems are amenable to mathematical and
computational analysis, and a challenging chore is to translate imprecise words into precise
computer code. The code to solve the posed problem is based upon a logical construct known
as an algorithm. An algorithm is much like a recipe for cooking. An important element of
most good scientific computing task involves what is known as object-oriented programming.
Such an approach relies upon identifying repetitive tasks and writing a single algorithm for
a task that is commonly executed as part of solving a larger problem. These building blocks,
known as objects can be highly refined and optimized since they will be repeated many times
in the course of a calculation. One might imagine developing a sub-algorithm for performing
matrix inversion within a larger problem that requires inversion of many matrices of different
types. Rather than write separate code for each matrix inversion, one writes one subroutine
to invert matrices of arbitrary dimension, provided of course they are invertible. Then that
subroutine may be called upon many times within the more general algorithm.

35

You might also like