Skip to content

Commit

Permalink
Merge pull request #271 from rafmudaf/build_system/cygwin
Browse files Browse the repository at this point in the history
Build system: cygwin/mingw
  • Loading branch information
rafmudaf authored Apr 19, 2019
2 parents d23e964 + 2d0f1f1 commit f01cbd7
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 205 deletions.
15 changes: 0 additions & 15 deletions docs/source/install/get_openfast.rst

This file was deleted.

29 changes: 25 additions & 4 deletions docs/source/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,36 @@ Installing OpenFAST
===================

The following pages provide instructions for building OpenFAST and/or its modules from source code.
The developer team is moving towards a CMake-only approach that well supports Window Visual Studio users, but at this time we provide a separate build path for those users.
The developer team is moving towards a CMake-only approach that well supports Window Visual Studio users,
but at this time we provide a separate build path for those users.

Obtaining the OpenFAST source code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

OpenFAST can be cloned (i.e., downloaded) from its `Github Repository <https:// github.com/openfast/openfast>`_.
For example, from a command line:

::

git clone https://github.com/OpenFAST/OpenFAST.git

It can also be downloaded directly from https://github.com/OpenFAST/OpenFAST.

Linux and Mac
~~~~~~~~~~~~~

.. toctree::
:maxdepth: 1

get_openfast.rst
install_cmake_linux.rst
install_spack.rst
install_cmake_cygwin.rst

Windows
~~~~~~~

.. toctree::
:maxdepth: 1

install_cmake_windows.rst
install_vs_windows.rst

install_cmake_cygwin.rst
161 changes: 8 additions & 153 deletions docs/source/install/install_cmake_cygwin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Building OpenFAST on Windows with CMake and Cygwin 64-bit
=========================================================
WARNING: This build process takes a significantly long amount of time. If GNU tools are not required,
it is recommended that Windows users follow the instructions at :ref:`install_cmake_windows` or :ref:`install_vs_windows`.

Installing prerequisites
------------------------
Expand Down Expand Up @@ -42,6 +44,11 @@ Installing prerequisites
- ``liblapack-devel``
- ``libopenblas``

- To run the test suite, install these optional packages from ``Python``:

- ``python3``
- ``Python3-numpy``

- Click ``Next`` and accept all additional packages that the setup
process requests to install to satisfy dependencies

Expand All @@ -50,165 +57,13 @@ Installing prerequisites

Compiling OpenFAST
------------------

1. Open ``Cygwin64 Terminal`` from the ``Start`` menu

2. Create a directory where you will clone OpenFAST repository (change
``code`` to your preferred name)

::

mkdir code
cd code

3. Clone the OpenFAST repository

::

git clone https://github.com/OpenFAST/OpenFAST.git

This will create a directory called ``OpenFAST`` within the ``code``
directory.

4. Create a build directory

::

cd OpenFAST
mkdir build
cd build

5. Run ``cmake``. Note that this step is necessary only if you change
compiler settings, or add new files to any of the ``CMakeLists.txt``.
Modification of ``.f90`` files do not require you to run ``cmake``
again, just re-run ``make`` command (see next item) to recompile with
latest source code modifications.

::

FC=gfortran cmake ../

Sample output is shown below:

::

$ FC=gfortran cmake ../
-- The Fortran compiler identification is GNU 5.4.0
-- The C compiler identification is GNU 5.4.0
-- Check for working Fortran compiler: /usr/bin/gfortran.exe
-- Check for working Fortran compiler: /usr/bin/gfortran.exe -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran.exe supports Fortran 90
-- Checking whether /usr/bin/gfortran.exe supports Fortran 90 -- yes
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- A library with BLAS API found.
-- A library with BLAS API found.
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- A library with LAPACK API found.
-- Setting system file as: src/SysGnuLinux.f90
-- Configuring done
-- Generating done
-- Build files have been written to: /home/sanantha/code/OpenFAST/build

6. Compile ``OpenFAST``

::

make

Grab a cup of coffee as this takes a while on Cygwin. Once the
compilation is completed, the ``OpenFAST`` executable is present in
``OpenFAST/build/glue-codes/openfast/openfast.exe``

7. Test the executable

::

$ glue-codes/openfast/openfast.exe -h


**************************************************************************************************
FAST (v8.17.00a-bjj, 27-Aug-2016)

Copyright (C) 2016 National Renewable Energy Laboratory

This program comes with ABSOLUTELY NO WARRANTY. See the "license.txt" file distributed with this
software for details.
**************************************************************************************************

Running FAST (v8.17.00a-bjj, 27-Aug-2016), compiled as a 64-bit application using double
precision
linked with NWTC Subroutine Library (v2.11.00, 12-Nov-2016)


Syntax is:

FAST_x64.exe [-h] <InputFile>

where:

-h generates this help message.
<InputFile> is the name of the required primary input file.

Note: values enclosed in square brackets [] are optional. Do not enter the brackets.


FAST_InitializeAll:The required input file was not specified on the command line.

FAST encountered an error during module initialization.
Simulation error level: FATAL ERROR

Aborting FAST.

\`\`\`
From here, pick up from the Linux with CMake instructions at :ref:`cmake-build-instructions`.

Other tips
----------

- You can specify an installation location during your ``cmake``
process so that the executable, libraries, and headers (e.g., ``MAP``
and ``OpenFOAM`` headers) are installed in a common location that you
can use to update your environment variables.

::

# 1. Create an installation location mkdir -p ~/software

# 2. Instruct CMake to use the custom install location FC=gfortran cmake
-DCMAKE\_INSTALL\_PREFIX:PATH=$HOME/software ../

# 3. Compile OpenFAST executable make

# 4. Install OpenFAST to custom install location make install \`\`\`

With this step, you can execute ``make install`` after ``make`` (see
step 6 above). Now the ``openfast.exe`` and other executables (e.g.,
``aerodyn.exe``) are available in ``~/software/bin/`` directory.

- If you desire to be able to run ``openfast.exe`` from the ``cmd``
window, then you must add the ``C:\cygwin64\lib\lapack`` and
``C:\cygwin64\home\<USERNAME>\software\bin`` to your ``%PATH%``
variable in environment setting. Replace ``<USERNAME>`` with your
account name on windows system.

- In addition to ``openfast.exe``, the current CMake setup also allows
the user to compile other executables or libraries without compiling
the entire codebase. Use ``make help`` to see what targets are
available and then do ``make <TARGET>`` to choose your desired
target. For example, ``make aerodyn`` will compile only the
``aerodyn.exe`` executable and its dependencies without compiling the
remaining targets.
2 changes: 2 additions & 0 deletions docs/source/install/install_cmake_linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ OpenFAST has the following dependencies:

- **Optional:** For the testing framework, Python 3+

.. _cmake-build-instructions:

CMake build instructions
------------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/install/install_cmake_windows.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _install_cmake_windows:

Building OpenFAST with CMake on Windows
=======================================
Building OpenFAST on Windows with CMake and Visual Studio
=========================================================

We describe here how to install OpenFAST (or any of its modules) using the `CMake <https://cmake.org>`_
build system on Windows systems. Separate CMake documentation is
Expand Down
4 changes: 2 additions & 2 deletions modules/map/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.
#

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAP_DLL_EXPORTS -DCMINPACK_NO_DLL -DNDEBUG -D_WINDOWS -D_USRDLL")
if(WIN32 OR CYGWIN OR MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMAP_DLL_EXPORTS -DCMINPACK_NO_DLL -DNDEBUG -D_WINDOWS -D_USRDLL")
endif()

generate_f90_types(src/MAP_Registry.txt MAP_Types.f90 -ccode)
Expand Down
2 changes: 1 addition & 1 deletion modules/map/src/mapsys.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# include <stdbool.h>
# define map_snprintf snprintf
# define map_strcat(a,b,c) strncat(a,c,b)
# if defined(_MINGW)
# if defined(__MINGW32__)
# define MAP_EXTERNCALL __declspec( dllexport )
# else
# define MAP_EXTERNCALL
Expand Down
2 changes: 1 addition & 1 deletion modules/map/src/outputstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ MAP_ERROR_CODE write_expanded_input_file_to_summary_file(FILE* file, Initializat
};


#if !defined(_MSC_VER)
#if !defined(_MSC_VER) && !defined(__MINGW32__)
MAP_ERROR_CODE fopen_s(FILE** f, const char* name, const char* mode)
{
assert(f);
Expand Down
2 changes: 1 addition & 1 deletion modules/map/src/outputstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "MAP_Types.h"


#if !defined(_MSC_VER)
#if !defined(_MSC_VER) && !defined(__MINGW32__)
MAP_ERROR_CODE fopen_s(FILE** f, const char* name, const char* mode);
#endif

Expand Down
8 changes: 4 additions & 4 deletions modules/nwtc-library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ set(NWTCLIBS_SOURCES
get_filename_component(FCNAME ${CMAKE_Fortran_COMPILER} NAME)

if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU")
if (APPLE OR UNIX)
set(NWTC_SYS_FILE src/SysGnuLinux.f90)
elseif (WIN32)
if (WIN32)
set(NWTC_SYS_FILE src/SysGnuWin.f90)
endif (APPLE OR UNIX)
elseif (APPLE OR UNIX OR CYGWIN)
set(NWTC_SYS_FILE src/SysGnuLinux.f90)
endif ()
elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
if (APPLE OR UNIX)
set(NWTC_SYS_FILE src/SysIFL.f90)
Expand Down
4 changes: 2 additions & 2 deletions modules/nwtc-library/src/NetLib/lapack/NWTC_LAPACK.f90
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ SUBROUTINE LAPACK_DGEMM( TRANSA, TRANSB, ALPHA, A, B, BETA, C, ErrStat, ErrMsg )
END IF


CALL dgemm (TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, M)
CALL DGEMM (TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, M)


RETURN
Expand Down Expand Up @@ -387,7 +387,7 @@ SUBROUTINE LAPACK_SGEMM( TRANSA, TRANSB, ALPHA, A, B, BETA, C, ErrStat, ErrMsg )
END IF


CALL sgemm (TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, M)
CALL SGEMM (TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, M)


RETURN
Expand Down
8 changes: 4 additions & 4 deletions modules/nwtc-library/src/SysGnuLinux.f90
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ SUBROUTINE OpenCon

! This routine opens the console for standard output.

!bjj: removed for use with CygWin; Because CU = 6 now, this statement is not necessary
!bjj: Because CU = 6 now, this statement is not necessary
! OPEN ( CU , FILE='/dev/stdout' , STATUS='OLD' )

CALL FlushOut ( CU )
! CALL FlushOut ( CU )

RETURN
END SUBROUTINE OpenCon
Expand Down Expand Up @@ -379,8 +379,7 @@ SUBROUTINE WriteScr ( Str, Frm )

CHARACTER(*), INTENT(IN) :: Str ! The input string to write to the screen.
CHARACTER(*), INTENT(IN) :: Frm ! Format specifier for the output.
INTEGER :: ErrStat ! Error stat
! This SUBROUTINE is used to dynamically load a DLL.us of write operation (so code doesn't crash)
INTEGER :: ErrStat ! Error status of write operation (so code doesn't crash)

IF ( LEN_TRIM(Str) < 1 ) THEN
WRITE ( CU, '()', IOSTAT=ErrStat )
Expand All @@ -396,6 +395,7 @@ END SUBROUTINE WriteScr ! ( Str )
!=======================================================================
SUBROUTINE LoadDynamicLib ( DLL, ErrStat, ErrMsg )

! This SUBROUTINE is used to dynamically load a DLL.

TYPE (DLL_Type), INTENT(INOUT) :: DLL ! The DLL to be loaded.
INTEGER(IntKi), INTENT( OUT) :: ErrStat ! Error status of the operation
Expand Down
Loading

0 comments on commit f01cbd7

Please sign in to comment.