Topic: Launch file name

Fortran, in the new build, does not recognize the input file name given in the Launch Option.  No matter how I configure it, it does not recognized it. I've tried fully qualified, with and without quotes.  No matter what I do, I get a return code of 9 (file not found).  And, yes, the file does exist and is spelled correctly.

Re: Launch file name

Version 2.34, build 2366 does not have this problem.

Re: Launch file name

Version 2.35, build 2398 has the problem.

Re: Launch file name

Jeff,  not sure what's going on, but now I can't get any version to work, so I'm checking for changes in my program.  So no need to rush for a solution.....
Don

Re: Launch file name

Jeff, nothing has changed in my program.  I am using the latest update to Windows 10. Could this be a problem?

Re: Launch file name

Don,

I'll see if I can replicate the problem.  It should just work on any version of Windows 10.  What exactly are you entering into Launch Options?

Jeff Armstrong
Approximatrix, LLC

Re: Launch file name

Launch options:

file: Example.WDC

Directory: .\ (where .\ is C:\USDA Projects\WinDAM C\, which works with the .\ in Build and Module options)

When I use the fully qualified name in the file, in debug it gives me something like C:\\\\\\\\USDA Projects\\\\ etc.

Re: Launch file name

You can remove the ".\" from the directory field.  Simply Fortran will default to the project's directory if it's blank.

What exactly did you mean by " does not recognize the input file name given in the Launch Option?"  When you simply print the command line argument corresponding to "Example.WDC," what is printed?

I'll see if I can replicate the problem on a Windows 10 system with the most recent update.

Jeff Armstrong
Approximatrix, LLC

Re: Launch file name

Jeff, the input file, in this case "Example1.WDC", contains commands and data for the program and is in the project directory, "C:\USDA Projects\WinDAM C".  The program takes that file from the command line (Launch), opens it and extracts the contents which tell the program what actions to take.  In the past, this has worked like a charm, but recently (last major Windows 10 upgrade???), the OPEN statement returns a IOSTAT code of 9, which I think means file not found. This causes the program to terminate.
Don

Re: Launch file name

Don,

If you Print *, the command-line argument prior to the OPEN statement, what is the result? 

I'm trying to sort out if it is a problem with the command line handling in the runtime or the Launch Options in Simply Fortran.

Jeff Armstrong
Approximatrix, LLC

Re: Launch file name

The Print * does not print anything to the console. Wasn't sure if you meant "Print *," or "Print *" so I ran it both ways.

The Open statement is:

Open (UNIT=nRead,FILE=File_In(1:length),ACTION='READ',STATUS='OLD',IOSTAT=IOErr)


And File_In(1:length) is 'Example4.WDC' (with the single quotes).  IOErr = 9 after the Open.

Re: Launch file name

Sorry, Don, I think we're having some miscommunication. Could you try, in your code:

       Print *, File_In(1:length)
       Open (UNIT=nRead,FILE=File_In(1:length),ACTION='READ',STATUS='OLD',IOSTAT=IOErr)

I know you're saying that File_In(1:length) is 'Example4.WDC', but I want to confirm that it is.

Jeff Armstrong
Approximatrix, LLC

13 (edited by Don Hazlewood 2017-07-11 03:07:40)

Re: Launch file name

The console doesn't show anything printed, so I not sure if this is where it should show up.  I put a Watch on File_In(1:length) and it show 'Exampl4.WDC' which is the correct file name.
Don

Re: Launch file name

Don,

You can get a text error message from OPEN as well using the IOMSG argument in the OPEN statement:

Character(256)::ErrMsg

!...

       Print *, File_In(1:length)
       Open (UNIT=nRead,FILE=File_In(1:length),ACTION='READ',STATUS='OLD',IOSTAT=IOErr, IOMSG=ErrMsg)
       If(IOErr .NE. 0) Then
           Print *, IOErr, ErrMsg
       End If

When the file isn't present, IOErr seems to be 2 for me, but it may be runtime-dependent. What is the message you're seeing?

Jeff Armstrong
Approximatrix, LLC

15 (edited by Don Hazlewood 2017-07-11 16:38:17)

Re: Launch file name

I knew there was a way to get the error printed, but couldn't remember how.

Also, I have a similar program that was compiled on 1/2/2016 that executes correctly.  When I recompiled it just today and tried to run, I get the error 9.

Okay, made the change. I'm still not getting anything to print to the console. However, looking at the error message in debug, the contents are 'Error closing file in OPEN statement.' which confuses me as to why it would be closing a file.

Re: Launch file name

Don,

What unit number are you using?   What's the value of nRead?   Is it possibly 5 or 6?  Or have you used this unit number before in your code?

The error implies you're reusing a unit number without actually closing the unit prior to this OPEN statement.  Units 5 and 6 are especially problematic because they are reserved for standard input and output.  Both 5 and 6 should always be avoided for files for compatibility.  I usually suggest using unit numbers in the hundreds.

Jeff Armstrong
Approximatrix, LLC

Re: Launch file name

I think I am using 5 as input and 6 as output.  I'll change them and let you know how it works.

18 (edited by Don Hazlewood 2017-07-11 23:39:32)

Re: Launch file name

Jeff, that seems to have been the problem.  Thanks, I would NEVER have thought of that!

However, I cannot find the output file anywhere, not in the project directory, not on C:.  Can you help with that?

Re: Launch file name

I would guess that using 5 or 6 may be at issue on current versions of Windows 10, causing the error in the OPEN statement.  I might work better, actually, if run in an external console.

Is the output file OPENed explicitly, or are you just writing to a unit number?

Jeff Armstrong
Approximatrix, LLC

20 (edited by Don Hazlewood 2017-07-12 16:05:04)

Re: Launch file name

It's opened explicitly as:

Open (Unit=nPrnt,File=File_Out,Action='Write',Status='Unknown')

where 'nPrnt' is now 106.

I also tried changing nRead back to 5 and nPrnt to 6 and putting Close statements for both when the file_open program is entered.  It did not give the error 9, but I still can't find the output and I can't get anything to write to the console.

11:00 CDT - I just updated to 2.38 and still get the same results.

Re: Launch file name

Try

Open (Unit=nPrnt,File="abc",Action='Write',Status='Unknown')

as a test.  I suspect that variable File_Out is somehow not defined properly.

22 (edited by Don Hazlewood 2017-07-13 02:25:43)

Re: Launch file name

Thanks, I'll give it a try.


Nope, didn't create the output file.  No error or anything.  I'm probably filling up the "cloud" with all my output....

Re: Launch file name

Don,

Can you add the status indicators to this OPEN statement as well? Perhaps it will yield more info:

       Open (Unit=nPrnt,File=File_Out,Action='Write',Status='Unknown',IOSTAT=IOErr, IOMSG=ErrMsg)
       If(IOErr .NE. 0) Then
           Print *, IOErr, ErrMsg
       End If
Jeff Armstrong
Approximatrix, LLC

Re: Launch file name

IOErr is zero and MsgErr is a bunch of hex data (MsgErr is defined as Character(256).  So, to me, it doesn't look like it really helps any.  A friend, who is a Professor of Computer Science at Kansas State University, has compiled this code and it runs successfully.  He uses gfortran.  If you have any questions for him, I'll be glad to pass them along.
Don

Re: Launch file name

Well, IOErr being zero means the file was successfully opened, and ErrMsg would be left unmodified in that case.  I'm not sure, though, why you can't find the output file, though.  Would you be open to sending the project and source code along to support at approximatrix.com?

The file should be opened in the same directory as the project file (ending in .prj) based on the information you've given so far. 

A friend, who is a Professor of Computer Science at Kansas State University, has compiled this code and it runs successfully.  He uses gfortran.

Simply Fortran is using gfortran as well, but it is probably a different version.

Jeff Armstrong
Approximatrix, LLC