I am coding and running a physics simulation in Fortran using MS Visual Studio Code on Windows 11 and I want to use MPI. I have installed Microsoft MPI (MSMPI) and know that it is correctly installed. When I enter 'set msmpi,' into the Windows powershell, I see all directories and locations that I want to be seeing:
MSMPI_BENCHMARKS=C:\Program Files\Microsoft MPI\Benchmarks\
MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\
MSMPI_INC=C:\Program Files (x86)\Microsoft SDKs\MPI\Include\
MSMPI_LIB32=C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x86\
MSMPI_LIB64=C:\Program Files (x86)\Microsoft SDKs\MPI\Lib\x64\
The program itself has the following form (I omit the parts that are irrelevant to the MPI issue):
PROGRAM xyz
USE MPI
...irrelevant...
INCLUDE 'mpif.h'
...irrelevant...
CALL MPI_INIT(ierr)
CALL MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
CALL MPI_REDUCE(var1, var2, 1, MPI_DOUBLE_PRECISION, MPI_SUM, 0, MPI_COMM_WORLD, ierr)
...irrelevant...
CALL MPI_FINALIZE(ierr)
END PROGRAM xyz
When I attempt to run the code, I receive an error message:
Error: Can't open include file 'mpif.h'`
I have watched several Youtube videos on how to get VS Code to access the MPI library, but I have only been able to gather information piece-meal, because some of these information sources are older, i.e., VS Code no longer contains the settings and options as they're shown in the videos. So far, I have only been able to gather that I must make entries into the settings.JSON file. At the moment, this is what I have:
{
"workbench.colorTheme": "Visual Studio Dark",
"explorer.confirmDelete": false,
"code-runner.runInTerminal": true,
"fortran.preferredCase": "uppercase",
"fortran.linter.compiler": "gfortran",
"editor.renderWhitespace": "none",
"editor.accessibilitySupport": "off",
"editor.tabSize": 6,
"C_Cpp.default.includePath": [
"C :\\Program Files\\Microsoft MPI\\MPI\\Include",
"${workspaceFolder}/**",
],
"fortran.linter.includePaths": [
"C:\\Program Files (x86)\\Microsoft SDKs\\MPI\\Include",
"${workspaceFolder}/**",
],
"fortran.fortls.preprocessor.directories": [
],
"jake.autoDetect": "on",
"grunt.autoDetect": "on",
"gulp.autoDetect": "on",
"json.schemas": [
]
}
I am not sure what I must do from here out. Is this what my settings.JSON file should look like?
I continue to receive an error message that the header file cannot be found when I run the code. I apologize in advance if I am overlooking something that is obvious to a more experienced programmer. I am younger student who is still new to programming and this is the first time that I've ever had to code while manually accessing libraries. Any help at all would be immensely appreciated.


use MPI, do not also useinclude 'mpif.h'. One use one of these, not both.use MPIrather thaninclude 'mpif.h'. Using the module rather than the include file traps more mistakes at compile time.use mpi_f08, though I have my doubts that MS are that up to date.