Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

About open file path in Fortran dll

bronzemurphy
Beginner
565 Views
Hello!
I made a Fortran dll called by a C# exe.

It's working directory is F:\\project\\...\\bin
A character variable fnamecontains the file absolute pathsuch as: F:\\data\\a.txtin the dll.

[fortran]!!CODE A:

open(3,file=fname,form='formatted',action='read')
read(3,*) var
...
close(3)


!!CODE B:

open(3,file='F:\data\a.txt',form='formatted',action='read')
read(3,*) var
...
close(3)[/fortran]


Dll with CODE A cannot work. It says 'file not found'. It seems that fname was considered as an relative path under the working directory.
Dll with CODE B works fine.

The opened file name must be a variable. How could I fix it? Thanks.
0 Kudos
1 Reply
anthonyrichards
New Contributor III
565 Views
Are you sending FNAME from C#? Can you check the exact string held by fname in code A?
0 Kudos
Reply