Technical Aspects
Contents
I Introduction to command-line environment 2
I.I How to open the terminal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
I.II Paths and useful commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
I.III Text editors (suggestions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
II How to install gfortran 5
III How to install NetCDF libraries 6
IV How to connect remotely to a computer 9
V How to install Canopy-python 10
1
I Introduction to command-line environment
I.I How to open the terminal
GNU/Linux
You can either:
X Open the Dash by clicking the Ubuntu icon in the upper-left, typer ”terminal”, and select the
Terminal application from the results that appear.
X Hit the keyboard shortcut
Ctrl
-
Alt
+
T
MacOS
X Press
cmd /
+ . The search bar will open.
X Write ”terminal” and press the return key
Windows
X Press +
R
to open RUN dialog box.
X Write ”cmd”,and click/tap on OK.
2
I Introduction to command-line environment
I.II Paths and useful commands
GNU/Linux and MacOS are based on UNIX, therefore all the commands are similar for both OS. Windows, on the other
hand, uses different command lines.
Path
Comment
Paths are written using ”/” Paths are written using \
Example
/Users/user/Desktop
c:\Users\user\Desktop
Change directory
Command
cd
cd
Example
cd dirname
cd dirname
Create a new directory
Command
mkdir
mkdir
Example
mkdir dirname
mkdir dirname
View the contents of a directory Command
ls
dir
Print current working directory Command
pwd
cd
Move (rename) a file/directory
Command
mv
move
Example
mv infile outfile
move infile outfile
Copy a file
Command
cp
copy
Example
cp file filecopy
copy file filecopy
Copy a directory
Command
cp -r
xcopy
Example
cp -r dir dircopy
xcopy dir dircopy
Remove a file
Command
rm
del
Example
rm filename
del filername
Remove a directory
Command
rm -r
rd
Example
rm -r dirname
rddirname
3
I Introduction to command-line environment
I.III Text editors (suggestions)
This is a list of some text editor that may be useful for this course.
GNU/Linux
X You can use the default text editors in GNU/Linux: Emacs or Vim.
Quick reference cards:
1. Emacs reference card
2. Vim quick reference card
MacOS
X You can install Emacs or Vim for Mac.
- Emacs: https://emacsformacosx.com
- Vim (macVim): https://github.com/macvim-dev/macvim
X Another alternative is to install Xcode (it may be useful in the future).
- Open up the App Store application and search for Xcode - the suite of tools for developers
- Agree to Xcode licence. Once Xcode is downloaded, open up the Terminal app and type:
sudo xcodebuild -license
- Hit spacebar a few times as directed and then type: ’agree’.
Windows
X You can use the default text editors in Windows: Notepad or Wordpad.
X Another recommended alternative is Notepad++. You can downloaded it from:
https://notepad-plus-plus.org/download/v7.3.html
4
II How to install gfortran
GNU/Linux
X GNU/Linux should include by default the gfortran libraries. However, in case it is not installed,
open up the terminal and type:
sudo apt-get install gfortran
MacOS
X The ”GCC Wiki” implementation described in the following procedure is typically the newest
binary release of gfortran, but requires that you download a version appropriate for your architec-
ture.
I - Visit the GCC Wiki GFortranBinaries page and scroll to the MacOS section.
II - Download gfortran-macosx-x86.dmg (Intel) or gfortran-macosx-ppc.dmg (PowerPC).
III - If your browser did not automatically mount the disk image, the double-click the dmg file to
mount and open it.
IV - Open the unmounted gfortran-macosx-{architecture}-{version} folder, double-click
gfortran.pkg, and follow the prompts to install it.
Windows
X Stand-alone gfortran binaries for Windows are available as an installer .
I - Download the installer, and run it.
II - Accept the GNU Public License, choose an directory to install gfortran, and let it work for you.
III - The installer sets your PATH environment variable, so that simply typing gfortran in a com-
mand prompt will run the compiler.
5
III How to install NetCDF libraries
GNU/Linux
X Alternative I - Use a package manager to download libraries
This approach is generally the easiest one provided you find a library which was compiled with
the same compile you plan to use (gnu gfortran for example). Make sure you install development
libraries and Fortran interface libraries.
X Alternative II - Download the libraries from the source page
You can download the gzipped tar file with the source code from:
http://www.unidata.ucar.edu/downloads/netcdf/index.jsp
To install it do the following. Untar the downloaded file and enter the directory with downloaded
code:
tar -xzf netcdf-3.6.3.tar.gz
cd netcdf-3.6.3
Choose a directory where you want to install NetCDF, say ”/opt/netcdf/3.6.3” (make sure that
directory above it exists and is writable to you). Make sure that Fortran compiler is installed and is
functional. Now, start the installation process. Inform the system which Fortran compiler you are
going to use
export FC=gfortran
Configure the package giving it the desired location for installation
./configure —prefix=/opt/netcdf/3.6.3
Compile and install the package
make
make install
6
III How to install NetCDF libraries
MacOS
Taken from http://mazamascience.com/WorkingWithData/?p=1474
I - Install Xcode
Open up the App Store application and search for Xcode the suite of tools for developers.
II - Agree to Xcode license
Once Xcode is downloaded, open up the Terminal app and type:
sudo xcodebuild -license
Hit spacebar a few times as directed and then type: ‘agree’.
III - Install MacPorts
Download the appropriate version of MacPorts from www.macports.org/install.php . Then click on the
package to open up the package installer. After installation has finished you should close any Terminal
windows and open up a new one that will now be aware of the new port command. Try it out with:
port help
...
port info netcdf
IV - Install netcdf libraries and associated tools
Each of the following installations will automatically install any dependencies.
sudo port install netcdf
...
port port install ncview
V - Make sure you have X11
To install X11 just open the Utilities folder on your machine and click on the X11 icon. If X11 is not installed
you will be prompted to install it. This will take you to the https://xquartz.macosforge.org where you
can download the disk image for the latest version of XQuartz.
Once the download is finished, double click on the XQuartz.dmg file and again on the XQuartz package and
walk through the installer. The last instruction is to log out and back in again.
7
III How to install NetCDF libraries
Windows
Instructions provided by Jimmy Thelander
I - Download MSYS2:
32 bit: http://repo.msys2.org/distrib/i686/msys2-i686-20161025.exe
64 bit: http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20161025.exe
II - Install MSYS2
III - Start MSYS2
IV - Install compilers and dependencies
Type in the MSYS2 terminal (all in one line):
For 32-bit:
pacman -S mingw-w64-i686-gcc mingw-w64-i686-hdf5 gcc gcc-fortran tar zlib make
For 64-bit:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-hdf5 gcc gcc-fortran tar zlib make
V - Download NetCDF
cd ~
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.4.1.1.tar.gz
VI - Build netcdf (replace mingw64 with mingw32 if 32-bit system)
tar xfvz netcdf-4.4.1.1.tar.gz
cd netcdf-4.4.1.1
The following command goes in one single line:
LDFLAGS="-L/mingw64/lib" CFLAGS="-I/mingw64/include" CPPFLAGS="-I/mingw64/include"
./configure --prefix=/mingw64/
make
make install
VII - Download NetCDF-Fortran
cd ~
wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.4.tar.gz
VIII - Build NetCDF-Fortran (replace mingw64 with mingw32 if 32-bit system)
tar xfvz netcdf-fortran-4.4.4.tar.gz
cd netcdf-fortran-4.4.4
The following command goes in one single line:
LDFLAGS="-L/mingw64/lib" CFLAGS="-I/mingw64/include" CPPFLAGS="-I/mingw64/include"
./configure --prefix=/mingw64/
make
make install
8
IV How to connect remotely to a computer
GNU/Linux and MacOS
X Mac and Linux come with SSH clients that can help connecting to remote servers. However, X11
(the graphical user interface) is no longer included with OS X. X11 server and client libraries for
OS X are available from the XQuartz project (http://xquartz.macosforge.org ).
I - Login by typing
ssh -XY <userid>@<hostname> <press enter>
<remote_password> <press enter>
Windows
X Both SSH and the graphical user interface X11 are not included by default in Windows. There are
many options available but in this guide we will present how to install PuTTY. PuTTY is a free
implementation of Telnet and SSH for Windows, along with a xterm terminal emulator:
I - Download and install XMing:
http://sourceforge.net/projects/xming/
Select Multiple Windows and type the number 0 for Display number.
II - Download and install PuTTY:
https://the.earth.li/ sgtatham/putty/latest/x86/putty.exe
After you have downloaded the installer for Windows, run it, and follow through the steps.
Unless you know what you are doing, stick with the default installation options. After download
completes, you are done with the installation.
To connect to a remote server using PuTTY, provide the hostname of the remote server and
the port number on which the SSH server is listening. The default port is 22. Make sure the
connection type is ssh.
III - Configure the X11 forwarding.
Scroll to Connection > SSH > X11. Check the box next to Enable X11 Forwarding. By
default the X Display location is empty. You can enter localhost:0. The remote authentication
should be set to MIT-Magic-Cookie-1.
IV - Login to the remote server
Go back to Session. Click Open to bring up the terminal and login using your userid/password.
9
V How to install Canopy-python
Instructions taken from http://docs.enthought.com/canopy/quick-start
GNU/Linux
I - Download Canopy:
Canopy 2.7 for LINUX: https://store.enthought.com/downloads/installer/74/
II - Install Canopy
Open the terminal and type the following commands:
cd ~/Downloads
bash canopy-2.0.0-rh5-64.sh
III - Launch Canopy
Canopy can be launched by executing the following command in the terminal:
~/Canopy/canopy
MacOS
I - Download Canopy:
Canopy 2.7 for MacOS: https://store.enthought.com/downloads/installer/70/
II - Install Canopy
The Mac OSX version of Canopy is distributed as a disk image (.dmg) file. Opening this file displays the
installation window shown below. Canopy can be installed by dragging the Canopy icon to the Applications
folder in the window, to the computer Desktop, or to another folder. If you drag it to the Applications
folder, it will show as “Canopy” along with your other applications.
Windows
I - Download Canopy:
32 bit: https://store.enthought.com/downloads/installer/78/
64 bit: https://store.enthought.com/downloads/installer/82/
II - Install Canopy
To start the installer, double-click the downloaded file. Verify that the publisher is listed as Enthought, Inc.
and click Run.
Environment Setup for all OS:
When Canopy is launched for the first time, it will automatically configure your Python environment in the default location unless
specified otherwise by a command-line option or a preference setting.
10
V How to install Canopy-python
NOTE: Make sure you have the following Python Packages installed in the Canopy after installation
1. NumPy
2. SciPy
3. matplotlib
4. Basemap
5. netCDF4
6. Pandas
7. TkInter
8. Jupyter
Installing packages in Canopy for all OS:
In the editor window of Canopy, go to Tools>Package Manager. A new window will pop-up, you can search
the desired package here and then just click on install. The majority of the packages listed above are already
installed by default.
11