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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Integrating text files read inside a fortran .dll 1

Status
Not open for further replies.

peiffou

Technical User
Nov 25, 2009
2
US
All,

I have a Fortran dll project that creates a 'project.dll' file , the subroutine of whom is called inside of an other executable file. This subroutine inside 'project.dll' needs to read some data from a text file called 'project.txt' that I have to put in the same folder.

My question is the following: how could I include this text file 'project.txt' inside 'project.dll' so that I just have one file, 'project.dll', to import in my executable.

Thank you!
 
Here is one solution if you have access to project.dll source

1) Put the entire contents of the file into a string array
Code:
   integer, paramter:: LINEMAX = 50, COLMAX = 80
   character*COLMAX projin(LINEMAX)
   data projin /' line1', 'line2'... /

2) Remove the open and close for the file

3) Replace the channel in the read statement with the projin(line), where line is the line number, starting at 1. Increment the line number after every read


If you don't have access to project.dll source, in the wrapper, do step 1 above followed by writing all of it to project.txt before calling project.dll routines.
 
Thank you xwb.

But I have a huge input file already organized in a certain way, and would like to copy and paste it directly in the code. Is there any way to do that?

Thanks
 
1) Which variant are you using: F77 or F9x.
2) If F77, how wide are your lines?

One way would be to write a program that reads your data file and generates the code for you. If you are using F77 and the lines are wider than 66 chars, then you'll need to generate continuation line. That way, whenever you change the data file, all you need to do is rerun the generator and rebuild.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top