Skip to content

Commit

Permalink
Merge pull request #10 from rafmudaf/f/FloatingLin
Browse files Browse the repository at this point in the history
Merges openfast/dev
  • Loading branch information
ghaymanNREL authored Oct 24, 2019
2 parents 3cb7fec + 2fccdbf commit 5332ba3
Show file tree
Hide file tree
Showing 81 changed files with 239,816 additions and 1,717 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ language: c

matrix:
include:
- os: linux
dist: bionic
env: FC=/usr/bin/gfortran-7; DOUBLE_PRECISION=ON
- os: linux
dist: bionic
env: FC=/usr/bin/gfortran-7; DOUBLE_PRECISION=OFF
- os: linux
dist: bionic
env: FC=/usr/bin/gfortran-7; DOUBLE_PRECISION=ON; CPP_API=ON; CMAKE_FLAGS="-DBUILD_OPENFAST_CPP_API=$CPP_API"
- os: linux
dist: bionic
env: FC=/usr/bin/gfortran-7; DOUBLE_PRECISION=ON; CPP_API=ON; CMAKE_FLAGS="-DBUILD_OPENFAST_CPP_API=$CPP_API -DGENERATE_TYPES=ON"
- os: osx
osx_image: xcode9.2
osx_image: xcode11
env: FC=/usr/local/bin/gfortran-7; DOUBLE_PRECISION=ON
- os: osx
osx_image: xcode9.2
osx_image: xcode11
env: FC=/usr/local/bin/gfortran-7; DOUBLE_PRECISION=OFF

# macos dependency install
Expand All @@ -36,10 +36,7 @@ addons:
update: true

before_install:
# mac configuration
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python; fi

# linux configuration
# linux configuration
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gfortran libblas-dev liblapack-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CPP_API" == "ON" ]]; then sudo apt-get install libopenmpi-dev libyaml-cpp-dev libhdf5-dev libxml2-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv shell 3.7.1; fi
Expand All @@ -60,6 +57,9 @@ script:
# beamdyn regression tests
- if [[ "$DOUBLE_PRECISION" == "ON" ]]; then ctest -j4 -VV -R bd_; fi

# linearization cases
- if [[ "$DOUBLE_PRECISION" == "ON" ]]; then ctest -j5 -L linear; fi

# subset of openfast regression tests
# do not run
# - 3, 4, 7, 15, 16, 17 since the free yaw is not well trusted
Expand Down
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the build type: Debug Release" FORCE)
endif (NOT CMAKE_BUILD_TYPE)

option(GENERATE_TYPES "Use the openfast-regsitry to autogenerate types modules" off)
option(BUILD_SHARED_LIBS "Enable building shared libraries" off)
option(DOUBLE_PRECISION "Treat REAL as double precision" on)
option(USE_DLL_INTERFACE "Enable runtime loading of dynamic libraries" on)
Expand Down Expand Up @@ -71,7 +72,9 @@ endif()
########################################################################
# Build rules for OpenFAST Registry
#
add_subdirectory(modules/openfast-registry)
if(GENERATE_TYPES)
add_subdirectory(modules/openfast-registry)
endif()

########################################################################
# OpenFAST modules
Expand All @@ -98,7 +101,7 @@ set(OPENFAST_MODULES
icedyn
icefloe
map
)
)

set(OPENFAST_REGISTRY_INCLUDES "" CACHE INTERNAL "Registry includes paths")
set_registry_includes("modules" ${OPENFAST_MODULES})
Expand Down
12 changes: 5 additions & 7 deletions cmake/OpenfastCmakeUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,17 @@
# - regfile (filename): Path to the .txt definitions file
#
# Outputs:
# - outfile (filename): F90 or C file to be generated
# - outfile (filename): Path to the F90 or C file to be generated
#
function(generate_f90_types regfile outfile)
get_filename_component(input ${regfile} ABSOLUTE)
get_filename_component(outdir ${regfile} DIRECTORY)
get_filename_component(output_base ${outfile} NAME)
get_filename_component(outdir ${outfile} DIRECTORY)

set(output "${CMAKE_CURRENT_BINARY_DIR}/${output_base}")
add_custom_command(
OUTPUT ${output}
OUTPUT ${outfile}
DEPENDS openfast_registry ${input}
COMMAND ${CMAKE_BINARY_DIR}/modules/openfast-registry/openfast_registry
${input} ${OPENFAST_REGISTRY_INCLUDES} ${ARGN})
COMMAND ${CMAKE_BINARY_DIR}/modules/openfast-registry/openfast_registry ${input} "-O" "${outdir}" ${OPENFAST_REGISTRY_INCLUDES} ${ARGN}
)
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
endfunction(generate_f90_types)

Expand Down
5 changes: 3 additions & 2 deletions docs/source/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ For other questions regarding OpenFAST, please contact

dev_phil.rst
github_workflow.rst
build_doc.rst
debugging.rst
doxy_doc.rst
build_doc.rst
types_files.rst
performance.rst
doxy_doc.rst
124 changes: 124 additions & 0 deletions docs/source/dev/types_files.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
.. _types_files:

Types Files and the OpenFAST Registry
=====================================
Being a modern software project, OpenFAST has a complex system of custom data
types. In Fortran, these are known as "derived data types." Each module
contains a unique collection of derived types which may add on to but must
comply with the OpenFAST Framework. The module types are generally
auto-generated by an included program called *OpenFAST Registry*. The OpenFAST
Registry is written in C and adapted from a similar utility used in
`WRF <http://www.mmm.ucar.edu/wrf/WG2/software_2.0/registry_schaffer.pdf>`__.
Visit the `OpenFAST Registry README <https://github.com/OpenFAST/openfast/tree/master/modules/openfast-registry>`__
for more information.

The OpenFAST Registry requires an input file to describe the necessary types
for a given module. Generally, all module use a similar naming convention,
**<Module>_Registry.txt**, and resulting Fortran code will be in a file
called **<Module>_Types.f90**. For example, the AeroDyn OpenFAST Registry input
file is located at ``openfast/modules/aerodyn/src/AeroDyn_Registry.txt`` and
the resulting auto-generated Fortran source code is at
``openfast/modules/aerodyn/src/AeroDyn_Types.f90``.

Since the types-modules are autogenerated, any changes to the data types
directly should be expressed in the OpenFAST Registry input files so that the
changes are not subsequently overwritten.

Compiling the OpenFAST Registry
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The OpenFAST Registry is included
in the OpenFAST build system through CMake. However, the default is to
**not** compile the OpenFAST Registry executable and instead use the types
modules that are included in *git* while compiling OpenFAST. To include the
OpenFAST Registry in the build process and compile the Registry program,
configure CMake with the ``GENERATE_TYPES`` flag:

.. code-block:: bash
cmake .. -DGENERATE_TYPES=ON
With ``GENERATE_TYPES`` enabled, CMake will configure the `openfast-registry`
target to compile as a dependency of all other targets. The OpenFAST Registry
executable will be found in
``openfast/build/modules/openfast-registry/openfast-registry``.

.. _regenerating_types:

Regenerating a types module
~~~~~~~~~~~~~~~~~~~~~~~~~~~
With the ``GENERATE_TYPES`` flag enabled, an additional step will be added to
modules that are configured can make use of the OpenFAST Registry. The
additional step will execute the OpenFAST Registry and regenerate the types
module overwriting the existing modules. Any changes to the types module will
be evident in *git*. For modules where the registry input file has not
changed, the resulting types module will not change. However, for registry
input files that have been modified, the output types module will be
recompiled.

Adding a new types module
~~~~~~~~~~~~~~~~~~~~~~~~~
The process for adding a new types module follows :ref:`regenerating_types`
closely. Here, an additional step is required to configure CMake to execute
the Registry on the new input file and include the resulting types module
in the compile step.

First, a new OpenFAST Registry input file must be created. Then, it must be
configured to pass through the Registry in the corresponding module's
``CMakeLists.txt``:

.. code-block:: cmake
# This is the control statement for allowing the Registry to execute
if (GENERATE_TYPES)
# Here is the CMake wrapper-function to execute the Registry
# syntax: generate_f90_types(<Registry input file> <output file location>)
generate_f90_types(src/AeroDyn_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/AeroDyn_Types.f90)
generate_f90_types(src/New_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/New_Types.f90)
endif()
Finally, the resulting types module must be added to the source files for the
corresponding module:

.. code-block:: cmake
# AeroDyn lib
set(AD_LIBS_SOURCES
src/AeroDyn.f90
src/AeroDyn_IO.f90
src/AirfoilInfo.f90
src/BEMT.f90
src/DBEMT.f90
src/BEMTUncoupled.f90
src/UnsteadyAero.f90
src/fmin_fcn.f90
src/mod_root1dim.f90
src/AeroDyn_Types.f90
src/AirfoilInfo_Types.f90
src/BEMT_Types.f90
src/DBEMT_Types.f90
src/UnsteadyAero_Types.f90
# Add the new types module here
src/New_Types.f90
)
With CMake properly configured, a message will display during the build process
indicating that the OpenFAST Registry is executing:

.. code-block:: bash
[ 64%] Generating ../../../modules/aerodyn/src/New_Types.f90
----- FAST Registry --------------
----------------------------------------------------------
input file: /Users/rmudafor/Development/openfast/modules/aerodyn/src/New_Registry.txt
# more build process output will follow
And finally there should be an indication that the resulting types module is
compiled:

.. code-block:: bash
Scanning dependencies of target aerodynlib
[ 70%] Building Fortran object modules/aerodyn/CMakeFiles/aerodynlib.dir/src/New_Types.f90.o
6 changes: 0 additions & 6 deletions docs/source/install/install_cmake_windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ can then build any module library, module driver, or glue code. Note that any ti
CMake is rerun, the Visual Studio solution will be regenerated causing the Visual Studio
GUI to lag momentarily while it reloads the data.

**The CMake-generated Visual Studio build is currently damaged.** Some modules are compiled
before their associated registry type files are seen by Visual Studio so an initial build
will fail. However, a simple work around is to run the build command in Visual Studio
multiple times until it succeeds.


CMake options
~~~~~~~~~~~~~

Expand Down
7 changes: 0 additions & 7 deletions docs/source/install/install_vs_windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,4 @@ format. Go ahead and accept the upgrade on those files.

6. Build the solution using the ``Build->Build Solution`` menu option.

NOTE: If this is the first time building OpenFAST, you will encounter many error
messages. This is due to a known issue with Visual Studio's ability to understand
the OpenFAST dependency structure, which includes Registry-generated Fortran files.
You can resolve this issue by simply closing Visual Studio and then reopening the
``FAST.sln`` solution file. After you have reopened Visual Studio, build the
solution again via the ``Build->Build Solution`` menu option.

7. If the solution built without errors, the executable will be located under the ``openfast\build\bin`` folder.
35 changes: 16 additions & 19 deletions modules/aerodyn/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
# limitations under the License.
#

generate_f90_types(src/AeroDyn_Registry.txt AeroDyn_Types.f90)
generate_f90_types(src/AirfoilInfo_Registry.txt AirfoilInfo_Types.f90 -noextrap)
generate_f90_types(src/BEMT_Registry.txt BEMT_Types.f90)
generate_f90_types(src/DBEMT_Registry.txt DBEMT_Types.f90)
generate_f90_types(src/UnsteadyAero_Registry.txt UnsteadyAero_Types.f90)

generate_f90_types(src/AeroDyn_Driver_Registry.txt
AeroDyn_Driver_Types.f90 -noextrap)
if (GENERATE_TYPES)
generate_f90_types(src/AeroDyn_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/AeroDyn_Types.f90)
generate_f90_types(src/AirfoilInfo_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/AirfoilInfo_Types.f90 -noextrap)
generate_f90_types(src/BEMT_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/BEMT_Types.f90)
generate_f90_types(src/DBEMT_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/DBEMT_Types.f90)
generate_f90_types(src/UnsteadyAero_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/UnsteadyAero_Types.f90)
generate_f90_types(src/AeroDyn_Driver_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/AeroDyn_Driver_Types.f90 -noextrap)
endif()

# AeroDyn lib
set(AD_LIBS_SOURCES
Expand All @@ -34,14 +34,12 @@ set(AD_LIBS_SOURCES
src/UnsteadyAero.f90
src/fmin_fcn.f90
src/mod_root1dim.f90

# Autogenerated files
AeroDyn_Types.f90
AirfoilInfo_Types.f90
BEMT_Types.f90
DBEMT_Types.f90
UnsteadyAero_Types.f90
)
src/AeroDyn_Types.f90
src/AirfoilInfo_Types.f90
src/BEMT_Types.f90
src/DBEMT_Types.f90
src/UnsteadyAero_Types.f90
)

add_library(aerodynlib ${AD_LIBS_SOURCES})
target_link_libraries(aerodynlib nwtclibs)
Expand All @@ -50,9 +48,8 @@ target_link_libraries(aerodynlib nwtclibs)
set(AD_DRIVER_SOURCES
src/AeroDyn_Driver.f90
src/AeroDyn_Driver_Subs.f90

# Autogenerated files
AeroDyn_Driver_Types.f90)
src/AeroDyn_Driver_Types.f90
)

add_executable(aerodyn_driver ${AD_DRIVER_SOURCES})
target_link_libraries(aerodyn_driver aerodynlib nwtclibs versioninfolib ${CMAKE_DL_LIBS})
Expand Down
Loading

0 comments on commit 5332ba3

Please sign in to comment.