views:

26

answers:

1

I am writing in fortran and compiling using the g95 compiler.

I need to have a log file output to a DLL i am writing, that is currently linking and running with the master program, but producing incorrect results. I don't know much about FORTRAN, but i did get the following code to produce output in an EXE i compiled:

  OPEN(UNIT=3, FILE='LOG.txt', STATUS='NEW')
  WRITE(3,*) "the gospel of PTP is bestowed upon the file."
  CLOSE(3)

this works in a stand alone EXE, when i run it, it produces a file with the string inside. But when i try to include it in the DLL i am working on, it crashes everything. when i comment it back out, everything runs and works again, but obviously doesn't produce the desired output.

Any ideas? Any FORTRAN or g95 people?

A: 

A guess which might help, or might not, I have rarely used Fortran DLLs to write anything directly:

  • To where do you expect the DLL to write the file 'LOG.txt' ? Is it perhaps trying to write into a location it is forbidden to write to ? Why that would crash your program I'm not very sure, but it's something for you to check. I expect that you ran the EXE version of your code from one of your user directories.

And, a comment:

  • In general avoid single-digit unit numbers in Fortran. Most o/s use them for stdout, stderr, etc, and while there are usual assignments (eg stdout is usually 5 I think, and stderr 6) these are not defined in the Fortran standard and compiler-writers are free to use unit numbers as they see fit.
High Performance Mark