Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27992 Discussions

NetCDF Win64 - anybody had recent success in building Fortran libs?


I know its a perenial question but wondering/hoping someone has a recent recipe for navigating this morass or can supply a pre-built library please.

0 Kudos
4 Replies
Honored Contributor I

Yes, we use netCDF win64 in our programs. Not sure if there is a more recent version that we should be using, but it works in our stuff.

Can you tell us what troubles you are encountering?

0 Kudos

Thanks for responding. I have been using a pre-built Win64 library sourced from a Chinese academic for some years - the only one I could find anywhere on planet earth - and due to what appears a recurring bug I'd like to update and/or build a local version. I note that the process for building the Fortran version on IVF has slowly progressed from impossible some 15 years ago to mildly complex now, with the CMAKE option via VS. While I do use the VS (2019) for debugging, I am not expert in its workings. I'm using IVF but am not a MAKE afficionado as I prefer to construct my own BAT file builds and library management. Clearly I lack experience in the intracacies of the complex CMAKE/MAKE and VS paths and options. I am not a C user and do not have a C compiler. My NetCDF needs are modest, namely static libraries for building standalone Fortran 90 code to service numerical modelling data i/o.

I've been referring to:
as well as following the recipe at:

This is what I've done:
1. downloaded pre-built Win64 C libraries with standard install under C:\Program Files\netCDF 4.8.0
2. launched command prompt via "Compiler 19.1 Update 3 for Intel 64 Visual Studio 2019 environment.lnk"
3. Added and verified these PATHs:
C:\Program Files\netCDF 4.8.0\lib
C:\Program Files\netCDF 4.8.0\include
C:\Program Files\netCDF 4.8.0\deps\x64\lib
C:\Program Files\netCDF 4.8.0\deps\x64\include
4. downloaded and installed F90 sources in a local folder \netcdf-fortran-4.5.3
5. created a local \build folder parallel to above
6. noting that the C libraries were built using VS 2017, and assuming things might work their way through, the first attempt using CMAKE from \build was based on following:
cmake -G "Visual Studio 15 2017 Win64" --build . ..\netcdf-fortran-4.5.3
CMake Error at CMakeLists.txt:12 (PROJECT):
Visual Studio 15 2017 Win64
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "S:/util/NetCDF/2021/build/CMakeFiles/CMakeOutput.log".
7. The above log file only contains "The system is: Windows - 10.0.19042 - AMD64"
8. Reverting to explicitly targeting VS 2019:
cmake -G "Visual Studio 16 2019" -A "Win64" --build . ..\netcdf-fortran-4.5.3
Failed to run MSBuild command:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
to get the value of VCTargetsPath:
(refer attached file cmake.txt for the full output text ...)
9. Referring to the above, MSBuild.exe is available but is looking for a file/path?
As a result of the above, the following files are also written (identical for steps 6 and 8):

I suspect that:
a) my CMAKE command (following the previous recipe) may not be valid as it does not seem to reflect cmake --help syntax
but other variants seem to make no difference
b) clearly I'm missing a vital VCTargetsPath

Any advice appreciated.


0 Kudos

After further Google trolling I can see at least that my issue relates, at some level, to installation updates etc.

Having updated VS2019 twice now, with collateral damage to the MSVC path used also by IVF, my CMAKE error message changed from not finding the VCTargetsPath to:

CMake Error: Unknown argument --build
CMake Error: Run 'cmake --help' for all supported options.

which is ironic given that "--build <dir>" is listed in the help file as a valid (and indeed necessary according to other comments) command in this instance.

Playing with variants of the above in terms of positioning or more explicit arguments based on --help have, at best, returned the original "cannot find  VCTargetsPath".

At least I see there is an entire universe of comment regarding CMAKE and its various (constantly changing)  "features".

Appreciate anyone who thinks they understand CMAKE in this context to offer suggestions ...

0 Kudos
Honored Contributor I

When we first started to use the netCDF libraries in our programs, we tried to build them all using CMake. That turned out to be a less than smooth experience. However, if I remember correctly, the UCAR people provide DLLs that merely miss the Fortran interface. That makes things much simpler: we use the prebuilt DLLs and in our Visual Studio project we simply build the Fortran interfaces. This solves the problem of dealing with .mod files for different compilers (one reason to include all source code with the source of our programs).

On Linux we rely on the netCDF libraries being available in the system's installation. Again the Fortran code is included in the build procedure.

0 Kudos