Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

link two fortran files same folder and link .DAT file

Status
Not open for further replies.

new3guy

Programmer
May 8, 2012
1
US
Hello,
I am new to FORTRAN and would appreciate your help.
So there are two questions that I had. I will try to explain them as briefly as possible without sacrificing the important details.
(1) I have this FORTRAN file named tech.for. I also have a .DAT file by name PLOT.DAT. The purpose of tech.for is to take the PLOT.DAT as the input and then generate a bunch of other text files, which I can use to plot in Excel. The person who gave it to me said I need to compile, link, and run tech.for, which will then give me the required output files. First thing I did was to put both the files - tech.for and PLOT.DAT in the same folder (say tech_test).
So I used g95 compiler and compiled it using command prompt which gave me a list of warnings, but nevertheless I got a .exe file (I named it tech.exe). But running this .exe file (by double clicking it) generated several files (.DAT and one .OUT) and they were all empty. So when I ran it in command prompt I got an error message, which I quote below:
"At line 69 of file A:\GETRAN\tech_test\tech.for (Unit 16 "PLOT.DAT") Traceback: not available, compile with -ftrace=frame or -ftrace=full Fortran runtime error: End of file"

Based on this message, I did use both -ftrace=frame and later -ftrace=full while compiling, but during execution I still got the same error message.
I conveyed this message to the person from whom I got tech.for program, and he said it is because PLOT.DAT and tech.for are NOT in the same directory!?! Well, this is confusing because like I mentioned before, they are in the same directory (under techplo_test folder).
Sometimes in MATLAB even though a function is in the same folder as the driver program, it is usually not recognized and therefore I have to open the function m-file, hit the run button, and select the option of "add to path" in the dialog box, and then it works. I wonder if the problem I am facing with FORTRAN is similar to the MATLAB problem/solution that I just mentioned.

(2) My second question is that there is a driver function and a subroutine file, both in same folder. I tried to compile the driver function from command prompt using g95 but I got an error saying that it can't recognize the name of the subroutine (undefined reference to GTD7, GTD7 being the name of the subroutine). When I do it with the subroutine, I get an error that no variable is declared or there is no input, or something along that lines (Error: numeric constant required at <1>). So basically, these two are not aware of each other. So how do I compile such a thing - with driver and several subroutines?

I would be grateful for your help.
Thanks
 
1) The error message suggests that you are building it from a floppy. If that is not the case, delete the object files and rebuild it.

2) Declare the routines as external.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top