-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add recipe for gen_domain tools from CIME
- Loading branch information
Showing
5 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.18) | ||
project( | ||
cime_gen_domain | ||
VERSION $ENV{PKG_VERSION} | ||
LANGUAGES Fortran) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) | ||
|
||
include("${CMAKE_SOURCE_DIR}/cmake_macros/gnu.cmake") | ||
|
||
find_package(NETCDF REQUIRED) | ||
|
||
message(STATUS "netcdf_c_incdir=${netcdf_c_incdir}") | ||
message(STATUS "netcdf_c_libs=${netcdf_c_libs}") | ||
message(STATUS "netcdf_f_incdir=${netcdf_f_incdir}") | ||
message(STATUS "netcdf_f_libs=${netcdf_f_libs}") | ||
|
||
SET(SRC ${CMAKE_SOURCE_DIR}/tools/mapping/gen_domain_files/src) | ||
|
||
include_directories(${netcdf_f_incdir}) | ||
add_definitions(-DLINUX) | ||
add_executable(gen_domain ${SRC}/gen_domain.F90) | ||
target_link_libraries(gen_domain ${netcdf_f_libs}) | ||
|
||
install(TARGETS gen_domain DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -x | ||
set -e | ||
|
||
cp -r ${RECIPE_DIR}/cmake ${RECIPE_DIR}/cmake_macros ${RECIPE_DIR}/CMakeLists.txt . | ||
|
||
rm -rf build | ||
mkdir build | ||
cd build | ||
cmake \ | ||
-D CMAKE_INSTALL_PREFIX="${PREFIX}" \ | ||
-D NETCDF_PATH="${PREFIX}" \ | ||
-D CMAKE_BUILD_TYPE=Release \ | ||
.. | ||
cmake --build . | ||
cmake --install . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# - Try to find Netcdf | ||
|
||
function(get_netcdf_libs ncpath nfpath) | ||
|
||
set(ncconfig ${ncpath}/bin/nc-config) | ||
set(nfconfig ${nfpath}/bin/nf-config) | ||
|
||
# Get C libs | ||
if (EXISTS ${ncconfig}) | ||
execute_process(COMMAND ${ncconfig} --libs OUTPUT_VARIABLE nclibs OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
endif() | ||
|
||
# Fall back to find_library | ||
if (NOT nclibs) | ||
find_library(nclibs_temp netcdf REQUIRED HINTS ${ncpath}/lib ${ncpath}/lib64) | ||
set(nclibs ${nclibs_temp}) | ||
endif() | ||
|
||
# Get fortran libs | ||
if (EXISTS ${nfconfig}) | ||
execute_process(COMMAND ${nfconfig} --flibs OUTPUT_VARIABLE nflibs OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
endif() | ||
|
||
if (NOT nflibs) | ||
find_library(nflibs_temp netcdff REQUIRED HINTS ${nfpath}/lib ${nfpath}/lib64) | ||
set(nflibs ${nflibs_temp}) | ||
endif() | ||
|
||
set(netcdf_c_libs ${nclibs} PARENT_SCOPE) | ||
set(netcdf_f_libs ${nflibs} PARENT_SCOPE) | ||
endfunction() | ||
|
||
function(create_netcdf_target) | ||
|
||
# Grab things from env | ||
set(NETCDF_PATH $ENV{NETCDF_PATH}) | ||
set(NETCDF_C_PATH $ENV{NETCDF_C_PATH}) | ||
set(NETCDF_FORTRAN_PATH $ENV{NETCDF_FORTRAN_PATH}) | ||
|
||
if (NETCDF_C_PATH) | ||
# Sanity checks | ||
if (NOT NETCDF_FORTRAN_PATH) | ||
message(FATAL_ERROR "NETCDF_C_PATH specified without NETCDF_FORTRAN_PATH") | ||
endif() | ||
if (NOT EXISTS ${NETCDF_C_PATH}/lib AND NOT EXISTS ${NETCDF_C_PATH}/lib64) | ||
message(FATAL_ERROR "NETCDF_C_PATH does not contain a lib or lib64 directory") | ||
endif () | ||
if (NOT EXISTS ${NETCDF_FORTRAN_PATH}/lib AND NOT EXISTS ${NETCDF_FORTRAN_PATH}/lib64) | ||
message(FATAL_ERROR "NETCDF_FORTRAN_PATH does not contain a lib or lib64 directory") | ||
endif () | ||
|
||
get_netcdf_libs(${NETCDF_C_PATH} ${NETCDF_FORTRAN_PATH}) | ||
find_path (netcdf_c_incdir netcdf.h REQUIRED HINTS ${NETCDF_C_PATH}/include) | ||
find_path (netcdf_f_incdir netcdf.inc REQUIRED HINTS ${NETCDF_FORTRAN_PATH}/include) | ||
|
||
elseif (NETCDF_FORTRAN_PATH) | ||
message(FATAL_ERROR "NETCDF_FORTRAN_PATH specified without NETCDF_C_PATH") | ||
|
||
elseif (NETCDF_PATH) | ||
# Sanity checks | ||
if (NOT EXISTS ${NETCDF_PATH}/lib AND NOT EXISTS ${NETCDF_PATH}/lib64) | ||
message(FATAL_ERROR "NETCDF_PATH does not contain a lib or lib64 directory") | ||
endif () | ||
|
||
get_netcdf_libs(${NETCDF_PATH} ${NETCDF_PATH}) | ||
find_path(netcdf_c_incdir netcdf.h REQUIRED HINTS ${NETCDF_PATH}/include) | ||
find_path(netcdf_f_incdir netcdf.inc REQUIRED HINTS ${NETCDF_PATH}/include) | ||
|
||
else() | ||
message(FATAL_ERROR "NETCDF not found: Define NETCDF_PATH or NETCDF_C_PATH and NETCDF_FORTRAN_PATH in config_machines.xml or config_compilers.xml") | ||
endif() | ||
|
||
set(netcdf_c_incdir ${netcdf_c_incdir}) | ||
set(netcdf_f_incdir ${netcdf_f_incdir}) | ||
set(netcdf_c_libs ${netcdf_c_libs} PARENT_SCOPE) | ||
set(netcdf_f_libs ${netcdf_f_libs} PARENT_SCOPE) | ||
endfunction() | ||
|
||
create_netcdf_target() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") | ||
string(APPEND CMAKE_C_FLAGS "-mcmodel=small") | ||
string(APPEND CMAKE_Fortran_FLAGS "-mcmodel=small") | ||
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") | ||
string(APPEND CMAKE_C_FLAGS " -mcmodel=large") | ||
string(APPEND CMAKE_Fortran_FLAGS " -mcmodel=large") | ||
else() | ||
string(APPEND CMAKE_C_FLAGS "-mcmodel=medium") | ||
string(APPEND CMAKE_Fortran_FLAGS "-mcmodel=medium") | ||
endif() | ||
string(APPEND CMAKE_Fortran_FLAGS " -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") | ||
if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10) | ||
string(APPEND CMAKE_Fortran_FLAGS " -fallow-argument-mismatch") | ||
endif() | ||
string(APPEND CPPDEFS " -DFORTRANUNDERSCORE -DNO_R16 -DCPRGNU") | ||
if (compile_threaded) | ||
string(APPEND CMAKE_C_FLAGS " -fopenmp") | ||
string(APPEND CMAKE_CXX_FLAGS " -fopenmp") | ||
string(APPEND CMAKE_Fortran_FLAGS " -fopenmp") | ||
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fopenmp") | ||
endif() | ||
string(APPEND CMAKE_C_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds -ffpe-trap=invalid,zero,overflow") | ||
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -g -Wall -fbacktrace") | ||
string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -g -Wall -fbacktrace -fcheck=bounds,pointer -ffpe-trap=invalid,zero,overflow") | ||
string(APPEND CPPDEFS_DEBUG " -DYAKL_DEBUG") | ||
string(APPEND CMAKE_C_FLAGS_RELEASE " -O") | ||
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O") | ||
string(APPEND CMAKE_Fortran_FLAGS_RELEASE " -O") | ||
if (COMP_NAME STREQUAL csm_share) | ||
string(APPEND CMAKE_C_FLAGS " -std=c99") | ||
endif() | ||
string(APPEND CMAKE_Fortran_FORMAT_FIXED_FLAG " -ffixed-form") | ||
string(APPEND CMAKE_Fortran_FORMAT_FREE_FLAG " -ffree-form") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{% set name = "cime_gen_domain" %} | ||
{% set version = "6.0.234" %} | ||
|
||
package: | ||
name: {{ name|lower }} | ||
version: {{ version }} | ||
|
||
source: | ||
- url: https://github.com/ESMCI/cime/archive/refs/tags/cime{{ version }}.tar.gz | ||
sha256: 9596339ac0dcec4d2b2817d526ea8eabc27bdfcd6903bd58a14add21f2f1afcd | ||
|
||
build: | ||
skip: true # [not linux] | ||
number: 0 | ||
|
||
requirements: | ||
build: | ||
- {{ compiler('fortran') }} | ||
- {{ stdlib("c") }} | ||
- cmake | ||
host: | ||
- hdf5 | ||
- hdf5 * nompi_* | ||
- libnetcdf | ||
- libnetcdf * nompi_* | ||
- netcdf-fortran | ||
- netcdf-fortran * nompi_* | ||
|
||
test: | ||
requires: | ||
- curl | ||
- nccmp | ||
commands: | ||
- curl -O https://web.lcrc.anl.gov/public/e3sm/inputdata/cpl/gridmaps/IcoswISC30E3r5/map_IcoswISC30E3r5_to_ne30pg2_traave.20231121.nc | ||
- curl -O https://web.lcrc.anl.gov/public/e3sm/inputdata/share/domains/domain.ocn.IcoswISC30E3r5.231121.nc | ||
- curl -O https://web.lcrc.anl.gov/public/e3sm/inputdata/share/domains/domain.lnd.ne30pg2_IcoswISC30E3r5.231121.nc | ||
- curl -O https://web.lcrc.anl.gov/public/e3sm/inputdata/share/domains/domain.ocn.ne30pg2_IcoswISC30E3r5.231121.nc | ||
- gen_domain -o IcoswISC30E3r5 -l ne30pg2 -m map_IcoswISC30E3r5_to_ne30pg2_traave.20231121.nc | ||
- nccmp -d -T 0.0 domain.ocn.IcoswISC30E3r5.*.nc | ||
- nccmp -d -T 0.0 domain.lnd.ne30pg2_IcoswISC30E3r5.*.nc | ||
- nccmp -d -T 0.0 domain.ocn.ne30pg2_IcoswISC30E3r5.*.nc | ||
|
||
about: | ||
home: https://github.com/ESMCI/cime | ||
license: NCSA | ||
license_family: OTHER | ||
license_file: LICENSE.TXT | ||
summary: The gen_domain tool from Common Infrastructure for Modeling the Earth (CIME) | ||
doc_url: http://esmci.github.io/cime | ||
dev_url: https://github.com/ESMCI/cime | ||
|
||
extra: | ||
recipe-maintainers: | ||
- xylar |