promulaFortran | ||||||
promulaFortran is a software tool that translates FORTRAN source code (source.for) to C source code (source.c). | ||||||
| ||||||
Promula® FORTRAN to C Translator/Compiler | ||||||
The Promula FORTRAN to C Translator (promulaFortran) is a tool that translates FORTRAN source code to correct (compilable) and clean (readable and maintainable) C source code. The C code produced can then be compiled with almost any C compiler on almost any platform to produce executable code, which in turn will produce results on the target C platform that are identical to the results produced on the source FORTRAN platform. What’s more, the C code is clean and readable so that, if you wish, you can start maintaining your application in C rather than in FORTRAN. And, unlike the original FORTRAN, the C code is portable so you can move it to multiple "open" platforms. In addition, the tool is flexible and configurable to allow extensive user control over both the input FORTRAN dialect accepted and the look of the C output generated. | ||||||
This tool is intended for those who wish to convert their FORTRAN codes to C automatically; 100 percent conversion rates are achieved routinely. The conversions yield reproducible results and are repeatable and verifiable. A number of input FORTRAN dialects are supported via a dialect definition flag, and the form of the output C code is controlled by a multitude of command-line switches. | ||||||
The translations are so complete and correct that the tool may also be used in conjunction with a standard C Compiler as a general-purpose, multi-dialect and portable FORTRAN compiler. It runs on multiple platforms and supports both the ANSI FORTRAN 66 and ANSI FORTRAN 77 standard dialects, as well as a large number of extensions found in various commercial FORTRAN compilers. The following FORTRAN dialects are supported: VAX, PDP, SUN, HP, CRAY, PRIME, Data General, UNISYS, and Honeywell. Some FORTRAN 90 extensions are also supported. With this product, existing FORTRAN applications will compile on "open" platforms as is, i.e., without making any changes to the original FORTRAN source code. | ||||||
Validated by the GSA FORTRAN Compiler Validation Test Suite, the compiler works by translating FORTRAN source code to C source code (from where it derives its portability). It requires a C compiler/linker to produce executable code and is the ideal processor for hybrid FORTRAN/C applications. Symbolic FORTRAN debugging is supported by the symbolic debugger of the host C platform (e.g., the dbx tool for UNIX platforms). | ||||||
| ||||||
No matter how old or how extended your FORTRAN dialect is, promulaFortran will process it by first translating it to the more versatile and more portable C language. Your long-established FORTRAN programs do not have to be maintenance burdens running inefficiently on old platforms; with promulaFortran, you can give them new life on contemporary platforms where you can take advantage of new technology options, including the option of program maintenance in either FORTRAN or C. | ||||||
promulaFortran offers a number of advantages over other FORTRAN to C translators:
| ||||||
How Does It Work? | ||||||
promulaFortran translates FORTRAN code to C code which can then be compiled via any standard C compiler and linked with the promulaFortran runtime library to produce efficient executable code. The resultant executable code produces the same results on a target platform as the original code does on the source platform. | ||||||
In designing promulaFortran we took the position that the only difference between a translator and a compiler should be that a compiler converts the source code into machine language while a translator takes it to a higher level language. promulaFortran compiles the FORTRAN source language into a low level pseudo-code. This pseudo-code is much like the output produced by the first, or second, pass of contemporary compilers. Second, it optimizes that code using the same techniques as used during the optimization pass of a compiler. Third, it does code generation; but the code generated is not machine code, it is C. | ||||||
A more detailed description of the design and methodology of promulaFortran appeared in a
series of three technical papers in the Journal of C Language Translation:
| ||||||
Rationale for Developing promulaFortran | ||||||
Since the beginning of FORTRAN there has always been a problem -FORTRAN is not transportable from machine to machine or even from one operating system to another. | ||||||
In contrast, the C language is unique in that it is available for almost every type of computer -from home computers to supercomputers. It is extremely efficient, modular, and portable. It is presently the language of choice for many operating system programmers and compiler designers. | ||||||
In addition to authoring promulaFortran, we have been developing FORTRAN development tools and FORTRAN applications for clients since 1967. In converting FORTRAN programs from one platform to another, our typical problem was not that we could not find a good FORTRAN 77 compiler for the target platform, but rather that we were confronted by FORTRAN programs that were almost always written in non-standard, non-machine-transportable FORTRAN dialects. The typical mainframe FORTRAN program is not written in standard FORTRAN and makes assumptions about the machine and operating system for which it was originally written. FORTRAN programs are just not portable. | ||||||
promulaFortran was designed to deal with actual FORTRAN programs, written by “nonstructured" FORTRAN programmers who took advantage of every possible special feature of their particular vendor’s compiler, and who had never known or cared that there was a standard, or two, available. | ||||||
If you have a relatively small FORTRAN 77 program and wish to use it on a new platform in a C environment, then you have a variety of compilers and/or translators available to you, but we think promulaFortran will give you the best results. However, if you have a serious FORTRAN program and you do not wish to do any changes by hand, then we know that promulaFortran is your only current alternative. | ||||||
We originally developed promulaFortran for use in our own consulting business because we were unable to find a FORTRAN compiler which would effectively and accurately process the typical FORTRAN programs which we wished to migrate to the PC or other workstations. Having once developed the translator, we discovered that far more than just translation could be achieved during the conversion. Many other problems could also be solved by translating to C. | ||||||
Downsizing Mainframe Codes for Use on the PC DOS Platform | ||||||
Many FORTRAN programs are written with the assumption that a very large memory
is available. This is because most machines above the PC class have virtual
operating systems. A standard “error-free" translation of a statement like the
following
DIMENSION A(10000,20),B(10000,20) would be static float a[20][10000],b[20][10000]; The fact that this is syntactically error-free is of little significance since no C compiler presently available for the PC will accept it. Faced with this problem, what do you do? In the brute force approach, you would probably go through the code -maybe all 10000 lines of it -and change the references to arrays A and B to some sort of disk reference. You would probably also analyze how these arrays are referenced so that you could make the disk accesses as efficient as possible. | ||||||
In processing large programs on the limited memory model of the PC-DOS platform, promulaFortran takes a virtual memory approach. In promulaFortran, you can tell the translator that all variables larger than a certain number of bytes should be treated as virtual memory disk variables. The runtime library has a very efficient set of virtual memory management routines, and the translator replaces references to the specified variables with function calls to the virtual memory functions. The subscript calculations are replaced by virtual memory address calculations. | ||||||
Thus, promulaFortran allows you to bring an entire class of FORTRAN programs to the PC which cannot now be processed easily by any other product available. | ||||||
Dealing with FORTRAN Dialect Problems | ||||||
Other translators deal primarily with FORTRAN 77, require that tokens contain no blanks and be separated, and treat FORTRAN statement names as reserved words. FORTRAN codes not meeting these specifications must be changed by the user manually. Our experience has been that many FORTRAN programs are written in FORTRAN 66 or in some mixed dialect of FORTRAN 66 and FORTRAN 77. Since FORTRAN has no keywords and explicitly ignores all blanks in its source statements, many perfectly readable FORTRAN programs do not meet the above requirements. | ||||||
promulaFortran translates FORTRAN 66 as well as FORTRAN 77 programs. The user can control those aspects of the two languages which conflict by selecting options in the translation process. | ||||||
The translator accepts split tokens, token sequences without separators, blank lines, comment lines within continuation sequences, and other potential translation ambiguities. You do not have to “clean up the code" to use promulaFortran. So, if you have an old 66 program punched on a 026 keypunch with a drum card on as few cards as possible and you can get it onto a disk, promulaFortran can process it for you. | ||||||
Also promulaFortran knows the difference between
DO10I=1,5 and DO10I=1.5 or DO 10 I = 1,5 and DO 10 I = 1.5 and translates them all correctly. promulaFortran deals with all of the “violations" of standard character manipulation including hiding character values in arithmetic variables, mixing character and non-character variables in COMMON blocks, equivalencing character variables with arithmetic variables, and assuming that CHARACTER*N and CHARACTER*1(N) have the same memory representations. | ||||||
Dealing with C Types and FORTRAN Types | ||||||
promulaFortran gives you access to all of the following standard C types:
| ||||||
Though promulaFortran has the usual set of default FORTRAN types, you can specify which FORTRAN type should connect to which C type. If your dialect of FORTRAN includes nonstandard types such as BOOLEAN or BYTE or INTEGER*3, then you can include these. In addition, FORTRAN compilers differ as to whether logical types are bit sequences or simply TRUE/FALSE values. You may also select this. If bit sequences are assumed, the “logical" operators become bit-manipulation operators. | ||||||
Dealing with FORTRAN Input/Output in C | ||||||
The approach taken to FORTRAN input/output statements by promulaFortran is straightforward. The C programs should behave identically to their FORTRAN counterparts. All standard I/O statements are accepted including long FORMAT statements. These tend to be rejected by C compilers because their initialization strings exceed the compiler limit on the length of individual static strings. C input/output is managed via calls to functions in the C library. C has no input/output statements as such. FORTRAN input/output statements are translated into calls to functions in the promulaFortran runtime library. These functions perform input/output the way FORTRAN does. | ||||||
Though the general form of input/output statements is quite standard throughout the FORTRAN dialect community, no two FORTRAN compilers have the identical set of options. This is the major area in which dialects differ. With the promulaFortran dialect manager you may describe the individual options associated with your particular dialect. In addition, you may specify the form of the function to be referenced in the translation. Then you can simply write the needed function and include it in your version of the runtime library. | ||||||
Runtime Library | ||||||
The promulaFortran runtime library is a set of approximately 300 functions designed for use with the promulaFortran translator. It may also be used by those FORTRAN programmers who wish to program in C, but who do not wish to give up the input/output conventions, formatting controls, and intrinsic functions which they have grown used to. | ||||||
Initially, C codes using this library can be produced by translating FORTRAN programs into C using the promulaFortran translator. Once in C, the programs may then be maintained by using these functions. | ||||||
If there is one certainty, it is that no two FORTRANs behave in the same way, especially with regard to their runtime libraries. Thus, if your conventions differ from the ones used here, then you may alter the library code. Alternatively, your version of FORTRAN may contain statements which require runtime support not included in this library. In this case, you can add the additional functions needed. | ||||||
Dealing with COMMON Blocks | ||||||
If there is any aspect of FORTRAN that can destroy the validity of a translation, it is COMMON blocks -especially when combined with EQUIVALENCE statements. Every storage trick ever conceived gets used in the nuances of changing COMMON block definitions through a large FORTRAN program. There is no best way to translate COMMON blocks. Some compilers, for example, insert extra bytes to achieve various types of alignments, and programmers using these compilers will take that fact into account without any warning or comment for the user. | ||||||
promulaFortran translates COMMON blocks in one of four ways. It is up to you to select
the appropriate one depending upon your needs and preferences:
| ||||||
Allocation of Local Variables | ||||||
Most FORTRAN compilers allocate a fixed unique storage location to all variables, be they COMMON or local. The equivalent allocation in C is called “static“, and by default all variables in the translation are declared as static variables. C, however, has two additional storage allocation methods -auto and dynamic. | ||||||
Auto variables are stored on the program stack automatically when a function is called and are automatically removed when the function is exited. The advantage of these variables is that they occupy memory only when needed and their physical allocation is quick and transparent to the C program. The disadvantage of auto variables is that the program stack tends to be quite short; thus, the number and size of auto variables are very limited. | ||||||
Dynamic variables are stored on the heap via explicit calls to a function and must also be freed explicitly via a function call. The disadvantage of dynamic variables is that their allocation is slow as compared to auto variables, and the allocation itself must be done explicitly. The advantage is that the heap is generally quite large. | ||||||
Using promulaFortran you have complete control over the allocation of variables in the translation. | ||||||
A Sample Translation to C | ||||||
The output from promulaFortran does not look like machine translation. To present some of the design features of the translator, consider the following example program which computes the mean and variance of a set of values. | ||||||
| ||||||
In summary, promulaFortran looks for every opportunity to simplify and optimize the translation and to make it look as natural as possible in the C language form. | ||||||
Licensing | ||||||
The product includes both the translator/compiler and an extensive FORTRAN Run-time Library (about 300 functions written in portable C source code). The run-time library may be linked into your executables for royalty-free distribution. | ||||||
A free demo/evaluation service and four license levels are available
for the product:
| ||||||
As part of the Demo Service, we will be happy to do a sample FORTRAN-to-C translation for any client who may be interested in evaluating how well and how completely Promula FORTRAN will translate the client’s particular dialect of FORTRAN source code. If you will send us a sample of your FORTRAN source code -subject to a non-disclosure agreement, if necessary -then we will translate it to C using Promula FORTRAN and show you the resulting C source code for your evaluation. You may include as many lines of FORTRAN code as you wish in the sample. If the sample is a complete application, then the demo will show reproducibility of results by compiling it, linking it into executable form, running it on some target platform, and comparing results. | ||||||
The Demo Service is provided free of charge. The turnaround for a typical demo translation is 1-2 days. | ||||||
The Standard License | ||||||
The Standard License includes the translator software (in executable form) for the target platform and software user documentation (a Compiler Manual and a Translator Manual). It also includes the source code of the Promula FORTRAN Library so that you may compile and link your applications into executable codes on arbitrary target platforms. | ||||||
The Custom License | ||||||
The standard version of the translator is capable of translating several dialects of FORTRAN -certainly all those we have seen in the long lifetime of the tool (since 1987). Over the years, thousands of our clients have used the standard version of the translator to port thousands of applications (millions of lines of FORTRAN code) to C. From time to time, however, a client comes along with a "strange" FORTRAN dialect, whose extensions we haven't seen before. For such a client, we will make a custom version of the tool, tailored to handle the "strange" dialect. The custom license allows for varying degrees or levels of tool customization. | ||||||
The Enterprise License | ||||||
This is an unlimited multi-user, multi-machine, site license. It is intended for use in large-scale portation projects that may require tailored translations and customized runtime library support. This license includes the Promula FORTRAN to C Translator for a particular platform, the source code for the Promula FORTRAN Runtime Library, and six (6) months of software maintenance and user support (by telephone, fax, mail, or e-mail). | ||||||
As part of the support services under this license, PDC will revise or configure the translator to produce custom translations that satisfy both local FORTRAN dialect requirements as well as particular programming conventions for the C output. | ||||||
Consulting Services | ||||||
In support of our Custom or Site License, for clients wishing to perform their own conversions, we offer consulting services to ensure that their ports are done in an efficient and effective manner to meet their project needs and deadlines. Software upgrade services (e.g., improved user interfaces) for the ported software are also available. Our consulting rates are: $1,200 a day per consultant (plus reasonable travel and living expenses). | ||||||
For clients wishing to outsource, we will perform turnkey portations and guarantee performance, subject to reproducibility of results. Fixed rates of between $0.20 and $1.00 per line of source code apply, depending upon the number of lines of code to be converted, the complexity (machine dependence) of the application, and its runtime library support needs. | ||||||
The FORTRAN Library Source | ||||||
The Promula FORTRAN Runtime Library is a comprehensive library of about 300 functions (written in standard, portable C) which support the full functionality of the FORTRAN language (FORTRAN I/O, complex arithmetic, FORTRAN intrinsic functions, business format for PRIME FORTRAN applications, virtual memory management, etc.). With the source code of this library, C translations can be ported to arbitrary platforms. | ||||||
As part of the Custom or Site License, PDC will add functionality to this library, as needed in support of particular migration projects. | ||||||
Pricing | ||||||
Pricing information is available upon request. | ||||||
Customer References | ||||||
Click here for a partial list of promulaFortran clients. |