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
680 stars 456 forks source link

Compile OpenFAST using IntelFortran in Linux #975

Closed HCKimDaniel closed 2 years ago

HCKimDaniel commented 2 years ago

Is your feature request related to a problem? Please describe. The linux system used the gfortan automatically instead of intel Fortran when compiled

Describe the solution you'd like I want to compile OpenFAST with IntelFortran in the Linux system

Describe alternatives you've considered No Alternatives are considered

Additional context I am using TACC Frontera System for compiling OpenFAST. I want to compile OpenFAST with IntelFortran in the Linux system, but it used the gfortran automatically. Can you help me for me to compile OpenFAST using Intel Fortran in the Linux.

login1.frontera(1015)$ git clone https://github.com/OpenFAST/OpenFAST.git
Cloning into 'OpenFAST'...
remote: Enumerating objects: 49013, done.
remote: Counting objects: 100% (298/298), done.
remote: Compressing objects: 100% (158/158), done.
remote: Total 49013 (delta 176), reused 198 (delta 140), pack-reused 48715
Receiving objects: 100% (49013/49013), 202.92 MiB | 33.46 MiB/s, done.
Resolving deltas: 100% (32219/32219), done.
login1.frontera(1016)$ cd OpenFAST
login1.frontera(1017)$ mkdir build
login1.frontera(1018)$ cd build
login1.frontera(1019)$ cmake ../
-- The CXX compiler identification is GNU 8.3.0
-- The C compiler identification is GNU 8.3.0
-- The Fortran compiler identification is GNU 8.3.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/apps/gcc/8.3.0/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/apps/gcc/8.3.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/apps/gcc/8.3.0/bin/gfortran - skipped
-- Checking whether /opt/apps/gcc/8.3.0/bin/gfortran supports Fortran 90
-- Checking whether /opt/apps/gcc/8.3.0/bin/gfortran supports Fortran 90 - yes
-- Performing Test HAS_FORTRAN2008
-- Performing Test HAS_FORTRAN2008 - Success
-- Enabling Fortran 2008 features
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - found
-- Found BLAS: /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_gnu_thread.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_core.so;/opt/apps/gcc/8.3.0/lib64/libgomp.so;-lpthread;-lm;-ldl
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- Found LAPACK: /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_gnu_thread.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_core.so;/opt/apps/gcc/8.3.0/lib64/libgomp.so;-lpthread;-lm;-ldl;-lpthread;-lm;-ldl
-- Setting system file as: src/SysGnuLinux.f90
-- Configuring done
-- Generating done
-- Build files have been written to: /home1/08330/hckim81/OpenFAST/build
>
rafmudaf commented 2 years ago

Hello @HCKimDaniel - How does Frontera handle loading the Intel tool suite? For example, do you know whether your environment is able to access the Intel compiler and libraries? You could try which ifort.

HCKimDaniel commented 2 years ago

Hi!! @rafmudaf As far as I know, intel compiler can be assessed because I used ifort to compile an in-house code in Frontera. Also, I copy and paste the answer for which ifort below.

login3.frontera(1001)$ which ifort /opt/intel/compilers_and_libraries_2020.1.217/linux/bin/intel64/ifort

login3.frontera(1004)$ which cmake /opt/apps/cmake/3.20.3/bin/cmake

Currently Loaded Modules: 1) intel/19.1.1 4) autotools/1.2 7) pmix/3.1.4 10) TACC 2) impi/19.0.9 5) python3/3.7.0 8) hwloc/1.11.12 3) git/2.24.1 6) cmake/3.20.3 9) xalt/2.10.34

The difference from the previous compiling experience is that cmake is used for the openfast. If I follow the compile process from the website "https://openfast.readthedocs.io/en/main/source/install/index.html#cmake-with-make-for-linux-macos", the frontera system uses the gfortran automatically. Do I need to change the cmake option in the related cmake input file to compile openfast using ifort?

rafmudaf commented 2 years ago

Yes, you could try that. Change the value for CMAKE_FORTRAN_COMPILER in openfast/build/CMakeCache.txt to contain the path from the which ifort command. Be sure to run cmake .. after saving this change.

However, I think this will not change the math libraries that would have been found by CMake. A safer method might be to set the FC environment variable to the path to ifort and start the configuration and compile from scratch. Something like this:

cd openfast/
rm -rf build
mkdir build && cd build
export FC=/opt/intel/compilers_and_libraries_2020.1.217/linux/bin/intel64/ifort
cmake ..
HCKimDaniel commented 2 years ago

There is no value for CMAKE_FORTRAN_COMPILER in openfast/build/CMakeCache.txt. Do you mean that I need to add the value in openfast/build/CMakeCache.txt?

rafmudaf commented 2 years ago

Could you post the CMakeCache file here? You can just attach it to a comment rather than copy-paste the contents.

HCKimDaniel commented 2 years ago

I posted CMakeCache.txt below CMakeCache.txt

rafmudaf commented 2 years ago

Did the cmake configuration command (cmake ..) end successfully? As in, did it state

-- Configuring done
-- Generating done
-- Build files have been written to: <path>/openfast/build

If CMake finished correctly, the CMakeCache must contain a variable for the Fortran compiler in the same way that it contains paths to the C++ and C compilers.

HCKimDaniel commented 2 years ago

OK. I cloned the repository from GitHub again and tried as you commented

cd openfast/
rm -rf build
mkdir build && cd build
export FC=/opt/intel/compilers_and_libraries_2020.1.217/linux/bin/intel64/ifort
cmake ..

The message is changed like below after cmake ... I think taht the fortran compiler is successfully changed to ifort based on the message. I will compile openfast again. And let you know the update. Thank you.

login3.frontera(1078)$ rm -rf build
login3.frontera(1079)$ mkdir build && cd build
login3.frontera(1080)$ export FC=/opt/intel/compilers_and_libraries_2020.1.217/l                                                                                                                                                             inux/bin/intel64/ifort
login3.frontera(1081)$ cmake ..
-- The CXX compiler identification is GNU 8.3.0
-- The C compiler identification is GNU 8.3.0
-- The Fortran compiler identification is Intel 19.1.0.20200306
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/apps/gcc/8.3.0/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/apps/gcc/8.3.0/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /opt/intel/compilers_and_libraries_2020.1                                                                                                                                                             .217/linux/bin/intel64/ifort - skipped
-- Checking whether /opt/intel/compilers_and_libraries_2020.1.217/linux/bin/inte                                                                                                                                                             l64/ifort supports Fortran 90
-- Checking whether /opt/intel/compilers_and_libraries_2020.1.217/linux/bin/inte                                                                                                                                                             l64/ifort supports Fortran 90 - yes
-- Performing Test HAS_FORTRAN2008
-- Performing Test HAS_FORTRAN2008 - Success
-- Enabling Fortran 2008 features
-- Found MKL: /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel6                                                                                                                                                             4/libmkl_intel_lp64.so;/opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/l                                                                                                                                                             ib/intel64/libmkl_sequential.so;/opt/intel/compilers_and_libraries_2020.1.217/li                                                                                                                                                             nux/mkl/lib/intel64/libmkl_core.so
-- Setting system file as: src/SysIFL.f90
-- Configuring done
-- Generating done
-- Build files have been written to: /home1/08330/hckim81/OpenFAST/build
rafmudaf commented 2 years ago

Yes, this looks good. At least CMake is able to find your Intel compiler and the Intel MKL library. Please let me know if you're able to compile.

HCKimDaniel commented 2 years ago

@rafmudaf Thank you so much!!! It fully works well.