comp.lang.ada
 help / color / mirror / Atom feed
* Fortran 77 to Ada
@ 1999-11-19  0:00 Chris
  1999-11-20  0:00 ` Robert Dewar
  1999-11-20  0:00 ` Geoff Bull
  0 siblings, 2 replies; 9+ messages in thread
From: Chris @ 1999-11-19  0:00 UTC (permalink / raw)


Do you know any tools able to translate automatically
(almost) a Fortran software program (F77 type)into an Ada83
software program ?


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
  1999-11-19  0:00 Fortran 77 to Ada Chris
@ 1999-11-20  0:00 ` Robert Dewar
  1999-11-22  0:00   ` Ted Dennison
  1999-11-22  0:00   ` Gautier
  1999-11-20  0:00 ` Geoff Bull
  1 sibling, 2 replies; 9+ messages in thread
From: Robert Dewar @ 1999-11-20  0:00 UTC (permalink / raw)


In article <18cf8f9c.09c1c234@usw-ex0108-062.remarq.com>,
  Chris <caux@apside.fr> wrote:
> Do you know any tools able to translate automatically
> (almost) a Fortran software program (F77 type)into an Ada83
> software program ?


It would be interesting to know why anyone would want to do
such a pointless thing. I know this sort of thing used to
happen when the mandate was unreasonably interpreted but I
would have thought we would have seen the end of this kind
of pointless excercise.

Of course there can be exceptions (e.g. a target where Ada is
available and Fortran is not, not easy to think of such), but
in normal cases there are two possibilities:

a) the code is high quality and works fine, in this case why
on earth translate it.

b) the code is in bad shape and need reengineering. In this
case I think you do much better to start from scratch rather
than working from a translated version that is even messier
than the original [an inevitable consequence of automatic
translation]



Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
  1999-11-19  0:00 Fortran 77 to Ada Chris
  1999-11-20  0:00 ` Robert Dewar
@ 1999-11-20  0:00 ` Geoff Bull
  1999-11-22  0:00   ` okellogg
  1999-11-22  0:00   ` Robert Dewar
  1 sibling, 2 replies; 9+ messages in thread
From: Geoff Bull @ 1999-11-20  0:00 UTC (permalink / raw)


Chris wrote:
> 
> Do you know any tools able to translate automatically
> (almost) a Fortran software program (F77 type)into an Ada83
> software program ?
> 

I hava a perl script called f2ada.pl - but I don't know where it came
from. It doesn't work perfectly, you will almost certainly
need to do some fixing up.

Below is the header which should help you find it.
Don't be put off by the Ada-95, I don't recall seeing anything
generated that wasn't Ada-83 (apart from some complete rubbish, 
of course. Since, it's GPL'd, I can mail it to you if you can't
find it on the web. 

You could probably (with a lot of effort) hack f2c to generate Ada 
(maybe that's already been done by someone?).

Any reason why you can't just leave the Fortran as is and use a
pragma import?


#!/usr/local/bin/perl
#
# f2a.pl:    VAX Fortran-77 to Ada-95 converter toy
# Version:   0.1  (1996/11/26)
# Usage:     perl f2a.pl <fortran_inputfilename>
#            Output will go to stdout.
# Author:    Oliver M. Kellogg (oliver.kellogg@space.otn.dasa.de)
# Copyright: (C) 1996, Dornier Satellite Systems GmbH, a division of
#            Daimler-Benz Aerospace AG (DASA), Munich, Germany
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
---------------------------------------------------------------------------
# Special warnings:
#
# 1. This toy program has been my Perl learning experience. I am sure
#    there are ample ways to improve it or make it more elegant.
# 2. The aim of this toy is NOT to replace a Fortran compiler
#    (like for example the f2c program does.) Do not expect to pass the
#    output through an Ada compiler directly without manual tuning.
# 3. Being a primitive one-pass text substitution tool, translation is
#    at best HALF automatic.
#    The tool has been tried only on some standalone numerical
algorithms.
#    Character strings and I/O operations are not supported at all, nor
#    are those constructs that don't map to Ada in an easy way.
#    Best results are obtained on "structured" F77 code (i.e. code that
#    minimizes use of GOTO and employs block oriented statements like
#    IF/THEN/ELSE/ENDIF and DO/ENDDO.) If you feed spaghetti to it,
#    it will output no other than that.
# 4. and most importantly, the program just goes to show how much
#    inferior automatic translation is w.r.t. a software redesign.
#    I strongly DISCOURAGE its use if redesign is at all possible.
#
#
---------------------------------------------------------------------------
# What, you're still reading on after all that?
# Well then, have fun with the f2a.pl converter toy, and please send
your
# suggestions/bugreports/improvements to:
# Oliver.Kellogg@space.otn.dasa.de




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
  1999-11-20  0:00 ` Geoff Bull
@ 1999-11-22  0:00   ` okellogg
  1999-11-22  0:00   ` Robert Dewar
  1 sibling, 0 replies; 9+ messages in thread
From: okellogg @ 1999-11-22  0:00 UTC (permalink / raw)


In article <38361943.813C2E20@acenet.com.au>,
  Geoff Bull <gbull@acenet.com.au> wrote:
> I hava a perl script called f2ada.pl - but I don't know where it came
> from. It doesn't work perfectly, you will almost certainly
> need to do some fixing up.
>

The current version can be found at
ftp://wuarchive.wustl.edu/languages/ada/ajpo/tools/for2ada95/

Also, bear in mind that the converter does not translate the
Fortran I/O statements.
Anyway, I agree with Robert Dewar -- it's always better to
redesign the code !

Oliver Kellogg  (oliver dot kellogg at vs dot dasa dot de)



Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
  1999-11-20  0:00 ` Robert Dewar
  1999-11-22  0:00   ` Ted Dennison
@ 1999-11-22  0:00   ` Gautier
  1999-11-22  0:00     ` Robert Dewar
  1 sibling, 1 reply; 9+ messages in thread
From: Gautier @ 1999-11-22  0:00 UTC (permalink / raw)


> It would be interesting to know why anyone would want to do
> such a pointless thing.
(bla bla)

You just forget a third possibility:

c) the code is high quality and works fine, but one wants to
extend its features.

An example from here: there was a finite element code, but
for one type of element, in a fixed dimension, with a certain
type of filling matrices, a floating-point precision one has
to change from machine to machine, only one equation, etc.

In such a case, it is *very* valuable to use f2a.pl, program
happily, minimize debugging and concentrate on algorithms.

So, please do constructive answers when you don't know the
contents of the subject. Typically you decide it is pointless
before trying to know what shape the Fortran code has.

-- 
Gautier

--------
http://members.xoom.com/gdemont/




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
  1999-11-22  0:00   ` Gautier
@ 1999-11-22  0:00     ` Robert Dewar
       [not found]       ` <foY6OBD5gjcPjzWrpLelVV=Ml6VL@4ax.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Dewar @ 1999-11-22  0:00 UTC (permalink / raw)


In article <3839167F.F9E3B57E@maths.unine.ch>,
  gautier.demontmollin@maths.unine.ch wrote:
> So, please do constructive answers when you don't know the
> contents of the subject. Typically you decide it is pointless
> before trying to know what shape the Fortran code has.


Any automatic translation of Fortran code into Ada will result
in just what you expect: Fortran code in Ada, and this is almost
always a bad idea.

The best way to extend such code is to do it in a modular way
that allows new functionality to be added by adding new modules.
There is of course no reason not to use mixed language
(Fortran,Ada) for such a task, especially if you are using a
compiler that fully implements Annex G (including the important
pragma for using column major ordering of arrays, to be Fortran
compatible).

If the original code is not susceptible to being extended in a
modular manner, then it probably should be reengineered in any
case. The ideal thing is to do minimal reengineering in Fortran,
to allow the necessary extension, but if major reengineering is
needed then all the more need to recode instead of settling for
the junk that comes out of automatic translators.

There may be legitimate situations for using such automatic
translators, but all I can say is

a) I have seen dozens of cases in which people have tried to use
such tools where it was inadvisable, and often people were doing
it for the flimsiest of reasons.

b) I have never seen one legitimate case where it was helpful

Of course a lot depends on your quality standards. For me, the
code coming out of automatic translators requires so much hand
massaging to meet my minimal quality standards that the
translators are useless.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
  1999-11-20  0:00 ` Geoff Bull
  1999-11-22  0:00   ` okellogg
@ 1999-11-22  0:00   ` Robert Dewar
  1 sibling, 0 replies; 9+ messages in thread
From: Robert Dewar @ 1999-11-22  0:00 UTC (permalink / raw)


In article <38361943.813C2E20@acenet.com.au>,
  Geoff Bull <gbull@acenet.com.au> wrote:
> Below is the header which should help you find it.
> Don't be put off by the Ada-95, I don't recall seeing anything
> generated that wasn't Ada-83 (apart from some complete
rubbish,
> of course. Since, it's GPL'd, I can mail it to you if you
can't
> find it on the web.


Actually it is quite impossible to generate a general Fortran
to Ada-83 translator, with any kind of reasonable quality in
the output.

Why? Because it is part of the fundamental semantics of Fortran
that arrays are stored in column major order, and programs can
and do depend on this.

As a result, if you are translating code for multi-dimensional
fortran arrays into Ada 83, you have no choice but to manually
linearize all arrays into single dimension arrays, a step that
will badly damage the semantic level of the output.

In Ada 95, the pragma Convention (Fortran, ...) that ensures
column major order for an annex G compliant compiler (*) helps
to generate reasonable code in far more cases [though if your
translator promises 100% conversion, then indeed it would still
have to do nasty things like pass all arrays by explicit use of
the Address attribute]

(*) note to T.E.D. yes, this is implementation advice (see RM
    3.6.2 (11)). But of course the reason this is IA is
    precisely that it would be hard to formalize this
    requirement. You should certainly make sure that any
    Ada compiler you are going to be using in a Fortran context
    supports this important feature!



Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
  1999-11-20  0:00 ` Robert Dewar
@ 1999-11-22  0:00   ` Ted Dennison
  1999-11-22  0:00   ` Gautier
  1 sibling, 0 replies; 9+ messages in thread
From: Ted Dennison @ 1999-11-22  0:00 UTC (permalink / raw)


In article <8152h5$n7e$1@nnrp1.deja.com>,
  Robert Dewar <robert_dewar@my-deja.com> wrote:
> In article <18cf8f9c.09c1c234@usw-ex0108-062.remarq.com>,
>   Chris <caux@apside.fr> wrote:
> > Do you know any tools able to translate automatically
> > (almost) a Fortran software program (F77 type)into an Ada83
> > software program ?

> in normal cases there are two possibilities:
>
> a) the code is high quality and works fine, in this case why
> on earth translate it.
>
> b) the code is in bad shape and need reengineering. In this

How about
 c) Some Fortran code running on machine A needs to communicate with
some Ada code runnning on machine B. Fortran code A has a single source
file that specifies the data structures used in the interface. It would
be nice to be able generate the Ada interface data structure code
automagicly from the Fortran interface data structure code whenever the
latter changes.

I once had to write a special-purpose Fortran to C translator for the
above reason.

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Before you buy.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Fortran 77 to Ada
       [not found]       ` <foY6OBD5gjcPjzWrpLelVV=Ml6VL@4ax.com>
@ 1999-11-25  0:00         ` Simon Wright
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Wright @ 1999-11-25  0:00 UTC (permalink / raw)


Brian Orpin <abuse@borpin.co.uk> writes:

> We are in the situation that we have Fortran code, recently written and
> modelled using some long standing modelling SW so we have confidence it
> works.  This is then taken and translated (using the previously mentioned
> script) and used directly.

But it would be even better if you could just use the Fortran code,
surely!!!

Or you could change the modelling suite to use Ada.




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1999-11-25  0:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-19  0:00 Fortran 77 to Ada Chris
1999-11-20  0:00 ` Robert Dewar
1999-11-22  0:00   ` Ted Dennison
1999-11-22  0:00   ` Gautier
1999-11-22  0:00     ` Robert Dewar
     [not found]       ` <foY6OBD5gjcPjzWrpLelVV=Ml6VL@4ax.com>
1999-11-25  0:00         ` Simon Wright
1999-11-20  0:00 ` Geoff Bull
1999-11-22  0:00   ` okellogg
1999-11-22  0:00   ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox