Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

List-directed input and output

aqui
Beginner
1,545 Views
Morning,

The programs I'm involved with are run from a command prompt using list-directed input and output, i.e. one would type

ProgramName OutputFile.txt

and press Return. In CVF, this could be replicated by entering 'OutputFile.txt' in Program arguments under the Debug tab of the Project settings.

In Intel Visual Fortran, I've tried to do the same thing by placing the same text in the Command Arguments entry in the Debugging tab of the Project Properties, but to no avail. I've tried including the full paths with the file names and also removing < and >, again to no avail.

Any help that anybody can provide would be greatly appreciated.

Adam
0 Kudos
9 Replies
mecej4
Honored Contributor III
1,545 Views
Did you specify the working directory in the Project->Properties->Configuration Properties->Debugging window?

With that done, so that the target .exe can find the input file, it worked for me.

"I've tried including the full paths with the file names and also removing < and >, again to no avail." -- that should not work! Fortran programs do not parse command arguments without some explicit coding on your part for that purpose. Since the .exe file is built to read from and write to the console device, that is what it will do, and whatever command arguments you give will be ignored.

Use the GETARG subroutine or use the F2003 GET_COMMAND_ARGUMENT subroutine if you want to process command arguments.
0 Kudos
Steven_L_Intel1
Employee
1,545 Views
Which VS version are you using? I recall that VS2005 had some problems with this.
0 Kudos
aqui
Beginner
1,545 Views
Thanks for the replies. I'm using VS2008.

I have specified the working directory in the project properties, but still no joy I'm afraid. I've tried a few different programs as well.

Are there any other settings I should be looking at?

Thanks,

Adam
0 Kudos
aqui
Beginner
1,545 Views
I'm still no further forward with this. Here is a screenshot of the Project Settings:

Settings

And here is one showing the location of the specified input file:

path

Any further assistance that anybody is able to provide would be much appreciated.

Regards,

Adam
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,545 Views
Here are my 2c, although I did not verify it myself.

"Operators" < and > are used for standard input and output redirection (thus, have nothing to do with "list-directed", which is a Fortran term). Now, strictly speaking, the redirection is a command of command line interpreter (cmd.exe) and may not work automatically in other programs. Visual Studio possibly executes the console program directly (not throuth cmd.exe) and thus the redirection symbols may not work as expected.

Here Steve mentioned that the feature sort of works in Visual Studio, but for some reason you have to specify full paths to the input and output files (D:\ACQ\...\Ex1.inp).

Alternatively, you may try to invoke cmd.exe by setting:

Command: cmd.exe
Command arguments: /C $(TargetPath) Ex1.out
0 Kudos
aqui
Beginner
1,545 Views
Thanks Jugoslav - your second suggestion allows the program to be run from MS VS when the full paths to the files are included.

However, it gives rise to the message "Debugging information for 'cmd.exe' cannot be found or does not match. Symbols not loaded." and the program exits with code 0 (0x0) and one cannot do any actual debugging, e.g. breakpoints cannot be used/have no effect etc.

I seem to remember seeing the message 'No matching symbolic information found' or something similar in CVF 6.6, but it didn't seem to cause any problems so I ignored it. Do the messages correspond to one another?

Thanks for the help so far - appreciated.

Regards,

Adam
0 Kudos
Wendy_Doerner__Intel
Valued Contributor I
1,545 Views
It seems you are losing the correspondence with the debug information. Have you tried using the full path names (Jugoslav's first suggestion)?

------

Wendy

Attaching or including files in a post

0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,545 Views
Now that you say it, it is quite natural that you cannot debug it, so my suggestion was a dead end, sorry. If foo.exe launches bar.exe, you cannot debug the latter by specifying the former as the executable. They don't share the address space. You might Debug/Attach to process, but that's a cludge.

Have you tried the full paths to source files instead?

0 Kudos
IanH
Honored Contributor III
1,545 Views
Two suggestions:

- If you haven't already, install SP1 for VS2008, which apparently fixes this - see here.

- Write a little debug function that does the redirection inside your program. If the first argument has the magic word then the input and output units are reconnected appropriately.

[fortran]! compile with /assume:noold_unit_star

PROGRAM redirect_me

  USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: OUTPUT_UNIT, INPUT_UNIT
  IMPLICIT NONE
  CHARACTER(LEN=5) :: command_line_arg
  CHARACTER(LEN=256) :: str
  
  !*******

  CALL debug_redirect_check    
  
  READ (*, "(A)") str
  WRITE (*, "(A)") str

CONTAINS
  SUBROUTINE debug_redirect_check
    CALL GET_COMMAND_ARGUMENT(1, command_line_arg)
    IF (command_line_arg == 'please') THEN  ! magic debugging thing
      OPEN( UNIT=OUTPUT_UNIT, FILE='my_redirected_output_file.txt',  &
          STATUS='REPLACE', ACTION='WRITE' )
      OPEN( UNIT=INPUT_UNIT, FILE='my_redirected_input_file.txt',  &
          STATUS='OLD', ACTION='READ' )
    END IF
  END SUBROUTINE debug_redirect_check
END PROGRAM redirect_me
[/fortran]

0 Kudos
Reply