|
****JavaScript based drop down DHTML menu generated by NavStudio. (OpenCube Inc. - http://www.opencube.com)****
| Search |
|||||||||||||
|
Lahey/Fujitsu Fortran for .NET Contents
Introduction For further information about .NET technologies and the terms used in this white paper, visit Microsoft .NET. To try Fortran for .NET, download the LF Fortran v7.1 Trial. A New Fortran . . . Not your Father's Fortran.
The key to Fortran users getting access to these benefits is to use a compiler that generates Microsoft Intermediate Language (MSIL), rather than native machine code. A just-in-time (JIT) compiler provided by the .NET Framework compiles and links the MSIL for execution at the moment an object is needed. The Fortran for .NET compiler generates MSIL and has language extensions for object-oriented features and for interoperability with other .NET languages. The specifications of the compiler adhere to the Fortran 2003 Draft Standard whenever possible. Fortran for .NET supports object-oriented programming features that were not present in Fortran 95. The Fortran 2003 Draft Standard specifies the implementation of many of these features, including:
For full interoperability with other .NET languages, and to be compliant with the Common Language Specification (CLS), Fortran for .NET contains new language extensions including support for the following features:
Fortran for Visual Studio .NET.
Of special significance is the Lahey/Fujitsu Fortran for .NET integration with Visual Studio.NET Windows Forms and Web Forms. The Windows Forms Designer makes it easy to develop drag-and-drop Win32 GUI applications with event-driven Fortran code behind the controls; Web Forms is a similar designer for developing web pages. Fortran for ASP.NET. Fortran for .NET allows Fortran users the ability to embed Fortran code within ASP.NET pages, interleaved with HTML and ASP content. Fortran code can also be external to the page (known as code-behind) which results in better source code reuse and readability. When instructed to use Fortran, ASP.NET utilizes the Fortran for .NET compiler to execute the logic and generate dynamic content output, and posts the HTML back to the browser. When developing with the Web Forms designer in Visual Studio .NET, creating controls on the page is drag-and-drop, with easily modifiable properties and quick access to the Fortran code template for programming the event-driven procedures. Fortran for .NET Web Services. Fortran for .NET delivers the tools you need to expose your Fortran methods (procedures) to the Internet. One directive in the source code is all you need to make your .NET object's method web-service-enabled. ASP.NET handles most of the Internet functionality automatically:
ASP.NET also provides a browser-based client for testing your web service. A key part of Web Services usability is the Web Services Description Language (WSDL). From anywhere on the Internet, the ASP.NET server can be polled for the names of the available web service procedures, the parameters required, and the protocols they support. This information is returned by ASP.NET in a WSDL format file. The .NET SDK provides tools to analyze the WSDL, and Fortran for .NET provides a code generator to automatically create code (a proxy class) for calling the web service. This gives your application access to web services that may have been written in any .NET language, on a server anywhere on the web. Furthermore, the .NET SOAP class library has functions available to call the web service asynchronously so your application does not have to wait for the web server to respond. Will my older source compile without changes? Legacy Fortran programs are automatically and transparently converted to classes by the Fortran for .NET compiler without any need for source changes: main programs and external procedures are automatically implemented as a class definition; internal procedures are made static private methods; module names will be treated as a namespace name; derived types and their components become classes and class fields (referenced by the exact same syntax as in Fortran 95), or structures if the sequence statement is present. To take advantage of creating public classes with methods that can be called from other .NET programs, source code changes will be necessary. What about execution speed? The early releases of Fortran for .NET have limited optimizations for the MSIL code generation. Future improvements in this area, coupled with Microsoft's improvements to future releases of the CLR, will result in closing the gap between the execution speed of managed and unmanaged code. Why Fortran? Source Code Example
! This is the main program
Program MultiDog
! Make the .NET Framework's System namespace and the VirtualDog
! namespaces defined below accessible to this program
use System
use VirtualDog
! Define variables of the three dog types (classes)
type (Dog) :: d
type (Greyhound) :: g
type (Labrador) :: l
! Call the RollOver methods (procedures) of each class
call d%RollOver() ! Call C#
call g%RollOver() ! Call Fortran
call l%RollOver() ! Call Visual Basic
end program MultiDog
module
! Define a type (class) called Greyhound that extends
! the Dog class defined in C# code below, and is part of
! the VirtualDog namespace
type, extends( VirtualDog%Dog ), namespace( VirtualDog ) :: Greyhound
contains
! Declare a class method (procedure); the 'pass'
! attribute makes it an instance (dynamic) procedure
procedure, public, pass :: Bark
end type Greyhound
contains
! Define the Bark method that overrides the inherited
! class' method; i.e., give the Greyhound its own bark
subroutine Bark( this )
! Declare the passed-object (hidden argument in the
! call statement) as the same type as the class
class ( Greyhound ) :: this
print *, "BOW WOW (Fortran Dog)"
end subroutine Bark
end module
C#
// Make the .NET Framework's System
// namespace accessible to this program
using System;
// Be a part of the VirtualDog namespace
namespace VirtualDog {
// Define an overridable class called Dog
public class Dog {
// Define overridable methods of the class
public virtual void RollOver () {
Console.WriteLine(" Scratch my tummy.");
// The Bark method is called here. It is overridden
// sometimes in the Fortran and VB classes
Bark();
}
public virtual void Bark () {
Console.WriteLine(" WOOF WOOF (C# Dog)");
}
}
}
Visual Basic .NET
' Make the .NET Framework's System
' namespace accessible to this program
Imports System
' Be a part of the VirtualDog namespace
Namespace VirtualDog
' Define a type (class) called Labrador that extends
' the Dog class defined in C# code above
Public Class Labrador : Inherits Dog
' Define the Bark method that overrides the inherited
' class' method; i.e., give the Labrador its own bark
Public overrides Sub Bark ()
Console.WriteLine(" WAF WAF (VB Dog)")
End Sub
End Class
End Namespace
|
| For more information on LF Fortran v7.1, please visit the following links: | ||
|
LF v7.1 General
|
.NET Fortran language system
|
Fortran 95 (Win32) language system
.NET whitepaper | Trial download | Testimonials | On-line help |