Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
cmake_minimum_required(VERSION 3.19)

# Force static linking of runtime libraries
# for Intel & MS compilers on windows
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(CEA
Expand Down
18 changes: 15 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_Fortran_COMPILER": "gfortran",
"CMAKE_Fortran_FLAGS": "-std=f2008 -fimplicit-none -ffree-line-length-none"
"CMAKE_Fortran_FLAGS": "-fimplicit-none -ffree-line-length-none"
}
},
{
Expand All @@ -100,8 +100,20 @@
"cacheVariables": {
"CMAKE_C_COMPILER": "icc",
"CMAKE_CXX_COMPILER": "icpc",
"CMAKE_Fortran_COMPILER": "ifort",
"CMAKE_Fortran_FLAGS": "-std08"
"CMAKE_Fortran_COMPILER": "ifort"
}
},
{
"name": "intel-ifx",
"displayName": "Baseline Intel ifx Config",
"description": "Default configuration for the ifort compilier.",
"binaryDir": "build-intel",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_COMPILER": "icx",
"CMAKE_CXX_COMPILER": "icpx",
"CMAKE_Fortran_COMPILER": "ifx"
}
}
]
Expand Down
23 changes: 23 additions & 0 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# cmake/CompilerFlags.cmake
function(project_enable_fortran_std target)
# GNU Fortran
target_compile_options(${target} PRIVATE
$<$<COMPILE_LANG_AND_ID:Fortran,GNU>:-std=f2008>
)

# Intel classic ifort (Windows uses /, Linux often accepts - or -stand)
target_compile_options(${target} PRIVATE
$<$<COMPILE_LANG_AND_ID:Fortran,Intel>:
$<IF:$<PLATFORM_ID:Windows>,/stand:f08,-stand f08>
>
)

# IntelLLVM ifx
target_compile_options(${target} PRIVATE
$<$<COMPILE_LANG_AND_ID:Fortran,IntelLLVM>:
$<IF:$<PLATFORM_ID:Windows>,/stand:f08,-stand f08>
>
)
endfunction()


176 changes: 176 additions & 0 deletions docs/source/Win11-oneAPI_Walkthrough.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
Installation Walkthrough: Win w/Intel oneAPI
********************************************
This walkthrough provides an example of installation on Windows using
the Intel oneAPI compilers. It was developed using oneAPI 2025.3.

The example includes installation of the core CEA application, as well
as the C and Python bindings.

Prerequisites
-------------

This example assumes that the following tools are installed on your system:

* Visual Studio 2019 or later.
* Intel oneAPI Base Toolkit. As an alternate, Intel C++ Essentials should
work but is untested.
* Intel oneAPI HPC Toolkit. As an alternate, Intel Fortran Essentials should
work but is untested.
* Python ≥ 3.11 with ``pip`` for the optional binding, docs, and integration
tests.
* Git, if you plan to clone the repository and build from source.
* Doxygen, if you plan to generate a local copy of the documentation.

Preparations
------------
Start an Intel oneAPI command prompt so that the compiler variables and paths
are correctly setup. Create a directory to work in and cd into it::

mkdir \ceabuild
cd \ceabuild

Prepare the Python environment. For example, if using Anaconda::

conda create --name ceaEnv pip
conda activate ceaEnv

If using vanilla Python::

py -m venv ceaEnv
ceaEnv\Scripts\activate

Install Python packages::

pip install cython numpy setuptools pandas pytest

Clone the repository::

git clone https://github.com/nasa/cea.git


Build
-----

The CEA software package is compiled and installed using CMake. The basic
installation process is as follows::

cd cea
mkdir build-intel
cd build-intel
cmake -DCMAKE_INSTALL_PREFIX=<cea_install_dir> -DCEA_BUILD_TESTING=OFF -DCEA_ENABLE_BIND_PYTHON=ON --preset intel-ifx ..
cmake --build .

Test the Core CEA Executable
----------------------------
The cea/test directory tree contains example problems. It includes Python
code that runs the examples, compares results to reference output, and
reports whether or not the outputs match.

::

cd source
python ..\..\test\main_interface\test_main.py

The expected result is 13 out of 14 tests pass, with a small error on
example 11::

Reference | Test | Rel. Error
--------------------------------------------------------------
F- : 2.5000e-04 | 2.6000e-04 | 4.000%

Different results could indicate that something is wrong with the build.

Create Documentation (Optional)
-------------------------------
Prerequisites:

* The Doxygen documentation generator.
* The Sphinx Python package, installable with pip.
* The Breathe Python package, installable with pip.

CEA html documentation can be created by installing the Python binding in
edit mode, running Doxygen to create docs for the API, and then using Sphinx
to create the html files. Change directories to the **cea root** (the directory that
contains Doxyfile) and execute the following commands::

pip install -e .
doxygen
cd docs
sphinx-build -M html source .

Documentation will be generated in the docs/html directory.

Install CEA
-----------
To install CEA, run the following from the build-intel directory::

cmake --install .

This will install the ``cea`` executable, ``libcea`` library, C library,
and the default thermodynamic and transport property databases to the
``cea_install_dir`` that was specified when configuring CMake. If you
elected to generate documentation it can be manually copied to the
installation directory.

After installing the executable, install and test the Python binding::

cd ..
pip install .
pytest source\bind\python\tests

All tests should run (no skips!) and pass.

After the Python interface is tested and confirmed to be working, you can make a
wheel for further distribution. Runtime libraries are statically linked so the
wheel will be self-contained (but it still needs numpy)::

pip wheel --no-deps -w dist .

and the wheel will end up in the cea/dist directory. This directory can be moved
into the CEA installation directory so that the wheel is convienently available
for installation into new Python virtual environments using::

pip install <path-to-wheel>\<wheel-name>

Setup User Environment
----------------------

After installation, all that is required to use the `cea` executable is to add
the CEA install directory to the user's `PATH` environment variable, e.g.:

::

setx PATH=<cea_install_dir>\bin;%PATH%

Once properly configured, you should be able to run the provided sample problems
from any working directory as follows:

::

cea <cea_source_dir>\samples\rp1311_examples.inp


Minimal Builds
--------------

If you want a Fortran-only build or a Fortran+C build without Python/Cython/NumPy
dependencies, use the following options when configuring CMake:

Fortran-only (no C/Python bindings)::

-DCEA_ENABLE_BIND_PYTHON=OFF -DCEA_ENABLE_BIND_C=OFF -DCEA_ENABLE_BIND_MATLAB=OFF

Fortran + C (no Python bindings)::

-DCEA_ENABLE_BIND_PYTHON=OFF -DCEA_ENABLE_BIND_C=ON -DCEA_ENABLE_BIND_MATLAB=OFF


Intel oneAPI on Linux
---------------------

This procedure can also be used to build CEA on Linux using Intel oneAPI. To build on Linux,
add an additional option when configuring CMake:

-G "Unix Makefiles"


1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Getting Started

installation
quick_start
Win11 Install Example <Win11-oneAPI_Walkthrough>

Interfaces
===========
Expand Down
23 changes: 21 additions & 2 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ add_installed_library(cea_core
transport.f90
units.f90
)
# Call function to correctly process compiler flags to check Fortran
# standard compliance based on compiler / OS
set(CMAKE_Fortran_STANDARD 2008)
set(CMAKE_Fortran_STANDARD_REQUIRED ON)
include(../cmake/CompilerFlags.cmake)
project_enable_fortran_std(cea_core)

target_link_libraries(cea_core PRIVATE fbasics::core)

if(CEA_BUILD_TESTING)
Expand All @@ -47,16 +54,28 @@ endif()
# Main application
#=====================================================================
add_executable(cea main.f90)
project_enable_fortran_std(cea)
target_link_libraries(cea PRIVATE cea::core fbasics::core)
install(TARGETS cea DESTINATION ${CMAKE_INSTALL_BINDIR})

if(WIN32)
# on windows, several dll either need to be installed on the target
# machine, or they need to be statically linked. linking seemed easier than
# finding the path to the various DLLs and installing them.
# If the intel compilers are used on windows, CMAKE_MSVC_RUNTIME_LIBRARY is set in the root
# CMakeLists.txt to force the use of static runtime libraries for all targets
if (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM" OR CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
target_link_options(cea
PUBLIC "-libs:static")
else()
target_link_options(cea
PUBLIC "-static-libgfortran"
PUBLIC "-static-libgcc")
endif()
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM" OR CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
# Static link runtime libraries on linux if using Intel compilers
target_link_options(cea
PUBLIC "-static-libgfortran"
PUBLIC "-static-libgcc")
PUBLIC "-static-intel")
endif()

if(CEA_BUILD_TESTING)
Expand Down
7 changes: 7 additions & 0 deletions source/bind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ if (CEA_ENABLE_BIND_PYTHON)
PREFIX ""
)
target_link_libraries(libcea ${PYTHON_LIBRARIES})
# numpy headers include a workaround for intel compilers, at least as of 2.4.1
# They are triggered if __INTEL_COMPILER is defined, but that isn't defined by
# default if using ifc
if (CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM" OR CMAKE_C_COMPILER_ID STREQUAL "Intel")
target_compile_options(libcea PUBLIC "-D__INTEL_COMPILER")
target_link_options(libcea PUBLIC "/static")
endif()
endif()

# set rpath for dynmaic linkers on non-windows platforms
Expand Down
24 changes: 21 additions & 3 deletions source/bind/c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@

add_installed_library(cea_bindc SHARED bindc.F90)
#include(../cmake/CompilerFlags.cmake)
project_enable_fortran_std(cea_bindc)
target_link_libraries(cea_bindc PRIVATE cea::core fbasics::core)
target_include_directories(cea_bindc PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
install(FILES cea.h cea_enum.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/cea/bindc)
if(WIN32)
# on windows, several dll either need to be installed on the target
# machine, or they need to be statically linked. linking seemed easier than
# finding the path to the various DLLs and installing them.
# If the intel compilers are used, static link the intel runtime
# The appropriate intel flags are different on linux and windows, because

if (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM" OR CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
target_link_options(cea_bindc
PUBLIC "-libs:static")
set_target_properties(cea_bindc PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS ON
PREFIX ""
MSVC_RUNTIME_LIBRARY "MultiThreaded"
)
else()
target_link_options(cea_bindc
PUBLIC "-static-libgfortran"
PUBLIC "-static-libgcc"
PUBLIC "-static-libquadmath")
endif()
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM" OR CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
target_link_options(cea_bindc
PUBLIC "-static-libgfortran"
PUBLIC "-static-libgcc"
PUBLIC "-static-libquadmath")
PUBLIC "-static-intel")
endif()

if (CEA_BUILD_TESTING)
Expand Down
2 changes: 0 additions & 2 deletions source/bind/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import pytest

PROJECT_PYTHON_DIR = Path(__file__).resolve().parents[1]
if str(PROJECT_PYTHON_DIR) not in sys.path:
sys.path.insert(0, str(PROJECT_PYTHON_DIR))


@pytest.fixture(scope="session")
Expand Down
Loading