Hi George,
Andrea isn't on the dev@dynare.org. Please take contact with him directly (with cc to me) and discuss with him who should make the changes that you recommend.
All the best,
Michelapp
Perendia wrote:
Dear Andrea and Michel (et al)
I have encountered an unexpected problem integrating KalmanFilter with the f90 QT library - passing the QT result arrays back to C++.
QT Fortran routines have been written in standard Fortran FUNCTION format, (i.e., not SUBROUTINE), so that they are returning double or single dimensional array (they are named by), by value ( not reference) and, as it appears, only simple, single variables seems can be passed from Fortran FUNCTIONs back to C++ (e.g. INT or REAL).
On the other hand, NAG, BLAS and LAPACK routines have all been written as Fortran SUBROUTINEs and the subroutines are the equivalent of "C" functions returning "(void)".
SUBROUTINE can be integrated with C more easily as they receive parameters and return their results through the variables passed as calling parameters by references.
For example, dgemv.f from BLAS library gets Y by reference and returns modified Y passed as calling parameter reference.
SUBROUTINE DGEMV(TRANS,M,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
....
- Y - DOUBLE PRECISION array of DIMENSION at least
...
Before entry .... the incremented array Y
must contain the vector y. On exit, Y is overwritten by the
updated vector y.
....
I could not find any references on how to get arrays from Fortran FUCTION as return value back to C - does anyone know how to do it or, if at all possible?
One way I can think of is less explored option of returning Fortran pointer to the resulting array from the QT functions instead of the array by value and I think I can work one of that out.
However, even if there is another way to pass function result arrays back to C++, I expect it is bound to be less efficient than passing it by reference (or Fortran pointer), especially for larger matrices. And, if there is no efficient alternative, I can either easily rewrite QT library as SUBROUTINE routines instead FUCTION or try to use Fortran pointers and, if ok, I can then also rewrite QT library to return pointers..
Best regards
George
Dev mailing list Dev@dynare.org http://www.dynare.org/cgi-bin/mailman/listinfo/dev