diff --git a/.github/workflows/extbuild.yml b/.github/workflows/extbuild.yml new file mode 100644 index 0000000000..821654ba1e --- /dev/null +++ b/.github/workflows/extbuild.yml @@ -0,0 +1,110 @@ +# This is a basic workflow to help you get started with Actions +name: extbuild +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # Build the ESMF library, if the cache contains a previous build it will be used instead + build-cdeps: + runs-on: ubuntu-latest + env: + CC: mpicc + FC: mpifort + CXX: mpicxx + CPPFLAGS: "-I/usr/include -I/usr/local/include" + steps: + - uses: actions/checkout@v2 + - id: cache-esmf + uses: actions/cache@v2 + with: + path: ~/ESMF + key: ${{ runner.os }}-ESMF + - id: load-env + run: sudo apt-get install gfortran wget openmpi-bin netcdf-bin libopenmpi-dev + + - id: build-ESMF + if: steps.cache-esmf.outputs.cache-hit != 'true' + run: | + wget https://github.com/esmf-org/esmf/archive/ESMF_8_1_0_beta_snapshot_25.tar.gz + tar -xzvf ESMF_8_1_0_beta_snapshot_25.tar.gz + pushd esmf-ESMF_8_1_0_beta_snapshot_25 + export ESMF_DIR=`pwd` + export ESMF_COMM=openmpi + export ESMF_YAMLCPP="internal" + export ESMF_INSTALL_PREFIX=$HOME/ESMF + export ESMF_BOPT=g + make + make install + popd + - id: cache-pnetcdf + uses: actions/cache@v2 + with: + path: ~/pnetcdf + key: ${{ runner.os }}-pnetcdf + - name: pnetcdf build + if: steps.cache-pnetcdf.outputs.cache-hit != 'true' + run: | + wget https://parallel-netcdf.github.io/Release/pnetcdf-1.12.1.tar.gz + tar -xzvf pnetcdf-1.12.1.tar.gz + ls -l + pushd pnetcdf-1.12.1 + ./configure --prefix=$HOME/pnetcdf --enable-shared --disable-cxx + make + make install + popd + - name: Cache netcdf-fortran + id: cache-netcdf-fortran + uses: actions/cache@v2 + with: + path: ~/netcdf-fortran + key: ${{ runner.os }}-netcdf-fortran + - name: netcdf fortran build + if: steps.cache-netcdf-fortran.outputs.cache-hit != 'true' + run: | + sudo apt-get install libnetcdf-dev + wget https://github.com/Unidata/netcdf-fortran/archive/v4.5.2.tar.gz + tar -xzvf v4.5.2.tar.gz + ls -l + pushd netcdf-fortran-4.5.2 + ./configure --prefix=$HOME/netcdf-fortran + make + make install + + - name: Cache PIO + id: cache-PIO + uses: actions/cache@v2 + with: + path: ~/pio + key: ${{ runner.os }}-pio + restore-keys: | + ${{ runner.os }}-netcdf-fortran + ${{ runner.os }}-pnetcdf + - name: Build PIO + if: steps.cache-PIO.outputs.cache-hit != 'true' + run: | + wget https://github.com/NCAR/ParallelIO/releases/download/pio_2_5_1/pio-2.5.1.tar.gz + tar -xzvf pio-2.5.1.tar.gz + mkdir build-pio + pushd build-pio + cmake -Wno-dev -DNetCDF_C_LIBRARY=/usr/lib/x86_64-linux-gnu/libnetcdf.so -DNetCDF_C_INCLUDE_DIR=/usr/include -DCMAKE_PREFIX_PATH=/usr -DCMAKE_INSTALL_PREFIX=$HOME/pio -DPIO_HDF5_LOGGING=On -DPIO_USE_MALLOC=On -DPIO_ENABLE_LOGGING=On -DPIO_ENABLE_TIMING=Off -DNetCDF_Fortran_PATH=$HOME/netcdf-fortran -DPnetCDF_PATH=$HOME/pnetcdf ../pio-2.5.1 + make VERBOSE=1 + make install + popd + + - name: Build CDEPS + run: | + export ESMFMKFILE=$HOME/ESMF/lib/libg/Linux.gfortran.64.openmpi.default/esmf.mk + export PIO=$HOME/pio + git submodule init + git submodule update + mkdir build-cdeps + pushd build-cdeps + cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_Fortran_FLAGS="-g -Wall -ffree-form -ffree-line-length-none" ../ + make VERBOSE=1 + popd diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..eff7950f69 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "fox"] + path = fox + url = https://github.com/ESMCI/fox.git diff --git a/CMakeLists.txt b/CMakeLists.txt index d3b12130fb..1dc0570676 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,12 @@ project(NUOPC_DATA_MODELS LANGUAGES Fortran VERSION 0.1) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) include(ExternalProject) find_package(ESMF REQUIRED) +if (DEFINED PIO) + set(PIO_PATH ${PIO}) +else() + set(PIO_PATH $ENV{PIO}) +endif() +find_package(PIO REQUIRED COMPONENT C Fortran PATH ${PIO_PATH}) if (DEFINED CIMEROOT) message("Using CIME in ${CIMEROOT} with compiler ${COMPILER}") @@ -11,7 +17,6 @@ if (DEFINED CIMEROOT) if (${PIO_VERSION} LESS 2) message( FATAL_ERROR "Version 2 of the PIO library required") endif() - set(FOX ${LIBROOT}) set(CMAKE_Fortran_FLAGS "${FFLAGS} -I${LIBROOT}/include -I${LIBROOT}/finclude -I${LIBROOT}/nuopc/esmf/${NINST_VALUE}/include") else () set(BLD_STANDALONE TRUE) @@ -23,10 +28,10 @@ endif() if(BLD_STANDALONE) add_subdirectory(share) list(APPEND EXTRA_LIBS cdeps_share) - list(APPEND EXTRA_INCLUDES "${PIO_INCDIR}" "${CMAKE_BINARY_DIR}/share" ) + list(APPEND EXTRA_INCLUDES "${CMAKE_BINARY_DIR}/share" ) endif() - +add_subdirectory(fox) add_subdirectory(streams) add_subdirectory(dshr) diff --git a/cime_config/buildlib b/cime_config/buildlib index 24a498e032..5ab48bea79 100755 --- a/cime_config/buildlib +++ b/cime_config/buildlib @@ -22,7 +22,6 @@ logger = logging.getLogger(__name__) def buildlib(bldroot, libroot, case, compname=None): if bldroot.endswith("obj") and not compname: compname = os.path.basename(os.path.abspath(os.path.join(bldroot,os.pardir))) - print "HERE compname is {} libroot={} bldroot={}".format(compname, libroot, bldroot) if case.get_value("DEBUG"): strdebug = "debug" @@ -58,6 +57,8 @@ def buildlib(bldroot, libroot, case, compname=None): cmake_flags += " -DCMAKE_INSTALL_PREFIX={} ".format(libroot) cmake_flags += " -DLIBROOT={} ".format(libroot) + srcpath cmake_flags += " -DMPILIB={} ".format(mpilib) + cmake_flags += " -DPIO_C_LIBRARY={path}/lib -DPIO_C_INCLUDE_DIR={path}/include ".format(path=os.path.join(case.get_value("EXEROOT"),sharedpath)) + cmake_flags += " -DPIO_Fortran_LIBRARY={path}/lib -DPIO_Fortran_INCLUDE_DIR={path}/include ".format(path=os.path.join(case.get_value("EXEROOT"),sharedpath)) logger.info("cmake_flags {}".format(cmake_flags)) s,o,e = run_cmd("cmake {} ".format(cmake_flags), from_dir=bldroot, verbose=True) diff --git a/cmake/FindPIO.cmake b/cmake/FindPIO.cmake new file mode 100644 index 0000000000..2a7af648aa --- /dev/null +++ b/cmake/FindPIO.cmake @@ -0,0 +1,103 @@ +# - Try to find PIO +# +# This can be controled by setting PIO_PATH or PIO__PATH Cmake variables, +# where is the COMPONENT language one needs. +# +# Once done, this will define: +# +# PIO__FOUND (BOOL) - system has PIO +# PIO__IS_SHARED (BOOL) - whether the library is shared/dynamic +# PIO__INCLUDE_DIR (PATH) - Location of the header files and modules +# PIO__LIBRARY (File) - Path to the library files +# PIO__LIBRARIES (List) - link these to use PIO +# +# Available COMPONENTS are: C Fortran +# If no components are specified only C is assumed +include (LibFind) +include (LibCheck) + +# Define PIO C Component +define_package_component(PIO DEFAULT + COMPONENT C + INCLUDE_NAMES pio.h + LIBRARY_NAMES pioc) + +# Define PIO Fortran Component +define_package_component(PIO + COMPONENT Fortran + INCLUDE_NAMES pio.mod pio.inc + LIBRARY_NAMES piof) + +# Search for list of valid components requested +find_valid_components(PIO) + +#============================================================================== +# SEARCH FOR VALIDATED COMPONENTS +foreach (pcomp IN LISTS PIO_FIND_VALID_COMPONENTS) + + # If not found already, search... + if (NOT PIO_${pcomp}_FOUND) + + # Manually add the MPI include and library dirs to search paths + # and search for the package component + if (MPI_${pcomp}_FOUND) + initialize_paths (PIO_${pcomp}_PATHS + INCLUDE_DIRECTORIES ${MPI_${pcomp}_INCLUDE_PATH} + LIBRARIES ${MPI_${pcomp}_LIBRARIES}) + find_package_component(PIO COMPONENT ${pcomp} + PATHS ${PIO_${pcomp}_PATHS}) + else () + find_package_component(PIO COMPONENT ${pcomp} HINT PIO_${pcomp}_PATH=${PIO_PATH}) + endif () + + # Continue only if component found + if (PIO_${pcomp}_FOUND) + + # Checks + if (pcomp STREQUAL C) + + # Check version + check_version (PIO + NAME "pio_meta.h" + HINTS ${PIO_C_INCLUDE_DIRS} + MACRO_REGEX "PIO_VERSION_") + + endif () + + # Dependencies + if (pcomp STREQUAL C AND NOT PIO_C_IS_SHARED) + + # DEPENDENCY: PnetCDF (if PnetCDF enabled) + check_macro (PIO_HAS_PNETCDF + NAME TryPIO_PNETCDF.c + HINTS ${CMAKE_MODULE_PATH} + DEFINITIONS -I${PIO_C_INCLUDE_DIR} + COMMENT "whether PIO has PnetCDF support") + if (PIO_HAS_PNETCDF) + find_package (PnetCDF COMPONENTS C) + endif () + + + elseif (pcomp STREQUAL Fortran AND NOT PIO_Fortran_IS_SHARED) + + # DEPENDENCY: PIO + set (orig_comp ${pcomp}) + set (orig_comps ${PIO_FIND_VALID_COMPONENTS}) + find_package (PIO COMPONENTS C) + set (PIO_FIND_VALID_COMPONENTS ${orig_comps}) + set (pcomp ${orig_comp}) + if (PIO_C_FOUND) + list (APPEND PIO_Fortran_INCLUDE_DIRS ${PIO_C_INCLUDE_DIRS}) + list (APPEND PIO_Fortran_LIBRARIES ${PIO_C_LIBRARIES}) + endif () + + endif () + + endif () + + endif () + +endforeach () +message("PIO_C_FOUND ${PIO_C_FOUND}") +message("PIO_Fortran_FOUND ${PIO_Fortran_FOUND}") +message("PIO_Fortran_INCLUDE_DIR ${PIO_Fortran_INCLUDE_DIR}") diff --git a/cmake/LibCheck.cmake b/cmake/LibCheck.cmake new file mode 100644 index 0000000000..3f12bdf796 --- /dev/null +++ b/cmake/LibCheck.cmake @@ -0,0 +1,104 @@ +include (CMakeParseArguments) +include (CheckFunctionExists) +#============================================================================== +# +# FUNCTIONS TO HELP WITH Check* MODULES +# +#============================================================================== + +#______________________________________________________________________________ +# - Basic function to check a property of a package using a try_compile step +# +# SYNTAX: check_macro ( +# NAME +# HINTS ... +# DEFINITIONS ... +# COMMENT ) +# +function (check_macro VARIABLE) + + # Parse the input arguments + set (oneValueArgs COMMENT NAME) + set (multiValueArgs HINTS DEFINITIONS) + cmake_parse_arguments (${VARIABLE} "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # If the return variable is defined, already, don't continue + if (NOT DEFINED ${VARIABLE}) + + message (STATUS "Checking ${${VARIABLE}_COMMENT}") + find_file (${VARIABLE}_TRY_FILE + NAMES ${${VARIABLE}_NAME} + HINTS ${${VARIABLE}_HINTS}) + if (${VARIABLE}_TRY_FILE) + try_compile (COMPILE_RESULT + ${CMAKE_CURRENT_BINARY_DIR}/try${VARIABLE} + SOURCES ${${VARIABLE}_TRY_FILE} + COMPILE_DEFINITIONS ${${VARIABLE}_DEFINITIONS} + OUTPUT_VARIABLE TryOUT) + if (COMPILE_RESULT) + message (STATUS "Checking ${${VARIABLE}_COMMENT} - yes") + else () + message (STATUS "Checking ${${VARIABLE}_COMMENT} - no") + endif () + + set (${VARIABLE} ${COMPILE_RESULT} + CACHE BOOL "${${VARIABLE}_COMMENT}") + + else () + message (STATUS "Checking ${${VARIABLE}_COMMENT} - failed") + endif () + + unset (${VARIABLE}_TRY_FILE CACHE) + endif () + +endfunction () + +#______________________________________________________________________________ +# - Basic function to check the version of a package using a try_run step +# +# SYNTAX: check_version ( +# NAME +# HINTS ... +# DEFINITIONS ...) +# +function (check_version PKG) + + # Parse the input arguments + set (oneValueArgs NAME MACRO_REGEX) + set (multiValueArgs HINTS) + cmake_parse_arguments (${PKG} "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # If the return variable is defined, already, don't continue + if (NOT DEFINED ${PKG}_VERSION) + + message (STATUS "Checking ${PKG} version") + find_file (${PKG}_VERSION_HEADER + NAMES ${${PKG}_NAME} + HINTS ${${PKG}_HINTS}) + if (${PKG}_VERSION_HEADER) + set (def) + file (STRINGS ${${PKG}_VERSION_HEADER} deflines + REGEX "^#define[ \\t]+${${PKG}_MACRO_REGEX}") + foreach (defline IN LISTS deflines) + string (REPLACE "\"" "" defline "${defline}") + string (REPLACE "." "" defline "${defline}") + string (REGEX REPLACE "[ \\t]+" ";" deflist "${defline}") + list (GET deflist 2 arg) + list (APPEND def ${arg}) + endforeach () + string (REPLACE ";" "." vers "${def}") + message (STATUS "Checking ${PKG} version - ${vers}") + set (${PKG}_VERSION ${vers} + CACHE STRING "${PKG} version string") + if (${PKG}_VERSION VERSION_LESS ${PKG}_FIND_VERSION}) + message (FATAL_ERROR "${PKG} version insufficient") + endif () + else () + message (STATUS "Checking ${PKG} version - failed") + endif () + + unset (${PKG}_VERSION_HEADER CACHE) + + endif () + +endfunction () \ No newline at end of file diff --git a/cmake/LibFind.cmake b/cmake/LibFind.cmake new file mode 100644 index 0000000000..61cd93aa37 --- /dev/null +++ b/cmake/LibFind.cmake @@ -0,0 +1,333 @@ +include (CMakeParseArguments) +include(FindPackageHandleStandardArgs) + +#============================================================================== +# +# FUNCTIONS TO HELP WITH Find* MODULES +# +#============================================================================== + +#______________________________________________________________________________ +# - Wrapper for finding static libraries ONLY +# +macro (find_static_library) + set (_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) + find_library(${ARGN}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset (_CMAKE_FIND_LIBRARY_SUFFIXES) +endmacro () + + +#______________________________________________________________________________ +# - Wrapper for finding shared/dynamic libraries ONLY +# +macro (find_shared_library) + set (_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + find_library(${ARGN}) + set (CMAKE_FIND_LIBRARY_SUFFIXES ${_CMAKE_FIND_LIBRARY_SUFFIXES}) + unset (_CMAKE_FIND_LIBRARY_SUFFIXES) +endmacro () + + +#______________________________________________________________________________ +# - Function to determine type (SHARED or STATIC) of library +# +# Input: +# LIB (FILE) +# +# Returns: +# RETURN_VAR (BOOL) +# +function (is_shared_library RETURN_VAR LIB) + get_filename_component(libext ${LIB} EXT) + if (libext MATCHES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + set (${RETURN_VAR} TRUE PARENT_SCOPE) + else () + set (${RETURN_VAR} FALSE PARENT_SCOPE) + endif () +endfunction () + + +#______________________________________________________________________________ +# - Function to define a valid package component +# +# Input: +# ${PKG}_DEFAULT (BOOL) +# ${PKG}_COMPONENT (STRING) +# ${PKG}_INCLUDE_NAMES (LIST) +# ${PKG}_LIBRARY_NAMES (LIST) +# +# Returns: +# ${PKG}_DEFAULT_COMPONENT (STRING) +# ${PKG}_VALID_COMPONENTS (LIST) +# ${PKG}_${COMPONENT}_INCLUDE_NAMES (LIST) +# ${PKG}_${COMPONENT}_LIBRARY_NAMES (LIST) +# +function (define_package_component PKG) + + # Parse the input arguments + set (options DEFAULT) + set (oneValueArgs COMPONENT) + set (multiValueArgs INCLUDE_NAMES LIBRARY_NAMES) + cmake_parse_arguments (${PKG} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if (${PKG}_COMPONENT) + set (PKGCOMP ${PKG}_${${PKG}_COMPONENT}) + else () + set (PKGCOMP ${PKG}) + endif () + + # Set return values + if (${PKG}_COMPONENT) + if (${PKG}_DEFAULT) + set (${PKG}_DEFAULT_COMPONENT ${${PKG}_COMPONENT} PARENT_SCOPE) + endif () + set (VALID_COMPONENTS ${${PKG}_VALID_COMPONENTS}) + list (APPEND VALID_COMPONENTS ${${PKG}_COMPONENT}) + set (${PKG}_VALID_COMPONENTS ${VALID_COMPONENTS} PARENT_SCOPE) + endif () + set (${PKGCOMP}_INCLUDE_NAMES ${${PKG}_INCLUDE_NAMES} PARENT_SCOPE) + set (${PKGCOMP}_LIBRARY_NAMES ${${PKG}_LIBRARY_NAMES} PARENT_SCOPE) + +endfunction () + + +#______________________________________________________________________________ +# - Function to find valid package components +# +# Assumes pre-defined variables: +# ${PKG}_FIND_COMPONENTS (LIST) +# ${PKG}_DEFAULT_COMPONENT (STRING) +# ${PKG}_VALID_COMPONENTS (LIST) +# +# Returns: +# ${PKG}_FIND_VALID_COMPONENTS (LIST) +# +function (find_valid_components PKG) + + if (NOT ${PKG}_FIND_COMPONENTS) + set (${PKG}_FIND_COMPONENTS ${${PKG}_DEFAULT_COMPONENT}) + endif () + + set (FIND_VALID_COMPONENTS) + foreach (comp IN LISTS ${PKG}_FIND_COMPONENTS) + if (";${${PKG}_VALID_COMPONENTS};" MATCHES ";${comp};") + list (APPEND FIND_VALID_COMPONENTS ${comp}) + endif () + endforeach () + + set (${PKG}_FIND_VALID_COMPONENTS ${FIND_VALID_COMPONENTS} PARENT_SCOPE) + +endfunction () + + +#______________________________________________________________________________ +# - Initialize a list of paths from a list of includes and libraries +# +# Input: +# INCLUDE_DIRECTORIES +# LIBRARIES +# +# Ouput: +# ${PATHLIST} +# +function (initialize_paths PATHLIST) + + # Parse the input arguments + set (multiValueArgs INCLUDE_DIRECTORIES LIBRARIES) + cmake_parse_arguments (INIT "" "" "${multiValueArgs}" ${ARGN}) + + set (paths) + foreach (inc IN LISTS INIT_INCLUDE_DIRECTORIES) + list (APPEND paths ${inc}) + get_filename_component (dname ${inc} NAME) + if (dname MATCHES "include") + get_filename_component (prefx ${inc} PATH) + list (APPEND paths ${prefx}) + endif () + endforeach () + foreach (lib IN LISTS INIT_LIBRARIES) + get_filename_component (libdir ${lib} PATH) + list (APPEND paths ${libdir}) + get_filename_component (dname ${libdir} PATH) + if (dname MATCHES "lib") + get_filename_component (prefx ${libdir} PATH) + list (APPEND paths ${prefx}) + endif () + endforeach () + + set (${PATHLIST} ${paths} PARENT_SCOPE) + +endfunction () + + +#______________________________________________________________________________ +# - Basic find package macro for a specific component +# +# Assumes pre-defined variables: +# ${PKG}_${COMP}_INCLUDE_NAMES or ${PKG}_INCLUDE_NAMES +# ${PKG}_${COMP}_LIBRARY_NAMES or ${PKG}_LIBRARY_NAMES +# +# Input: +# ${PKG}_COMPONENT +# ${PKG}_HINTS +# ${PKG}_PATHS +# +function (find_package_component PKG) + + # Parse the input arguments + set (options) + set (oneValueArgs COMPONENT) + set (multiValueArgs HINTS PATHS) + cmake_parse_arguments (${PKG} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + set (COMP ${${PKG}_COMPONENT}) + if (COMP) + set (PKGCOMP ${PKG}_${COMP}) + else () + set (PKGCOMP ${PKG}) + endif () + string (TOUPPER ${PKG} PKGUP) + string (TOUPPER ${PKGCOMP} PKGCOMPUP) + + # Only continue if package not found already + if (NOT ${PKGCOMP}_FOUND) + + # Handle QUIET and REQUIRED arguments + if (${${PKG}_FIND_QUIETLY}) + set (${PKGCOMP}_FIND_QUIETLY TRUE) + endif () + if (${${PKG}_FIND_REQUIRED}) + set (${PKGCOMP}_FIND_REQUIRED TRUE) + endif () + + # Determine search order + set (SEARCH_DIRS) + if (${PKG}_HINTS) + list (APPEND SEARCH_DIRS ${${PKG}_HINTS}) + endif () + if (${PKGCOMP}_PATH) + list (APPEND SEARCH_DIRS ${${PKGCOMP}_PATH}) + endif () + if (${PKG}_PATH) + list (APPEND SEARCH_DIRS ${${PKG}_PATH}) + endif () + if (DEFINED ENV{${PKGCOMPUP}}) + list (APPEND SEARCH_DIRS $ENV{${PKGCOMPUP}}) + endif () + if (DEFINED ENV{${PKGUP}}) + list (APPEND SEARCH_DIRS $ENV{${PKGUP}}) + endif () + if (CMAKE_SYSTEM_PREFIX_PATH) + list (APPEND SEARCH_DIRS ${CMAKE_SYSTEM_PREFIX_PATH}) + endif () + if (${PKG}_PATHS) + list (APPEND SEARCH_DIRS ${${PKG}_PATHS}) + endif () + + # Start the search for the include file and library file. Only overload + # if the variable is not defined. + foreach (suffix PREFIX LIBRARY INCLUDE_DIR) + if (NOT DEFINED ${PKGCOMP}_${suffix}) + set (${PKGCOMP}_${suffix} ${PKGCOMP}_${suffix}-NOTFOUND) + endif () + endforeach () + + foreach (dir IN LISTS SEARCH_DIRS) + + # Search for include file names in current dirrectory + foreach (iname IN LISTS ${PKGCOMP}_INCLUDE_NAMES) + if (EXISTS ${dir}/${iname}) + set (${PKGCOMP}_PREFIX ${dir}) + set (${PKGCOMP}_INCLUDE_DIR ${dir}) + break () + endif () + if (EXISTS ${dir}/include/${iname}) + set (${PKGCOMP}_PREFIX ${dir}) + set (${PKGCOMP}_INCLUDE_DIR ${dir}/include) + break () + endif () + endforeach () + + # Search for library file names in the found prefix only! + if (${PKGCOMP}_PREFIX) + find_library (${PKGCOMP}_LIBRARY + NAMES ${${PKGCOMP}_LIBRARY_NAMES} + PATHS ${${PKGCOMP}_PREFIX} + PATH_SUFFIXES lib + NO_DEFAULT_PATH) + + # If found, check if library is static or dynamic + if (${PKGCOMP}_LIBRARY) + is_shared_library (${PKGCOMP}_IS_SHARED ${${PKGCOMP}_LIBRARY}) + + # If we want only shared libraries, and it isn't shared... + if (PREFER_SHARED AND NOT ${PKGCOMP}_IS_SHARED) + find_shared_library (${PKGCOMP}_SHARED_LIBRARY + NAMES ${${PKGCOMP}_LIBRARY_NAMES} + PATHS ${${PKGCOMP}_PREFIX} + PATH_SUFFIXES lib + NO_DEFAULT_PATH) + if (${PKGCOMP}_SHARED_LIBRARY) + set (${PKGCOMP}_LIBRARY ${${PKGCOMP}_SHARED_LIBRARY}) + set (${PKGCOMP}_IS_SHARED TRUE) + endif () + + # If we want only static libraries, and it is shared... + elseif (PREFER_STATIC AND ${PKGCOMP}_IS_SHARED) + find_static_library (${PKGCOMP}_STATIC_LIBRARY + NAMES ${${PKGCOMP}_LIBRARY_NAMES} + PATHS ${${PKGCOMP}_PREFIX} + PATH_SUFFIXES lib + NO_DEFAULT_PATH) + if (${PKGCOMP}_STATIC_LIBRARY) + set (${PKGCOMP}_LIBRARY ${${PKGCOMP}_STATIC_LIBRARY}) + set (${PKGCOMP}_IS_SHARED FALSE) + endif () + endif () + endif () + + # If include dir and library both found, then we're done + if (${PKGCOMP}_INCLUDE_DIR AND ${PKGCOMP}_LIBRARY) + break () + + # Otherwise, reset the search variables and continue + else () + set (${PKGCOMP}_PREFIX ${PKGCOMP}_PREFIX-NOTFOUND) + set (${PKGCOMP}_INCLUDE_DIR ${PKGCOMP}_INCLUDE_DIR-NOTFOUND) + set (${PKGCOMP}_LIBRARY ${PKGCOMP}_LIBRARY-NOTFOUND) + endif () + endif () + + endforeach () + + # handle the QUIETLY and REQUIRED arguments and + # set NetCDF_C_FOUND to TRUE if all listed variables are TRUE + find_package_handle_standard_args (${PKGCOMP} DEFAULT_MSG + ${PKGCOMP}_LIBRARY + ${PKGCOMP}_INCLUDE_DIR) + mark_as_advanced (${PKGCOMP}_INCLUDE_DIR ${PKGCOMP}_LIBRARY) + + # HACK For bug in CMake v3.0: + set (${PKGCOMP}_FOUND ${${PKGCOMPUP}_FOUND}) + + # Set return variables + if (${PKGCOMP}_FOUND) + set (${PKGCOMP}_INCLUDE_DIRS ${${PKGCOMP}_INCLUDE_DIR}) + set (${PKGCOMP}_LIBRARIES ${${PKGCOMP}_LIBRARY}) + endif () + + # Set variables in parent scope + set (${PKGCOMP}_FOUND ${${PKGCOMP}_FOUND} PARENT_SCOPE) + set (${PKGCOMP}_INCLUDE_DIR ${${PKGCOMP}_INCLUDE_DIR} PARENT_SCOPE) + set (${PKGCOMP}_INCLUDE_DIRS ${${PKGCOMP}_INCLUDE_DIRS} PARENT_SCOPE) + set (${PKGCOMP}_LIBRARY ${${PKGCOMP}_LIBRARY} PARENT_SCOPE) + set (${PKGCOMP}_LIBRARIES ${${PKGCOMP}_LIBRARIES} PARENT_SCOPE) + set (${PKGCOMP}_IS_SHARED ${${PKGCOMP}_IS_SHARED} PARENT_SCOPE) + + endif () + +endfunction () + + + diff --git a/datm/CMakeLists.txt b/datm/CMakeLists.txt index 61785d7d1c..a39d02e234 100644 --- a/datm/CMakeLists.txt +++ b/datm/CMakeLists.txt @@ -12,4 +12,4 @@ target_include_directories (datm PUBLIC "${CMAKE_BINARY_DIR}/dshr") target_include_directories (datm PUBLIC "${CMAKE_SOURCE_DIR}") target_include_directories (datm PUBLIC "${CMAKE_BINARY_DIR}/share") target_include_directories (datm PUBLIC "${CMAKE_BINARY_DIR}/streams") -target_include_directories (datm PUBLIC "${PIO_INCDIR}") +target_include_directories (datm PUBLIC "${PIO_Fortran_INCLUDE_DIR}") diff --git a/datm/atm_comp_nuopc.F90 b/datm/atm_comp_nuopc.F90 index f2ad7af196..cbe3a4fcfb 100644 --- a/datm/atm_comp_nuopc.F90 +++ b/datm/atm_comp_nuopc.F90 @@ -26,8 +26,6 @@ module atm_comp_nuopc use dshr_mod , only : dshr_orbital_init, dshr_orbital_update use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize - use perf_mod , only : t_startf, t_stopf, t_barrierf - use datm_datamode_core2_mod , only : datm_datamode_core2_advertise use datm_datamode_core2_mod , only : datm_datamode_core2_init_pointers use datm_datamode_core2_mod , only : datm_datamode_core2_advance @@ -332,8 +330,8 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) integer(i8) :: stepno ! step number real(r8) :: nextsw_cday ! calendar of next atm sw character(CL) :: cvalue ! character string for input config - real(R8) :: orbEccen ! orb eccentricity (unit-less) - real(R8) :: orbMvelpp ! orb moving vernal eq (radians) + real(R8) :: orbEccen ! orb eccentricity (unist-less) + real(R8) :: orbMvelpp ! orb moving vernal eqa (radians) real(R8) :: orbLambm0 ! orb mean long of perhelion (radians) real(R8) :: orbObliqr ! orb obliquity (radians) logical :: isPresent, isSet @@ -344,7 +342,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call ESMF_LogWrite(subname//' called', ESMF_LOGMSG_INFO) ! Initialize mesh, restart flag, compid, and logunit - call t_startf('datm_strdata_init') + call ESMF_TraceRegionEnter('datm_strdata_init') call dshr_mesh_init(gcomp, nullstr, logunit, 'ATM', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) @@ -354,7 +352,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) xmlfilename = 'datm.streams'//trim(inst_suffix)//'.xml' call shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, 'ATM', logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('datm_strdata_init') + call ESMF_TraceRegionExit('datm_strdata_init') ! NUOPC_Realize "realizes" a previously advertised field in the importState and exportState ! by replacing the advertised fields with the newly created fields of the same name. @@ -440,7 +438,7 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS - call t_startf(subname) + call ESMF_TraceRegionEnter(subname) call memcheck(subname, 5, my_task==master_task) ! Query the Component for its clock, importState and exportState @@ -475,11 +473,11 @@ subroutine ModelAdvance(gcomp, rc) endif ! Run datm - call t_startf('datm_run') + call ESMF_TraceRegionEnter('datm_run') call datm_comp_run(importstate, exportstate, next_ymd, next_tod, mon, & orbEccen, orbMvelpp, orbLambm0, orbObliqr, restart_write, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('datm_run') + call ESMF_TraceRegionExit('datm_run') ! Update nextsw_cday for scalar data ! Use nextYMD and nextTOD here since since the component - clock is advance at the END of the time interval @@ -487,7 +485,7 @@ subroutine ModelAdvance(gcomp, rc) call dshr_state_SetScalar(nextsw_cday, flds_scalar_index_nextsw_cday, exportState, flds_scalar_name, flds_scalar_num, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf(subname) + call ESMF_TraceRegionExit(subname) end subroutine ModelAdvance @@ -519,7 +517,7 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe rc = ESMF_SUCCESS - call t_startf('DATM_RUN') + call ESMF_TraceRegionEnter('DATM_RUN') !-------------------- ! First time initialization @@ -573,22 +571,20 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe call shr_strdata_setOrbs(sdat, orbEccen, orbMvelpp, orbLambm0, orbObliqr, idt) ! time and spatially interpolate to model time and grid - call t_barrierf('datm_BARRIER',mpicom) - call t_startf('datm_strdata_advance') + call ESMF_TraceRegionEnter('datm_strdata_advance') call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'datm', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('datm_strdata_advance') + call ESMF_TraceRegionExit('datm_strdata_advance') ! copy all fields from streams to export state as default ! This automatically will update the fields in the export state - call t_barrierf('datm_comp_dfield_copy_BARRIER', mpicom) - call t_startf('datm_dfield_copy') + call ESMF_TraceRegionEnter('datm_dfield_copy') call dshr_dfield_copy(dfields, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('datm_dfield_copy') + call ESMF_TraceRegionExit('datm_dfield_copy') ! Determine data model behavior based on the mode - call t_startf('datm_datamode') + call ESMF_TraceRegionEnter('datm_datamode') select case (trim(datamode)) case('CORE2_NYF','CORE2_IAF') call datm_datamode_core2_advance(exportstate, datamode, target_ymd, target_tod, target_mon, & @@ -637,8 +633,8 @@ subroutine datm_comp_run(importState, exportState, target_ymd, target_tod, targe if (ChkErr(rc,__LINE__,u_FILE_u)) return end if - call t_stopf('datm_datamode') - call t_stopf('DATM_RUN') + call ESMF_TraceRegionExit('datm_datamode') + call ESMF_TraceRegionExit('DATM_RUN') !-------- contains diff --git a/dice/CMakeLists.txt b/dice/CMakeLists.txt index 841ddd71ed..f45a446b35 100644 --- a/dice/CMakeLists.txt +++ b/dice/CMakeLists.txt @@ -17,4 +17,4 @@ target_include_directories (dice PUBLIC "${CMAKE_BINARY_DIR}/dshr") target_include_directories (dice PUBLIC "${CMAKE_SOURCE_DIR}") target_include_directories (dice PUBLIC "${CMAKE_BINARY_DIR}/share") target_include_directories (dice PUBLIC "${CMAKE_BINARY_DIR}/streams") -target_include_directories (dice PUBLIC "${PIO_INCDIR}") +target_include_directories (dice PUBLIC "${PIO_Fortran_INCLUDE_DIR}") diff --git a/dice/ice_comp_nuopc.F90 b/dice/ice_comp_nuopc.F90 index ce11df8505..55df6a81c9 100644 --- a/dice/ice_comp_nuopc.F90 +++ b/dice/ice_comp_nuopc.F90 @@ -23,7 +23,6 @@ module ice_comp_nuopc use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_xml, shr_strdata_advance use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize - use perf_mod , only : t_startf, t_stopf, t_adj_detailf, t_barrierf use dice_datamode_ssmi_mod , only : dice_datamode_ssmi_advertise use dice_datamode_ssmi_mod , only : dice_datamode_ssmi_init_pointers @@ -296,7 +295,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Initialize mesh, restart flag, logunit - call t_startf('dice_strdata_init') + call ESMF_TraceRegionEnter('dice_strdata_init') call dshr_mesh_init(gcomp, nullstr, logunit, 'ICE', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) @@ -306,7 +305,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) xmlfilename = 'dice.streams'//trim(inst_suffix)//'.xml' call shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, 'ICE', logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('dice_strdata_init') + call ESMF_TraceRegionExit('dice_strdata_init') ! NUOPC_Realize "realizes" a previously advertised field in the importState and exportState ! by replacing the advertised fields with the newly created fields of the same name. @@ -375,7 +374,7 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS - call t_startf(subname) + call ESMF_TraceRegionEnter(subname) call memcheck(subname, 5, my_task == master_task) ! Query the Component for its clock, importState and exportState @@ -413,7 +412,7 @@ subroutine ModelAdvance(gcomp, rc) call dice_comp_run(importState, exportState, next_ymd, next_tod, cosarg, restart_write, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf(subname) + call ESMF_TraceRegionExit(subname) end subroutine ModelAdvance @@ -440,7 +439,7 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar rc = ESMF_SUCCESS - call t_startf('DICE_RUN') + call ESMF_TraceRegionEnter('DICE_RUN') !-------------------- ! first time initialization @@ -477,27 +476,27 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar !-------------------- ! time and spatially interpolate to model time and grid - call t_barrierf('dice_BARRIER',mpicom) - call t_startf('dice_strdata_advance') + + call ESMF_TraceRegionEnter('dice_strdata_advance') call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'dice', rc=rc) - call t_stopf('dice_strdata_advance') + call ESMF_TraceRegionExit('dice_strdata_advance') !-------------------- ! copy all fields from streams to export state as default !-------------------- ! This automatically will update the fields in the export state - call t_barrierf('dice_comp_dfield_copy_BARRIER', mpicom) - call t_startf('dice_dfield_copy') + + call ESMF_TraceRegionEnter('dice_dfield_copy') call dshr_dfield_copy(dfields, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('dice_dfield_copy') + call ESMF_TraceRegionExit('dice_dfield_copy') !------------------------------------------------- ! Determine data model behavior based on the mode !------------------------------------------------- - call t_startf('dice_datamode') + call ESMF_TraceRegionEnter('dice_datamode') ! Perform data mode specific calculations select case (trim(datamode)) @@ -523,8 +522,8 @@ subroutine dice_comp_run(importstate, exportstate, target_ymd, target_tod, cosar if (ChkErr(rc,__LINE__,u_FILE_u)) return end if - call t_stopf('dice_datamode') - call t_stopf('DICE_RUN') + call ESMF_TraceRegionExit('dice_datamode') + call ESMF_TraceRegionExit('DICE_RUN') end subroutine dice_comp_run diff --git a/dlnd/CMakeLists.txt b/dlnd/CMakeLists.txt index 03a81ac0e5..ae080d3072 100644 --- a/dlnd/CMakeLists.txt +++ b/dlnd/CMakeLists.txt @@ -16,4 +16,4 @@ target_include_directories (dlnd PUBLIC "${CMAKE_BINARY_DIR}/dshr") target_include_directories (dlnd PUBLIC "${CMAKE_SOURCE_DIR}") target_include_directories (dlnd PUBLIC "${CMAKE_BINARY_DIR}/share") target_include_directories (dlnd PUBLIC "${CMAKE_BINARY_DIR}/streams") -target_include_directories (dlnd PUBLIC "${PIO_INCDIR}") +target_include_directories (dlnd PUBLIC "${PIO_Fortran_INCLUDE_DIR}") diff --git a/dlnd/lnd_comp_nuopc.F90 b/dlnd/lnd_comp_nuopc.F90 index 6d86145dfc..1354b3d11d 100644 --- a/dlnd/lnd_comp_nuopc.F90 +++ b/dlnd/lnd_comp_nuopc.F90 @@ -25,7 +25,6 @@ module lnd_comp_nuopc use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize use glc_elevclass_mod , only : glc_elevclass_as_string, glc_elevclass_init - use perf_mod , only : t_startf, t_stopf, t_adj_detailf, t_barrierf implicit none private ! except @@ -279,7 +278,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Initialize sdat - call t_startf('dlnd_strdata_init') + call ESMF_TraceRegionEnter('dlnd_strdata_init') call dshr_mesh_init(gcomp, nullstr, logunit, 'LND', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) @@ -288,7 +287,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) xmlfilename = 'dlnd.streams'//trim(inst_suffix)//'.xml' call shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, 'LND', logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('dlnd_strdata_init') + call ESMF_TraceRegionExit('dlnd_strdata_init') ! Realize the actively coupled fields, now that a mesh is established and ! initialize dfields data type (to map streams to export state fields) @@ -376,10 +375,10 @@ subroutine ModelAdvance(gcomp, rc) call ESMF_AlarmRingerOff( alarm, rc=rc ) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_startf('dlnd_restart') + call ESMF_TraceRegionEnter('dlnd_restart') call dshr_restart_write(rpfile, case_name, 'dlnd', inst_suffix, next_ymd, next_tod, & logunit, mpicom, my_task, sdat) - call t_stopf('dlnd_restart') + call ESMF_TraceRegionExit('dlnd_restart') endif ! write diagnostics @@ -512,7 +511,7 @@ subroutine dlnd_comp_run(importState, exportState, target_ymd, target_tod, rc) rc = ESMF_SUCCESS - call t_startf('DLND_RUN') + call ESMF_TraceRegionEnter('DLND_RUN') !-------------------- ! set module pointers @@ -561,29 +560,27 @@ subroutine dlnd_comp_run(importState, exportState, target_ymd, target_tod, rc) !-------------------- ! time and spatially interpolate to model time and grid - call t_barrierf('dlnd_BARRIER',mpicom) - call t_startf('dlnd_strdata_advance') + call ESMF_TraceRegionEnter('dlnd_strdata_advance') call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'dlnd', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('dlnd_strdata_advance') + call ESMF_TraceRegionExit('dlnd_strdata_advance') ! copy all fields from streams to export state as default ! This automatically will update the fields in the export state - call t_barrierf('dlnd_comp_strdata_copy_BARRIER', mpicom) - call t_startf('dlnd_strdata_copy') + call ESMF_TraceRegionEnter('dlnd_strdata_copy') call dshr_dfield_copy(dfields, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('dlnd_strdata_copy') + call ESMF_TraceRegionExit('dlnd_strdata_copy') ! determine data model behavior based on the mode - call t_startf('dlnd_datamode') + call ESMF_TraceRegionEnter('dlnd_datamode') select case (trim(datamode)) case('copyall') ! do nothing extra end select - call t_stopf('dlnd_datamode') - call t_stopf('DLND_RUN') + call ESMF_TraceRegionExit('dlnd_datamode') + call ESMF_TraceRegionExit('DLND_RUN') end subroutine dlnd_comp_run diff --git a/docn/CMakeLists.txt b/docn/CMakeLists.txt index 1253fd1d4e..33e3ba01ce 100644 --- a/docn/CMakeLists.txt +++ b/docn/CMakeLists.txt @@ -21,4 +21,4 @@ target_include_directories (docn PUBLIC "${CMAKE_BINARY_DIR}/dshr") target_include_directories (docn PUBLIC "${CMAKE_SOURCE_DIR}") target_include_directories (docn PUBLIC "${CMAKE_BINARY_DIR}/share") target_include_directories (docn PUBLIC "${CMAKE_BINARY_DIR}/streams") -target_include_directories (docn PUBLIC "${PIO_INCDIR}") +target_include_directories (docn PUBLIC "${PIO_Fortran_INCLUDE_DIR}") diff --git a/docn/ocn_comp_nuopc.F90 b/docn/ocn_comp_nuopc.F90 index 1236b056d4..074391dc3c 100644 --- a/docn/ocn_comp_nuopc.F90 +++ b/docn/ocn_comp_nuopc.F90 @@ -22,8 +22,6 @@ module ocn_comp_nuopc use dshr_mod , only : dshr_state_setscalar, dshr_set_runclock use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_realize - use perf_mod , only : t_startf, t_stopf, t_adj_detailf, t_barrierf - use pio ! Datamode specialized modules use docn_datamode_copyall_mod , only : docn_datamode_copyall_advertise @@ -324,7 +322,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Initialize model mesh, restart flag, logunit, model_mask and model_frac - call t_startf('docn_strdata_init') + call ESMF_TraceRegionEnter('docn_strdata_init') call dshr_mesh_init(gcomp, nullstr, logunit, 'OCN', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) @@ -336,7 +334,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) call shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, 'OCN', logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if - call t_stopf('docn_strdata_init') + call ESMF_TraceRegionExit('docn_strdata_init') ! Realize the actively coupled fields, now that a mesh is established and ! NUOPC_Realize "realizes" a previously advertised field in the importState and exportState @@ -447,7 +445,7 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod rc = ESMF_SUCCESS - call t_startf('DOCN_RUN') + call ESMF_TraceRegionEnter('DOCN_RUN') !-------------------- ! First time initialization @@ -496,21 +494,19 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod !-------------------- ! Advance data model streams - time and spatially interpolate to model time and grid - call t_barrierf('docn_BARRIER',mpicom) - call t_startf('docn_strdata_advance') + call ESMF_TraceRegionEnter('docn_strdata_advance') call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'docn', rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('docn_strdata_advance') + call ESMF_TraceRegionExit('docn_strdata_advance') ! Copy all fields from streams to export state as default ! This automatically will update the fields in the export state - call t_barrierf('docn_dfield_copy_BARRIER', mpicom) - call t_startf('docn_dfield_copy') + call ESMF_TraceRegionEnter('docn_dfield_copy') if(.not. aquaplanet) then call dshr_dfield_copy(dfields, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return endif - call t_stopf('docn_dfield_copy') + call ESMF_TraceRegionExit('docn_dfield_copy') ! Perform data mode specific calculations select case (trim(datamode)) @@ -525,7 +521,7 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod if (ChkErr(rc,__LINE__,u_FILE_u)) return case('sst_aquap_analytic') call docn_datamode_aquaplanet_advance(exportstate, model_mesh, sst_option=aquap_option, rc=rc) - if (chkerr(rc,__line__,u_file_u)) return + if (ChkErr(rc,__LINE__,u_file_u)) return case('sst_aquap_constant') call docn_datamode_aquaplanet_advance(exportState, model_mesh, sst_constant_value=sst_constant_value, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -546,7 +542,7 @@ subroutine docn_comp_run(importState, exportState, clock, target_ymd, target_tod end select end if - call t_stopf('DOCN_RUN') + call ESMF_TraceRegionExit('DOCN_RUN') ! write diagnostics if (diagnose_data) then diff --git a/drof/CMakeLists.txt b/drof/CMakeLists.txt index 41ded49c89..62a92cb83b 100644 --- a/drof/CMakeLists.txt +++ b/drof/CMakeLists.txt @@ -16,4 +16,4 @@ target_include_directories (drof PUBLIC "${CMAKE_BINARY_DIR}/dshr") target_include_directories (drof PUBLIC "${CMAKE_SOURCE_DIR}") target_include_directories (drof PUBLIC "${CMAKE_BINARY_DIR}/share") target_include_directories (drof PUBLIC "${CMAKE_BINARY_DIR}/streams") -target_include_directories (drof PUBLIC "${PIO_INCDIR}") +target_include_directories (drof PUBLIC "${PIO_Fortran_INCLUDE_DIR}") diff --git a/drof/rof_comp_nuopc.F90 b/drof/rof_comp_nuopc.F90 index e4963cd7ff..0765c10a9f 100644 --- a/drof/rof_comp_nuopc.F90 +++ b/drof/rof_comp_nuopc.F90 @@ -25,7 +25,6 @@ module rof_comp_nuopc use dshr_mod , only : dshr_restart_read, dshr_restart_write, dshr_mesh_init use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize - use perf_mod , only : t_startf, t_stopf, t_adj_detailf, t_barrierf implicit none private ! except @@ -277,7 +276,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Initialize mesh, restart flag, logunit - call t_startf('drof_strdata_init') + call ESMF_TraceRegionEnter('drof_strdata_init') call dshr_mesh_init(gcomp, nullstr, logunit, 'ROF', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) @@ -287,7 +286,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) xmlfilename = 'drof.streams'//trim(inst_suffix)//'.xml' call shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, 'ROF', logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('drof_strdata_init') + call ESMF_TraceRegionExit('drof_strdata_init') ! NUOPC_Realize "realizes" a previously advertised field in the importState and exportState ! by replacing the advertised fields with the newly created fields of the same name. @@ -392,7 +391,7 @@ subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc) character(*), parameter :: subName = "(drof_comp_run) " !------------------------------------------------------------------------------- - call t_startf('DROF_RUN') + call ESMF_TraceRegionEnter('DROF_RUN') !-------------------- ! First time initialization @@ -424,21 +423,19 @@ subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc) !-------------------- ! time and spatially interpolate to model time and grid - call t_barrierf('drof_BARRIER',mpicom) - call t_startf('drof_strdata_advance') + call ESMF_TraceRegionEnter('drof_strdata_advance') call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'drof', rc=rc) - call t_stopf('drof_strdata_advance') + call ESMF_TraceRegionExit('drof_strdata_advance') ! copy all fields from streams to export state as default ! This automatically will update the fields in the export state - call t_barrierf('drof_comp_dfield_copy_BARRIER', mpicom) - call t_startf('drof_dfield_copy') + call ESMF_TraceRegionEnter('drof_dfield_copy') call dshr_dfield_copy(dfields, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('drof_dfield_copy') + call ESMF_TraceRegionExit('drof_dfield_copy') ! determine data model behavior based on the mode - call t_startf('drof_datamode') + call ESMF_TraceRegionEnter('drof_datamode') select case (trim(datamode)) case('copyall') ! zero out "special values" of export fields @@ -463,8 +460,8 @@ subroutine drof_comp_run(exportState, target_ymd, target_tod, restart_write, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if - call t_stopf('drof_datamode') - call t_stopf('DROF_RUN') + call ESMF_TraceRegionExit('drof_datamode') + call ESMF_TraceRegionExit('DROF_RUN') end subroutine drof_comp_run diff --git a/dshr/CMakeLists.txt b/dshr/CMakeLists.txt index f45a646bb8..1a98d00ab3 100644 --- a/dshr/CMakeLists.txt +++ b/dshr/CMakeLists.txt @@ -19,6 +19,6 @@ add_dependencies(dshr streams) target_include_directories (dshr PUBLIC ${ESMF_F90COMPILEPATHS}) target_include_directories (dshr PUBLIC "${CMAKE_BINARY_DIR}/streams") target_include_directories (dshr PUBLIC "${CMAKE_BINARY_DIR}/share") -target_include_directories (dshr PUBLIC "${PIO_INCDIR}") +target_include_directories (dshr PUBLIC "${PIO_Fortran_INCLUDE_DIR}") install(TARGETS dshr LIBRARY DESTINATION lib) diff --git a/dshr/dshr_mod.F90 b/dshr/dshr_mod.F90 index 0ccd9cf9db..f28649773a 100644 --- a/dshr/dshr_mod.F90 +++ b/dshr/dshr_mod.F90 @@ -40,7 +40,6 @@ module dshr_mod use shr_pio_mod , only : shr_pio_getiosys, shr_pio_getiotype, shr_pio_getioformat use dshr_strdata_mod , only : shr_strdata_type, shr_strdata_init_from_xml, SHR_STRDATA_GET_STREAM_COUNT use dshr_methods_mod , only : chkerr - use perf_mod , only : t_startf, t_stopf use pio implicit none diff --git a/dwav/CMakeLists.txt b/dwav/CMakeLists.txt index 27dced49ea..c848741c61 100644 --- a/dwav/CMakeLists.txt +++ b/dwav/CMakeLists.txt @@ -16,4 +16,4 @@ target_include_directories (dwav PUBLIC "${CMAKE_BINARY_DIR}/dshr") target_include_directories (dwav PUBLIC "${CMAKE_SOURCE_DIR}") target_include_directories (dwav PUBLIC "${CMAKE_BINARY_DIR}/share") target_include_directories (dwav PUBLIC "${CMAKE_BINARY_DIR}/streams") -target_include_directories (dwav PUBLIC "${PIO_INCDIR}") +target_include_directories (dwav PUBLIC "${PIO_Fortran_INCLUDE_DIR}") diff --git a/dwav/wav_comp_nuopc.F90 b/dwav/wav_comp_nuopc.F90 index b9999b94bb..d48abb636f 100644 --- a/dwav/wav_comp_nuopc.F90 +++ b/dwav/wav_comp_nuopc.F90 @@ -24,7 +24,6 @@ module wav_comp_nuopc use dshr_mod , only : dshr_restart_read, dshr_restart_write, dshr_mesh_init use dshr_dfield_mod , only : dfield_type, dshr_dfield_add, dshr_dfield_copy use dshr_fldlist_mod , only : fldlist_type, dshr_fldlist_add, dshr_fldlist_realize - use perf_mod , only : t_startf, t_stopf, t_adj_detailf, t_barrierf implicit none private ! except @@ -264,7 +263,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS ! Initialize sdat - create the model domain mesh and intialize the sdat clock - call t_startf('dwav_strdata_init') + call ESMF_TraceRegionEnter('dwav_strdata_init') call dshr_mesh_init(gcomp, nullstr, logunit, 'WAV', nx_global, ny_global, & model_meshfile, model_maskfile, model_createmesh_fromfile, model_mesh, & model_mask, model_frac, restart_read, rc=rc) @@ -274,7 +273,7 @@ subroutine InitializeRealize(gcomp, importState, exportState, clock, rc) xmlfilename = 'dwav.streams'//trim(inst_suffix)//'.xml' call shr_strdata_init_from_xml(sdat, xmlfilename, model_mesh, clock, 'WAV', logunit, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('dwav_strdata_init') + call ESMF_TraceRegionExit('dwav_strdata_init') ! Realize the actively coupled fields, now that a mesh is established and ! initialize dfields data type (to map streams to export state fields) @@ -328,7 +327,7 @@ subroutine ModelAdvance(gcomp, rc) rc = ESMF_SUCCESS - call t_startf(subname) + call ESMF_TraceRegionEnter(subname) call memcheck(subname, 5, my_task == master_task) ! query the Component for its clock, importState and exportState @@ -357,13 +356,13 @@ subroutine ModelAdvance(gcomp, rc) call ESMF_AlarmRingerOff( alarm, rc=rc ) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_startf('dwav_restart') + call ESMF_TraceRegionEnter('dwav_restart') call NUOPC_CompAttributeGet(gcomp, name='case_name', value=case_name, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return call dshr_restart_write(rpfile, case_name, 'dwav', inst_suffix, next_ymd, next_tod, & logunit, mpicom, my_task, sdat) - call t_stopf('dwav_restart') + call ESMF_TraceRegionExit('dwav_restart') endif ! Write Diagnostics @@ -372,7 +371,7 @@ subroutine ModelAdvance(gcomp, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return end if - call t_stopf(subname) + call ESMF_TraceRegionExit(subname) end subroutine ModelAdvance @@ -484,41 +483,39 @@ subroutine dwav_comp_run(mpicom, my_task, logunit, target_ymd, target_tod, sdat, integer , intent(out) :: rc !------------------------------------------------------------------------------- - call t_startf('DWAV_RUN') + call ESMF_TraceRegionEnter('DWAV_RUN') !-------------------- ! advance dwav streams !-------------------- ! time and spatially interpolate to model time and grid - call t_barrierf('dwav_BARRIER',mpicom) - call t_startf('dwav_strdata_advance') + call ESMF_TraceRegionEnter('dwav_strdata_advance') call shr_strdata_advance(sdat, target_ymd, target_tod, logunit, 'dwav', rc=rc) - call t_stopf('dwav_strdata_advance') + call ESMF_TraceRegionExit('dwav_strdata_advance') !-------------------- ! copy all fields from streams to export state as default !-------------------- ! This automatically will update the fields in the export state - call t_barrierf('dwav_comp_strdata_copy_BARRIER', mpicom) - call t_startf('dwav_strdata_copy') + call ESMF_TraceRegionEnter('dwav_strdata_copy') call dshr_dfield_copy(dfields, sdat, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return - call t_stopf('dwav_strdata_copy') + call ESMF_TraceRegionExit('dwav_strdata_copy') !------------------------------------------------- ! determine data model behavior based on the mode !------------------------------------------------- - call t_startf('dwav_datamode') + call ESMF_TraceRegionEnter('dwav_datamode') select case (trim(datamode)) case('copyall') ! do nothing end select - call t_stopf('dwav_datamode') + call ESMF_TraceRegionExit('dwav_datamode') - call t_stopf('DWAV_RUN') + call ESMF_TraceRegionExit('DWAV_RUN') end subroutine dwav_comp_run diff --git a/fox b/fox new file mode 160000 index 0000000000..a2a181efd1 --- /dev/null +++ b/fox @@ -0,0 +1 @@ +Subproject commit a2a181efd1606cc85fd5f0cce5da7d643af1cac5 diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 8c8e5a701a..06bb2c7d3f 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -20,7 +20,8 @@ add_library(cdeps_share ${GenF90_SRCS} shr_precip_mod.F90 shr_string_mod.F90) -target_include_directories (cdeps_share PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ESMF_F90COMPILEPATHS} ${PIO_INCDIR}) +target_include_directories (cdeps_share PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ESMF_F90COMPILEPATHS} ${PIO_Fortran_INCLUDE_DIRS}) + #===== genf90 ===== if (DEFINED GENF90_PATH) diff --git a/streams/CMakeLists.txt b/streams/CMakeLists.txt index 750a88b224..b8466cadfb 100644 --- a/streams/CMakeLists.txt +++ b/streams/CMakeLists.txt @@ -1,7 +1,7 @@ set(SRCFILES dshr_methods_mod.F90 - dshr_strdata_mod.F90 - dshr_stream_mod.F90 - dshr_tinterp_mod.F90) + dshr_strdata_mod.F90 + dshr_stream_mod.F90 + dshr_tinterp_mod.F90) set(MODFILES ${SRCFILES}) foreach(FILE ${SRCFILES}) list(TRANSFORM MODFILES REPLACE ".F90" ".mod") @@ -13,15 +13,16 @@ foreach(FILE ${SRCFILES}) endforeach() message("Stream srcfiles are ${SRCFILES}") add_library(streams ${SRCFILES}) +add_dependencies(streams FoX_dom) if(BLD_STANDALONE) add_dependencies(streams cdeps_share) endif() +target_include_directories (streams PUBLIC ${CMAKE_BINARY_DIR}/fox/modules) target_include_directories (streams PUBLIC ${ESMF_F90COMPILEPATHS}) -target_include_directories (streams PUBLIC ${PIO_INCDIR}) -target_include_directories (streams PUBLIC ${FOX}/finclude) +target_include_directories (streams PUBLIC ${PIO_Fortran_INCLUDE_DIR}) target_include_directories (streams PUBLIC ${CMAKE_BINARY_DIR}/share) install(TARGETS streams - LIBRARY DESTINATION lib) + LIBRARY DESTINATION lib) foreach(MOD ${MODFILES}) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${MOD}" DESTINATION include) endforeach() diff --git a/streams/dshr_methods_mod.F90 b/streams/dshr_methods_mod.F90 index 565bd748f4..1483e66d15 100644 --- a/streams/dshr_methods_mod.F90 +++ b/streams/dshr_methods_mod.F90 @@ -4,7 +4,6 @@ module dshr_methods_mod use ESMF use shr_kind_mod , only : r8=>shr_kind_r8, cs=>shr_kind_cs, cl=>shr_kind_cl - use perf_mod , only : t_startf, t_stopf, t_adj_detailf, t_barrierf implicit none public @@ -211,7 +210,7 @@ subroutine dshr_fldbun_regrid(FBsrc, FBdst, RH, zeroregion, rc) rc = ESMF_SUCCESS - call t_startf(subname) + call ESMF_TraceRegionEnter(subname) localzr = ESMF_REGION_TOTAL if (present(zeroregion)) then @@ -254,7 +253,7 @@ subroutine dshr_fldbun_regrid(FBsrc, FBdst, RH, zeroregion, rc) deallocate(lfieldnamelist_src) deallocate(lfieldnamelist_dst) - call t_stopf(subname) + call ESMF_TraceRegionExit(subname) end subroutine dshr_fldbun_regrid diff --git a/streams/dshr_strdata_mod.F90 b/streams/dshr_strdata_mod.F90 index a250f7143d..39bc15b180 100644 --- a/streams/dshr_strdata_mod.F90 +++ b/streams/dshr_strdata_mod.F90 @@ -33,7 +33,6 @@ module dshr_strdata_mod use pio , only : pio_double, pio_real, pio_int, pio_offset_kind, pio_get_var use pio , only : pio_read_darray, pio_setframe, pio_fill_double, pio_get_att use pio , only : PIO_BCAST_ERROR, PIO_RETURN_ERROR, PIO_NOERR, PIO_INTERNAL_ERROR, PIO_SHORT - use perf_mod , only : t_startf, t_stopf, t_adj_detailf implicit none private @@ -731,9 +730,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ltimers = timers endif - if (.not.ltimers) call t_adj_detailf(tadj) - - call t_startf(trim(lstr)//trim(timname)//'_total') + call ESMF_TraceRegionEnter(trim(lstr)//trim(timname)//'_total') sdat%ymd = ymd sdat%tod = tod @@ -774,7 +771,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! fldbun_stream_ub to fldbun_stream_lb and read in new fldbun_stream_ub data ! --------------------------------------------------------- - call t_startf(trim(lstr)//trim(timname)//'_readLBUB') + call ESMF_TraceRegionEnter(trim(lstr)//trim(timname)//'_readLBUB') select case(sdat%stream(ns)%readmode) case ('single') @@ -831,7 +828,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) endif endif - call t_stopf(trim(lstr)//trim(timname)//'_readLBUB') + call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_readLBUB') enddo ! end of loop over streams @@ -847,19 +844,19 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! time interpolation method is coszen ! ------------------------------------------ - call t_startf(trim(lstr)//trim(timname)//'_coszen') + call ESMF_TraceRegionEnter(trim(lstr)//trim(timname)//'_coszen') allocate(coszen(sdat%model_lsize)) ! get coszen - call t_startf(trim(lstr)//trim(timname)//'_coszenC') + call ESMF_TraceRegionEnter(trim(lstr)//trim(timname)//'_coszenC') call shr_tInterp_getCosz(coszen, sdat%model_lon, sdat%model_lat, ymdmod(ns), todmod, & sdat%eccen, sdat%mvelpp, sdat%lambm0, sdat%obliqr, sdat%stream(ns)%calendar) - call t_stopf(trim(lstr)//trim(timname)//'_coszenC') + call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_coszenC') ! get avg cosz factor if (newdata(ns)) then ! compute a new avg cosz - call t_startf(trim(lstr)//trim(timname)//'_coszenN') + call ESMF_TraceRegionEnter(trim(lstr)//trim(timname)//'_coszenN') if (.not. allocated(sdat%tavCoszen)) then allocate(sdat%tavCoszen(sdat%model_lsize)) end if @@ -867,7 +864,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) sdat%pstrm(ns)%ymdLB, sdat%pstrm(ns)%todLB, sdat%pstrm(ns)%ymdUB, sdat%pstrm(ns)%todUB, & sdat%eccen, sdat%mvelpp, sdat%lambm0, sdat%obliqr, sdat%modeldt, & sdat%stream(ns)%calendar, rc=rc) - call t_stopf(trim(lstr)//trim(timname)//'_coszenN') + call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_coszenN') endif ! compute time interperpolate value - LB data normalized with this factor: cosz/tavCosz @@ -888,7 +885,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) end do deallocate(coszen) - call t_stopf(trim(lstr)//trim(timname)//'_coszen') + call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_coszen') elseif (trim(sdat%stream(ns)%tinterpalgo) /= trim(shr_strdata_nullstr)) then @@ -896,7 +893,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! time interpolation method is not coszen ! ------------------------------------------ - call t_startf(trim(lstr)//trim(timname)//'_tint') + call ESMF_TraceRegionEnter(trim(lstr)//trim(timname)//'_tint') call shr_tInterp_getFactors(sdat%pstrm(ns)%ymdlb, sdat%pstrm(ns)%todlb, & sdat%pstrm(ns)%ymdub, sdat%pstrm(ns)%todub, & ymdmod(ns), todmod, flb, fub, calendar=sdat%stream(ns)%calendar, logunit=sdat%logunit, & @@ -918,7 +915,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return dataptr(:) = dataptr_lb(:) * flb + dataptr_ub(:) * fub end do - call t_stopf(trim(lstr)//trim(timname)//'_tint') + call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_tint') else @@ -926,13 +923,13 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) ! zero out stream data for this field ! ------------------------------------------ - call t_startf(trim(lstr)//trim(timname)//'_zero') + call ESMF_TraceRegionEnter(trim(lstr)//trim(timname)//'_zero') do nf = 1,size(sdat%pstrm(ns)%fldlist_model) call dshr_fldbun_getfldptr(sdat%pstrm(ns)%fldbun_model, sdat%pstrm(ns)%fldlist_model(nf), dataptr, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return dataptr(:) = 0._r8 end do - call t_stopf(trim(lstr)//trim(timname)//'_zero') + call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_zero') endif @@ -943,8 +940,7 @@ subroutine shr_strdata_advance(sdat, ymd, tod, logunit, istr, timers, rc) endif ! nstreams > 0 - call t_stopf(trim(lstr)//trim(timname)//'_total') - if (.not.ltimers) call t_adj_detailf(-tadj) + call ESMF_TraceRegionExit(trim(lstr)//trim(timname)//'_total') end subroutine shr_strdata_advance @@ -1063,7 +1059,7 @@ subroutine shr_strdata_readLBUB(sdat, ns, mDate, mSec, newData, istr, rc) stream => sdat%stream(ns) stream_mesh => sdat%pstrm(ns)%stream_mesh - call t_startf(trim(istr)//'_setup') + call ESMF_TraceRegionEnter(trim(istr)//'_setup') ! allocate streamdat instance on all tasks call ESMF_VMGetCurrent(vm, rc=rc) if (ChkErr(rc,__LINE__,u_FILE_u)) return @@ -1085,15 +1081,15 @@ subroutine shr_strdata_readLBUB(sdat, ns, mDate, mSec, newData, istr, rc) rDateLB = real(sdat%pstrm(ns)%ymdLB,r8) + real(sdat%pstrm(ns)%todLB,r8)/shr_const_cday rDateUB = real(sdat%pstrm(ns)%ymdUB,r8) + real(sdat%pstrm(ns)%todUB,r8)/shr_const_cday - call t_stopf(trim(istr)//'_setup') + call ESMF_TraceRegionExit(trim(istr)//'_setup') ! if model current date is outside of model lower or upper bound - find the stream bounds if (rDateM < rDateLB .or. rDateM > rDateUB) then - call t_startf(trim(istr)//'_fbound') + call ESMF_TraceRegionEnter(trim(istr)//'_fbound') call shr_stream_findBounds(stream, mDate, mSec, & sdat%pstrm(ns)%ymdLB, dDateLB, sdat%pstrm(ns)%todLB, n_lb, filename_lb, & sdat%pstrm(ns)%ymdUB, dDateUB, sdat%pstrm(ns)%todUB, n_ub, filename_ub) - call t_stopf(trim(istr)//'_fbound') + call ESMF_TraceRegionExit(trim(istr)//'_fbound') endif ! determine if need to read in new stream data @@ -1126,7 +1122,7 @@ subroutine shr_strdata_readLBUB(sdat, ns, mDate, mSec, newData, istr, rc) endif ! determine previous & next data files in list of files - call t_startf(trim(istr)//'_filemgt') + call ESMF_TraceRegionEnter(trim(istr)//'_filemgt') if (sdat%masterproc .and. newdata) then call shr_stream_getPrevFileName(stream, filename_lb, filename_prev) call shr_stream_getNextFileName(stream, filename_ub, filename_next) @@ -1135,7 +1131,7 @@ subroutine shr_strdata_readLBUB(sdat, ns, mDate, mSec, newData, istr, rc) ! do nothing end if endif - call t_stopf(trim(istr)//'_filemgt') + call ESMF_TraceRegionExit(trim(istr)//'_filemgt') end subroutine shr_strdata_readLBUB @@ -1250,7 +1246,7 @@ subroutine shr_strdata_readstrm(sdat, ns, stream, stream_mesh, & ! the data for fldbun_stream with the field names fldname_stream_model ! ****************************************************************************** - call t_startf(trim(istr)//'_readpio') + call ESMF_TraceRegionEnter(trim(istr)//'_readpio') if (sdat%masterproc) then write(sdat%logunit,F02) 'file ' // trim(boundstr) //': ',trim(filename), nt endif @@ -1442,7 +1438,7 @@ subroutine shr_strdata_readstrm(sdat, ns, stream, stream_mesh, & if(.not. pio_iodesc_set) then deallocate(dataptr) endif - call t_stopf(trim(istr)//'_readpio') + call ESMF_TraceRegionExit(trim(istr)//'_readpio') end subroutine shr_strdata_readstrm