6

My boss just asked me to integrate his bosses old Fortran code into a project (Java) I'm working on. The code was written in the 90s, so I imagine it'll still compile, so rather than re-write it, I'm hoping I can just call the functions from a .dll. I'm already calling some C .dlls, so I think I've got that part covered.

I've been doing some reading, and most of the articles talk about integrating the Intel Visual Fortran Compiler into Microsoft Visual Studio. We've got a university site license for Visual Studio, but it looks like the Intel Visual Fortran Compiler is in around the $700 range. I don't think my boss will go for that, so I'm looking for another option. I know Microsoft makes a lot of products freely available to students via Project Dreamspark, but I didn't see anything Fortran related.

I'm looking at some cygwin based options right now (g95, I think), but I'm looking for other ideas/options. Any ideas?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Chad Mourning
  • 608
  • 2
  • 12
  • 25

4 Answers4

11

I've used the gfortran (g95) compiler with the -shared flag to create DLLs. first compile the .for/.f90 files with:

gfortran -c myfile1.f90
gfortran -c myfile2.f90

then:

gfortran -shared -o mydll.dll myfile1.o myfile2.o
bananafish
  • 2,877
  • 20
  • 29
3

MinGW will let you create a DLL that will work with your MS stuff.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
2

Look for a GCC port to Windows, such as Mingw or GCW. Both those will create .obj files which can be linked to in Visual Studio. Or you could futz around and configure VS to invoke one of those command line compilers into the project. But since the code is relatively static, it might be a nice compile once and forget it task, hopefully.

wallyk
  • 56,922
  • 16
  • 83
  • 148
1

Don't expect much help from Microsoft on Fortran. They spent years trying to kill it off in favour of Visual Basic / C.

You could try Silverfrost's compiler.

http://www.silverfrost.com/11/ftn95/ftn95_fortran_95_for_windows.aspx

This is available free ('personal edition' version) and works with Visual Studio. It's basically a F90/F95 compiler with a selection of later features included. You did not say if the old boss' code was written in F77 or F90. But I think that Silverfrost will handle the old code with minimal changes.

If it turns out well for you, there's also an academic version and an enterprise edition to move up to as desired.

  • "They spent years trying to kill it off in favour of Visual Basic / C." That's hardly true. Just because they don't produce a Fortran compiler any more (they used to) doesn't mean they were actively trying to kill the language. – David Heffernan Feb 22 '12 at 13:03
  • MS Fortran did exist in the early '90s. Borland had one too.But it was at best very half-hearted. –  Feb 22 '12 at 13:08