Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
14 Views

Problem debugging in VS2008 and using a pipeline in command arguments

Jump to solution
Hi!

I am trying to debug my code using VS2008 in windows XP and compiler Intel fortran 12.0. I want to put



as command argument. Unfortunately, the program does not recognize the pipeline and asks all the data by keyboard.

I have read in this web that I should install the SP1 update of the VS2008 to SP1. I have updated from the update page of Microsoft but I still have the same problem. I have attached the information about updates that VS2008 gives.

Thanks in advance for any idea.

Sincerely,
Paco Braxe

--------------------------------------------------

Microsoft Visual Studio 2008
Versin 9.0.21022.8 RTM
Microsoft .NET Framework
Versin 3.5 SP1

Edicin instalada: Professional

Microsoft Visual C++ 2008 91990-270-5477302-60141
Microsoft Visual C++ 2008

Actualizacin para Microsoft Visual Studio 2008 Professional - ESN (KB972221) KB972221
Este actualizacin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este actualizacin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/972221

Intel Visual Fortran Package ID: w_fcompxe_2011.4.196
Intel Visual Fortran Composer XE 2011 Integration for Microsoft Visual Studio* 2008, 12.0.3471.2008, Copyright (C) 2002-2011 Intel Corporation
* Other names and brands may be claimed as the property of others.

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB944899) KB944899
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/944899

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB945282) KB945282
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/945282

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB946040) KB946040
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/946040

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB946308) KB946308
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/946308

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB946344) KB946344
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/946344

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB946581) KB946581
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/946581

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB947171) KB947171
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/947171

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB947173) KB947173
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/947173

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB947180) KB947180
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/947180

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB947540) KB947540
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/947540

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB947789) KB947789
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/947789

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB948127) KB948127
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/948127

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB953256) KB953256
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/953256

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB971091) KB971091
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/971091

Revisin para Microsoft Visual Studio 2008 Professional - ESN (KB973674) KB973674
Este revisin es para Microsoft Visual Studio 2008 Professional - ESN.
Si ms tarde instala un service pack ms reciente, este revisin ser desinstalado automticamente.
Para obtener ms informacin, visite http://support.microsoft.com/kb/973674
0 Kudos

Accepted Solutions
Highlighted
14 Views
Assume your program name is "YourProgramName"
Define anenvironment variable

YourProgramName_Input = InputDataFile.txt

When your program starts call:

subroutine RedirectInput()
character(len=256) ::InputDataFile
integer :: len, status
call GET_ENVIRONMENT_VARIABLE('YourProgramName_Input', InputDataFile, len, status, .true.)
if(status .eq. 0) then
write(*,*)'Redirecting input: ', InputDataFile(1:len)
open(5,InputDataFile(1:len))
endif
end subroutine

Note, above code not tested

Jim Dempsey

View solution in original post

0 Kudos
6 Replies
Highlighted
Valued Contributor II
14 Views
I am not sure such a pipeline will work in the debugging environment. But what you can
do instead is:

open( 5, file = 'datafile' )

... ordinary processing


Less flexible perhaps, but it ought to solve the problem at hand

Regards,

Arjen
0 Kudos
Highlighted
14 Views
Visual Studio has a tradition of problems in this area. In VS2005 it didn't work at all. In VS2008, the program gets the input ok but if you are running under the debugger, the output, which is not redirected, fails to appear. And VS2010 crashes when I run the same program (which reads from unit 5 and writes to 6) under the debugger.

This issue is not Fortran-specific - I have seen many complaints from C++ users over the years.

What does seem to work is if you pass a filename as an argument in the Debugger properties and then use GET_COMMAND_ARGUMENT to retrieve the text and open the file.
Retired 12/31/2016
0 Kudos
Highlighted
15 Views
Assume your program name is "YourProgramName"
Define anenvironment variable

YourProgramName_Input = InputDataFile.txt

When your program starts call:

subroutine RedirectInput()
character(len=256) ::InputDataFile
integer :: len, status
call GET_ENVIRONMENT_VARIABLE('YourProgramName_Input', InputDataFile, len, status, .true.)
if(status .eq. 0) then
write(*,*)'Redirecting input: ', InputDataFile(1:len)
open(5,InputDataFile(1:len))
endif
end subroutine

Note, above code not tested

Jim Dempsey

View solution in original post

0 Kudos
Highlighted
14 Views
Environment variables are tricky to use in Visual Studio. I think GET_COMMAND_ARGUMENT is a better bet. Something like this:

[fortran]    program Console7

    implicit none

    character(80) input_file
    integer input_file_status
    character(100) line
    
    call GET_COMMAND_ARGUMENT(1,input_file,status=input_file_status)
    if (input_file_status == 0) then
      open (unit=5,file=input_file,status='old')
    end if
    
do read (5,'(A)',end=99) line write (6,'(A)') trim(line) end do 99 continue end program Console7[/fortran]
Retired 12/31/2016
0 Kudos
Highlighted
Beginner
14 Views
Thank you all for the replies. I have to say that I am very satisfied with this forum and how fast a good answer is obtained.

Regarding this issue, I use GET_COMMAND_ARGUMENT in all my recent programs, but when I want to reuse an old program, it can be a good idea let the read commands (read*,) unchanged. In this situation, to use a pipeline to debug is very useful.

I am surprised about what Steve Lionel says respect to VS2005. I am pretty sure that the pipeline worked for me! Unfortunately, I do not have that computer now to check it.

Best regards,
Paco
0 Kudos
Highlighted
Beginner
14 Views
Hi,

Just to finish my argument, the way I ask for data file in my new programs is very close to what Steve wrote:

[bash]program prueba
implicit none
character(260) :: datafile
integer :: length, status, iu = 5
real :: data

if (command_argument_count() > 0) then !assuming that first arg. is datafile call get_command_argument(1, datafile, length, status) open(newunit=iu, file=datafile) endif read(iu,*) data print*, data end program[/bash]

This program accepts:
1) data by keyword (exe)
2) data by pipeline (exe < datafile)
3) a datafile being the first argument (exe datafile).

Best regards,
Paco
0 Kudos