introduction to nag fortran builder

13
Introduction to NAG Fortran Builder Ian D Chivers & Jane Sleightholme Ian Chivers: Rhymney Consulting, London. Jane Sleightholme, King's College, London. [email protected] [email protected] Introduction This article is an introduction to the NAG Fortran Builder product. Fortran Builder is an Integrated Development Environment or IDE for Fortran. The product runs under Windows and was developed in Japan. The version tested included release 5.1 of the NAGWare Fortran compiler. The compiler can also be used from a command prompt if required. As of going to press NAG have not formally released Fortran Builder. If you would like more information could you please contact John Holden at NAG. His email address is: [email protected] Installation and setup There will be an installation program in the fully released product. This beta version is available via ftp from NAG as a zip file. It can be unpacked and a short cut created to the executable in the bin directory. Several screen shots follow that take you through some of the Fortran Builder IDE options. Opening Screen The following is the Fortran Builder opening screen. ACM Fortran Forum, August 2007, 26,2 12 Fortran Builder opening screen

Upload: jane

Post on 27-Jan-2017

240 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Introduction to NAG Fortran builder

Introduction to NAG Fortran Builder

Ian D Chivers & Jane Sleightholme

Ian Chivers: Rhymney Consulting, London.

Jane Sleightholme, King's College, London.

[email protected]

[email protected]

Introduction

This article is an introduction to the NAG Fortran Builder product. Fortran Builder is an Integrated Development

Environment or IDE for Fortran. The product runs under Windows and was developed in Japan. The version tested

included release 5.1 of the NAGWare Fortran compiler. The compiler can also be used from a command prompt if

required. As of going to press NAG have not formally released Fortran Builder. If you would like more information

could you please contact John Holden at NAG. His email address is: [email protected]

Installation and setup

There will be an installation program in the fully released product. This beta version is available via ftp from NAG as a

zip file. It can be unpacked and a short cut created to the executable in the bin directory. Several screen shots follow that

take you through some of the Fortran Builder IDE options.

Opening Screen

The following is the Fortran Builder opening screen.

ACM Fortran Forum, August 2007, 26, 2 12

Fortran Builder opening screen

Page 2: Introduction to NAG Fortran builder

As can be seen we have the traditional Windows interface with a menu bar and tool bar.

File Menu

The file menu shows some of the expected options for an IDE. We have chosen the File, New Project option for this

screen shot. There are a relatively small number of options available from this menu.

Under File -> New -> Project Fortran Builder provides the following options:

• Console application: A Fortran program or application that uses a console window for i/o.

• Static Library: A library of routines that can be statically linked into a program.

• Simdem Application: A Fortran program or application that uses the Simdem library for plotting or menu based

programming. There are over 60 template programs provided.

• Lapack Application: A Fortran program or application that uses the Lapack linear algebra library. NAG provide

over 15 templates with several examples per template.

• Dynamic Link Library: A library that can be linked to dynamically by a program or application. The program

can be written in another language, e.g. C++ Visual Basic. The application could be Excel or Matlab for

example.

13 ACM Fortran Forum, August 2007, 26, 2

File menu option

Page 3: Introduction to NAG Fortran builder

• NAG Library Application: A Fortran program that uses the NAG library. This needs to be purchased and

installed separately.

We will use sone of the sample files to illustrate features of the Fortran Builder IDE.

Example 1

We chose File -> New -> Project -> Simdem -> Use Template -> simdem10 as the basis for this example. This provides

us with the following screen.

This provides us with three components to the IDE. The left hand pane contains details about the project. The right hand

pane is the editor with colour coded Fortran source. The bottom pane is currently blank and contains details of the

compilation process. The two key menu items now are the Project and Run options.

ACM Fortran Forum, August 2007, 26, 2 14

Simdem example 10: Simple x-y plotting

Page 4: Introduction to NAG Fortran builder

Choosing Run -> Execute will compile and run the program. The next screen shot shows the program running.

The Tools menu

Nag also include a number of tools with the IDE. These are:

• Fortran 77 to 95 convertor

• Source code reformatter

• Call graph generator

We will use the sample code from the above example to illustrate the use of each of these tools. The original Fortran 77

fixed source code is shown below.

cc simdem10: gks004, a simple plotting subroutine (up to 4 graphs)c ===============================================================c w.g.bardsley, 3/Jan/2000cc The simfit package can be downloaded from http://www.simfit.man.ac.ukc and the dll files supplied with this package can be used as a stand-alonelibraryc for input/ouput, file handling, graphics, statistics, numerical analysis,etc.c The simdem programs are designed to illustrate how users of the SalfordSoftware

15 ACM Fortran Forum, August 2007, 26, 2

Page 5: Introduction to NAG Fortran builder

c compilers and the NAG Fortran Builder can use these libraries in their ownc programs without knowing anything about the windows API.c See the file simdem.txt for further details.cc Meaning of the argumentsc ========================c l = line type, e.g. 0 = none, 1 = solid, 2 = dashed, 3 = dotted, etcc m = symbol type, e.g. 0 = none, 5 = circle, 8 = triangle, 11 = square, etc.c n = number of points to be plottedc ptitle = plot titlec xtitle = x legend subtitlec ytitle = y legend subtitlec axes = .true.c gsave = .true.cc

program mainimplicit noneinteger i, ninteger nmaxparameter (nmax = 100)integer l1, l2, l3, l4, m1, m2, m3, m4, n1, n2, n3, n4double precision x1(nmax), x2(nmax), x3(nmax), x4(nmax)double precision y1(nmax), y2(nmax), y3(nmax), y4(nmax)double precision cosi, delta, sini, t(nmax)double precision a, b, c, d, pi2, zero, oneparameter (a = 1.0d+00, b = 2.0d+00, c = 3.0d+00, d = 4.0d+00,

+ pi2 = 6.2831853, zero = 0.0d+00, one = 1.0d+00)character ptitle*8, xtitle*1, ytitle*1logical axes, gsaveparameter (axes = .true., gsave = .true.)external gks004intrinsic sin, cos, dblel1 = 1l2 = 2l3 = 3l4 = 4m1 = 5m2 = 8m3 = 11m4 = 14n = nmax/2n1 = nn2 = nn3 = nn4 = ndelta = pi2/(dble(n) - one)t(1) = zerodo i = 2, n - 1

t(i) = t(i - 1) + deltaenddot(n) = pi2do i = 1, n

cosi = cos(t(i))

ACM Fortran Forum, August 2007, 26, 2 16

Page 6: Introduction to NAG Fortran builder

sini = sin(t(i))x1(i) = a*cosix2(i) = b*cosix3(i) = c*cosix4(i) = d*cosiy1(i) = a*siniy2(i) = b*siniy3(i) = c*siniy4(i) = d*sini

enddoptitle = 'y = f(x)'xtitle = 'x'ytitle = 'y'call gks004 (l1, l2, l3, l4,+ m1, m2, m3, m4,+ n1, n2, n3, n4,+ x1, x2, x3, x4,+ y1, y2, y3, y4,+ ptitle, xtitle, ytitle,+ axes, gsave)end

cc

Note that there are some problems with the original source. Some of the comment lines extend past column 72.

Here is the code after conversion to Fortran 95.

! simdem10: gks004, a simple plotting subroutine (up to 4 graphs)! ===============================================================! w.g.bardsley, 3/Jan/2000

! The simfit package can be downloaded from http://www.simfit.man.ac.uk! and the dll files supplied with this package can be used as a stand-al! for input/ouput, file handling, graphics, statistics, numerical analys! The simdem programs are designed to illustrate how users of the Salfor! compilers and the NAG Fortran Builder can use these libraries in their! programs without knowing anything about the windows API.! See the file simdem.txt for further details.

! Meaning of the arguments! ========================! l = line type, e.g. 0 = none, 1 = solid, 2 = dashed, 3 = dotted, etc! m = symbol type, e.g. 0 = none, 5 = circle, 8 = triangle, 11 = square,! n = number of points to be plotted! ptitle = plot title! xtitle = x legend subtitle! ytitle = y legend subtitle! axes = .true.! gsave = .true.

PROGRAM mainIMPLICIT NONEINTEGER i, n

17 ACM Fortran Forum, August 2007, 26, 2

Page 7: Introduction to NAG Fortran builder

INTEGER nmaxPARAMETER (nmax=100)INTEGER l1, l2, l3, l4, m1, m2, m3, m4, n1, n2, n3, n4DOUBLE PRECISION x1(nmax), x2(nmax), x3(nmax), x4(nmax)DOUBLE PRECISION y1(nmax), y2(nmax), y3(nmax), y4(nmax)DOUBLE PRECISION cosi, delta, sini, t(nmax)DOUBLE PRECISION a, b, c, d, pi2, zero, onePARAMETER

(a=1.0D+00,b=2.0D+00,c=3.0D+00,d=4.0D+00,pi2=6.2831853,zero=0.0D+00,one=1.0D+00)CHARACTER ptitle*8, xtitle*1, ytitle*1LOGICAL axes, gsavePARAMETER (axes=.TRUE.,gsave=.TRUE.)EXTERNAL gks004INTRINSIC sin, cos, dble

l1 = 1l2 = 2l3 = 3l4 = 4m1 = 5m2 = 8m3 = 11m4 = 14n = nmax/2n1 = nn2 = nn3 = nn4 = ndelta = pi2/(dble(n)-one)t(1) = zeroDO i = 2, n - 1t(i) = t(i-1) + delta

END DOt(n) = pi2DO i = 1, ncosi = cos(t(i))sini = sin(t(i))x1(i) = a*cosix2(i) = b*cosix3(i) = c*cosix4(i) = d*cosiy1(i) = a*siniy2(i) = b*siniy3(i) = c*siniy4(i) = d*sini

END DOptitle = 'y = f(x)'xtitle = 'x'ytitle = 'y'CALL

gks004(l1,l2,l3,l4,m1,m2,m3,m4,n1,n2,n3,n4,x1,x2,x3,x4,y1,y2,y3,y4,ptitle,xtitle,ytitle,axes,gsave)END PROGRAM main

ACM Fortran Forum, August 2007, 26, 2 18

Page 8: Introduction to NAG Fortran builder

Note the following:

• the comment lines that originally extended past column 72 have been truncated.

• the parameter statement has wrapped due to text formatting.

• the call to gks004 has wrapped due to text formatting.

Here is the output from the Call Graph generator tool.

1: MAIN2: GKS004

Call-graph index

line: Procedure:2 GKS0041 MAIN

Called-by Table

GKS004 called by: MAIN

Whilst the above sample program is simple is does illustrate the use of the three tools.

IDE Help

The IDE also has on line help and documentation. Some examples of what are available are shown below.

19 ACM Fortran Forum, August 2007, 26, 2

Page 9: Introduction to NAG Fortran builder

Help Opening screen

We have the typical Contents, Index Search tabs options.

In the above screen the left hand pane has the details of the documentation included

• Fortran Builder Help

• LAPACK Guide

• F95 Compiler Manual

• Operation Guide

• Fortran Language Guide

• NAG Fortran Library Essential Introduction

• FAQ

• Copyright

and the main items can be expanded.

The right hand pane contains the actual documentation itself.

ACM Fortran Forum, August 2007, 26, 2 20

Page 10: Introduction to NAG Fortran builder

Expanding the tabs: 1

This screenshot expands the LAPACK and Operation Guide tabs.

21 ACM Fortran Forum, August 2007, 26, 2

Expanding the LAPACK and Operation Guide tabs

Page 11: Introduction to NAG Fortran builder

Expanding the tabs: 2

This screen shot expands the Compiler Manual and Language Guide tabs.

ACM Fortran Forum, August 2007, 26, 2 22

Expanding the f95 Compiler Manual and Language Guide tabs

Page 12: Introduction to NAG Fortran builder

Help: Index tab 1

This screenshot shows the information that is provided using the index tab. The ALLOCATABLE entry has been

highlighted to show a typical entry.

We have details about which version of the standard the feature came in, the syntax and semantics of the feature and

related areas. We also have the option of looking at a sample program regarding the feature.

23 ACM Fortran Forum, August 2007, 26, 2

Help entry: Index tab chosen 1

Page 13: Introduction to NAG Fortran builder

Help: Index tab 2

This is a variation of the above where the Example Program entry has been chosen.

We then have a sample program and some output.

Summary

NAG have put togethor a simple to use IDE and included three usefuls tools from NAGWare tools. Some of the key

features of the IDE are:

• The underlying compiler is the NAG f95 compiler, which is one of the best diagnostic compilers for the

Windows and Linux operating systems;

• The IDE is straightforward and easy to use;

• The Simdem project option comes with a good range of sample programs;

• The LAPACK project option comes with a good range of sample programs;

• The on-line help and documentation is very good;

Hopefully there will be a Linux version!

ACM Fortran Forum, August 2007, 26, 2 24

Help entry: index tab chosen 2