问题
I would like to create a HDF5 dataset from a fortran90 program compiled with intel fortran 2011 on Windows 7 using Visual Studio 2010
Can I use prebuilt binaries or how do I build new ones
回答1:
I build from source, the available built binaries use the MS C/C++ compiler while I want to build with the Intel compiler, and they are built with Intel Fortran v12.x while I'm using v14.x. I won't say that you can't use the binaries, but I've had enough of a struggle in the past to persuade me to build my own.
I've also had struggles with trying to build them directly from VS and now use CMake. Your first step ought to be to install CMake and figure out how to use it. You don't need much knowledge of the tool and the effort will be repaid several times over. You can, for example, also use CMake to build Szip and Zlib, if you want them. An increasing amount of this sort of software is made available with CMake support so you won't necessarily only use it for HDF5. For example, I use CMake to build VTK for Windows too.
Once you've done that and generated the solution/project files with CMake you can load up the solution in VS and build ALL_BUILD
. This generally works smoothly, though I have found that some projects need to have their linkages adjusted and sometimes I get spurious flags in the command-lines sent to the compilers. Then, running VS in administrator mode, you can build the pseudo-target INSTALL
.
I see that HDF5 1.8.12 is now available, I'll download and build it, let you know how I get on.
Compiling and Linking
If you just want to use HDF5 include the line
USE, NON_INTRINSIC :: hdf5
at the appropriate place in your source file(s). Then, under Project Properties | Fortran | General | Additional Include Directories
insert the path to the location of hdf5.mod
. That should get you compiling.
To link, under Project | Properties | Linker | General | Additional Library Directories
insert the path the location of the .lib
files. Then, under Project | Properties | Linker | Input | Additional Dependencies
insert hdf5_fortran.lib
.
You should then be able to compile and link your program. If you want to use additional facilities, such as the HDF5 Table Interface, then use h5tb
and figure out the linkages.
And consult the documentation. See, for example, ../HDF5-1.8.12/release_docs/USING_HDF5_VS.txt
回答2:
I succeeded thanks to High Performance Mark: Here was what I did (not sure that everything is necessary):
- Download and install cmake
- Download and install HDF5 [Windows (32-bit), Compilers: CMake VS 2010 C, C++, IVF 12, RWDI]
- Set environment variable: HDF5_DIR=C:/Program Files/HDF_Group/HDF5/1.8.x/cmake/hdf5
- Download HDF5 source
- Make empty build folder
- Run CMake(cmake-gui) from start menu
- Set source (HDF5 source) and destination (empty build folder)
- Configure
- Set generator to Visual Studio 10
- Specify native compilers [C:"", C++:"", Fortran: "<..>\ifort.exe"]
- Check: BUILD_SHARED_LIBS and HDF5_BUILD_FORTRAN
- Configure
- Configure
- Generate
- Open <..>\build\HDF5.sln in Visual Studio 2010
- build project ALL_BUILD
And finally
- Create new project with a Fortran example
- Linked the generated libs exactly as High Performance Mark describes
I hope some else can use the reciepe.
Thanks again
来源:https://stackoverflow.com/questions/20048938/use-hdf5-from-intel-fortran-on-windows