how to call C (non-intel C compiler) from ifort (intel fortran)? - Fortran

This is a discussion on how to call C (non-intel C compiler) from ifort (intel fortran)? - Fortran ; Hi there, I need to call C within fortran code. I could compile and link using Visual Fortran and Visual C++. Fortran code is like: .. CALL SUB1(arg1, .......) .. .. C code is like: #define sub1 __stdcall SUB1 .. ...

+ Reply to Thread
Results 1 to 5 of 5

how to call C (non-intel C compiler) from ifort (intel fortran)?

  1. Default how to call C (non-intel C compiler) from ifort (intel fortran)?

    Hi there,

    I need to call C within fortran code. I could compile and link using
    Visual Fortran
    and Visual C++.

    Fortran code is like:
    ..
    CALL SUB1(arg1, .......)
    ..
    ..
    C code is like:
    #define sub1 __stdcall SUB1
    ..
    void sub1 ( arg1, ........)
    ..
    ..
    Now I have to use another machine with Intel Fortran (ifort) with .NET
    (Visual Studio
    2005). When I linked, I got error message "unresolved external symbol
    _SUB1".
    What is the right way to do? (For using ifort with icc, an example is
    shown in
    http://www.ncsa.uiuc.edu/UserInfo/Re...trancallc.html)

    Any help is very much appreciated.


  2. Default Re: how to call C (non-intel C compiler) from ifort (intel fortran)?

    ktrchang@gmail.com wrote:
    > Hi there,
    >
    > I need to call C within fortran code. I could compile and link using
    > Visual Fortran
    > and Visual C++.
    >


    > What is the right way to do?


    There are plenty of examples in the doc directory of your Fortran
    installation, including (if you have a current ifort) documents on the
    ISO C interoperability scheme of current standard Fortran.

  3. Default Re: how to call C (non-intel C compiler) from ifort (intel fortran)?

    ktrchang@gmail.com wrote:

    > I need to call C within fortran code. I could compile and link using
    > Visual Fortran and Visual C++.


    > CALL SUB1(arg1, .......)


    > C code is like:
    > #define sub1 __stdcall SUB1
    > void sub1 ( arg1, ........)


    > Now I have to use another machine with Intel Fortran (ifort)
    > with .NET (Visual Studio 2005). When I linked, I got error message
    > "unresolved external symbol _SUB1".


    It is not unusual for Fortran subroutine and function names to
    be generated with an extra _ on them. Also, since C is case sensitive
    and the routine in the message is upper case change the C routine
    name to _SUB1.

    #define sub1 __stdcall _SUB1

    -- glen


  4. Default Re: how to call C (non-intel C compiler) from ifort (intel fortran)?

    ktrchang@gmail.com wrote:
    | Hi there,
    |
    | I need to call C within fortran code. I could compile and link using
    | Visual Fortran
    | and Visual C++.
    |
    | Fortran code is like:
    | .
    | CALL SUB1(arg1, .......)
    | .
    | .
    | C code is like:
    | #define sub1 __stdcall SUB1
    | .
    | void sub1 ( arg1, ........)
    | .
    | .
    | Now I have to use another machine with Intel Fortran (ifort) with .NET
    | (Visual Studio
    | 2005). When I linked, I got error message "unresolved external symbol
    | _SUB1".
    | What is the right way to do? (For using ifort with icc, an example is
    | shown in
    |
    http://www.ncsa.uiuc.edu/UserInfo/Re...trancallc.html)
    |
    | Any help is very much appreciated.

    Intel changed the default calling convention from __stdcall to __cdecl,
    when it took over the CVF. So, either adjust it on C side, or change the
    calling convention on Fortran side. In addition, the way how CHARACTER
    arguments are passed is also changed -- the hidden length is now passed
    at the end of argument-list rather than immediately following the string
    argument.

    --
    Jugoslav
    ___________
    www.xeffort.com

    Please reply to the newsgroup.
    You can find my real e-mail on my home page above.


  5. Default Re: how to call C (non-intel C compiler) from ifort (intel fortran)?

    On Sep 27, 7:02 pm, ktrch...@gmail.com wrote:
    > Hi there,
    >
    > I need to call C within fortran code. I could compile and link using
    > Visual Fortran
    > and Visual C++.
    >
    > Fortran code is like:
    > .
    > CALL SUB1(arg1, .......)
    > .
    > .
    > C code is like:
    > #define sub1 __stdcall SUB1
    > .
    > void sub1 ( arg1, ........)
    > .
    > .
    > Now I have to use another machine with Intel Fortran (ifort) with .NET
    > (Visual Studio
    > 2005). When I linked, I got error message "unresolved external symbol
    > _SUB1".
    > What is the right way to do? (For using ifort with icc, an example is
    > shown inhttp://www.ncsa.uiuc.edu/UserInfo/Resources/Hardware/Intel64Cluster/D...)
    >
    > Any help is very much appreciated.



    Thank you all for the postings.

    In ifort /help, it shows:
    /Gm enable CVF and Powerstation calling convention
    compatibility
    (same as /iface:cvf)

    With /Gm, error of unresolved external symbol is resolved.

    BTW, I intended to include link below but it was cut off.
    http://www.ncsa.uiuc.edu/UserInfo/Re...ntel64Cluster/
    Doc/fortrancallc.html

    ReggieC



+ Reply to Thread

Similar Threads

  1. Xcode, Intel ifort and opening files
    By Application Development in forum Fortran
    Replies: 4
    Last Post: 12-14-2007, 06:24 PM
  2. Problem with log function - Intel fortran compiler under Linux
    By Application Development in forum Fortran
    Replies: 56
    Last Post: 10-19-2007, 02:35 AM
  3. Intel Fortran compiler version 10 released
    By Application Development in forum Fortran
    Replies: 0
    Last Post: 06-05-2007, 11:07 AM
  4. Using Intel Fortran Compiler v8.0 on AMD-Cluster with Suse LES 10.0
    By Application Development in forum Fortran
    Replies: 0
    Last Post: 04-03-2007, 08:09 AM
  5. Intel Fortran 9.1
    By Application Development in forum Fortran
    Replies: 0
    Last Post: 03-25-2007, 06:59 AM