Post by b***@aol.comPost by Paul RobinsonPost 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