In my managed main-program (.net c#) i fill up a matrix and vector and call a frotran routine:
private void B_LGS_Click(object sender, RoutedEventArgs e)
{
// prepare vector and matrix
int M = LV_PagesURLs.Items.Count;
int N = 3;
if (M < 3) { MessageBox.Show('At least 3 domains and authority values are needed to solve the linear equation.'); return; }
double[,] A = new double[N, M];
double[] b = new double[M];
for ( int i = 0; i < M; i++ )
{
ListViewItem LVI = (ListViewItem)LV_PagesURLs.Items[i];
WebanalyzerURI URI = (WebanalyzerURI)LVI.Content;
int FWDLinkAmount = WebAnalyzerFacade.Webcrawler.get_forwarddomainamount_of(URI.AbsoluteURI);
int BACKLinkAmount = WebAnalyzerFacade.Webcrawler.get_backdomainamount_of(URI.AbsoluteURI);
int DBLLinkAmount = WebAnalyzerFacade.Webcrawler.get_doubledomainamount_of(URI.AbsoluteURI);
A[0, i] = FWDLinkAmount;
A[1, i] = BACKLinkAmount;
A[2, i] = DBLLinkAmount;
b[i] = URI.Auth;
}
// solve the linear equation
/*WebanalyzerWPF.NumericsFacade NumericFacilities = new WebanalyzerWPF.NumericsFacade();
NumericFacilities.solve_Ax_Equals_b(A, b);*/
Numerics.SolveOverdeterminedEquationSystem_DGELS(M, N, A, b);
The fortran routine itself look like this, note that I have deleted some of the code to localize the problem:
SUBROUTINE SolveOverdeterminedEquationSystem_DGELS( M, N, A, b) ASSEMBLY_INTERFACE(NAME='SolveOverdeterminedEquationSystem_DGELS')
CHARACTER TRANS
INTEGER INFO, LDA, LDB, LWORK, M, N, NRHS, MN
DOUBLE PRECISION A(:,:), b(:)
DOUBLE PRECISION, ALLOCATABLE:: WORK(:)
END SUBROUTINE
I often (but now always) get the following error(exception) when calling the fortran function:
CallbackOnCollectedDelegate has been recognized For the delegate of type 'ftn95lib.mdl!Salford.Fortran.RTLibrary+clearwin_callback::Invoke' a callback has been performed.....
Note that I had to translate the error message from german in english. Apparently the garbage collector removes something used by the fortran routine. But I can't figure out what I have done wrong.
I use VS2008 and Silverfrost FTN95 for Microsoft Visual Studio .NET 2.0.0.0 under vista.
Any help appreciated!