[PYTHON] Try Fortran with VS Code up to debug settings. [Win10]

at first

When building and debugging Fortran on Windows, I investigated what kind of tools should be combined. I was a little stuck with a problem that did not stop at the breakpoint in debugging, but it was solved. I am thinking with the minimum necessary configuration.

Tools and environment to use

・ Windows 10 ・ Visual Studio Code

1. Fortran compiler preparation

-Download "tdm64-gcc-***. Exe" from TDM-GCC

2. VS Code preparation

{
 // Learn the available attributes using IntelliSense.
 // Hover and display the description of existing attributes.
 // Check the following for more information: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
 "name": "(gdb) start",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/a.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/TDM-GCC-64/bin/gdb.exe",
            "setupCommands": [
                {
 "description": "Enable reformatting of gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

3. Fortran build

-Build work is executed at the command prompt, not on VS Code. -Be sure to add the option "-g" to debug this time.

C:\Temp>gfortran -g fortran_program.f90

-The exe file is created. image.png

4. Debugging with VS Code

-Open the Fortran file with VS Code and hit the debug point to the left of the number of lines. image.png -Execution-> Debug execution. Then, it stops at the debug point properly! image.png

the end

I was a little clogged up with the need for options when building, but I'm glad I did. When I was a student, I could only debug with print statements, so I'm deeply impressed that I can debug with Fortran as well. Please use it if you like.

I'm not sure if "gfortran -g" can be run from VS Code. I wonder how to do it, maybe it's easy, but I'll leave it here.

Recommended Posts

Try Fortran with VS Code up to debug settings. [Win10]
Settings to debug the contents of the library with VS Code
Debug Python with VS Code
Try running Jupyter with VS Code
Debug settings in virtual environment when using Pipenv with VS Code
VS Code settings
Debug with VS Code using boost python numpy
Try touching the micro: bit with VS Code + Python
VS Code settings for developing in Python with completion
Remote debug Django environment created with docker-compose with VS Code
Settings when developing App Engine / Python apps with VS Code
Set VS Code to PyCharm.
Try to bring up a subwindow with PyQt5 and Python
Try HeloWorld in your own language (with How to & code)
Try to create a python environment with Visual Studio Code & WSL
How to develop containers on remote servers with VS Code Remote-Containers
How to build Python and Jupyter execution environment with VS Code
Try to operate Facebook with Python
Try to profile with ONNX Runtime
Migrate from VS Code to PyCharm
Try to output audio with M5STACK
I want to debug with Python
Install python with mac vs code
How to debug a Python program by remotely connecting to a Docker container in WSL2 environment with VS Code
I was addicted to creating a Python venv environment with VS Code
Steps to create a Python virtual environment with VS Code on Windows
I made a tool to convert Jupyter py to ipynb with VS Code
How to use VS Code (code server) with Google Colab in just 3 lines
Try to reproduce color film with Python
Try logging in to qiita with Python
Pass PYTHONPATH in 1 minute with VS Code
Display Japanese graphs with VS Code + matplotlib
Try to predict cherry blossoms with xgboost
Try converting to tidy data with pandas
Quickly try to visualize datasets with pandas
Django initial setup up to Intellij Debug
First YDK to try with Cisco IOS-XE
VS Code Pylint is annoying with import! !! !! !!
Try to generate an image with aliasing
Try to use up the Raspberry Pi 2's 4-core CPU with Parallel Python