- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am working on recompiling a really old fortran code into a 32 bit application. It has multiple
subroutines, multiple main programs and uses many text files as reference for data. I am not familiar on
how to recompile them.
For the sake of simplicity, lets assume the following:
Main Programs: MAIN.FOR, A.FOR and B.FOR
Subroutines: SUB1.FOR, SUB2.FOR
Data Files: FILE1, FILE2
The MAKEFILE in the old folder reads like this:
***************************************************************
.SUFFIXES: .for
.for.obj:
fl /Gt9 $(fflags) >>prog.log
all: log prog.exe
log: del prog.log
prog.exe: MAIN.obj \
SUB1.obj \
SUB2.obj \
A.obj \
B.obj
\makefile
link @prog.rsp >>prog.log
A: A.obj
link @A.rsp >>prog.log
B: B.obj
link @B.rsp >>prog.log
*********************************************************************
To do this in visual fortran, I made three different projects under one solution and made project
PROG (startup project containing MAIN.FOR and subroutines) dependent on project A(with A.FOR and
subroutines) and project B(with B.FOR and subroutines). I included FILE1 and FILE2 in solution items
folder and built the solution. However, this doesn't seem to achieve the required objective of linking the
A and B with MAIN. I am relatively new to VS and would be so grateful if anybody could help me with
this situation.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create only one project with all *. for files included.
Lines
prog.exe: MAIN.obj \
SUB1.obj \
SUB2.obj \
A.obj \
B.obj
in makefile mean that prog.exe depends on compiled MAIN, SUB1, SUB2, A and B source files.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That wouldn't work and i would get an error like this
error LNK2005: _MAIN__ already defined in A.obj
error LNK2005: _MAIN__ already defined in B.obj
I have provided the makefile of the old code so that you could get an idea of the order/technique of compilation. I dont want to make another makefile. I would prefer to compile using visual studio.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On your old platform, how did execution flow pass from MAIN to A and B?
If via CALL, then you wil be required to change "PROGRAM" in A and B to "SUBROUTINE" (without arguments), and if END contained "END PROGRAM" change to "END SUBROUTINE".
If you were on a really old system, then MAIN, A, B would look like a card stack, where A runs after MAIN and B runs after A. For this you would likely write a batch file
: YourBatchFile.bat
MAIN
A
B
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suspect that these old sources were actually multiple programs that shared some sources. Multiple main programs don't work in any Fortran implementation I have known over 35 years.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As Steve said, multiple main programs never have been allowed to link together. However, various typos when resurrecting old code may cause the compiler to see multiple main programs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your replies. I had earlier misunderstood the structure of the code. It basically creates multiple applications utilizing the same subroutines.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page