Software Archive
Read-only legacy content
17060 ディスカッション

Read Input file from working directorly

Intel_C_Intel
従業員
1,437件の閲覧回数
I'm working with a program which use Excel spreadsheet to take input data and write to an input file, then use a Fortran Console application to read that input file, perform some calculation and then write to several output files. The question is the location of the input file created by Excel may very. how could the Fortran Consonle application know where to find it. Is there anyway I could pass an argument or commnd line from Excel to Fortran exe.
0 件の賞賛
2 返答(返信)
Jugoslav_Dujic
高評価コントリビューター II
1,437件の閲覧回数
Sure, see NARGS/GETARG:

 
PROGRAM Foo 
 
USE DFLIB 
 
CHARACTER (MAX_PATH)::     sDir="" 
 
IF (NARGS() .GT. 0) CALL GETARG(1, sDir) 


and change all your open statements so that they look like:

 
OPEN (11, FILE=TRIM(sDir)//"input.txt") 


HTH

Jugoslav
durisinm
初心者
1,437件の閲覧回数
You can also consider writing an Excel VBA macro to pass an argument directly to a Fortran DLL. You can probably change your console application to a DLL by changing its main program to a subroutine. If you do, though, the Fortran code shouldn't write any output to the console. The console won't exist unless the DLL explicitly creates it. Writing to and reading from files is OK.

Mike
返信