how to call a fortran subroutine

This is a discussion on how to call a fortran subroutine within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, I'm startin with C++ now and I want to call a FORTRAN subprogram with a parameter so fortran ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    2

    Question how to call a fortran subroutine

    Hello everyone,

    I'm startin with C++ now and I want to call a FORTRAN subprogram with a parameter so fortran make some work with it.

    How could I do it?

    thankyou very much.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    meaning commandline? system()
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    2
    Sorry, perhaps I wasn't as clear as I must.

    I want to call a function written on FORTRAN.

    how can I do it?

    Thank you.

  4. #4
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    Well you wont be able to call it directly from your code, i.e you cant write fotran in a C++ program b/c the compiler will go nuts, if you really must use this routine, then make sure its in a dll or lib and then load it up and call it, im not sure how fortran works so you might want to use google and look up calling conventions and how to load code at runtime.
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    that certainly isn't any more clear. your only way is to have it exported from a dll. load it in the c program. Aside from that I have NO idea what you're talking about. there's no such thing as inline FORTRAN unless I just missed that along the way
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    no theres no inline fortran unless your compiler supports that but i seriously doubt that it will. I think that the super exspensive version of VS.Net might support it but im not 100% sure. What is so important about the routine that you couldnt just re-write it in C++?
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  7. #7
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    how to call a fortran subroutine
    I really donīt have a concret answer, but Iīm currently reading a book and I found that might be intressting...

    For example extern "ADA" can be used to declare functions written in the ADA language, extern "FORTRAN" for functions written in the FORTRAN language, and so on.
    Code:
    extern "C"
    {
    int printf(const char* ...)
    ...
    ...
    }

    I donīt know how this work but try searching on google that have superier better examples then this one.

  8. #8
    Registered User
    Join Date
    Jun 2002
    Posts
    25
    did some work for you...it looks like its very possible with the right tools...

    http://www.thp.univie.ac.at/~jthorn/c2f.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 10:13 AM
  2. Call Fortran function from .dll/.so
    By MarkZWEERS in forum C++ Programming
    Replies: 2
    Last Post: 10-14-2008, 12:50 PM
  3. problem with subroutine
    By pankleks in forum C Programming
    Replies: 2
    Last Post: 11-24-2005, 02:57 AM
  4. Iterative Tree Traversal using a stack
    By BigDaddyDrew in forum C++ Programming
    Replies: 7
    Last Post: 03-10-2003, 05:44 PM
  5. call by reference and a call by value
    By IceCold in forum C Programming
    Replies: 4
    Last Post: 09-08-2001, 06:06 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21