Skip to content
Draft
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
43 changes: 23 additions & 20 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# EditorConfig file. For more info, please see:
# https://EditorConfig.org

# top-most EditorConfig file
# Global Editor Config for MAPL
#
# This is an ini style configuration. See http://editorconfig.org/ for more information on this file.
#
# Top level editor config.
root = true

# All files should have a final newline and not have trailing whitespace
# but we need to explicitly enumerate files we care about to prevent random junk
# from being linted
# Always use Unix style new lines with new line ending on every file and trim whitespace
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[{CMakeLists.txt, *.cmake}]
# Python: PEP8 defines 4 spaces for indentation
[*.py]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
max_line_length = 132
insert_final_newline = true
indent_size = 4

[*.md]
max_line_length = off
trim_trailing_whitespace = false
charset = utf-8
insert_final_newline = true
# YAML format, 2 spaces
[{*.yaml,*.yml}]
indent_style = space
indent_size = 2

[*.{yml,yaml,json}]
# CMake (from KitWare: https://github.com/Kitware/CMake/blob/master/.editorconfig)
[{CMakeLists.txt,*.cmake,*.rst}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

# Markdown
[*.md]
trim_trailing_whitespace = true
indent_style = space
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
### Added

## [3.5.2.1] - 2025-01-24

### Changed

- Updates needed to build on SLES15 at NCCS

## [3.5.2] - 2021-Jul-14

### Fixed
Expand Down Expand Up @@ -43,12 +49,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Previous option `CPP_DEBUG_<target` has now been replaced with a
more fine-grained combination of cmake variables: `XFLAGS` and
`XFLAGS_SOURCES`. To use

```
$cmake .. -DXFLAGS="foo bar=7 DEBUG" -DXFLAGS_SOURCES="<file1> <file2>"
$ make
```

NOTE: This change requires checking for specified sources in every
directory (or rather in those that use `esma_set_this()` and thus
add some overhead to cmake. We may later decide to implement a
Expand Down Expand Up @@ -98,7 +104,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added new `ESMA_USE_GFE_NAMESPACE` which defaults to `OFF`. If you set this to `ON`, you must then use the new GFE namespace style in CMake, e.g., `gftl` ==> `GFTL::gftl`.
- Added new `ESMA_USE_GFE_NAMESPACE` which defaults to `OFF`. If you set this to `ON`, you must then use the new GFE namespace style in CMake, e.g., `gftl` ==> `GFTL::gftl`.

## [3.3.7] - 2021-03-09

Expand Down Expand Up @@ -285,7 +291,7 @@ due to the need for yaFyaml and pFlogger
- Added macro to add a post-build check availability of Python modules
Use: `esma_check_python_module(<module>)`
- Added option is `esma_add_library() to use SHARED

## [2.2.1] - 2020-03-27

### Changed
Expand Down
96 changes: 79 additions & 17 deletions DetermineSite.cmake
Original file line number Diff line number Diff line change
@@ -1,29 +1,91 @@
# Set the site variable

set(DETECTED_SITE "UNKNOWN")

# In ecbuild, ecbuild itself sets a site_name for us
# called BUILD_SITE. If it didn't, we could use
# site_name(BUILD_SITE) as they do

if (${BUILD_SITE} MATCHES "discover*" OR ${BUILD_SITE} MATCHES "borg*")
set (DETECTED_SITE "NCCS")
# Here we try to detect the site using the hostname essentially. This we can pretty easily do
# because we know the NASA systems.

if (${BUILD_SITE} MATCHES "discover*" OR ${BUILD_SITE} MATCHES "borg*" OR ${BUILD_SITE} MATCHES "warp*")
set (DETECTED_SITE "NCCS")
# NCCS now has two OSs. We need to detect if we are on SLES 15. If so, we set a flag "BUILT_ON_SLES15"
# which we will use to make sure people building on SLES15 run on SLES15
# The commmand we use in bash is:
# grep VERSION_ID /etc/os-release | cut -d= -f2 | cut -d. -f1 | sed 's/"//g'
execute_process(
COMMAND grep VERSION_ID /etc/os-release
COMMAND cut -d= -f2
COMMAND cut -d. -f1
COMMAND sed s/\"//g
OUTPUT_VARIABLE OS_RELEASE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (OS_RELEASE STREQUAL "15")
set (BUILT_ON_SLES15 TRUE)
else ()
set (BUILT_ON_SLES15 FALSE)
endif ()
elseif (${BUILD_SITE} MATCHES "pfe" OR ${BUILD_SITE} MATCHES "r[0-9]*i[0-9]*n[0-9]*" OR ${BUILD_SITE} MATCHES "r[0-9]*c[0-9]*t[0-9]*n[0-9]*")
set (DETECTED_SITE "NAS")
set (DETECTED_SITE "NAS")
elseif (EXISTS /ford1/share/gmao_SIteam AND EXISTS /ford1/local AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (DETECTED_SITE "GMAO.desktop")
else ()
file(DOWNLOAD http://169.254.169.254/latest/meta-data/instance-id ${CMAKE_CURRENT_BINARY_DIR}/instance-id
INACTIVITY_TIMEOUT 1.0
TIMEOUT 1.0
STATUS DOWNLOAD_STATUS
)
list(GET DOWNLOAD_STATUS 0 RETURN_CODE)

if (RETURN_CODE EQUAL 0)
set (DETECTED_SITE "AWS")
else ()
set (DETECTED_SITE ${BUILD_SITE})
endif ()
set (DETECTED_SITE "GMAO.desktop")
endif ()

# If we didn't detect the site, try to detect AWS
if (NOT DEFINED DETECTED_SITE OR DETECTED_SITE STREQUAL "UNKNOWN")
# Try to detect AWS
file(DOWNLOAD http://169.254.169.254/latest/meta-data/instance-id ${CMAKE_CURRENT_BINARY_DIR}/instance-id
INACTIVITY_TIMEOUT 1.0
TIMEOUT 1.0
STATUS DOWNLOAD_STATUS
)
list(GET DOWNLOAD_STATUS 0 RETURN_CODE)

if (RETURN_CODE EQUAL 0)
set (DETECTED_SITE "AWS")
endif ()
endif ()

# If we didn't detect AWS, we look for Azure
if (NOT DEFINED DETECTED_SITE OR DETECTED_SITE STREQUAL "UNKNOWN")
# Per https://learn.microsoft.com/en-us/azure/virtual-machines/linux/instance-metadata-service?tabs=linux
# it says you can run:
# curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq
# to know more about the instance. Well, we don't need jq, we just need to know if we can get to
# that page. So we'll just try to download it.
file(DOWNLOAD http://169.254.169.254/metadata/instance?api-version=2021-02-01 ${CMAKE_CURRENT_BINARY_DIR}/instance
HTTPHEADER "Metadata:true"
INACTIVITY_TIMEOUT 1.0
TIMEOUT 1.0
STATUS DOWNLOAD_STATUS
)

list(GET DOWNLOAD_STATUS 0 RETURN_CODE)

if (RETURN_CODE EQUAL 0)
set (DETECTED_SITE "Azure")
endif ()
endif ()

# Note: No access to Google Cloud yet but my guess is we do something similar following:
# https://cloud.google.com/compute/docs/instances/detect-compute-engine

# Finally, if we didn't detect anything, we'll just use the BUILD_SITE
if (NOT DEFINED DETECTED_SITE OR DETECTED_SITE STREQUAL "UNKNOWN")
set (DETECTED_SITE ${BUILD_SITE})
endif ()

set(GEOS_SITE ${DETECTED_SITE} CACHE STRING "Detected site for use with GEOS setup scripts")
message(STATUS "Setting GEOS_SITE to ${GEOS_SITE}")

if (DETECTED_SITE STREQUAL "NCCS")
if (BUILT_ON_SLES15)
message(STATUS "Building on SLES15 at NCCS. Can only run on Milan processors")
else ()
message(STATUS "Building on SLES12 at NCCS. Can run on Cascade Lake or Skylake processors")
endif ()
endif ()

25 changes: 19 additions & 6 deletions FindF2PY2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,27 @@
# By default, the module finds the F2PY2 program associated with the installed NumPy package.
#

# Path to the f2py executable
find_package(Python2 COMPONENTS Interpreter)
# It turns out that on machines where Python2 does not exist, this code will still
# find plain "f2py" and think that is f2py2. Even if you remove f2py from the find_program
# call below, it still finds that. So instead, we must disable this code if no Python2
# interpreter is found.

# Find the Python2 interpreter which must exist else we cannot find f2py2
find_package(Python2 COMPONENTS Interpreter QUIET)

# If we do not have a Python2 interpreter, we cannot find f2py2 and we are done
if(NOT Python2_FOUND)
message(WARNING "[F2PY2]: Python2 interpreter not found, we will not search for f2py2. This means f2py2 libraries will not be built. Please convert your code to Python3.")
set(F2PY2_FOUND FALSE)
return()
endif()

# Path to the f2py2 executable
find_program(F2PY2_EXECUTABLE NAMES "f2py${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}"
"f2py-${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}"
"f2py${Python2_VERSION_MAJOR}"
"f2py"
)
"f2py-${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}"
"f2py${Python2_VERSION_MAJOR}"
"f2py"
)

if(F2PY2_EXECUTABLE)
# extract the version string
Expand Down
Loading