Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

need help using calling C library in Visual Studio

Felipe_A_
Beginner
439 Views

Hi,

I am new to Intel Fortran and VS and I would appreciate if you could help me...

I need to use this mUMFPACK module for Fortran, which seems to require library written in C. In my mac I am able 

to install suitesparse and compile the module umfpack.f90 from the command line. However, I would like to make it work

on VS my Windows computer as well...

I found this option https://github.com/jlblancoc/suitesparse-metis-for-windows followed all the steps to built suitesparse.

Now, what I need to do is to use the mUMFPACK module for Fortran. Here is what I did

  1. On the build/SuiteSparse/SuiteSparse.sln that is produced by Cmake I added a project MAIN with 2 files: umf_test.f90 (attached) which calls the module umfpack.f90 and the module itself.
  2. On the umfpack.f90 file I add the command INCLUDE 'umfpack.h'.
  3. Right-click the executable Fortran MAIN project and select Dependencies to set the executable project as dependent on the umfpack project

When I try to build it, though, I get the following error. I tried it in the Intel 64 Visual Studio 2015 environment command line as well, but I am even less familiar with that...

Are these steps correct? If so, what am I missing?

Compiling with Intel(R) Visual Fortran Compiler 17.0.0.109 [IA-32]...
ifort /nologo /debug:full /Od /warn:interfaces /module:"Debug\" /object:"Debug\" /Fd"Debug\vc140.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin" /Qm32 "C:\Users\falves\Dropbox\Repo\hank-main\umfpack.f90"
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(1): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/* ========================================================================== /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(2): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 === umfpack.h ============================================================ /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(3): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
========================================================================== /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(5): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 -------------------------------------------------------------------------- /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(6): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 Copyright (c) 2005-2012 by Timothy A. Davis, http://www.suitesparse.com/
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(7): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 All Rights Reserved. See ../Doc/License for License. /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(7): error #5082: Syntax error, found IDENTIFIER 'RESERVED' when expecting one of: => = / , [ ( * ;
/
 All Rights Reserved. See ../Doc/License for License. /
--------------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(7): error #5082: Syntax error, found '.' when expecting one of: [ 
/
 All Rights Reserved. See ../Doc/License for License. /
------------------------------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(8): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 -------------------------------------------------------------------------- /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(10): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/

^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(11): error #5082: Syntax error, found IDENTIFIER 'IS' when expecting one of: => = . [ % ( :
This is the umfpack.h include file, and should be included in all user code
---------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(12): error #5082: Syntax error, found IDENTIFIER 'USES' when expecting one of: => = . [ % ( :
that uses UMFPACK. Do not include any of the umf_* header files in user
---------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(12): error #5082: Syntax error, found IDENTIFIER 'NOT' when expecting one of: .EQV. .NEQV. .XOR. .OR. .AND. .LT. < .LE. <= .EQ. == .NE. /= .GT. > ...
that uses UMFPACK. Do not include any of the umf_* header files in user
---------------------------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(13): error #5144: Invalid character_kind_parameter. No underscore
code. All routines in UMFPACK starting with "umfpack_" are user-callable.
-----------------------------------------------------------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(13): error #5082: Syntax error, found IDENTIFIER 'ROUTINES' when expecting one of: => = / . , [ % ( ; : )
code. All routines in UMFPACK starting with "umfpack_" are user-callable.
---------------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(14): error #5144: Invalid character_kind_parameter. No underscore
All other routines are prefixed "umf_XY_", (where X is d or z, and Y is
---------------------------------------------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(14): error #5082: Syntax error, found 'ALL' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
All other routines are prefixed "umf_XY_", (where X is d or z, and Y is
----^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(15): error #5276: Unbalanced parentheses
i or l) and are not user-callable.
----------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(15): error #5082: Syntax error, found IDENTIFIER 'OR' when expecting one of: => = . [ % ( :
i or l) and are not user-callable.
------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(18): warning #5117: Bad # preprocessor line
#ifndef UMFPACK_H
-^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(19): warning #5117: Bad # preprocessor line
#define UMFPACK_H
-^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(16): error #5082: Syntax error, found '' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
*/
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(21): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 -------------------------------------------------------------------------- /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(22): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 Make it easy for C++ programs to include UMFPACK /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(22): error #5082: Syntax error, found IDENTIFIER 'EASY' when expecting one of: => = / , [ ( * ;
/
 Make it easy for C++ programs to include UMFPACK /
-----------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(25): warning #5117: Bad # preprocessor line
#ifdef __cplusplus
-^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(23): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 -------------------------------------------------------------------------- /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(26): error #5144: Invalid character_kind_parameter. No underscore
extern "C" {
----------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(27): warning #5117: Bad # preprocessor line
#endif
-^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(29): warning #5117: Bad # preprocessor line
#include "SuiteSparse_config.h"
-^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(26): error #5078: Unrecognized token '{' skipped
extern "C" {
-----------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(26): error #5082: Syntax error, found CHARACTER_CONSTANT 'C' when expecting one of: => = . [ % ( :
extern "C" {
-------^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(31): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 -------------------------------------------------------------------------- /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(32): error #5082: Syntax error, found '/' when expecting one of: ; TYPE INTEGER REAL COMPLEX BYTE CHARACTER CLASS DOUBLE ...
/
 size of Info and Control arrays /
^
C:\SP_ROOT\build\install\include\suitesparse\umfpack.h(32): error #5082: Syntax error, found IDENTIFIER 'INFO' when expecting one of: => = / , [ ( * ;
/
 size of Info and Control arrays */
-----------^
C:\Users\falves\Dropbox\Repo\hank-main\umfpack.f90(46): catastrophic error: Too many errors, exiting
compilation aborted for C:\Users\falves\Dropbox\Repo\hank-main\umfpack.f90 (code 1)

ifort /nologo /debug:full /Od /warn:interfaces /module:"Debug\" /object:"Debug\" /Fd"Debug\vc140.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin" /Qm32 "C:\Users\falves\Documents\Visual Studio 2015\Projects\SuiteSparse_test\main.f90"

0 Kudos
1 Reply
Steven_L_Intel1
Employee
439 Views

umfpack.h is a C/C++ header file. You can't use this in Fortran source.

Looking at the UMFPACK user guide it seems that calling this from Fortran requires some effort and it makes a lot of assumptions about how Fortran compilers do calls and argument passing. It doesn't seem like something you can just grab and start using without digging in to the implementation and making sure the interfaces work for you.

0 Kudos
Reply