On 03/21/2012 02:32 PM, Giovanni Azua wrote:
> Hello,
> 
> I have a project for which the main language is C (soon CPP) that calls
> some functions from Intel MKL. I have the need to use four third-party
> high performance fortran routines and I need to:
> 
> 1) be able to call these Fortran routines from my C code
> 2) Automatically generate C headers I can include in my C code (use
> the FortranCInterface.cmake)
> 3) be able to compile the Fortran routines and have them linking
> with/calling MKL's LAPACK and BLAS implementations and not any other
> possible GNU variants.
> 
> I followed the example here
> <http://public.kitware.com/cgi-bin/viewcvs.cgi/Tests/Fortran/?root=CMake> and
> I think I am not too far from the target. However, there are a few
> unclear points e.g. I didn't exactly understand what this line is doing:
> 
> list(APPENDFORTRAN_FUNCTIONSmy_sub mysub)
> 
> my attempt to achieve the same thing is:
> 
> add_library(qr_updatesSTATIC
>     src/addcols.f
>     src/addcolsq.f
>     src/delcols.f
>     src/delcolsq.f
> )
> 
> list(APPEND FORTRAN_FUNCTIONS ADDCOLS addcols)
> list(APPEND FORTRAN_FUNCTIONS ADDCOLSQ addcolsq)
> list(APPEND FORTRAN_FUNCTIONS DELCOLS delcols)
> list(APPEND FORTRAN_FUNCTIONS DELCOLSQ delcolsq)
> FortranCInterface_HEADER(qr_updates.h
>     MACRO_NAMESPACE "FC_"
>     SYMBOL_NAMESPACE "F_"
>     SYMBOLS ${FORTRAN_FUNCTIONS}
> )
> include_directories("${myproject_BINARY_DIR}")
> 
> then I get the following qr_updates.h as output:
> 
> *#ifndef* FC_HEADER_INCLUDED
> *#define* FC_HEADER_INCLUDED
> 
> /* Mangling for Fortran global symbols without underscores. */
> *#define* FC_GLOBAL(name,NAME) name*##*_
> 
> /* Mangling for Fortran global symbols with underscores. */
> *#define* FC_GLOBAL_(name,NAME) name*##*_
> 
> /* Mangling for Fortran module symbols without underscores. */
> *#define* FC_MODULE(mod_name,name, mod_NAME,NAME)
> __*##*mod_name*##*_MOD_*##*name
> 
> /* Mangling for Fortran module symbols with underscores. */
> *#define* FC_MODULE_(mod_name,name, mod_NAME,NAME)
> __*##*mod_name*##*_MOD_*##*name
> 
> /*--------------------------------------------------------------------------*/
> /* Mangle some symbols automatically.                                  
>     */
> *#define* F_ADDCOLS FC_GLOBAL(addcols, ADDCOLS)
> *#define* F_addcols FC_GLOBAL(addcols, ADDCOLS)
> *#define* F_ADDCOLSQ FC_GLOBAL(addcolsq, ADDCOLSQ)
> *#define* F_addcolsq FC_GLOBAL(addcolsq, ADDCOLSQ)
> *#define* F_DELCOLS FC_GLOBAL(delcols, DELCOLS)
> *#define* F_delcols FC_GLOBAL(delcols, DELCOLS)
> *#define* F_DELCOLSQ FC_GLOBAL(delcolsq, DELCOLSQ)
> *#define* F_delcolsq FC_GLOBAL(delcolsq, DELCOLSQ)
> 
> *#endif*
> *
> *
> but the signatures in this generated header look fishy, am I missing
> anything? For example the function signature for the ADDCOLSQ Fortran
> routine looks like this:
> 
>       *SUBROUTINE*ADDCOLSQ( M, N, A, LDA, Q, LDQ, K, P, TAU, WORK, INFO)
> *
> *     Craig Lucas, University of Manchester
> *     March, 2004
> *
> *     .. Scalar Arguments ..
>       *INTEGER*            INFO, K, LDA, LDQ, M, N, P
> *     ..
> *     .. Array Arguments ..
>       *DOUBLE* *PRECISION*   A( LDA, * ), Q( LDQ, * ), TAU( * ), WORK( * )
> 
> I expected the generated header to contain a matching signature or?
> 
> TIA,
> Best regards,
> Giovanni

Hi Giovanni

I think you misunderstand what FortranCInterface.cmake does. It doesn
*not* generate signatures, it only generates macros to handle the
*name-mangling* for you. You still have to provide the signatures
yourself, using the defined macros. E.g. (I hope I get this one right,
it's been quite some time I last did this...):

void F_ADDCOLSQ(int M, int N, double* A, int LDA, double* Q, int LDQ,
                int K, int P, double* TAU, double* WORK, int* info);


I hope this gets you started.

Michael
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to