Topic: Problem writing to file - sometimes

I have some Fortran code that has 3 .txt files as input and 2 .txt as output. If I run the code in the directory that contains the  .f90 source file and the .exe file all is ok. But, if I run it under a user directory the program will not write to any output file. I used the IOMSG= err= and iostat ... none of them return abnormal values. I'm not getting any output ... and I'm not getting any errors.

All advice would be appreciated, Thanks

Re: Problem writing to file - sometimes

Could you clarify things a bit more?  When you say:

But, if I run it under a user directory...

what exactly do you mean by this?  Are you running it from Simply Fortran still?   Are you launching it from Windows Explorer?

Jeff Armstrong
Approximatrix, LLC

Re: Problem writing to file - sometimes

Hi Jeff, I write, compile and debug my fortran code in c:\users\imre\fortran\time4taxv3 . This directory has my source code, the .exe file, all the input and output files etc. When I run the code from this directory every thing works good.

I wanted to move the actual running of the code to c:\users\imre\documents\taxes\2020.taxes ... I do not want someone to erase or change the source code accidentally. I copied the 3 .txt input files to the 2020.taxes directory an ran c:\users\imre\fortran\time4taxv3\time4taxv3.exe . The code seemed to be running ok but it would not write to either output file. I got no errors and I got no output.

I then copied c:\users\imre\fortran\time4taxv3\time4taxv3.ex to the 2020.taxes directory ... same thing, no errors and no output.

When I open the output files I do not specify the full pathname, I do the fillowing:


     arg1="taxout.txt"

     open(unit=120,file=arg1,position="append",action="write",IOMSG=erroro,err=125,iostat=ir)

     write (unit=120,fmt=123,err=125,iostat=ist) date,vendor,cost,taxcat,addres,desc
123  format (5a1,1x,20a1,1x,8a1,1x,20a1,1x,20a1,1x,20a1)




Thank You !!

Re: Problem writing to file - sometimes

First, can you try running the executable in your new directory from a command prompt?  It sounds like you're double-clicking in Windows Explorer, which might mean that any errors being printed are being obscured by the windows opening and closing too fast.

Also, does your executable rely on any libraries or DLLs?

Finally, can you make sure that your executable is statically linked?  In Project Options under Linker, "All Static" should be checked to ensure the executable isn't trying to use any DLLs.  I doubt this is the issue, but it can't hurt to check. 

You might have to add some debugging information to your program, though, to see why it isn't running in a different directory.  The compiler doesn't embed any path information in executables, so it really shouldn't matter.

Jeff Armstrong
Approximatrix, LLC