"Value of Double cannot be converted"

I am working in VB.net 2003.

The project is to convert some fortran code to vb.
I have a set of fortran routines and one function.

I have converted them to the best of my abilty but have a few remaining problems: (at least I hope so)

Problem 1^^^^^^^^^^^^^^^^^^
"Value of type 'Double' cannot be converted to '2-dimensional array of Double"

This is the line raising the error: eight lines after the "180:"

Call DBNFAC(W(IWP, 1), NWROW, N, ILB, IUB, IFLAG)

Problem 2^^^^^^^^^^^^^^^^^^
What should be done with the Dim statements from fortran.
they are commented out just above the line:
'***FIRST EXECUTABLE STATEMENT DBINT4

Here is the code. Any clues would be most appriciated.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Sub DBINT4(ByVal X() As Double, ByVal Y() As Double, ByVal NDATA As Integer, ByVal IBCL As Integer, ByVal IBCR As Integer, ByVal FBCL As Double, ByVal FBCR As Double, ByVal KNTOPT As Integer, ByVal T() As Double, ByVal BCOEF() As Double, ByVal N As Integer, ByVal K As Integer, ByVal W(,) As Double)
'***BEGIN PROLOGUE DBINT4
'***DATE WRITTEN 800901 (YYMMDD)
'***REVISION DATE 820801 (YYMMDD)
'***CATEGORY NO. E1A
'***KEYWORDS B-SPLINE,DATA FITTING,DOUBLE PRECISION,INTERPOLATION,
' SPLINE
'***AUTHOR AMOS, D. E., (SNLA)
'***PURPOSE Computes the B-representation of a cubic spline
' which interpolates data (X(I),Y(I)),I=1,NDATA.
'***DESCRIPTION
'
' Written by D. E. Amos, August, 1979.
'
' References
' SAND-78-1968
'
' A Practical Guide to Splines by C. de Boor, Applied
' Mathematics Series 27, Springer, 1979.
'
' SIAM J. Numerical Analysis, 14, No. 3, June, 1977, pp.441-472.
'
' Abstract **** a double precision routine ****
'
' DBINT4 computes the B representation (T,BCOEF,N,K) of a
' cubic spline (K=4) which interpolates data (X(I),Y(I)),
' I=1,NDATA. Parameters IBCL, IBCR, FBCL, FBCR allow the
' specification of the spline first or second derivative at
' both X(1) and X(NDATA). When this data is not specified
' by the problem, it is common practice to use a natural
' spline by setting second derivatives at X(1) and X(NDATA)
' to zero (IBCL=IBCR=2,FBCL=FBCR=0.0). The spline is defined
' on T(4) .LE. X .LE. T(N+1) with (ordered) interior knots at
' X(I) values where N=NDATA+2. The knots T(1),T(2),T(3) lie to
' the left of T(4)=X(1) and the knots T(N+2), T(N+3), T(N+4)
' lie to the right of T(N+1)=X(NDATA) in increasing order. If
' no extrapolation outside (X(1),X(NDATA)) is anticipated, the
' knots T(1)=T(2)=T(3)=T(4)=X(1) and T(N+2)=T(N+3)=T(N+4)=
' T(N+1)=X(NDATA) can be specified by KNTOPT=1. KNTOPT=2
' selects a knot placement for T(1), T(2), T(3) to make the
' first 7 knots symmetric about T(4)=X(1) and similarly for
' T(N+2), T(N+3), T(N+4) about T(N+1)=X(NDATA). KNTOPT=3
' allows the user to make his own selection, in increasing
' order, for T(1), T(2), T(3) to the left of X(1) and T(N+2),
' T(N+3), T(N+4) to the right of X(NDATA) in the work array
' W(1) through W(6). In any case, the interpolation on
' T(4) .LE. X .LE. T(N+1) by using function DBVALU is unique
' for given boundary conditions.
'
' DBINT4 calls DBSPVD, DBNFAC, DBNSLV, D1MACH, XERROR
'
' Description of Arguments
'
' Input X,Y,FBCL,FBCR,W are double precision
' X - X vector of abscissae of length NDATA, distinct
' and in increasing order
' Y - Y vector of ordinates of length NDATA
' NDATA - number of data points, NDATA .GE. 2
' IBCL - selection parameter for left boundary condition
' IBCL = 1 constrain the first derivative at
' X(1) to FBCL
' = 2 constrain the second derivative at
' X(1) to FBCL
' IBCR - selection parameter for right boundary condition
' IBCR = 1 constrain first derivative at
' X(NDATA) to FBCR
' IBCR = 2 constrain second derivative at
' X(NDATA) to FBCR
' FBCL - left boundary values governed by IBCL
' FBCR - right boundary values governed by IBCR
' KNTOPT - knot selection parameter
' KNTOPT = 1 sets knot multiplicity at T(4) and
' T(N+1) to 4
' = 2 sets a symmetric placement of knots
' about T(4) and T(N+1)
' = 3 sets T(I)=W(I) and T(N+1+I)=W(3+I),I=1,3
' where W(I),I=1,6 is supplied by the user
' W - work array of dimension at least 5*(NDATA+2)
' If KNTOPT=3, then W(1),W(2),W(3) are knot values to
' the left of X(1) and W(4),W(5),W(6) are knot
' values to the right of X(NDATA) in increasing
' order to be supplied by the user
'
' Output T,BCOEF are double precision
' T - knot array of length N+4
' BCOEF - B spline coefficient array of length N
' N - number of coefficients, N=NDATA+2
' K - order of spline, K=4
'
' Error Conditions
' Improper input is a fatal error
' Singular system of equations is a fatal error
'***REFERENCES D.E. AMOS, *COMPUTATION WITH SPLINES AND B-SPLINES*,
' SAND78-1968, SANDIA LABORATORIES, MARCH 1979.
' C. DE BOOR, *PACKAGE FOR CALCULATING WITH B-SPLINES*,
' SIAM JOURNAL ON NUMERICAL ANALYSIS, VOLUME 14, NO. 3,
' JUNE 1977, PP. 441-472.
' C. DE BOOR, *A PRACTICAL GUIDE TO SPLINES*, APPLIED
' MATHEMATICS SERIES 27, SPRINGER, 1979.
'***ROUTINES CALLED D1MACH,DBNFAC,DBNSLV,DBSPVD,XERROR
'***END PROLOGUE DBINT4
'
'
Dim I As Integer
Dim IFLAG As Integer
Dim ILB As Integer
Dim ILEFT As Integer
Dim IT As Integer
Dim IUB As Integer
Dim IW As Integer
Dim IWP As Integer
Dim J As Integer
Dim JW As Integer
Dim NDM As Integer
Dim NP As Integer
Dim NWROW As Integer
Dim TOL As Double
Dim TXN As Double
Dim TX1 As Double
Dim VNIKX(,) As Double
Dim WDTOL As Double
Dim WORK() As Double
Dim XL As Double
Dim D1MACH() As Double

'Dim X(1), Y(1), T(1), BCOEF(1), W(5, 1), VNIKX(4, 4), WORK(15)
'***FIRST EXECUTABLE STATEMENT DBINT4
WDTOL = D1MACH(4)
TOL = Sqrt(WDTOL)
If (NDATA < 2) Then GoTo 200
NDM = NDATA - 1
For I = 1 To NDM
If (X(I) >= X(I + 1)) Then GoTo 210
10: Next I
If (IBCL < 1 Or IBCL > 2) Then GoTo 220
If (IBCR < 1 Or IBCR > 2) Then GoTo 230
If (KNTOPT < 1 Or KNTOPT > 3) Then GoTo 240
K = 4
N = NDATA + 2
NP = N + 1
For I = 1 To NDATA
T(I + 3) = X(I)
20: Next I
Select Case KNTOPT
Case 1 : GoTo 30
Case 2 : GoTo 50
Case 3 : GoTo 90
End Select
' SET UP KNOT ARRAY WITH MULTIPLICITY 4 AT X(1) AND X(NDATA)
30: REM
For I = 1 To 3
T(4 - I) = X(1)
T(NP + I) = X(NDATA)
40: Next I
GoTo 110
' SET UP KNOT ARRAY WITH SYMMETRIC PLACEMENT ABOUT END POINTS
50: REM
If (NDATA > 3) Then GoTo 70
XL = (X(NDATA) - X(1)) / 3.0
For I = 1 To 3
T(4 - I) = T(5 - I) - XL
T(NP + I) = T(NP + I - 1) + XL
60: Next I
GoTo 110
70: REM
TX1 = X(1) + X(1)
TXN = X(NDATA) + X(NDATA)
For I = 1 To 3
T(4 - I) = TX1 - X(I + 1)
T(NP + I) = TXN - X(NDATA - I)
80: Next I
GoTo 110
' SET UP KNOT ARRAY LESS THAN X(1) AND GREATER THAN X(NDATA) TO BE
' SUPPLIED BY USER IN WORK LOCATIONS W(1) THROUGH W(6) WHEN KNTOPT=3
90: REM
For I = 1 To 3
T(4 - I) = W(4 - I, 1)
'If 1 >= I - 1 Then max0 = 1 Else max0 = I - 1
JW = Max(1, I - 1)
IW = I + 2 Mod 5 + 1
T(NP + I) = W(IW, JW)
If (T(4 - I) > T(5 - I)) Then GoTo 250
If (T(NP + I) < T(NP + I - 1)) Then GoTo 250
100: Next I
110: REM
'
For I = 1 To 5
For J = 1 To N
W(I, J) = 0.0
120: Next J
130: Next I
' SET UP LEFT INTERPOLATION POINT AND LEFT BOUNDARY CONDITION FOR
' RIGHT LIMITS
IT = IBCL + 1
Call DBSPVD(T, K, IT, X(1), K, 4, VNIKX, WORK)
IW = 0
If (Abs(VNIKX(3, 1)) < TOL) Then IW = 1
For J = 1 To 3
W(J + 1, 4 - J) = VNIKX(4 - J, IT)
W(J, 4 - J) = VNIKX(4 - J, 1)
140: Next J
BCOEF(1) = Y(1)
BCOEF(2) = FBCL
' SET UP INTERPOLATION EQUATIONS FOR POINTS I=2 TO I=NDATA-1
ILEFT = 4
If (NDM < 2) Then GoTo 170
For I = 2 To NDM
ILEFT = ILEFT + 1
Call DBSPVD(T, K, 1, X(I), ILEFT, 4, VNIKX, WORK)
For J = 1 To 3
W(J + 1, 3 + I - J) = VNIKX(4 - J, 1)
150: Next J
BCOEF(I + 1) = Y(I)
160: Next I
' SET UP RIGHT INTERPOLATION POINT AND RIGHT BOUNDARY CONDITION FOR
' LEFT LIMITS(ILEFT IS ASSOCIATED WITH T(N)=X(NDATA-1))
170: REM
IT = IBCR + 1
Call DBSPVD(T, K, IT, X(NDATA), ILEFT, 4, VNIKX, WORK)
JW = 0
If (Abs(VNIKX(2, 1)) < TOL) Then JW = 1
For J = 1 To 3
W(J + 1, 3 + NDATA - J) = VNIKX(5 - J, IT)
W(J + 2, 3 + NDATA - J) = VNIKX(5 - J, 1)
180: Next J
BCOEF(N - 1) = FBCR
BCOEF(N) = Y(NDATA)
' SOLVE SYSTEM OF EQUATIONS
ILB = 2 - JW
IUB = 2 - IW
NWROW = 5
IWP = IW + 1
Call DBNFAC(W(IWP, 1), NWROW, N, ILB, IUB, IFLAG)
If (IFLAG = 2) Then GoTo 190
Call DBNSLV(W(IWP, 1), NWROW, N, ILB, IUB, BCOEF)
Exit Sub
'
'
190: REM
Call XERROR(" DBINT4, THE SYSTEM OF EQUATIONS IS SINGULAR", 45, 2, 1)
Exit Sub
200: REM
Call XERROR(" DBINT4, NDATA IS LESS THAN 2", 30, 2, 1)
Exit Sub
210: REM
Call XERROR(" DBINT4, X VALUES ARE NOT DISTINCT OR NOT ORDERED", 50, 2, 1)
Exit Sub
220: REM
Call XERROR(" DBINT4, IBCL IS NOT 1 OR 2", 28, 2, 1)
Exit Sub
230: REM
Call XERROR(" DBINT4, IBCR IS NOT 1 OR 2", 28, 2, 1)
Exit Sub
240: REM
Call XERROR(" DBINT4, KNTOPT IS NOT 1, 2, OR 3", 34, 2, 1)
Exit Sub
250: REM
Call XERROR(" DBINT4, KNOT INPUT THROUGH W ARRAY IS NOT ORDEREDPROPERLY", 60, 2, 1)
End Sub
[13655 byte] By [schmidtmotorworks] at [2007-11-20 9:28:33]