Installing and running NCL under Cygwin/X (Windows)This document contains helpful notes on running NCL under Cygwin/X on Windows systems. If you want to run NCL under Windows, you must first download and install Cygwin/X. Cygwin/X provides you with a UNIX shell and an X server from which you can then run NCL.
Here are some step-by-step instructions for getting NCL to run under Cygwin/X. Please read these instructions all the way through before starting the installation.
- Install Cygwin/X
- Run Cygwin/X
- Make sure you have a Cygwin home directory
- Download NCL
- Install NCL
- Set up your environment to run NCL
- Set up C-shell
- Set up DISPLAY environment variable
- Test NCL
- Troubleshooting problems
Install Cygwin/XTo download and install Cygwin/X, go to the URL:
Read the "Downloading and installing" paragraph, which tells you which installation file you need to download (setup.exe), and what to do with it. These notes are based on running version 2.738 of setup.exe or later.
When you start the installation process (by downloading "setup.exe" and double-clicking on the file wherever you downloaded it), you will be asked where to install Cygwin. I highly recommend that you select the default options, unless you know what you are doing.
You will eventually be asked to select a mirror site from which to download the software. I have found that some mirrors work better than others, and you may have to try several before you get a successful installation. I recommend starting with a mirror that is close to your geographic location, so the download is hopefully quicker.
Once you select a mirror site, you will be prompted for which packages to install. The packages have categories like "Shells", "Devel", "Graphics", etc. Clicking on the plus (+) sign next to each category name will expand or close the list of packages associated with that category. There's a search box at the top that is very useful to find packages that you are not sure what category they're in.
Note that when you select one package, it may cause several other packages to be chosen as well. This is okay; don't go back and unselect those packages!
Some categories and their related packages that you should install as a minimum include:
- Category "Devel": install "autoconf", "binutils", "bison",
"byacc", "flex", "gcc", "gcc4", "gcc4-fortran", "gcc-g++", "gdb",
"make", "makedepend", "openssl-devel".
- Category "Editors": [optional] some popular editors that
you might want for editing your files include "nedit", "emacs", and
- Category "Graphics": [optional] install "ghostscript" for
viewing PostScript files, "ImageMagick" for "convert"
- Category "Libs": "expat", "libcurl3", "libexpat-devel",
"libgfortran3", "libidn-devel", "libxml2", "sunrpc", "zlib"
- Category "Net": `install "libcurl-devel", "libcurl4", and
- Category "Shells": install "bash", "sh-utils", "pdsh", and
- Category "X11": install all of the required packages that
Cygwin/X" section mentions (see #15 where it lists all the "X11"
packages and whether they are required or optional). As of April
2010, the list of packages that we recommend are:
To select any of these packages for installation, click on the little circular icon next to it until you get a version number. Make sure you select the latest version number, if there are multiple ones. Some of the other options will be things like "skip", "uninstall", and "keep", which you don't want to use the first time through.)
If the installation is successful, then the last item may be a window asking if you want to create some icon shortcuts for your desktop. Answer "yes" to this question as it will provide you with a little "startxwin" icon under Windows that you can double-click to start up Cygwin/X.
If the installation fails or hangs while trying to install the software, then reboot if necessary, and rerun the setup.exe file as you did before, only this time choose a different mirror site.
Run Cygwin/XOnce the installation of Cygwin/X is complete, you need to start Cygwin/X, which will provide a terminal window for you to type commands in. If you have have a "startxwin" icon on your desktop, then you can start Cygwin/X by double-clicking on this icon. Otherwise, read the section "Using Cygwin/X" on how to start it. If you are successful, a window will pop up which you will then use for most of the instructions that follow. Newer versions of Cygwin/X will show a little "X" icon on your task bar if the X server was started successfully.
You must start X/Cygwin before proceeding to the next section.
Tip: if you installed Cygwin/X to the suggested location, then the Cygwin/X files will be installed under various directories under "c:\cygwin", and a home directory will be created for you under a path like "c:\cygwin\home\".
Make sure you have a Cygwin home directoryNote: some users have reported that a home directory has not been set up for them by Cygwin. I read in several FAQs that if the name of your home directory has a space in it, it won't work. I found an FAQ on this topic at http://www-cdf.fnal.gov/~cplager/cygwin.html#tidbits:
Cygwin doesn't like it if there is a space in your Windows username. If you have a space, do the following after installing Cygwin:
- Edit /etc/passwd (using either emacs, vi, or even Windows Wordpad)
- Find your entry (it will start with your windows username)
- Take the space out of your username (1st entry) and your home directory (2nd to last entry).
- Quit all Cygwin
- Use Windows Explorer to rename your home directory (for example "C:\cygwin\home\cplager")
Download NCLNow you are ready to download and install NCL. If you haven't already, go to the Earth System Grid web site and download the NCL binary that has the word "CYGWIN" in the name of the file.
A good place to save this file is in the location "c:\cygwin\home\xxx", where xxx is the home directory the Cygwin/X installation set up for you.
Install NCLOnce you have the *.tar.gz file, decide where you want to install NCL. If you are new to UNIX and don't know where you want to put it, then I recommend installing NCL in the directory "/usr/local". I'll use this path in my example below, and I will assume that you saved the file to "c:\cygwin\home\xxx", using "JohnDoe" as an example for xxx, and "ncl_ncarg-6.1.2.CYGWIN_NT-6.1-WOW64_i686.tar.gz" as the name of the file. (The name of the file may vary slightly, since the version number changes almost monthly.)
From the Cygwin/X window that you opened earlier, type the following commands:
mkdir /usr/local cd /usr/local gunzip /cygwin/home/JohnDoe/ncl_ncarg-6.1.2.CYGWIN_NT-6.1-WOW64_i686.tar.gz tar -xvf /cygwin/home/JohnDoe/ncl_ncarg-6.1.2.CYGWIN_NT-6.1-WOW64_i686.tarNote: the path "/usr/local" may already exist, in which case you'll get an error message when you type "mkdir /usr/local". This is okay, and you can safely ignore the message.
Set up your environment to run NCLEvery user of NCL needs to set their environment before they can use NCL. You can do this by opening your "c:\cygwin\home\xxx\.bashrc" (or "c:\cygwin\home\xxx\.bash_profile" if ".bashrc" doesn't exist) file with a UNIX editor and adding the lines:
export NCARG_ROOT=/usr/local export PATH=/usr/local/bin:$PATHPlease note that you must use a UNIX editor to change this file, and not a Windows application like "notepad". The UNIX editor should be invoked from a Cygwin or X/Cygwin window. If you are unfamiliar with UNIX editors, we recommend that you use nedit, which is available through the Cygwin "setup.exe" program.
Make sure you add the above lines after the last reference to PATH. If PATH already has "/usr/local/bin" as part of it, then you don't need to add the last line.
If you plan to use csh (C-shell) or tcsh , then add the following lines to your "c:\cygwin\home\xxx\.cshrc" (or ".tcshrc") file:
setenv NCARG_ROOT /usr/local setenv PATH /usr/local/bin:$PATHTo make sure these changes take effect right away, you can "source" the files, or completely exit your Cygwin/X window and start it up again. Here's how to source the files:
source ~/.cshrc source ~/.tcshrc
. ~/.bashrc . ~/.bash_profile
Set up C-shellIf you plan to use the "ng4ex" script, then you'll need to make sure you have C-shell before you can run it.
In the same Cygwin/X window, type:
which csh which tcshIf it reports that csh cannot be found but that tcsh can, then type the following:
ln -s /usr/bin/tcsh.exe /usr/bin/csh.exe cshThis will put you into a C-shell environment. You only need to execute the "ln -s" command once, but the "csh" command you will need to execute any time you are not in C-shell.
If the above "which" commands report that neither "tcsh" or "csh" can be found, thn you need to run "setup.exe" again, and make sure that you select the "tcsh" package (which falls under the "Shells" category) to be installed.
Set up DISPLAY environment variableIn order to run any X applications, including running NCL to display graphics to your screen, you may need to set up your environment by opening "c:\cygwin\home\xxx\.bashrc" in your favorite editor, and adding the following lines at the bottom:
export DISPLAY=:0.0If you are using C-shell, then edit "c:\cygwin\home\xxx\.cshrc" and add the following line:
setenv DISPLAY :0.0You should now be ready to run NCL.
Test NCLTo test your installation of NCL, type the following:
ncl -VThis should echo the version of NCL, like "6.1.2".
For a graphical test, type:
cp $NCARG_ROOT/lib/ncarg/nclex/xyplot/xy04n.ncl . ncl xy04n.ncl
A window with an XY plot should pop up. If you click anywhere in the window with your left mouse button, the window will go away.
Troubleshooting problemsIf you are having problems running the test in the above section, then here are some troubleshooting tips:
- If you get an error about "ncl" not being able to
find a missing "libxxxx.so" library, then
rerun the Cygwin "setup.exe" program and search for xxxx.
Make sure this package will get installed and finish running
the "setup.exe" program. You will probably need to logout and possibly
even reboot for the change to work properly.
- If you get the error:
warning:GKS:GOPWK: --X driver error: error opening displaythen this probably means that your DISPLAY environment variable is not set, or it is set incorrectly. Please type:
printenv DISPLAYand make sure that it is set to what is discussed in the "Set up DISPLAY environment variable" section above.
- If it appears your DISPLAY is set correctly, and yet "ng4ex" still
doesn't work, then you might be running the commands from a Cygwin
window, and not a Cygwin/X window. The distinction is important, and
you need to be running "ng4ex" from a Cygwin/X Window. Please read
the section "Run Cygwin/X" and make sure you
follow these instructions and then run "ng4ex" from this window.
You can tell if your Cygwin window is really a Cygwin/X window by the "X" icon that should appear in the upper left corner of the window.