分享

Clive Page博士的Fortran 资源

 mtjs 2010-03-20
copy from:http://www.star./~cgp/fortran.html

Thank you so much Dr. Clive Page,i got lot from this page. by mtjs

Clive Page's list of Fortran Resources

Last revised: 2009 Jan 29.

Fortran90/95

Fortran95 was a relatively minor revision to Fortran90, so that nearly all compilers for Fortran90 have now been updated to add the small set of additional features introduced with Fortran95.

Fortran95 Compilers

Just as with buses, so with Open Source compilers for Fortran95: you wait ages for one, then two arrive at once. The two possiblilities are: These two compilers started out with a common code base but the development project subsequently forked. One might think this is an unfortunate thing to happen, but in fact there now seems to be some element of competition between the two sets of developers, and both projects are advancing quite rapidly. In fact g95 is mostly the work of one exceptional person, Andy Vaught, while gfortran has a larger group of programmers working part-time.

Both compilers are already pretty much adequate for everyday use: they both support nearly every feature of Fortran-95 and a few features of Fortran-2003 such as stream-IO. At present (April 2007) my impression is that g95 is slightly better at handling some of the more baroque features of Fortran and diagnosing errors, but gfortran is said to produce code which often executes somewhat faster. The tables at Messrs Polydron give more details. By the time you read this the situation may have changed, as both compilers are in active development. Note that when installing g95 on Windows XP it is a very good idea to install it in a subdirectory of the file system root such as C:\g95\ . There is as yet not much documentation on either compiler. I considered trying to revise my old book but decided that so much needed to be changed that it would be easier to start from scratch. I am working on this slowly, but it is at present only about a quarter complete.

Besides these Open Source compilers, there are two commercial compilers which can be used free of charge for personal use under limited circumstances:

Information on a large number of compilers for Fortran can be found on Michel Olagnon's invaluable Fortran 90 List.

Fortran90/95 Information

How to use PGPLOT Graphics Library with Fortran95 on Windows-XP

NEW PGPLOT is an excellent mature and well-documented library of grapical routines but has previously been hard to install on Windows to use with modern Fortran compilers such as g95 and gfortran. See this how-to document for instructions.

Revised notes on Stream I/O in Fortran

Stream I/O was introduced in the Fortran2003 Standard but is already supported by the g95 and gfortran compilers. This is an important facility for handling files written by non-Fortran software packages. I have written some notes on Stream I/O.

Using DISLIN to put a GUI Front-end on a Fortran Program

The graphics library DISLIN has a Fortran90 interface. It is a commercial package but the licence permits use free of charge for non-commercial purposes. DISLIN can also be used to create a graphical user interface and I have written some notes on how to do this here.

Fortran77 Programmers Converting to Fortran90/95

Here are some notes from a Fortran90 course for Fortran77 programmers that I have given a few times, in HTML or in PDF and a document called Fortran90 for Fun and Profit (PostScript format) which gives a summary of the most useful new features of Fortran90.

 

Some words of advice for someone wanting to upgrade a large f77 program to f90 are here

The University of Liverpool has a Fortran95 course on-line.

They also have High Performance Fortran information and links.

The Manchester and North Training and Education Center have a collection of courses and on-line training materials for Fortran77 programmers to introduce them to Fortran90.

High Performance Object-oriented Fortran90 is covered here.

Fortran77 to Fortran90 style converters

Note that, with some extremely minor exceptions, the whole of Fortran77 is a subset of Fortran90, so that no conversion of astandard conforming Fortran77 program is necessary. The style converters listed here may be useful, however, as they convert the source from fixed to free-format style, and do other syntax conversions which may make subsequent program maintenance simpler.
  • Metcalf and Reid's conversion program convert.f90 which has the useful option of being able to create interface blocks.
  • Alan Miller's program to_f90 which attempts more ambitious conversions such as adding INTENTs for subprogram arguments (and usually succeeds) can be found on his site http://users./amiller/.
  • FLECS (another converter) flecs90.tar.gz 
Note that I have only used the first two of these myself; they have somewhat different capabilities, but I have found both very useful. 

The F Programming Language

The F language is a subset of Fortran90 with, esssentially, all the new features included but all the antique stuff left out. It is available for Linux, Solaris, and Windows, and can be downloaded free from The Fortran Company web-site. Some notes on how to use the Windows version of F have been posted by Penn State.

A comparison of F with a similar subset supported by the (non-free) ELF90 compiler from Lahey can be found in the 1996 Nov/Dec issue of The Fortran Journal

Fortran2003

The new Standard is now fixed. for a good description of its new features The Future of Fortran by John Reid. 

The site of The Fortran Standards Technical Committee covers their current activities.


Fortran77

The Fortran77 Standard was in use for a long time but has long been superseded by Fortran90 and Fortran95. The latest Standard, to be called Fortran2003, is released but it the first compilers which support it fully are not expected before late 2008.

Fortran77 Compilers

Now that there are several Fortran95 compilers available, it no longer makes sense to use those which only support Fortran77, such as GNU's g77. The version which I formerly packaged for downloading does not work under Windows XP (only under operating systems which are now obsolescent such as Windows-98).

Fortran77 Information

Around 1987 I wrote a slim volume called Professional Programmer's Guide to Fortran77 which was published by Messrs Pitman. It is now both out-of-date and out-of-print. Although it is not much use any more, it is still available on-line, which may be printed our downloaded in various formats:

Another Fortran77 textbook is available on-line written by Ian Chivers and Jane Sleightholme of King's College London: their site has links to many other useful resources.

Fortran77 syntax checking - FTNCHEK

Since Fortran77 has more pitfalls than newer forms of the language, I strongly recommend using a syntax checker on every new or modified Fortran77 program.  The program called FTNCHEK from Robert Moniot and colleagues does an excellent job and is entirely free.  You can download the program for any of a range of operating systems fromhttp://www.dsm./~ftnchek/

General Information on Fortran:

Algorithms and procedures in Fortran:

Companies with useful on-line information include:

Fortran, HTML, Java, C, and C++

To generate HTML from Fortran90 you can use Fortran2html

To combine Java and Fortran check out Putting a Java interface on Fortran code

The call C from Fortran or vice-versa you can to use the cfortran package of Burkhard Burow.

To mix C++ and Fortran look at the site of .

Incidentally there are links to a number of C and C++ critiques here, and here are documents discussing the strengths and weaknesses of C++ and Fortran 90 from the University of Washington and on the site of Purple Sage Solutions.

CGI programming in Fortran

Some useful resources include:

Graphics Packages:

I have used PGPLOT for many years and recommend it highly. See this how-to document for instructions on installing it on Windows-XP.

Other people have recommended  PLPLOT which looks somewhat similar.

More advanced packages for X-windows systems include the YGL graphics library which has a Fortran interface.

f90gl is a public domain implementation of the official Fortran 90 bindings for the OpenGL graphics system now supported very widely.

Makefiles for Fortran Compilation

A number of scripts have been posted to generate files for use with the Unix make utility, but I have not been able to test most of them:

Miscellaneous Fortran Hints and Tips

Converting text to upper-case

A simple Fortran90 function to do this is here:
function upcase(string) result(upper)
character(len=*), intent(in) :: string
character(len=len(string)) :: upper
integer :: j
do j = 1,len(string)
if(string(j:j) >= "a" .and. string(j:j) <= "z") then
upper(j:j) = achar(iachar(string(j:j)) - 32)
else
upper(j:j) = string(j:j)
end if
end do
end function upcase

But the conversion can be done in a single statement if you try hard enough, for example:

Character (len=20) Function Up (string)
Character(len=*) string
Up = &
transfer(merge(achar(iachar(transfer(string,"x",len(string)))- &
(ichar('a')-ichar('A')) ), &
transfer(string,"x",len(string)) , &
transfer(string,"x",len(string)) >= "a" .and. &
transfer(string,"x",len(string)) <= "z"), repeat("x", len(string)))
return
end function Up

 

Wild-card string matching

Here is a Fortran function which does wild-card matching to a pattern, which may contain "?" to match any single character, and "*" to match zero or more consecutive characters of any type. It can be compiled by any Fortran90 compiler, including g95. A test program is provided at the beginning of the file. WARNING: this code does not yet work in all cases, at least one bug remains. Use at your own risk while work continues.

Anyone who has copied the function previously linked here called match_wild.f should note that it contained some bugs, and arevised version called match_wild.f90 should be used instead. I am very grateful to Rolf Sander for finding and fixing the mistakes.

Reading single keystrokes from Fortran

There is no portable way of doing this, although many vendor's compilers provide a specific routine to do this, but this file sys_keyin.c is a few lines of C which works on most Unix systems (on some you may need to remove the underscores from the end of the function names).

Reading command-line arguments

There was nothing built-in to Fortran95 to read the command-line arguments, but Fortran2003 solves this. Both g95 and gfortran compilers the following Fortran2003 procedures:
  • COMMAND_ARGUMENT_COUNT() - This is an integer function returning the number of argument strings on the command-line (excluding the initial command-name if there is one).
  • CALL GET_COMMAND_ARGUMENT(number, value, length, status) - This is a subroutine returning the string value of the Nth argument (argument 0 being the command-name). The length (optional) returns the length of the value returned, and status (also optional) returns 0 normally, or non-zero if there is an error such as a non-existing argument).
If you use a compiler which does not yet support these, then a package from Lawson Wakefield provides an excellent portable solution: f2kcli has versions of these routines for about 80 different compilers. 

Acknowlegements: The text of my old Fortran book was originally produced using WordPerfect, and then converted to Latex.  The further conversion to HTML used tth which seems to me one of the best such converters.

Comments and corrections (especially noting broken links) to:  clive.page [at-sign]

 


 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多