- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have inherited a large Fortran project, and I need to migrate it to Windows. We use Visual Studio 2008. It was developed in Linux, and the previous owners said to use Visual Fortran. So I got the proper version installed nicely. Now can I open the Linux project directly? Can I reuse the makefiles? I tried clicking around but couldn't find how.
Is there an approved method for doing this?
I am probably not the first person to have this problem, though everybody else here seems to be porting in the other direction.
Edit: I solved it in the end, scroll down to the end to see my solution
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Makefiles are useable on Windows as well as on Linux, though sometimes people use features that are specific to the one or the other platform or the make utilities they have available. My personal preference is to keep them as simple as possible and not use any trickery - that way I do not have to know all the tricks you can play ;).
On Windows, if you open a command window via your Intel Fortran installation (something like: Start menu, Intel Fortran, Command prompt, your choice of platform (32/64 bits) - the details vary per version), you can then go to the directory containing your source files and type the command "nmake" - that is the Windows make utility. It works very much like the Linux variants.
Of course, you may need to set the right compiler name in your makefiles and possibly change the flags, but that is a minor issue. Alternatives exist as well, like using CMake, but that requires you to set up a new build system. (One reason for doing so is that a build system based on CMake or similar utilities is platform-independent.)
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have migrated and now maintaining a large application from Windows to Linux (core development is under Windows and the Linux version is lined-up about once a year).
The application is built from 550 fortran source files with about 700000 lines of code.
Compilation and linkage are done from the command line with two .sh files with the list of the fortran and object files included in two text files. So in addition of the intel compiler I use only a text editor.
I think that you can perform the reverse migration from Linux to Windows using the same approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually I can probably manage without makefiles...? I mean, why bother having Visual Studio and then hack it by hand? Maybe it will just compile and build if I can work out how to do it. I pressed compile all and it did its best.
Can it work that way, just like C++ does?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I should be able to compile and build from Visual Studio (we are in the 21st century now, we don't do command line any more, surely).
But it trips up at the first #include
So it seems I need some serious help with my project properties. Where can I find this? The online help and the manuals are much less helpful than I would expect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include is not standard Fortran, you will have to turn on C-style preprocessing. You should be able to do that via the Fortran/Preprocessor tab in the Properties window.
(I do not see why "command line" should not be done anymore, but that may be a personal matter ;)).
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, that did the trick.
Properties/Fortran/Preprocessor/Preprocess Source File = Yes (/fpp)
Now I just need it to find the include files. This is going to be a long week...
(I am not a Fortran person. I am a Visual C++ person. I don't do command line ;-) At least I promised myself 20 years ago I would never do it again.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try the "additional include directories" property, just underneath the preprocessor one.
(A command-line interface is just another tool, and much easier to automate ;))
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, found that one, same as C++. Does it need the whole path? Poor little thing can't do relative paths, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It can do relative paths, but as they are relative, you must take special care - just like with C++ - that you point to the right directories. I think the working directory is the one containing the project file, but I am not all that sure. I mostly end up experimenting, until VS and I agree on what it finds ...
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ah yes, the relative path starts where the .vfproj file is. Very good.
Now it all compiles, but linking is another story. Unresolved external symbols. Where are they? I have here four little projects which reference each other. I am guessing the things it needs are in /Debug...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just as with C++ you should edit the dependencies, that will pass the libraries to the main program. Circular dependencies are bad, though, you need to break such a circle.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hm, you are supposed to have a main program - identified, mostly, by a program statement. That is the project that needs linking. Others are in general simply libraries. It may require you to select a different type of project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It looks like the project type that you selected was a "Windows" project.
You can do that with Fortran, but then you need to provide the WinMain entry point, and the whole this is probably more complicated than it was on Linux :-)
Try recreating this as a "Console" project.
--Lorri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your help. I finally got it all to compile. What I did:
Two directories seemed to be libraries, so I made these with New - Project - Library - Static Lib
The other two were supposed to be standalone projects, so I made those with New - project - Console Application - Main program
I set project properties:
To read #include - Properties/Fortran/Preprocessor/Preprocess Source File = Yes (/fpp)
Path to include files - Properties/Fortran/Preprocessor/Additional Include Directories = relative path from vfproj file
add the new libraries so - Linker/General/Additional Library dependencies = relative path from vfproj file to debug
Linker/Input/Additional Dependencies - libname1.lib libname2.lib
I had to copy a lot of code around because Visual Fortran will not tolerate the circular dependencies the old code had. Now in future it will be a bit more robust and the single parts can be compiled separately.
My personal opinion is that anyone who does not use IMPLICIT NONE should be forced to debug spaghetti till they resign.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page