forked from DOI-USGS/COAWST
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update WWIII to v7.12 and COAWST to v3.7
git-svn-id: https://coawstmodel.sourcerepo.com/coawstmodel/COAWST@1535 48cfb302-6b48-4dc2-989a-fd0c5d807893
- Loading branch information
jcwarner
committed
Apr 16, 2021
1 parent
649ed10
commit ef3549b
Showing
8 changed files
with
4,617 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,107 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
project(ww3nemslib VERSION 7.00 LANGUAGES Fortran) | ||
|
||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
|
||
find_package(NetCDF REQUIRED Fortran) | ||
find_package(MPI REQUIRED) | ||
find_package(ESMF MODULE REQUIRED) | ||
|
||
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") | ||
set(CMAKE_Fortran_FLAGS "-fno-second-underscore -ffree-line-length-none -fconvert=big-endian -O3 -march=native") | ||
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") | ||
set(CMAKE_Fortran_FLAGS "-no-fma -ip -g -i4 -real-size 32 -fp-model precise -assume byterecl -convert big_endian -fno-alias -fno-fnalias -sox -xhost -O3") | ||
endif() | ||
|
||
set(SRCS | ||
constants.ftn | ||
w3adatmd.ftn | ||
w3arrymd.ftn | ||
w3cspcmd.ftn | ||
w3dispmd.ftn | ||
w3fldsmd.ftn | ||
w3flx1md.ftn | ||
w3gdatmd.ftn | ||
w3gsrumd.ftn | ||
w3idatmd.ftn | ||
w3initmd.ftn | ||
w3iobcmd.ftn | ||
w3iogomd.ftn | ||
w3iogrmd.ftn | ||
w3iopomd.ftn | ||
w3iorsmd.ftn | ||
w3iosfmd.ftn | ||
w3iotrmd.ftn | ||
w3nmlmultimd.ftn | ||
w3odatmd.ftn | ||
w3parall.ftn | ||
w3partmd.ftn | ||
w3pro3md.ftn | ||
w3profsmd.ftn | ||
w3sbt1md.ftn | ||
w3sdb1md.ftn | ||
w3servmd.ftn | ||
w3snl1md.ftn | ||
w3src4md.ftn | ||
w3srcemd.ftn | ||
w3timemd.ftn | ||
w3triamd.ftn | ||
w3updtmd.ftn | ||
w3uqckmd.ftn | ||
w3wavemd.ftn | ||
w3wdasmd.ftn | ||
w3wdatmd.ftn | ||
wmesmfmd.ftn | ||
wmfinlmd.ftn | ||
wmgridmd.ftn | ||
wminiomd.ftn | ||
wminitmd.ftn | ||
wmiopomd.ftn | ||
wmmdatmd.ftn | ||
wmscrpmd.ftn | ||
wmunitmd.ftn | ||
wmupdtmd.ftn | ||
wmwavemd.ftn | ||
SCRIP/scrip_constants.f | ||
SCRIP/scrip_errormod.f90 | ||
SCRIP/scrip_grids.f | ||
SCRIP/scrip_interface.ftn | ||
SCRIP/scrip_iounitsmod.f90 | ||
SCRIP/scrip_kindsmod.f90 | ||
SCRIP/scrip_netcdfmod.f90 | ||
SCRIP/scrip_remap_conservative.f | ||
SCRIP/scrip_remap_read.f | ||
SCRIP/scrip_remap_vars.f | ||
SCRIP/scrip_remap_write.f | ||
SCRIP/scrip_timers.f | ||
) | ||
|
||
get_filename_component(aux_dir "${CMAKE_CURRENT_SOURCE_DIR}/../aux" ABSOLUTE) | ||
get_filename_component(ftn_dir "${CMAKE_CURRENT_SOURCE_DIR}/../ftn" ABSOLUTE) | ||
|
||
message(STATUS "aux_dir ${aux_dir}") | ||
message(STATUS "ftn_dir ${ftn_dir}") | ||
|
||
add_executable(w3adc ../aux/w3adc.f) | ||
|
||
foreach(src_file ${SRCS}) | ||
STRING(REGEX REPLACE ".ftn" ".F90" gen_src_file ${src_file}) | ||
STRING(REGEX REPLACE "/" "_" gen_log_file ${gen_src_file}) | ||
add_custom_command( | ||
OUTPUT ${gen_src_file} | ||
DEPENDS w3adc ${ftn_dir}/${src_file} | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/run_w3adc.sh ${ftn_dir} ${src_file} > ${gen_log_file}.w3adc.log 2>&1 | ||
COMMENT "Running w3adc ${src_file}") | ||
list(APPEND SRCS_F90 ${gen_src_file}) | ||
endforeach() | ||
|
||
add_library(ww3_multi_esmf STATIC ${SRCS_F90}) | ||
|
||
set(mod_dir ${CMAKE_CURRENT_BINARY_DIR}/mod) | ||
set_target_properties(ww3_multi_esmf PROPERTIES Fortran_MODULE_DIRECTORY ${mod_dir}) | ||
|
||
target_include_directories(ww3_multi_esmf PUBLIC ${mod_dir}) | ||
target_include_directories(ww3_multi_esmf PRIVATE ${ftn_dir} ${ESMF_MOD}) | ||
|
||
target_link_libraries(ww3_multi_esmf PUBLIC esmf NetCDF::NetCDF_Fortran MPI::MPI_Fortran) |
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,105 @@ | ||
# - Try to find ESMF | ||
# | ||
# Requires setting ESMFMKFILE to the filepath of esmf.mk. If this is NOT set, | ||
# then ESMF_FOUND will always be FALSE. If ESMFMKFILE exists, then ESMF_FOUND=TRUE | ||
# and all ESMF makefile variables will be set in the global scope. Optionally, | ||
# set ESMF_MKGLOBALS to a string list to filter makefile variables. For example, | ||
# to globally scope only ESMF_LIBSDIR and ESMF_APPSDIR variables, use this CMake | ||
# command in CMakeLists.txt: | ||
# | ||
# set(ESMF_MKGLOBALS "LIBSDIR" "APPSDIR") | ||
|
||
|
||
# Add the ESMFMKFILE path to the cache if defined as system env variable | ||
if (DEFINED ENV{ESMFMKFILE} AND NOT DEFINED ESMFMKFILE) | ||
set(ESMFMKFILE $ENV{ESMFMKFILE} CACHE FILEPATH "Path to ESMF mk file") | ||
endif () | ||
|
||
# Found the mk file and ESMF exists on the system | ||
if (EXISTS ${ESMFMKFILE}) | ||
set(ESMF_FOUND TRUE CACHE BOOL "ESMF mk file found" FORCE) | ||
# Did not find the ESMF mk file | ||
else() | ||
set(ESMF_FOUND FALSE CACHE BOOL "ESMF mk file NOT found" FORCE) | ||
# Best to warn users that without the mk file there is no way to find ESMF | ||
if (NOT DEFINED ESMFMKFILE) | ||
message(FATAL_ERROR "ESMFMKFILE not defined. This is the path to esmf.mk file. \ | ||
Without this filepath, ESMF_FOUND will always be FALSE.") | ||
endif () | ||
endif() | ||
|
||
# Only parse the mk file if it is found | ||
if (ESMF_FOUND) | ||
# Read the mk file | ||
file(STRINGS "${ESMFMKFILE}" esmfmkfile_contents) | ||
# Parse each line in the mk file | ||
foreach(str ${esmfmkfile_contents}) | ||
# Only consider uncommented lines | ||
string(REGEX MATCH "^[^#]" def ${str}) | ||
# Line is not commented | ||
if (def) | ||
# Extract the variable name | ||
string(REGEX MATCH "^[^=]+" esmf_varname ${str}) | ||
# Extract the variable's value | ||
string(REGEX MATCH "=.+$" esmf_vardef ${str}) | ||
# Only for variables with a defined value | ||
if (esmf_vardef) | ||
# Get rid of the assignment string | ||
string(SUBSTRING ${esmf_vardef} 1 -1 esmf_vardef) | ||
# Remove whitespace | ||
string(STRIP ${esmf_vardef} esmf_vardef) | ||
# A string or single-valued list | ||
if(NOT DEFINED ESMF_MKGLOBALS) | ||
# Set in global scope | ||
set(${esmf_varname} ${esmf_vardef}) | ||
# Don't display by default in GUI | ||
mark_as_advanced(esmf_varname) | ||
else() # Need to filter global promotion | ||
foreach(m ${ESMF_MKGLOBALS}) | ||
string(FIND ${esmf_varname} ${m} match) | ||
# Found the string | ||
if(NOT ${match} EQUAL -1) | ||
# Promote to global scope | ||
set(${esmf_varname} ${esmf_vardef}) | ||
# Don't display by default in the GUI | ||
mark_as_advanced (esmf_varname) | ||
# No need to search for the current string filter | ||
break() | ||
endif() | ||
endforeach() | ||
endif() | ||
endif() | ||
endif() | ||
endforeach() | ||
|
||
separate_arguments(ESMF_F90COMPILEPATHS NATIVE_COMMAND ${ESMF_F90COMPILEPATHS}) | ||
foreach (ITEM ${ESMF_F90COMPILEPATHS}) | ||
string(REGEX REPLACE "^-I" "" ITEM "${ITEM}") | ||
list(APPEND tmp ${ITEM}) | ||
endforeach() | ||
set(ESMF_F90COMPILEPATHS ${tmp}) | ||
|
||
add_library(esmf UNKNOWN IMPORTED) | ||
# Look for static library, if not found try dynamic library | ||
find_library(esmf_lib NAMES libesmf.a PATHS ${ESMF_LIBSDIR}) | ||
if(esmf_lib MATCHES "esmf_lib-NOTFOUND") | ||
message(STATUS "Static ESMF library not found, searching for dynamic library instead") | ||
find_library(esmf_lib NAMES esmf_fullylinked PATHS ${ESMF_LIBSDIR}) | ||
if(esmf_lib MATCHES "esmf_lib-NOTFOUND") | ||
message(FATAL_ERROR "Neither the dynamic nor the static ESMF library was found") | ||
else() | ||
message(STATUS "Found ESMF library: ${esmf_lib}") | ||
endif() | ||
set(ESMF_INTERFACE_LINK_LIBRARIES "") | ||
else() | ||
# When linking the static library, also need the ESMF linker flags; strip any leading/trailing whitespaces | ||
string(STRIP "${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90LINKLIBS} ${ESMF_F90LINKOPTS}" ESMF_INTERFACE_LINK_LIBRARIES) | ||
message(STATUS "Found ESMF library: ${esmf_lib}") | ||
endif() | ||
|
||
set_target_properties(esmf PROPERTIES | ||
IMPORTED_LOCATION ${esmf_lib} | ||
INTERFACE_INCLUDE_DIRECTORIES "${ESMF_F90COMPILEPATHS}" | ||
INTERFACE_LINK_LIBRARIES "${ESMF_INTERFACE_LINK_LIBRARIES}") | ||
|
||
endif() |
Oops, something went wrong.