- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
We have implented a new fortran code (CODE1) that we want now to integrate in an older program (CODE2).
The CODE1 needs to be compiled with ifort (we use structure definitions and dynamic memory with allocate). We have compiled it successfully.
The CODE2 is an old code implemented with Fortran77 and C++. Until now we have compiled this old program with f77 ang g++ using the library -lg2c.
The point is that now we would like to compile the old part of CODE2 implemented in fortran with f77, the new one (CODE1) with ifort, and the C++ part with g++ and after that we would like to link all the code with g++, not ifort.
Do you think this is possible? The key is that we want to avoid changing the old program linker from g++ to ifort. This would force us to test completely again the old program, and it would be a hard work.
To simplify, is it possible to do something like this?
f77 -c .... *.for #for the old fortran code
g++ -c .... *.cpp #for the old c++ code
ifort -c .... *.f90 #for the new fortran code
g++ *.o -lg2c -l?????? # linking the new and the old code
where ???? is something that would allow us to link the ifort compiled code to our old code?
We are quite lost about this topic, so if you can point us how to do it?
Thank you in advance.
We have implented a new fortran code (CODE1) that we want now to integrate in an older program (CODE2).
The CODE1 needs to be compiled with ifort (we use structure definitions and dynamic memory with allocate). We have compiled it successfully.
The CODE2 is an old code implemented with Fortran77 and C++. Until now we have compiled this old program with f77 ang g++ using the library -lg2c.
The point is that now we would like to compile the old part of CODE2 implemented in fortran with f77, the new one (CODE1) with ifort, and the C++ part with g++ and after that we would like to link all the code with g++, not ifort.
Do you think this is possible? The key is that we want to avoid changing the old program linker from g++ to ifort. This would force us to test completely again the old program, and it would be a hard work.
To simplify, is it possible to do something like this?
f77 -c .... *.for #for the old fortran code
g++ -c .... *.cpp #for the old c++ code
ifort -c .... *.f90 #for the new fortran code
g++ *.o -lg2c -l?????? # linking the new and the old code
where ???? is something that would allow us to link the ifort compiled code to our old code?
We are quite lost about this topic, so if you can point us how to do it?
Thank you in advance.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't use -lg2c with ifort. Nor can you mix another brand of Fortran (whatever you call f77) with ifort. There may be exceptions, but the only good advice is don't try it.
You should build all the Fortran code with the same compiler. If your "f77" code is truly Fortran, ifort should work.
In order to use g++ to drive the link, you must find out which libraries are required from the ifort installation. For a Fortran driven link, you can see the libraries required by e.g. ifort -# *.f. The details could change each time you have a major Fortran upgrade.
If you can make a Fortran main program, it is easy to link a combined g++ and ifort build by
ifort *.o -lstdc++, if your g++ is in the supported range (3.3 to 4.1).
You should build all the Fortran code with the same compiler. If your "f77" code is truly Fortran, ifort should work.
In order to use g++ to drive the link, you must find out which libraries are required from the ifort installation. For a Fortran driven link, you can see the libraries required by e.g. ifort -# *.f. The details could change each time you have a major Fortran upgrade.
If you can make a Fortran main program, it is easy to link a combined g++ and ifort build by
ifort *.o -lstdc++, if your g++ is in the supported range (3.3 to 4.1).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for your advices. It seems that our only choice left is try to compile everything with ifort and forget fortran 77 compiler (f77)
Thank you again for your well explained response
Thank you again for your well explained response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm guessing that you thought the older Fortran77 code needed a "Fortran77" compiler. My advice is to try to convert the older code to free format, which can usuallybe done automatically with a conversion program (there are a few different ones available). This helps simplify the build process.
In practice, it is often possible to call a Fortran77 subroutine compiled with a different Fortran-compiler, if it contains no I/O. But, it is worth avoiding the trouble unless there is some reason that you don't have the source code available.
Joe krahn
In practice, it is often possible to call a Fortran77 subroutine compiled with a different Fortran-compiler, if it contains no I/O. But, it is worth avoiding the trouble unless there is some reason that you don't have the source code available.
Joe krahn

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