Discussion:
Tools to convert Program in BASIC to Fortran
(too old to reply)
Samuel H. Dupree, Jr.
2004-08-27 04:57:27 UTC
Permalink
Greetings,

First, forgive me for cross posting. I have a colleague who has a large
PowerBasic celestial mechanics program and would like to convert it to
Fortran 77. Does anyone know of any tools that would allow him to
convert his code from PowerBasic to Fortran 77? Fortran 90/95?

Thanks for responding in advance.

Sam Dupree.
--
------------------------------------------------------------------------
Samuel H. Dupree, Jr.
***@speakeasy.net
600 West Harvey Street
Apartment A-703
http://www.speakeasy.org/~sdupree/
Philadelphia, PA 19144-4345, USA

HOME: 215-842-3663 WORK: 610-354-2533
FAX: 610-354-7436

"What does it take to travel in space?" The will to do
it. - Dr. Wernher von Braun
------------------------------------------------------------------------
Greg Neill
2004-08-27 11:35:26 UTC
Permalink
Post by Samuel H. Dupree, Jr.
Greetings,
First, forgive me for cross posting. I have a colleague who has a large
PowerBasic celestial mechanics program and would like to convert it to
Fortran 77. Does anyone know of any tools that would allow him to
convert his code from PowerBasic to Fortran 77? Fortran 90/95?
I believe that they are called "Graduate Students". :-)
b***@aol.com
2004-08-27 13:19:53 UTC
Permalink
Post by Samuel H. Dupree, Jr.
Greetings,
First, forgive me for cross posting. I have a colleague who has a large
PowerBasic celestial mechanics program and would like to convert it to
Fortran 77. Does anyone know of any tools that would allow him to
convert his code from PowerBasic to Fortran 77? Fortran 90/95?
There is a 452-line Basic program at
http://custom.lab.unb.br/pub/asme/BASIC/BAS2FORT.ZIP that seems to
convert from some form of Basic to Fortran 77.

I am ignorant of PowerBasic, but Visual Basic seems similar to
Fortran. An ad-hoc translator that replaces FOR-NEXT with DO-ENDDO,
SUB with SUBROUTINE etc. could probably get most of the work done,
although manual work will remain.

Visual Basic and Fortran 90/95 has dynamic array allocation but
Fortran 77 does not, so translating to F77 may be more difficult.
Paul Robinson
2004-08-29 03:36:45 UTC
Permalink
Post by Samuel H. Dupree, Jr.
Greetings,
First, forgive me for cross posting. I have a colleague who has a large
PowerBasic celestial mechanics program and would like to convert it to
Fortran 77. Does anyone know of any tools that would allow him to
convert his code from PowerBasic to Fortran 77? Fortran 90/95?
It's funny because I went the other way. I just finished writing a
7,000 line set of programs in Visual Basic to convert Microsoft Fortran
for DOS into VB.

I am not sure if I'd want to try to go that route, as there are things
you can do in basic you cannot do in Fortran. I suppose you could if
you were willing to hand-optimize the code once you finished.
b***@aol.com
2004-08-30 13:34:15 UTC
Permalink
Post by Paul Robinson
Post by Samuel H. Dupree, Jr.
First, forgive me for cross posting. I have a colleague who has a large
PowerBasic celestial mechanics program and would like to convert it to
Fortran 77. Does anyone know of any tools that would allow him to
convert his code from PowerBasic to Fortran 77? Fortran 90/95?
It's funny because I went the other way. I just finished writing a
7,000 line set of programs in Visual Basic to convert Microsoft Fortran
for DOS into VB.
I am not sure if I'd want to try to go that route, as there are things
you can do in basic you cannot do in Fortran. I suppose you could if
you were willing to hand-optimize the code once you finished.
There are things you can do in Fortran and not Basic, such as easily
call state-of-the-art numerical libraries like Lapack and performa
array operations like
a(1,:) = b(:) + c(:) (in Fortran 90/95). Fortran has always been the
language designed for numerical work, and it makes sense to use it for
such programs.
Tom Lake
2004-08-30 16:35:11 UTC
Permalink
Post by b***@aol.com
There are things you can do in Fortran and not Basic, such as easily
call state-of-the-art numerical libraries like Lapack and performa
array operations like
a(1,:) = b(:) + c(:) (in Fortran 90/95). Fortran has always been the
language designed for numerical work, and it makes sense to use it for
such programs.
Minicomputer and mainframe BASIC has always had MAT operators. You can
write

MAT a = b + c

It wasn't until MS had to squeeze BASIC into a 4K memory that features got
dropped. If you want to run BASIC that's based on the ISO standard, try
True BASIC. If you've come from a mainframe/mini background you'll like it.
If you learned BASIC using the "Street BASIC" on microcomputers, you
probably won't unless you really start writing large programs. To me,
there's something worthwhile in using the BASIC that's endorsed by the
authors of the original BASIC; John Kemeny, now deceased, and Tom Kurtz who
is less deceased than Kemeny ;-)

Tom Lake
Jonathan Berry
2004-08-30 18:38:00 UTC
Permalink
Post by b***@aol.com
Post by Paul Robinson
Post by Samuel H. Dupree, Jr.
First, forgive me for cross posting. I have a colleague who has a large
PowerBasic celestial mechanics program and would like to convert it to
Fortran 77. Does anyone know of any tools that would allow him to
convert his code from PowerBasic to Fortran 77? Fortran 90/95?
It's funny because I went the other way. I just finished writing a
7,000 line set of programs in Visual Basic to convert Microsoft Fortran
for DOS into VB.
I am not sure if I'd want to try to go that route, as there are things
you can do in basic you cannot do in Fortran. I suppose you could if
you were willing to hand-optimize the code once you finished.
There are things you can do in Fortran and not Basic, such as easily
call state-of-the-art numerical libraries like Lapack and performa
array operations like
a(1,:) = b(:) + c(:) (in Fortran 90/95). Fortran has always been the
language designed for numerical work, and it makes sense to use it for
such programs.
Any relation to "Big Al" Alexander Beliavsky, one of the
great chess players of all time?

PowerBASIC has matrix operations. Maybe you don't
need to convert to ForTran at all. I don't use them, but
perhaps PB/CC will fit your needs. PB/CC 3.01 help file gives
the following on the MAT statement:

------------------- begin help file extract.

Purpose To simplify Matrix Algebra calculations.

Syntax MAT a1() = CON 'Set all elements of a1() to one

MAT a1() = CON(expr) 'Set all elements of a1() to value of expr
MAT a1() = IDN 'Establish a1() as an identity matrix
MAT a1() = ZER 'Set all elements of a1() to zero
MAT a1() = a2() + a3() 'Addition
MAT a1() = a2() 'Assignment
MAT a1() = INV(a2()) 'Inversion
MAT a1() = (expr) * a2() 'Scalar Multiplication

MAT a1() = a2() - a3() 'Subtraction
MAT a1() = a2() * a3() 'Multiplication
MAT a1() = TRN(a2()) 'Transposition

Remarks Array names with the MAT statements may optionally include a set of empty parentheses. The following are both equally valid, but the inclusion of the parentheses improves clarity of the code:

MAT a1 = CON
MAT a1() = CON

MAT CON, IDN ZER + - = and TRN operations are valid with Byte, Word, Double-word, Integer, Long-integer, Quad-integer, Single-precision, Double-precision and Extended-precision arrays.
Matrix * and INV operations are only valid with floating-point numbers: Single-precision, Double-precision and Extended-precision arrays.
It is the programmer's responsibility to ensure that arrays used with MAT are of the appropriate size and type. All operations involving two or more arrays require that they be of exactly the same size and type, without exception. Failure to adhere causes undefined results. In the interest of execution speed, no error checking is performed at run-time.

Every scalar value denoted here as 'expr' must be enclosed in parentheses. Although Matrix operations tend to imply a two-dimensional array, unless otherwise noted (such as with MAT IDN, *, TRN), MAT may be used with arrays of one to eight dimensions. It is permissible to specify one array for multiple MAT parameters.

Examples MAT array1() = IDN

This establishes array1 as an identity matrix, with all diagonal elements as 1 and all others as zero. This produces undefined results if array1 is not a "square" matrix.

MAT array1() = (expr) * array2()

Each element of array2 is multiplied by the scalar value of the expr, then assigned to array1.

MAT array1() = TRN(array2())

Transposes the row and columns from array2 to array1. Arrays must be equivalent: array1(5,2) and array2(2,5). Only a square matrix may be transposed to itself.

MAT array1() = INV(array2())

Inverts the array from array2 to array1. Only a square matrix may be inverted. Proof: If array1 is then multiplied by array2, the resulting "
array3" will be equal to an Identify Matrix, (MAT array3 = array1 * array2 ' array3 should now be equal to "MAT array3 IDN").

MAT a() = b() * c()

Array multiplication occurs as follows:

' Row Column assumption:
' array [a]l,n = [b]l,m * [c]m,n

FOR i = 1 TO l ' Row [a]l = Row [b]l
FOR j = 1 TO n ' Column [a]n = Column [c]n
a(i,j) = 0# ' # if Double-precision
FOR k = 1 TO m ' Column [b]m = Row [c]m
a(i,j) = a(i,j) + b(l,k) * c(k,j)
NEXT k
NEXT j
NEXT i

------------------------------end of help file extract

--
happy
Jonathan Berry and Erika http://members.shaw.ca/berry5868/fun.htm
b***@aol.com
2004-08-30 23:10:22 UTC
Permalink
Post by Jonathan Berry
Post by b***@aol.com
There are things you can do in Fortran and not Basic, such as easily
call state-of-the-art numerical libraries like Lapack and performa
array operations like
a(1,:) = b(:) + c(:) (in Fortran 90/95). Fortran has always been the
language designed for numerical work, and it makes sense to use it for
such programs.
Any relation to "Big Al" Alexander Beliavsky, one of the
great chess players of all time?
I chose Beliavsky as a pseudonym because he is one of my favorite
chess players.

<PowerBasic matrix info snipped>

The array operations in PowerBasic look good, and the notation does
not differ much from that of Fortran 90/95. Fortran 90/95 does not
have built-in matrix inversion, perhaps because the optimal algorithm
for inversion could depend on the properties of the matrix (what if
it's singular?).

Does PowerBasic support array sections such as

y(1:3) = z(2:4)

and does it extend basic math functions such as sin, exp to arrays,
permitting

y(1:3) = exp(z(2:4)) ?

Loading...