Home > Software engineering >  Fortran in Visual Studio 2022
Fortran in Visual Studio 2022

Time:06-23

I installed Visual Studio 2022. I then installed Intel OneAPI Base Toolkit followed by the HPC toolkit. Everything seems fine and I am able to create a Fortran project, but I am unable to run any code. When I write a code, the run bottom is greyed out (see attachment). I have read that I need to set up the Runtime library correctly but I don't think I know how to do that. For example, when I go to Project > Settings and scroll down to IFX Intel or IFortran Intel, I see "libraries" and I can change it but I don't know what to change it to.

  • I am a newbie, so if you provide a solution please be detailed. Thank you.enter image description here

CodePudding user response:

The problem is solved now. It turns out that it was a compatibility issue between VS 2022 2.0 version and Intel OneAPI. This lastest version of VS is incompatible with Intel OneAPI Fortran. There is a workaround to manually turn on the “Use the legacy native solution and build services". See details here:

https://developercommunity.visualstudio.com/t/Cant-open-existing-fortran-projects-Ca/10051432#T-N10052680

CodePudding user response:

The following applies to a recent installation of Visual Studio 2019 with the Intel compiler via Intel Parallel Studio. It might apply for your problem with the more recent VS 2022 / Intel oneAPI, too:

In Visual Studio go to Help/About Microsoft Visual Studio: Is the Intel compiler shown in the list?

If not, a reinstallation as described here may help, paying attention to this point:

Be sure to check the box Microsoft Visual Studio 2019 in the Integrate IDE step

A reinstallation in this way (done by the IT department of my company) fixed a similar issue to yours for me.

CodePudding user response:

For the screenshot provided you do not have a Fortran project created. You are just looking at a source file on its own.

The project creation screen looks like this

scr1

and the loaded project should have files in the solution explorer (top-right pane below).

scr2

It is worth mentioning (like others have stated) that there is something broken in the VS integrations with VS2022 17.2.X.

Possible remediations are as follows

  • Use a prior version of visual studio. I keep VS 2017 around for this reason, but VS2019 would work also. Even VS 2022 17.1.X works. If you have this then try it out to check if you can compile Fortran.

  • Install the patch mentioned in the Intel Forum post

  • Do the UseLegacy workaround option from the VS forum post, but for me this disabled the Save-All functionality for some reason.

I am not aware of any other remediations at this point.

  • Related