Instructions for the installation of Fortran and c compilers, and a graphics library, on a Windows PC

A. J. Schultz

April, 2004

 

Text in bold are either text that you type or icons, menus or buttons that you click.

 

There are a number of free compilers one can install.  Some, such as Cygwin, emulate Linux in a window on your PC, while MinGW runs from a DOS command window.  I think MinGW is the easiest to install and run.

 

To install the Fortran and c compilers on your Windows PC (version numbers as of the above date):

 

1.                  Point your web browser to http://www.mingw.org/.

2.                  Click on Download in the frame on the left.

3.                  Scroll down the page to the row with Current/MinGW/bin in the rather long table.

4.                  Click on MinGW-3.1.0-1.exe, which will send you to the SourceForge.net web site.

5.                  Click on one of the Download icons.  I download the file to c:\temp on my PC.

6.                  Double click on c:\temp\MinGW-3.1.0-1.exe to launch the Setup Wizard.  If you choose the defaults, then this will create a folder c:\MinGW with all of the binaries, libraries and includes for g77 and gcc.

7.                  Right click on My Computer on your PC desktop, then left click on Properties (or go to the Control Panel folder and double click on System).

8.                  Click the Advanced tab, then Environmental Variables.

9.                  Select PATH in the User variables window (or create it with New).  Add c:\MinGW\bin to the PATH, such as %PATH%;c:\MinGW\bin;C:\GSAS\EXE. 

10.              It appears that one does not have to explicitly define the LIBRARY_PATH, so I suggest skipping this step.  However, if you find that it is necessary, under user variables, click New, then type LIBRARY_PATH for Variable name and c:\MinGW\lib for Variable value, then click OK.

11.              Click OK as many times as necessary to close the System Properties utility.

 

You should now be able to compile a program.  To test the Fortran compiler with a modified Hello World program, use a text editor such as Wordpad to create a file with the following text:

 

      PROGRAM HELLO

 

      CHARACTER YOURNAME*30

 

      WRITE (*, 100)

100   FORMAT(/,' Input your name: ',$)

      READ (*, *) YOURNAME

 

      WRITE (*, 200) YOURNAME

200   FORMAT(//,' Hello ',A/)

 

      STOP

      END

 

 

Name the file hello.f.  Then launch a DOS Command window, cd to the folder with hello.f.  In the following example, the file hello.f created in c:\MinGW was compiled and run:

 

C:\>cd mingw

 

C:\MinGW>g77 hello.f -o hello

 

C:\MinGW>hello

 

 Input your name: Art

 

 

 Hello Art

 

 

C:\MinGW>

 

 


 

To install the GrWin graphics library which will allow you to compile and run pgplot programs, do the following:

 

  1. Point your web browser to http://spdg1.sci.shizuoka.ac.jp/grwinlib/english/.
  2. Scroll down to Contents and click Download.
  3. Click on lGrWn0999be-MinGW.exe and save it to c:\temp.
  4. Double click on lGrWn0999be-MinGW.exe to laucnch the Setup Wizard.  Accept all of the defaults.
  5. You may need to define PGPLOT_FONT to c:\grwin\pgplot\grfont.dat in the system environmental variables, although it might be already defined for GSAS.  There is also a grfont.dat file with WinGX and ORTEP3 with the variable name PGFONT.
  6. In my case I found that the PATH search order is important since there appears to be an older version of grwnd.exe in the GSAS distribution kit that gets installed in the GSAS directory.  In that case, if PATH = “%PATH%;C:\GSAS\EXE;c:\MinGW\bin”, the programs will compile (see below), but the graphics windows will not display the graphs and you will get “No window” and “Incompatible library version” messages.  Switching the order to “%PATH%;c:\MinGW\bin;C:\GSAS\EXE” should fix the problem.

 

To test the installation, launch a command window and then type:

 

      > cd c:\grwin\demo

      > gwf77 trigfn

      > trigfn

 

You should see some sine and cosine curves in a graphics window.

 

To test a pgplot program,

 

      > cd c:\grwin\pgplot

      > pggwf77 pgdemo1

      > pgedmo1

 

When asked for a graphics device, type ? to see your choices.  If you choose /cgw, you will see a series of various types of graphs by typing return in the command window

 

By the way, gwf77 and pggwf77 are batch files which are stored in the c:\mingw\bin directory by the GrWin setup program.  You can examine the files to see what they do.