ameba
asked on
Fortran syntax help needed
Trying to convert some Fortran to VB. Here is a start of Fortran sub:
SUBROUTINE TRIDAG(AAA,AAB,AAC,ABB,E1, NN,BCT,BCB )
REAL*8 AAA(*),AAB(*),AAC(*),ABB(* ),E1(20000 )
REAL*8 BET, GAM(20000)
INTEGER BCT, BCB, NN
...
I thought argument AAA is an array, this also shows it is used as array:
BET=AAB(I)-AAA(I)*GAM(I)
But, when sub is called, it seems only ONE ELEMENT is passed, instead of array:
CALL TRIDAG(AA(1),AB(1),AC(1),B B(1),E1,NN ,BCT,BCB)
CALL TRIDAG(AA(2),AB(2),AC(2),B B(2),E1,NN ,BCT,BCB)
Please, help me understand syntax ... maybe only subset of array AA is being passed?
Thanks
SUBROUTINE TRIDAG(AAA,AAB,AAC,ABB,E1,
REAL*8 AAA(*),AAB(*),AAC(*),ABB(*
REAL*8 BET, GAM(20000)
INTEGER BCT, BCB, NN
...
I thought argument AAA is an array, this also shows it is used as array:
BET=AAB(I)-AAA(I)*GAM(I)
But, when sub is called, it seems only ONE ELEMENT is passed, instead of array:
CALL TRIDAG(AA(1),AB(1),AC(1),B
CALL TRIDAG(AA(2),AB(2),AC(2),B
Please, help me understand syntax ... maybe only subset of array AA is being passed?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tested "Convert Fortran to Visual Basic" but it doesn't recognize declaration.
Dim aaa(*) as double ' this doesn't work in VB
I don't see many Fortran programmers on EE :-)
Dim aaa(*) as double ' this doesn't work in VB
I don't see many Fortran programmers on EE :-)
ASKER
AAA(*)
is 'Assumed-size array', its size is known to caller
http://www.ibiblio.org/pub/languages/fortran/ch2-4.html
Call Tridag(AA(2), ...)
I think this means we are passing array block, starting with element 2. Will try and see if I get the same results as with Fortran Exe.
is 'Assumed-size array', its size is known to caller
http://www.ibiblio.org/pub/languages/fortran/ch2-4.html
Call Tridag(AA(2), ...)
I think this means we are passing array block, starting with element 2. Will try and see if I get the same results as with Fortran Exe.
the fnction TRIDAG is called with an array for first 4 parameters, but the passed array is of size one elemnt.
That's ok (if the programmer wants this).
That's ok (if the programmer wants this).
ASKER
Thanks, ahoffmann
>the passed array is of size one elemnt.
I don't think it's possible that 2 means 'upper bound' in Call Tridag(AA(2), ...)
Because there is a loop on that array (2 to NN) and passed NN is 51 or 501.
C------------------------- ---------- ---------- ---------- ---------- --
C SOLVER FROM "NUMERICAL RECIPES", TRIDAG
C------------------------- ---------- ---------- ---------- ---------- --
SUBROUTINE TRIDAG(AAA,AAB,AAC,ABB,E1, NN,BCT,BCB )
INTEGER NN
REAL*8 AAA(*),AAB(*),AAC(*),ABB(* ),E1(20000 )
REAL*8 BET, GAM(20000)
INTEGER BCT, BCB, N
DO I=1,20000
GAM(I)=1.0
E1(I)=1.0
ENDDO
N = NN
IF(BCB.GT.1) N=N-1
IF(BCT.GT.1) N=N-1
BET=AAB(1)
E1(1)=ABB(1)/BET
DO I=2,N
GAM(I) = AAC(I-1) / BET
BET = AAB(I) - AAA(I) * GAM(I)
E1(I) = (ABB(I) - AAA(I) * E1(I-1)) / BET
ENDDO
DO I=N-1,1,-1
E1(I)=E1(I)-GAM(I+1)*E1(I+ 1)
ENDDO
RETURN
END
I think I got it right, although program results are a bit different. For argument "AA(2)" I'm passing part of array, i.e. first element is AA(2).
But I don't know for sure that program is correct. Maybe what you are saying is true and all other elements AAA(2)to AAA(50) are zero's...?
I don't have Fortran compiler here to check.
>the passed array is of size one elemnt.
I don't think it's possible that 2 means 'upper bound' in Call Tridag(AA(2), ...)
Because there is a loop on that array (2 to NN) and passed NN is 51 or 501.
C-------------------------
C SOLVER FROM "NUMERICAL RECIPES", TRIDAG
C-------------------------
SUBROUTINE TRIDAG(AAA,AAB,AAC,ABB,E1,
INTEGER NN
REAL*8 AAA(*),AAB(*),AAC(*),ABB(*
REAL*8 BET, GAM(20000)
INTEGER BCT, BCB, N
DO I=1,20000
GAM(I)=1.0
E1(I)=1.0
ENDDO
N = NN
IF(BCB.GT.1) N=N-1
IF(BCT.GT.1) N=N-1
BET=AAB(1)
E1(1)=ABB(1)/BET
DO I=2,N
GAM(I) = AAC(I-1) / BET
BET = AAB(I) - AAA(I) * GAM(I)
E1(I) = (ABB(I) - AAA(I) * E1(I-1)) / BET
ENDDO
DO I=N-1,1,-1
E1(I)=E1(I)-GAM(I+1)*E1(I+
ENDDO
RETURN
END
I think I got it right, although program results are a bit different. For argument "AA(2)" I'm passing part of array, i.e. first element is AA(2).
But I don't know for sure that program is correct. Maybe what you are saying is true and all other elements AAA(2)to AAA(50) are zero's...?
I don't have Fortran compiler here to check.
ASKER
Thanks. Everything is working OK. I have small difference when compared to Fortran results, but first 9 digits are the same. :-)
0.563085102878388 ' Fortran
0.563085102830859 ' VB
0.563085102830685 ' VB with option "Allow unrounded Floating Point Operations"
0.563085102878388 ' Fortran
0.563085102830859 ' VB
0.563085102830685 ' VB with option "Allow unrounded Floating Point Operations"
ameba thanks, but that wasn't necessary i only posted it as *help* don't know if it would help you did most of it yourself
ASKER
I expect converter would convert it to:
Private Sub TRIDAG(AAA() As Double, AAB() As Double, AAC() As Double, ABB() As Double, _
E1() As Double, NN As Long, BCT As Long, BCB As Long)
and the call to:
CALL TRIDAG(AA(1), AB(1), AC(1), BB(1), E1, NN, BCT, BCB)
and I would get error "Expecting array" with "AA(1)" highlighted.
I'll try it later, if there isn't any 'easier' suggestion.