Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gsi update #8

Merged
merged 38 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fc4f7df
Bugfixes for CMakeLists.txt to work with multiple kinds
climbfuji Feb 3, 2020
c2718d5
Remove unnecessary line from CMakeLists.txt
climbfuji Feb 4, 2020
ab0b429
Merge pull request #5 from climbfuji/bugfixes_dom_20200203
climbfuji Feb 5, 2020
811c8bd
Create LICENSE file
Hang-Lei-NOAA Feb 24, 2020
b001998
Delete LICENSE
Hang-Lei-NOAA Feb 24, 2020
b57fc82
Create LICENSE file
Hang-Lei-NOAA Feb 24, 2020
eabff7c
Add LGPL license to repository
climbfuji Feb 25, 2020
be83085
Merge pull request #6 from climbfuji/add_lgpl_license
climbfuji Feb 25, 2020
4b4dfae
Update LICENSE.md
Hang-Lei-NOAA Mar 4, 2020
3c88af2
updates to build for GSI
mark-a-potts May 1, 2020
cab6fad
Updates to build for GSI
mark-a-potts May 1, 2020
7433043
Changes for gsi
mark-a-potts May 6, 2020
da497ee
Added in some extra cmake stuff
mark-a-potts May 6, 2020
4457a02
fixed error on include line
mark-a-potts May 6, 2020
ca63cb7
Merge branch 'gsi-update' of github.com:mark-a-potts/NCEPLIBS-bufr in…
mark-a-potts May 6, 2020
9fb33ca
adding cmake files
mark-a-potts Jun 12, 2020
b42777c
Merge branch 'gsi-update' of github.com:mark-a-potts/NCEPLIBS-bufr in…
mark-a-potts Jun 12, 2020
3bd405d
updated
mark-a-potts Jun 15, 2020
058f04d
updates to flags
mark-a-potts Jun 24, 2020
495feca
Merge branch 'gsi-update' of github.com:mark-a-potts/NCEPLIBS-bufr in…
mark-a-potts Jun 24, 2020
e84e8b3
added VERSION
mark-a-potts Jun 24, 2020
623666f
added DUNDERSCORE flags
mark-a-potts Jun 24, 2020
676049d
added dynamic alloc for gnu
mark-a-potts Jun 24, 2020
ac65f1d
returned guard
mark-a-potts Jun 24, 2020
adac342
updated to match new NCEPLIBS interface
mark-a-potts Jun 24, 2020
f0af0a0
removed references to GEOS
mark-a-potts Jun 24, 2020
45f6e7f
Suggested fixes
mark-a-potts Jun 25, 2020
be41f2d
Fixed definitions
mark-a-potts Jun 25, 2020
c5eda35
Reformatted to match other NCEPLIBS structure
mark-a-potts Jun 25, 2020
ebe3d62
Suggested changes
mark-a-potts Jun 25, 2020
80bd416
removed file
mark-a-potts Jun 25, 2020
6c65164
removed directories
mark-a-potts Jun 25, 2020
a180e49
Fixes
mark-a-potts Jun 25, 2020
2bc1a08
More cleanup
mark-a-potts Jun 25, 2020
40a2fd6
Removed definitions that are not working for Intel
mark-a-potts Jun 25, 2020
fcebab0
make consistent with other nceplibs. DA is supported in INtel and GNU…
aerorahul Jul 7, 2020
b4a603d
fix order of files. install headers. check for endian and add endian …
aerorahul Jul 8, 2020
55038a7
Merge pull request #1 from aerorahul/consistency
mark-a-potts Jul 9, 2020
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
137 changes: 23 additions & 114 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,128 +1,37 @@
cmake_minimum_required(VERSION 3.15)
project(bufr VERSION 11.3.0)
set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION} CACHE INTERNAL "${PROJECT_NAME} version number")
enable_language (Fortran)

if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: PRODUCTION Debug Release."
FORCE)
file(STRINGS "VERSION" pVersion)

project(
bufr
VERSION ${pVersion}
LANGUAGES C Fortran)

if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
message(WARNING "Compiler not officially supported: ${CMAKE_C_COMPILER_ID}")
endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
aerorahul marked this conversation as resolved.
Show resolved Hide resolved
set(IntelComp true )
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU*" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang*")
elseif(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
set(GNUComp true )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "pgc*")
set(PGIComp true )
set(allocation_def "DYNAMIC_ALLOCATION")
aerorahul marked this conversation as resolved.
Show resolved Hide resolved
endif()

STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE)
aerorahul marked this conversation as resolved.
Show resolved Hide resolved
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION)
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "DEBUG" BUILD_DEBUG)

option(GSIBUILD "Build only libs for GSI" ON)

set(definitions "UNDERSCORE" "NFILES=32" "MAXCD=250" "MAXNC=600" "MXNAF=3")

if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) )
if(IntelComp)
#shared with C and Fortran
set(shared_flags "-g" "-traceback" "-O3" "-axCORE-AVX2")

set(c_DA_allocation_def "DYNAMIC_ALLOCATION")
set(c_4_DA_flags)
set(c_8_DA_definitions "F77_INTSIZE_8")
set(c_d_DA_flags)

set(fortran_4_DA_flags)
set(fortran_8_DA_flags "-r8" "-i8")
set(fortran_d_DA_flags "-r8")

set(c_nonDA_allocation_def "STATIC_ALLOCATION")
set(c_4_flags)
set(c_8_flags)
set(c_8_definitions "F77_INTSIZE_8")
set(c_d_flags)
set(c_SS_flags "-mcmodel=medium" "-shared")

set(fortran_4_flags)
set(fortran_8_flags "-r8" "-i8")
set(fortran_d_flags "-r8")
set(fortran_SS_flags "-mcmodel=medium" "-shared")

elseif(GNUComp)
set(allocation_def "DYNAMIC_ALLOCATION")
set(shared_flags "-O3" "-ggdb" "-Wall")

set(c_d_flags)
set(c_4_flags)
set(c_8_flags)

set(shared_fortran_flags "-funroll-loops")
set(fortran_4_flags)
set(fortran_d_flags "-fdefault-real-8")
set(fortran_8_flags "-fdefault-integer-8" "-fdefault-real-8")
else()
message("unknown compiler!")
exit()
endif()
endif()


file(GLOB fortran_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f ${CMAKE_CURRENT_SOURCE_DIR}/src/*.F)
file(GLOB c_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)

if(GSIBUILD)
set(kinds "4" "d" "8")
else()
set(kinds "4" "d" "8" "SS" "4_DA" "8_DA" "d_DA")
endif()

foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})
set(versioned_lib_name ${PROJECT_NAME}_v${PROJECT_VERSION}_${kind})
add_library(${lib_name} STATIC ${fortran_src} ${c_src})
set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME "${versioned_lib_name}")

# different compiler definitions for Intel in DA vs non-DA
# -DDYNAMIC_ALLOCATION when compiled with DA and -DSTATIC_ALLOCATION
# check current kind and if it has 'DA' in it then set compiler def

if(IntelComp)
string(FIND ${kind} "DA" isDA)
if(isDA GREATER_EQUAL 0)
set(allocation_def ${c_DA_allocation_def})
else()
set(allocation_def ${c_nonDA_allocation_def})
endif()
endif()

target_compile_definitions(${lib_name} PRIVATE "${allocation_def}")

set_source_files_properties(${c_src} PROPERTIES
COMPILE_OPTIONS "${shared_flags};${c_${kind}_flags}")
set_source_files_properties(${c_src} PROPERTIES
COMPILE_DEFINITIONS "${c_definitions};${c_${kind}_definitions}")

set_source_files_properties(${fortran_src} PROPERTIES
COMPILE_OPTIONS "${shared_flags};${shared_fortran_flags};${fortran_${kind}_flags}")

set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")
set_target_properties(${lib_name} PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}")

target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include_${kind}}>)

install(TARGETS ${lib_name}
EXPORT ${PROJECT_NAME}-config
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
endforeach()

install(EXPORT ${PROJECT_NAME}-config DESTINATION ${CMAKE_INSTALL_PREFIX})
include(GNUInstallDirs)

add_subdirectory(src)
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright 2020 National Oceanic and Atmospheric Administration (by assignment from I. M. Systems Group)

The [NCEPLIBS-bufr] code incorporated in the Unified Forecast System (UFS) was jointly developed by the National Oceanic and Atmospheric Administration and the I. M. Systems Group. The gold standard copy of the Code will be maintained by NOAA at [https://github.com/NOAA-EMC/NCEPLIBS-bufr].

The National Oceanic and Atmospheric Administration is releasing this code under the GNU Lesser General Public License v3.0 (the "License"); you may not use this code except in compliance with the License.

You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11.3.1
20 changes: 20 additions & 0 deletions cmake/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@PACKAGE_INIT@

# * @PROJECT_NAME@::@PROJECT_NAME@_4 - real32 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_8 - real64 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_d - mixed library target
# * @PROJECT_NAME@::@PROJECT_NAME@_DA_4 - real32 library target with dynamic allocation
# * @PROJECT_NAME@::@PROJECT_NAME@_DA_8 - real64 library target with dynamic allocation
# * @PROJECT_NAME@::@PROJECT_NAME@_DA_d - mixed library target with dynamic allocation


# Include targets file. This will create IMPORTED target @PROJECT_NAME@
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")

# Get the build type from real32 library target
get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@_4 IMPORTED_CONFIGURATIONS)

check_required_components("@PROJECT_NAME@")

get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@_4 LOCATION)
message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"@PROJECT_VERSION@\")")
aerorahul marked this conversation as resolved.
Show resolved Hide resolved
27 changes: 27 additions & 0 deletions cmake/osx_extras.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# OSX fixes/workarounds
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved
#
# 1) OS X has links that claim to be gcc and gxx, but they are not.
# They are links to clang equivalents.
# In the future, we'll need a config flag to support both variants.
# But for now we want gcc only.

# 2) On OS X, object files with variables but no code (e.g. simple Fortran module files)
# cause warning messages in the link stage.
# The logic below deactivates the warnings.

foreach(lang Fortran C CXX)
set (CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set (CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> -c -no_warning_for_no_symbols <TARGET>")
# TODO: check next line
# I do not think we need this next line anymore. Keeping it visible in case mistaken.
# set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_compact_unwind")
endforeach()


# 3) Possibly not an OS X issue. Encountered with supporting run of tests when using OpenMP with intel.
# some funny rpath issue
set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set (OSX_EXTRA_LIBRARY_PATH $ENV{OSX_EXTRA_LIBRARY_PATH} CACHE PATH "Fill with DYLD_LIBRARY_PATH.")

# 4) In order for MKL to work at runtim, this is needed
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
111 changes: 111 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
cmake_minimum_required(VERSION 3.15)
aerorahul marked this conversation as resolved.
Show resolved Hide resolved

set(definitions "UNDERSCORE" "NFILES=32" "MAXCD=250" "MAXNC=600" "MXNAF=3")
add_compile_definitions(definitions)

if(InteComp)
set (FREAL8 "-r8")
set (FINT8 "-i8")
set (TRACEBACK "-traceback")
set (MMMED "-mcmodel=medium")
elseif(GNUComp)
set (FREAL8 "-fdefault-double-8" "-fdefault-real-8")
set (FINT8 "-fdefault-integer-8")
set (TRACEBACK "-fbacktrace")
set (MMMED "")
endif()
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved

set(fortran_8_flags ${FREAL8} ${FINT8} ${TRACEBACK})
aerorahul marked this conversation as resolved.
Show resolved Hide resolved
set(shared_flags ${DEBINFO} ${FOPT3} ${AVX2})
aerorahul marked this conversation as resolved.
Show resolved Hide resolved
set(fortran_8_DA_flags ${FREAL8} ${FINT8} ${TRACEBACK})
set(fortran_d_DA_flags ${FREAL8} ${TRACEBACK})
set(c_SS_flags ${MMMED} ${SHARED})
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved


set(c_DA_allocation_def "DYNAMIC_ALLOCATION")
set(c_nonDA_allocation_def "STATIC_ALLOCATION")

set(c_8_DA_definitions "F77_INTSIZE_8")
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved
set(fortran_4_DA_flags)
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved
set(c_8_definitions "F77_INTSIZE_8")
set(fortran_4_flags)
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved

include("list_of_files.cmake")
set(kinds "4" "d" "8" "4_DA" "8_DA" "d_DA")
aerorahul marked this conversation as resolved.
Show resolved Hide resolved

foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})

# different compiler definitions for Intel in DA vs non-DA
# -DDYNAMIC_ALLOCATION when compiled with DA and -DSTATIC_ALLOCATION
# check current kind and if it has 'DA' in it then set compiler def

if(IntelComp)
mark-a-potts marked this conversation as resolved.
Show resolved Hide resolved
string(FIND ${kind} "DA" isDA)
if(isDA GREATER_EQUAL 0)
set(allocation_def ${c_DA_allocation_def})
else()
set(allocation_def ${c_nonDA_allocation_def})
endif()
endif()

add_library(${lib_name}_f STATIC OBJECT ${fortran_src})
set_target_properties(${lib_name}_f PROPERTIES
COMPILE_OPTIONS "${shared_flags};${shared_fortran_flags};${fortran_${kind}_flags}")
set_target_properties(${lib_name}_f PROPERTIES
COMPILE_DEFINITIONS "${allocation_def}")

add_library(${lib_name}_c STATIC OBJECT ${c_src})
set_target_properties(${lib_name}_c PROPERTIES
COMPILE_OPTIONS "${shared_flags};${c_${kind}_flags}")

set_target_properties(${lib_name}_c PROPERTIES
COMPILE_DEFINITIONS "${c_${kind}_definitions};${allocation_def}")

set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")
set_target_properties(${lib_name}_f PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}")

add_library(${lib_name} STATIC $<TARGET_OBJECTS:${lib_name}_f> $<TARGET_OBJECTS:${lib_name}_c>)
add_library(${PROJECT_NAME}::${lib_name} ALIAS ${lib_name})

target_include_directories(${lib_name} INTERFACE
$<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:include_${kind}>)

list(APPEND LIB_TARGETS ${lib_name})
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})

endforeach()

install(
TARGETS ${LIB_TARGETS}
EXPORT ${PROJECT_NAME}Exports
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

### Package config
include(CMakePackageConfigHelpers)
set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})

export(EXPORT ${PROJECT_NAME}Exports
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}-targets.cmake)

configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION})
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})

write_basic_package_version_file(
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})

install(EXPORT ${PROJECT_NAME}Exports
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}-targets.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})
Loading