OpenFAST / openfast

Main repository for the NREL-supported OpenFAST whole-turbine and FAST.Farm wind farm simulation codes.
http://openfast.readthedocs.io
Apache License 2.0
656 stars 448 forks source link

Rebuild DISCON_*.dll using cmake #216

Closed YingyiLiu closed 5 years ago

YingyiLiu commented 5 years ago

Dear Rafeal,

I followed your instructions via our email communications below to rebuild the DISCON.dll (For the convenience of other users, I repost the information here):

-----------------------------------------------------------------------------------------------------------------

"Hello Yingyi,

As Jason mentioned, the compiled libraries are included in the latest OpenFAST release for both 32 bit and 64 bit architectures. If you are on Windows, using cmake is a little bit more complicated since you have to do the environment configuration that Visual Studio does for you. The simplest way to do this is to find the Visual Studio command prompt installed with intel tools; mine is called “Compiler 17.0 Update 7 for Intel 64 Visual Studio environment”. Then, navigate to one of the DISCON directories your listed below and do these steps:

mkdir build cd build cmake .. -G # this will list the available visual studio generators on your system cmake .. -G”Visual Studio 15 2017 Win64” # this is what I use start DISCON.sln # this opens the discon solution file and you can compile using visual studio from there

The process is similar for a linux machine except leave off the -G”Visual Studio” and use “make” to compile instead”.

Please let me know if you run into any problems.

Thanks Rafael M Mudafort"

-------------------------------------------------------------------------------------------------------------------

Based on your inputs, I installed the latest cmake for windows (cmake-3.13.1-win64-x64.msi) from here: https://cmake.org/download/. I choose the newly installed cmake to be included in the system path.

On my desktop, the only installed fortran compiler is "Intel Parallel Studio XE 2018", therefore, I navigate to its "Command Prompt with Intel Compiler 18.0 Update 2" at the location of "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Intel Parallel Studio XE 2018\Compiler and Performance Libraries", I choose the Intel 64 Visual Studio 2015 environment. A command window is opened which is named "Intel Compiler 2018 Update 2 Intel(R) 64 Visual Studio 2015", which means that I'm using an Intel Compiler 2018 (Compiler 18.0) under the environment of Visual Studio 2015 (VS2015). Sorry for the prolixity.

In the command window, I navigate to the path where "CMakeLists.txt" and "DISCON_OC3Hywind.F90" locate, followed by typing "mkdir build" and "cd build". When I type "cmake .. -G”Visual Studio 15 2017 Win64”, an error occurs reporting that:

-----------------------------------------------------------------

CMake Error at CMakeLists.txt:18 (project): Generator Visual Studio 15 2017 Win64 could not find any instance of Visual Studio.

-- Configuring incomplete, errors occurred!

See also "E:/Bitbucket/r-test-nezzy/5MW_Baseline/ServoData/DISCON_OC3/build/CMakeFiles/CMakeOutput.log". In CMakeOutput.log: "The system is: Windows - 6.1.7601 - AMD64"

-----------------------------------------------------------------

I realize that my installed is Visual Studio 2015, so I change the typing to "cmake .. -G”Visual Studio 14 2015 Win64”, another error occurs reporting that:

-----------------------------------------------------------------

CMake Error: Error: generator : Visual Studio 14 2015 Win64 Does not match the generator used previously: Visual Studio 15 2017 Win64 Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary director y.

-----------------------------------------------------------------

So do you know what is the reason? and what should I do further? Thanks.

bjonkman commented 5 years ago

@liuyingyi-ukyushu: if you switch generators using cmake, you will need to remove the cmake cache files (as listed in the error message above) and start again. I usually just create a new build directory for 32-bit vs 64-bit builds, or else just delete everything in the directory I'm building in.

However, I don't think the OpenFAST DISCON files currently build with cmake and Visual Studio. For now, you can use the openfast/vs-build/Discon/Discon.sln file to build those files instead.

@rafmudaf: I used cmake on Windows with Visual Studio last week and started a list of some suggested changes that I plan to send you. Here is what I have regarding the DISCON projects:

There are errors in all three of the DISCON projects:

YingyiLiu commented 5 years ago

@bjonkman: Thanks. I tested again by deleting the cmake cache files, here below is the information:

-----------------------------------------------------------------

E:\Bitbucket\r-test-nezzy\5MW_Baseline\ServoData\DISCON_OC3\build>cmake .. -G "Visual Studio 14 2015 Win64" -- The C compiler identification is MSVC 19.0.24210.0 -- The CXX compiler identification is MSVC 19.0.24210.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd6 4/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd6 4/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_am d64/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_am d64/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- The Fortran compiler identification is Intel 18.0.2.20180210 -- Check for working Fortran compiler: C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2 018/windows/bin/intel64/ifort.exe -- Check for working Fortran compiler: C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2 018/windows/bin/intel64/ifort.exe -- works -- Detecting Fortran compiler ABI info -- Detecting Fortran compiler ABI info - done -- Determine Intel Fortran Compiler Implicit Link Path -- Determine Intel Fortran Compiler Implicit Link Path -- done -- Checking whether C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018/windows/bin/int el64/ifort.exe supports Fortran 90 -- Checking whether C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2018/windows/bin/int el64/ifort.exe supports Fortran 90 -- yes -- Configuring done -- Generating done -- Build files have been written to: E:/Bitbucket/r-test-nezzy/5MW_Baseline/ServoData/DISCON_OC3/bui ld

-----------------------------------------------------------------

Actually, I cannot find the built DISCON_OC3.dll in the build directory. (The above information is posted for the purpose of reference by someone who needs it).

However, I succeed with the "openfast/vs-build/Discon/Discon.sln file" you recommend. But the newly generated Discon_OC3Hywind.dll is of 29 KB size, while the previously released (together with FAST v8.16) is 432 KB. Do the two dlls have the same functionality?

PS: the new Discon_OC3Hywind.dll has been generated together with other three files, i.e., Discon_OC3Hywind.exp (1 KB), Discon_OC3Hywind.lib (2 KB), Discon_OC3Hywind.pdb (492 KB).

bjonkman commented 5 years ago

@liuyingyi-ukyushu: when you ran cmake, it generated the Visual Studio files. You'd have to either open and run the Visual Studio solution file (.snl) it created, or tell cmake to run Visual Studio using this command: cmake --build . --config Release to generate the dlls. This is the step that will fail based on my own testing of it last week.

I think the differences in the sizes of the DLLs are because this OpenFAST solution is using dynamic libraries instead of static ones. If you run these DLLs on a computer that doesn't have the Intel compiler installed (and its paths set to find the Intel libraries), you will need to install Intel Redistributable libraries. The static versions have the libraries built into the DLL, so they don't require redistributable versions.

That should probably be changed in the OpenFAST project files.

YingyiLiu commented 5 years ago

@bjonkman Thanks. You are correct. When I run the command: cmake --build . --config Release, the following errors occur:

-----------------------------------------------------------------

E:\Bitbucket\r-test-nezzy\5MW_Baseline\ServoData\DISCON_OC3\build>cmake --build . --config Release 1>------ Build started: Project: DISCON_OC3Hywind, Configuration: Release x64 ------ 1>Compiling with Intel(R) Visual Fortran Compiler 18.0.2.185 [Intel(R) 64]... 1>DISCON_OC3Hywind.F90 1>Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 18.0 .2.185 Build 20180210 1>Copyright (C) 1985-2018 Intel Corporation. All rights reserved. 1>ifort: command line warning #10006: ignoring unknown option '/m64' 1>ifort: command line error: option '/g' is ambiguous 1> 1>Build log written to "file://E:\Bitbucket\r-test-nezzy\5MW_Baseline\ServoData\DISCON_OC3\build\DI SCON_OC3Hywind.dir\Release\BuildLog.htm" 1>DISCON_OC3Hywind - 1 error(s), 1 warning(s) ========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========

-----------------------------------------------------------------

Again, when I open and run the created Visual Studio solution file (.snl), the compiler reports the same two errors shown above in bold. I guess these might be the reason of the solutions you proposed to Rafeal on the 2nd floor above.

rafmudaf commented 5 years ago

@bjonkman @liuyingyi-ukyushu I believe I've fixed most of these issues in https://github.com/openfast/r-test/tree/pullrequest/rafaelmudafort.

@bjonkman if you have anything to add to that branch, please let me know. Otherwise, I'll update that in r-test and openfast.

bjonkman commented 5 years ago

@rafmudaf There are issues with the macro names in the OC3 and ITI versions of the controller build files. You name them set_gfortran and set_intel, but you call them set_discon_gfortran and set_discon_intel, so they don't build.

rafmudaf commented 5 years ago

Thanks for testing that, @bjonkman. Its now fixed.

YingyiLiu commented 5 years ago

@rafmudaf @bjonkman I've tested the update pulled from your repository, by running either the Visual Studio solution file (.snl) or cmake command, they all succeed. Thanks for your hard work.

rafmudaf commented 5 years ago

Fixed by pull request #228