Difference between revisions of "Compile/Build MOHID"
From MohidWiki
Paulochambel (talk | contribs) |
Paulochambel (talk | contribs) |
||
Line 1: | Line 1: | ||
− | MOHID Solutions | + | |
+ | == MOHID Solutions == | ||
+ | |||
+ | |||
- Available to all MOHID users via GitHub [https://github.com/Mohid-Water-Modelling-System/Mohid/tree/master/Solutions] | - Available to all MOHID users via GitHub [https://github.com/Mohid-Water-Modelling-System/Mohid/tree/master/Solutions] | ||
for Linux (based in makefiles) & Windows (several versions of Visual Studio) | for Linux (based in makefiles) & Windows (several versions of Visual Studio) | ||
+ | |||
+ | |||
+ | |||
+ | == Windows compile/Buid == | ||
+ | |||
- The main obstacle to have a painless MOHID build in Windows are the external libraries/include files: HDF5, NetCDF, MPI | - The main obstacle to have a painless MOHID build in Windows are the external libraries/include files: HDF5, NetCDF, MPI | ||
+ | |||
+ | === HDF5 === | ||
− | |||
- The HDF5 Group provide the libraries/include already files compiled for Windows (win32 and x64) | - The HDF5 Group provide the libraries/include already files compiled for Windows (win32 and x64) | ||
[https://www.hdfgroup.org/downloads/hdf5/]. Need to download the pre-built HDF5 Binary | [https://www.hdfgroup.org/downloads/hdf5/]. Need to download the pre-built HDF5 Binary | ||
Line 24: | Line 33: | ||
libhdf5_f90cstub.lib libhdf5_fortran.lib libhdf5_tools.lib libszip.lib libzlib.lib zlib.lib) | libhdf5_f90cstub.lib libhdf5_fortran.lib libhdf5_tools.lib libszip.lib libzlib.lib zlib.lib) | ||
− | NETCDF | + | === NETCDF === |
- UNIDATA supports Windows support via CMake. Download and install Cmake [https://cmake.org/]. Cmake | - UNIDATA supports Windows support via CMake. Download and install Cmake [https://cmake.org/]. Cmake | ||
is used to control the software compilation process using simple platform and compiler independent | is used to control the software compilation process using simple platform and compiler independent | ||
Line 96: | Line 105: | ||
in "Linker\Input\Additional Dependencies" | in "Linker\Input\Additional Dependencies" | ||
− | MPI | + | === MPI === |
Step 1 - download from Microsoft the pre-build libraries and mpich.exe [https://msdn.microsoft.com/en-us/library/bb524831(v=vs.85).aspx]. | Step 1 - download from Microsoft the pre-build libraries and mpich.exe [https://msdn.microsoft.com/en-us/library/bb524831(v=vs.85).aspx]. | ||
You need to download two files (msmpisdk.msi and msmpisetup.exe); | You need to download two files (msmpisdk.msi and msmpisetup.exe); |
Revision as of 14:26, 12 April 2018
MOHID Solutions
- Available to all MOHID users via GitHub [1] for Linux (based in makefiles) & Windows (several versions of Visual Studio)
Windows compile/Buid
- The main obstacle to have a painless MOHID build in Windows are the external libraries/include files: HDF5, NetCDF, MPI
HDF5
- The HDF5 Group provide the libraries/include already files compiled for Windows (win32 and x64) [2]. Need to download the pre-built HDF5 Binary Distributions (note: the pre-buil is usually done for specific Visual Studio versions).
- In the MOHID solution configuration is necessary to add in the "Properties\PreProcessor\Additional Include Directories" the path diretory where the include files of HDF5 for the platform in question (win32 or x64) are placed (e.g. ..\..\mohid\ExternalLibs\HDF5_1.8.17_x64\Include\fortran)
- Additionaly it is necessary to add in "Linker\General\Additional Library Directories" the path diretory where the library files of HDF5 for the platform in question (win32 or x64) are located (e.g. ..\..\mohid\ExternalLibs\HDF5_1.8.17_x64\lib)
- Finally it is necessary to add all the HDF5 libraries names in "Linker\Input\Additional Dependencies" (e.g.hdf5.lib hdf5_f90cstub.lib hdf5_fortran.lib hdf5_tools.lib libhdf5.lib libhdf5_f90cstub.lib libhdf5_fortran.lib libhdf5_tools.lib libszip.lib libzlib.lib zlib.lib)
NETCDF
- UNIDATA supports Windows support via CMake. Download and install Cmake [3]. Cmake is used to control the software compilation process using simple platform and compiler independent configuration files, and generate native makefiles and workspaces that can be used in the compiler environment of your choice. It is used by UNIDATa and also HDF5 Group;
- The UNIDATA provides all the source code necessary to compile the NETCDF libraries and include files that work as na interface between the the NETCDF and fortran. You nedd to download the NetCDF-Fortran Releases from the follow link [4]
- The UNIDATA provides all the the pre-built releases of NETCDF libraries and dll's for Windows (win32 or x64). Need to download the version that corresponds to the NetCDF-Fortran Releases and install the NETCDF pre-build for windows
The steps to compile netcdf are the follow (work for VS2015 + Intel 18 for win32 and x64): Step 1 - Extract all the files from the compress file provide by UNIDATA with the NetCDF-Fortran Releases maintaining the directories tree. Step 2 - Create a new diretory inside the parente diretory where all NetCDF-Fortran Releases are present (e.g. test_paulo_hdf5.1.8.17_x64) Step 3 - Create inside of this new diretory the a bat file (e.g. Run.bat) with the follow instructions in one code line
"C:\Program Files\CMake\bin\cmake" [-G"NMake Makefiles" -DCMAKE_BUILD_TYPE:STRING=RELEASE -DCMAKE_Fortran_COMPILER:STRING="C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2018.2.18\windows\bin\intel64/ifort.exe" -DBUILD_SHARED_LIBS=FALSE -DBUILD_V2=FALSE -DENABLE_TESTS=FALSE -DnetCDF_INCLUDE_DIR:STRING="D:\Projects\paulo\mohid\ExternalLibs\HDF5_1.8.17_x64\Include\fortran" -DNETCDF_C_LIBRARY:STRING="C:\Program Files\netCDF 4.4.1.1\lib\netcdf.lib"] ..
Step 5 - First path need to point to the cmake.exe; Second path need to point to the ifort.exe of interest (fortran compiler); Third path need to point to the include path of the HDF5 version and platform (win32 or x64) of interest; Fourth path need to point to the netcdf library netcdf.lib (win32 or x64) placed in the pc by the installation of the pre-built releases of NETCDF; Step 6 - In the parent directory there is file called CMakeLists.txt. Probably need to comment some instructions (I did). In my case the cmake only generate the VS2015 solution when I comment the follow instructions
#CHECK_LIBRARY_EXISTS(${NETCDF_C_LIBRARY} nc_def_opaque "" USE_NETCDF4) #CHECK_LIBRARY_EXISTS(${NETCDF_C_LIBRARY} nccreate "" USE_NETCDF_V2) #CHECK_LIBRARY_EXISTS(${NETCDF_C_LIBRARY} nc_set_log_level "" USE_LOGGING) #CHECK_LIBRARY_EXISTS(${NETCDF_C_LIBRARY} oc_open "" BUILD_DAP) #CHECK_LIBRARY_EXISTS(${NETCDF_C_LIBRARY} nc_use_parallel_enabled "" BUILD_PARALLEL)
Step 7 - For details look at https://github.com/Unidata/netcdf-fortran/issues/48 Step 8 - After executing the bat file a solution NC4F.sln is generate in the same place of the bat file. Open the solution Step 9 - In my case (VS2015 + Intel 18) it was missing in the solution to add in the c library ncfortran "Properties\C/C++\General\Additional Include Directories" the path where the NETCDF installation of NETCDF pre-build for Windows place the include files (*.h) "C:\Program Files\netCDF 4.4.1.1\include" Step 10 - Need to change the "netcdf" name to "netcdf90" to be compatible with the MOHID instruction for Windows (use ModuleNetcdf90) Step 11 - For the x64 platform the follow a configuration occure associate with the "target machine". Is define as X86 and should be x64. Need to change in the "Properties\Library\Comand line" Step 12 - Save the solution and build the solution. Copy the netcdff.lib and all the *.mod to a diretory that you want to use after in the MOHID build (e.g. ..\..\mohid\ExternalLibs\Netcdf_4.4.1.1\VS2015\x64); The steps to compile MOHID with the Netcdf include/library files are:
Step 1 - In the MOHID solution configuration is necessary to add in the "Properties\PreProcessor\Additional Include Directories" the path diretory where the include files of NetCDF for the platform in question (win32 or x64) are placed (e.g. ..\..\mohid\ExternalLibs\Netcdf_4.4.1.1\VS2015\x64)
Step 2 - Additionaly it is necessary to add in the "Linker\General\Additional Library Directories" the path diretory where the library files of NetCDf for the platform in question (win32 or x64) are placed (e.g. ..\..\mohid\ExternalLibs\Netcdf_4.4.1.1\VS2015\x64)
Step 3 - Finally it is necessary to add the Netcdf libraries of interest (e.g. netcdf.lib and netcdff.lib) in "Linker\Input\Additional Dependencies"
=== MPI === Step 1 - download from Microsoft the pre-build libraries and mpich.exe [5]. You need to download two files (msmpisdk.msi and msmpisetup.exe); Step 2 - Install mpich service executing the program msmpisetup.exe. The installed exe will be one invoque when and exe with mpi is run (mpiexec); Step 3 - Execute the msmpisdk.msi to have access to the libraries necessary to compile MOHID with MPI
The steps to compile MOHID with the MPI include/library/source code files are
Step 1 - In the MOHID solution configuration is necessary to add in the Mohid Base 1 library the source code mpi.f90
Step 2 - In the MOHID solution configuration is necessary to add in the "Properties\PreProcessor\Additional Include Directories" the path diretory where the include files of MPI for the platform in question (win32 or x64) are placed (e.g. ..\..\mohid\ExternalLibs\MPI_x64\Microsoft) Step 2 - Additionaly it is necessary to add the in the "Linker\General\Additional Library Directories" the path diretory where the library files of MPI for the platform in question (win32 or x64) are placed (e.g. ..\..\mohid\ExternalLibs\ExternalLibs\MPI_x64\Microsoft)
Step 3 - Finally it is necessary to add the MPI libraries of interest (e.g. msmpi.lib, msmpifec.lib, msmpifmc.lib) in "Linker\Input\Additional Dependencies"