Jiggling & Wiggling

2005/06/03

G95之how to

Filed under: 杂七杂八 — roylez @ 11:46 上午

How to configure emacs for g95 error messages (Helge Avlesen)
Add the following lines to your .emacs file:
;; add g95 to compilation mode
(eval-after-load “compile”
‘(setq compilation-error-regexp-alist
(cons ‘(“^In file \\(.+\\):\\([0-9]+\\)” 1 2)
compilation-error-regexp-alist)))

This will allow emacs to find the next error message in compile mode.

How to set up Photran to work with g95

Now you can develop your Fortran programs with g95 using Photran, a full featured Fortran IDE based on Eclipse. It is available for both Windows and Linux systems. Photran does not yet support automatic Makefile generation for complex builds, but g95 users can implement this with a separate Perl script. This is a summary of the steps required to setup Photran and g95 on a Windows XP system.

1. Install MinGW. The self-extracting installer MinGW-3.2.0-rc-3.exe provides MinGW, the binutils package, and Perl.

2. Install Msys, which provides make and several other tools. Both Msys and MinGW are available from: http://www.mingw.org/download.shtml. You may need to edit the file c:\msys\1.0\etc\profile to get MinGW to work with Msys.

3. Install the MinGW version of g95 into the MinGW directory.

4. Install the Photran/Eclipse package from http://www.photran.org/. Alternatively, you can install the Eclipse package, and then install the Photran plug-in.

5. Set up the PATH to find MinGW and g95, and the LIBRARY_PATH environment variable, e.g.:

SET PATH = c:\MinGW\bin;c:\msys\1.0\bin;%PATH%
SET LIBRARY_PATH = c:\MinGW\lib
6. Download the Perl script “mkmf.pl”, available from: http://www.gfdl.noaa.gov/~vb/mkmf.html.
Edit the script as follows:

Change all occurrences of ‘a.out’ to ‘a.exe’.
Change the FC and LD variables under the “#begin writing makefile” section to the following:
printf MAKEFILE “FC = g95\n”;
printf MAKEFILE “LD = g95\n\n\n”;
Save your edited script as “mkmf-g95.pl”.
7. To set up Photran to run Perl scripts, proceed as follows:

Start Photran.
Select , , .
Under “Configurations” select .
Select .
In the “Name” field enter: “Run Perl”.
In the “Location” field enter: “c:\WINDOWS\System32\cmd.exe”.
In the “Working Directory” field enter: “c:\WINDOWS\System32”.
In the “Arguments” field enter the following line:

/C “cd ${container_loc} && perl ${resource_name}”
Select the tab.
In “Type of launch configuration” select “Local”.
In “Display in favourites menu”, check the “External Tools” box.
Click , .

8. To add a Fortran project, proceed as follows:

Start Photran.
At the Photran workbench; select , , .
Give the project a name.
Select .
Select , and check:

Photran Error Parser for G95 Fortran
Photran GNU Linker Error Parser
Photran GNU Make Error Parser
Select , check “PE Windows Parser”. Uncheck “Elf Parser”.
Click .
Add some Fortran source files to the project, either using the Photran editor, or by copying some Fortran source files to the project directory using Windows Explorer.

Note: If you prefer to use a different editor for programming, you may tell Photran to use another editor, as follows:

Select , , , , .

Hilight the file types you want to be associated with it, such as ‘*.f90’, and ‘*.f’, and enter the path to the editor of your choice.

9. To compile, proceed as follows.

Copy the Perl script mkmf-g95.pl (item 6 above) to the project directory.

Select the script in the Navigator window.
Select , .

Check that the message “…. Makefile is ready” appears in the console.

To build the project, select , , .
If there are no errors, the executable “a.exe” will appear in the Navigator window.

10. To run your program:

Select , .
If necessary, expand the items listed under “Configurations”.
Select the current project.
Add the project name in the field.
Add the executable name in the field.
Select .

If all goes well, the results are displayed in the Console window.

For information on setting up Photran with Cygwin, see: ftp://ftp.swcp.com/pub/walt/F/photran.pdf

——————————————————————————–

How to configure LAPACK for g95
The only change that needs to be made to correctly build LAPACK for x86 machines is to set the NOOPT macro in make.inc:
NOOPT=-ffloat-store

This prevents optimizations from interfering with the subroutines that are trying to query various characteristics of the floating point unit.

——————————————————————————–

How to compile ARPACK with g95 (Guglielmo Pasa)
Use ARmakeg95.inc and Makefileg95.make and OBjectg.make in this tarball to build a static and a dynamic library for arpack.
——————————————————————————–

How to configure MPICH2-1.0.1 with g95 (Guglielmo Pasa)
Set
alias f77=g95 -ffixed-form -fno-underscoring
alias f90=g95 -ffree-form -fno-underscoring

verify that it detects the right compilers and then run
$ ./configure –prefix=/usr/local –enable-f77 –enable-f90
–with-pm=smpd
–with-pmi=smpd
$ make
$ make install

Try some tests. You can use the MPICH2 WinXP service binary distro found on the MPICH2 site with it.
——————————————————————————–

How to configure BLACS with g95 (Guglielmo Pasa)
If BLACS source tree is in $(HOME)/BLACS Edit Bmake.inc and change
BTOPdir=$(HOME)/BLACS

COMMLIB = MPI
PLAT = g95xp # for example

MPIdir = /usr/local # root installation directory of MPICH
MPILIBdir = $(MPIdir)/lib
MPIINCdir = $(MPIdir)/include
MPILIB = -L$(MPILIBdir) -lmpich -lpmpich -lmpich -lcrypto
….
INTFACE = -DNoChange # leaves symbols of C objects the same form as g95 ones
# i.e. no underscores and lower case

TRANSCOMM = -DCSameF77

F77 = g95
F77NO_OPTFLAGS = -ffixed-form -fno-underscoring

RANLIB = ranlib

Once this is done go to SRC/MPI and modify Makefile
In
Clong = …

If you are on windows, change all the .C extensions with .Z as windows isn’t case sensitive to copy/write files, so even if cygwin is case sensitive sometimes it fails to distinguish .C and .c

Cintobj = $(comm.:.o=.Z) $(supp:.o=.Z) $(Clong)

clean:
rm -f … $(long:.o=.Z)

Cblacs_gridinit_.C : etc change all extension .C to .Z

.SUFFIXES: .o .Z
.c.Z:
$(CC) -o C$*.o -c $(CCFLAGS) $(BLACSDEFS) -DCallFromC $

发表评论 »

还没有评论。

RSS feed for comments on this post. TrackBack URI

留下评论

通过访问 WordPress.com 创建免费网站或博客.