0
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run GDB",
            "type": "cppdbg",
            "request": "launch",
            "program": "/mnt/e/Fortran_Codes/wrfchembc_CT/wrfchembc_CT_pkg/wrfchembcCT",
            "args": [],
            "stopAtEntry": false,
            "cwd": "/mnt/e/Fortran_Codes/wrfchembc_CT/wrfchembc_CT_pkg/",
            "externalConsole": false,
            "MIMode": "gdb",
            "preLaunchTask": "make",
        }
    ]
}

Above is the launch.json file used for debugging a Fortran code. I am able to start debugging but without an input file with a Fortran namelist. What should I add here such that the debugger accepts the input file too.
Actually the executable takes in the input file as follows:

wrfchembcCT < wrfchembc_namelist

But I am not able to debug while passing the data file to the Fortran code.

2 Answers 2

2

I got this solved by providing complete path to the executable in program section. Its now working for some reason.

Sign up to request clarification or add additional context in comments.

Comments

1

all arguments with redirection symbols <>| are quoted, so redirection will not work in VSC

Option is to add a CLI argument to the application that will open the file in the argument as stdin

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run GDB",
            "type": "cppdbg",
            "request": "launch",
            "program": "/mnt/e/Fortran_Codes/wrfchembc_CT/wrfchembc_CT_pkg/wrfchembcCT",
            "args": ["--stdin", "wrfchembc_namelist"],
            "stopAtEntry": false,
            "cwd": "/mnt/e/Fortran_Codes/wrfchembc_CT/wrfchembc_CT_pkg/",
            "externalConsole": false,
            "MIMode": "gdb",
            "preLaunchTask": "make",
        }
    ]
}

Or you can start the program with a task, maybe starting a shell script that has redirection. And attach the debugger to this running program.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.