Wednesday, August 11, 2010

install FORTRAN, C compiler on Windows

install FORTRAN, C compiler and graph library on Windows
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. In the Downloads section, click on SourceForge File Release.
4. Download the Automated MinGW Installer package to your computer.
5. Double click on MinGW-5.1.6 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.
6. 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).
7. Click the Advanced tab, then Environmental Variables.
8. 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.
9. 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.
10. 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 Notepad 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 launch 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 with a text editor if you wish to see what they do.
----------------------------------------
Another FORTRAN compiler:
FTN77, FTN95, f77, fort77, bcf77 (16 bits), gfortran, ifort
edit FORTRAN files in MS-DOS prompt
notepad test.f
or
edit test.f
all FORTRAN compilers
comparison of different FORTRAN compilers
FORTRAN compiler for different OS
Compile multi files

1 comment:

  1. 10. OlĂ ,


    Brilliant article, glad I slogged through the #topic it seems that a whole lot of the details really come back to from my past project.

    write a c program that finds number of any paragraph and sentence in a text.
    I'm new at this and i really need to do this.


    Follow my new blog if you interested in just tag along me in any social media platforms!


    Thank you,

    ReplyDelete