Re: Calling a fortran subroutine from Visual C++



"William DePalo [MVP VC++]" <willd.no.spam@xxxxxxxx> wrote in message news:uo37xpscFHA.3620@xxxxxxxxxxxxxxxxxxxxxxx
"Ray J." <Ray J.@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:51F7C3A6-1708-40F7-ABB6-F96CBC142300@xxxxxxxxxxxxxxxx

I have a C++ program written and compiled on Solaris 8 with gcc. With gcc lets me compile fortran code along with the C++ program to be able to call the fortran code as a subroutine.

I never noticed that, but maybe it's not surprising since the Gnu Fortran compiler is closely related to gcc. Depending on your needs, have you tried Windows Services for Unix? I've used gcc (though not Gnu Fortran) in that environment.


Is there a way to call fortran code from a C++ program compiled with Visual C++?

Old MSDN libraries used to say how! Microsoft used to make a Fortran compiler, they sold the product and it became the DEC Fortran compiler for Windows, which became the Compaq Fortran compiler for Windows, and then Compaq or HP sold the product and now it's the Intel Fortran compiler for Windows. But MSDN libraries no longer say how to interoperate with it, so you'll need Intel's documents.


It's not clear to me what tools you have. [...] if it allows you to build a DLL, then the expedient thing to do is export your function from the DLL [...]

The big questions are what the types are, and whether there are arrays and stuff like that. By the way the declarations in the C++ program will surely need to be wrapped in extern "C" {}.


You will find some free Fortran compilers here:
http://www.thefreecountry.com/compilers/fortran.shtml

Interesting page, thank you. Hmm, they say that Intel's compiler is free for personal non-commercial use. I don't think it was when I hunted it down a while back.


They also list f2c, which I've used before. The resulting C code isn't human readable but it does compile, and can be called from C++ callers.

.



Relevant Pages

  • Re: DFPORT
    ... I work on a Windows XP platform. ... We normally use F77 Fortran and for this one problematic program we ... Since we also have the Intel Fortran compiler, we also had a lot of ... Windows Fortran comper (with appropriate libraries). ...
    (comp.lang.fortran)
  • Re: LAPACK
    ... >>what do I have to do for installing LAPACK on a pc with windows XP??? ... You need a Fortran compiler, unless you want to use CLAPACK. ... The speed of LAPACK is very dependent on the quality of your BLAS. ...
    (sci.math.num-analysis)
  • Re: Compiler query
    ... Windows 2000 is probably the worst Windows when it comes ... to the DOS Box. ... which compiles Fortran 77 as a subset of Fortran 90, ... -|I started off searching for a Fortran compiler to use - as the moment ...
    (comp.lang.fortran)
  • Re: "Visual" Fortran?
    ... > If you what a cheap/free FORTRAN compiler for Windows, ... > to beat the Watcom Compiler: ... > FORTRAN is likely to be a very poor choice. ... > Visual Basic 6.0 to do teh GUI from end, ...
    (comp.lang.fortran)
  • Re: who can help me? about OpenMP
    ... I know nothing about how Intel has implemented their compiler on ... Your best source of info on that is the Intel Fortran ... Fortran Compiler for Windows & Visual Fortran ...
    (comp.parallel)