Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • icon-libraries/libfortran-support
1 result
Show changes
Commits on Source (36)
Showing
with 708 additions and 324 deletions
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: CC0-1.0
# ---------------------------------------------------------------
---
Language: Cpp
# BasedOnStyle: GNU
......
with section("parse"):
additional_commands = {
"check_macro_defined": {
"pargs": 2,
"flags": ["QUIET"],
"kwargs": {
"LANG": 1
}
},
"add_icon_c_test": {
"pargs": 2
},
"list_sources": {
"pargs": 1,
"flags": ["EXCLUDE_GENERATED"],
"kwargs": {
"DIRECTORY": 1,
"INCLUDE_REGEX": 1
}
},
"FortUTF_Find_Tests": {}
}
with section("format"):
line_width = 80
autosort = True
keyword_case = 'upper'
with section("markup"):
first_comment_is_literal = True
with section("lint"):
disabled_codes = ['C0301']
function_pattern = '[0-9a-z_]+'
macro_pattern = '[0-9a-z_]+'
local_var_pattern = '[a-zA-Z][0-9a-zA-z_]+'
private_var_pattern = '[a-z][a-z0-9_]+'
public_var_pattern = '[A-Z][0-9a-zA-Z_]+'
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: CC0-1.0
# ---------------------------------------------------------------
# CMake stage files:
/**/CMakeFiles/*
/**/_deps/*
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------
include:
- project: 'anw_dienste/ci-templates'
file: '.slurm-ci.yml'
stages:
- lint
......@@ -23,81 +16,144 @@ workflow:
- if: $CI_COMMIT_REF_NAME == "master"
- if: '$CI_COMMIT_TAG =~ /^v?\d+\.\d+\.\d+$/'
.colorized:
variables:
DEFAULT: '\033[0m'
RED: '\033[0;31m'
variables:
ACCOUNT: "ka1125"
SCHEDULER_PARAMETERS: "--account=$ACCOUNT --partition=shared"
nag:
stage: build_and_test
extends:
- .default
before_script:
- . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list
- module list
script:
- module load gcc/11.2.0-gcc-11.2.0 nag/7.1-gcc-11.2.0
- export NAG_KUSARI_FILE="/etc/nag-license"
- mkdir nag71
- cd nag71
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=nagfor -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_RPATH=/sw/spack-levante/gcc-11.2.0-bcn7mb/lib64
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=nagfor -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_RPATH=/sw/spack-levante/gcc-11.2.0-bcn7mb/lib64
- make VERBOSE=1
- ctest --output-on-failure
tags:
- xen, levante
needs: ["Check Style", "Check License"]
- levante, hpc, dkrz
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check CMake Style", "Check License"]
gcc11:
stage: build_and_test
extends:
- .default
before_script:
- . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list
- module list
script:
- module load gcc/11.2.0-gcc-11.2.0
- mkdir gcc112
- cd gcc112
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_CXX_COMPILER=g++
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_CXX_COMPILER=g++
- make VERBOSE=1
- ctest --output-on-failure
tags:
- xen, levante
needs: ["Check Style", "Check License"]
- levante, hpc, dkrz
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check CMake Style", "Check License"]
intel22:
stage: build_and_test
extends:
- .default
before_script:
- . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list
- module list
script:
- module load gcc/11.2.0-gcc-11.2.0 intel-oneapi-compilers/2022.0.1-gcc-11.2.0
- mkdir intel22
- cd intel22
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_C_COMPILER=icc -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_CXX_COMPILER=icpc -DCMAKE_BUILD_RPATH=/sw/spack-levante/gcc-11.2.0-bcn7mb/lib64
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=icc -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_CXX_COMPILER=icpc -DCMAKE_BUILD_RPATH=/sw/spack-levante/gcc-11.2.0-bcn7mb/lib64
- make VERBOSE=1
- ctest --output-on-failure
tags:
- xen, levante
needs: ["Check Style", "Check License"]
- levante, hpc, dkrz
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check CMake Style", "Check License"]
nvhpc:
stage: build_and_test
extends:
- .default
before_script:
- . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list
- module list
script:
- module load gcc/11.2.0-gcc-11.2.0 nvhpc/22.5-gcc-11.2.0
- mkdir nvhpc
- cd nvhpc
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_C_COMPILER=nvc -DCMAKE_Fortran_COMPILER=nvfortran -DCMAKE_CXX_COMPILER=nvc++
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_COMPILER=nvc -DCMAKE_Fortran_COMPILER=nvfortran -DCMAKE_CXX_COMPILER=nvc++
- make VERBOSE=1
- ctest --output-on-failure
tags:
- xen, levante
needs: ["Check Style", "Check License"]
- levante, hpc, dkrz
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check CMake Style", "Check License"]
OpenACC:
stage: build_OpenACC
extends:
- .default
before_script:
- . /sw/etc/profile.levante && module use /sw/spack-levante/spack/modules && module list
- module list
script:
- module load gcc/11.2.0-gcc-11.2.0 nvhpc/22.5-gcc-11.2.0
- mkdir nvhpc
- cd nvhpc
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DBUILD_OPENACC=ON -DCMAKE_C_COMPILER=nvc -DCMAKE_Fortran_COMPILER=nvfortran -DCMAKE_CXX_COMPILER=nvc++
- /sw/spack-levante/cmake-3.23.1-q5kzz6/bin/cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DFS_ENABLE_OPENACC=ON -DCMAKE_C_COMPILER=nvc -DCMAKE_Fortran_COMPILER=nvfortran -DCMAKE_CXX_COMPILER=nvc++
- make VERBOSE=1
tags:
- xen, levante
- levante, hpc, dkrz
needs: ["nvhpc"]
Check Typo:
stage: lint
before_script:
# install typo check package
- conda install conda-forge::typos
script: typos
tags:
# choose conda available runner
- conda
needs: []
Check OpenACC Style:
extends: .colorized
stage: lint
variables:
BEAUTIFIER_TAG: "v0.3.0"
BEAUTIFIER_REPO: "https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.dkrz.de/dwd-sw/icon-openacc-beautifier.git"
GIT_SUBMODULE_STRATEGY: none
before_script:
- git clone --branch "${BEAUTIFIER_TAG}" --depth 1 "${BEAUTIFIER_REPO}"
script:
# apply beautifier:
- python3 icon-openacc-beautifier/main.py src/
# build git patch:
- git diff --ignore-submodules --patch-with-raw > acc_style.patch
- |
# Test if patching is necessary:
test ! -s acc_style.patch || {
printf "${RED}ERROR: There are ACC style errors. Please check your \
code. You might want to run the ACC beautifier or \`git apply acc_style.patch\` \
(see artifacts).${DEFAULT}\n" >&2
exit 1
}
tags:
# choose python capable runner:
- sphinx
artifacts:
paths:
- acc_style.patch
expire_in: 1 week
expose_as: 'OpenACC Style Git Patch'
when: on_failure
needs: []
Check Style:
stage: lint
before_script:
......@@ -120,7 +176,7 @@ Check Style:
- test ! -s style.patch || { echo "There are style errors. Please check
your code. You might want to run \`make format\` or \`git apply style.patch\`." && false; }
tags:
# choose runner
# choose python capable runner
- sphinx
artifacts:
paths:
......@@ -130,6 +186,19 @@ Check Style:
when: on_failure
needs: []
Check CMake Style:
stage: lint
before_script:
#install the formatting tool
- pip install cmake-format
script:
# check style for CMake files.
- cmake-lint CMakeLists.txt src/CMakeLists.txt test/CMakeLists.txt test/c/CMakeLists.txt test/fortran/CMakeLists.txt cmake/check_macro.cmake cmake/gtest_helper.cmake cmake/list_sources.cmake
tags:
# choose runner
- sphinx
needs: []
Check License:
stage: lint
before_script:
......@@ -152,7 +221,7 @@ Code Coverage:
script:
- mkdir build
- cd build
- cmake .. -DBACKTRACE_TEST=OFF -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_FLAGS="--coverage" -DCMAKE_Fortran_FLAGS="--coverage"
- cmake .. -DFS_ENABLE_BACKTRACE_TEST=OFF -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_FLAGS="--coverage" -DCMAKE_Fortran_FLAGS="--coverage"
- make
- ctest --output-on-failure
- gcovr --xml-pretty --exclude-unreachable-branches --gcov-ignore-errors=no_working_dir_found --print-summary src -o coverage.xml --root ${CI_PROJECT_DIR}
......@@ -182,7 +251,7 @@ Prepare Changelog:
artifacts:
paths:
- release_notes.md
needs: ["nag", "gcc11", "intel22", "nvhpc"]
needs: ["nag", "gcc11", "intel22", "nvhpc", "OpenACC"]
Release:
stage: release
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: CC0-1.0
# ---------------------------------------------------------------
categories:
feature: New features
bugfix: Bug fixes
......
<!--
ICON
---------------------------------------------------------------
Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
Contact information: icon-model.org
See AUTHORS.TXT for a list of authors
See LICENSES/ for license information
SPDX-License-Identifier: CC0-1.0
---------------------------------------------------------------
-->
## What is the bug
_Please describe the bug in a couple of words._
## How do you fix it
......@@ -30,6 +17,7 @@ _Describe important implementation details of the bugfix._
- [ ] Test coverage does not decrease
- [ ] Reviewed by a maintainer
- [ ] Incorporate review suggestions
- [ ] Prior to merging, please remove any boilerplate from the MR description, retaining only the _What is the bug_ and _How do you fix it_ section to maintain
- [ ] Remember to edit the commit message and select the proper changelog category (feature/bugfix/other)
**You are not supposed to merge this request by yourself, the maintainers of fortan-support take care of this action!**
<!--
ICON
---------------------------------------------------------------
Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
Contact information: icon-model.org
See AUTHORS.TXT for a list of authors
See LICENSES/ for license information
SPDX-License-Identifier: CC0-1.0
---------------------------------------------------------------
-->
## What is the new feature
_Please describe your feature in a couple of words._
## How is it implemented
......@@ -25,6 +12,7 @@ _Describe important implementation details of the feature._
- [ ] Test coverage does not decrease
- [ ] Reviewed by a maintainer
- [ ] Incorporate review suggestions
- [ ] Prior to merging, please remove any boilerplate from the MR description, retaining only the _Please describe your feature in a couple of words_ and _describe important implementation details of the feature_ section to maintain
- [ ] Remember to edit the commit message and select the proper changelog category (feature/bugfix/other)
**You are not supposed to merge this request by yourself, the maintainers of fortan-support take care of this action!**
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: CC-BY-4.0
# ---------------------------------------------------------------
# A more complete author list is provided in the ICON repository.
Daniel Hupp
Daniel Reinert
Daniel Rieger
Florian Prill
......
......@@ -11,22 +11,18 @@
cmake_minimum_required(VERSION 3.18)
project(fortran-support VERSION 0.1.0 LANGUAGES Fortran C)
find_package(OpenACC QUIET)
project(
fortran-support
VERSION 0.1.0
LANGUAGES Fortran C)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_TESTING "Build tests" ON)
option(BACKTRACE_TEST "Test backtrace function" ON)
option(BUILD_OMP "Build with OpenMP support" OFF)
option(BUILD_OPENACC "Build with OpenACC support" OFF)
option(MIXED_PRECISION "Use mixed precision" OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE)
message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}' as none was specified")
endif(NOT CMAKE_BUILD_TYPE)
option(FS_ENABLE_BACKTRACE_TEST "Test backtrace function" ON)
option(FS_ENABLE_OMP "Build with OpenMP support" OFF)
option(FS_ENABLE_OPENACC "Build with OpenACC support" OFF)
option(FS_ENABLE_MIXED_PRECISION "Use mixed precision" OFF)
include(GNUInstallDirs)
......@@ -38,38 +34,27 @@ if(BUILD_TESTING)
add_subdirectory(test)
endif()
export(
EXPORT "${PROJECT_NAME}-targets"
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake"
)
export(EXPORT "${PROJECT_NAME}-targets"
FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake")
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion
)
install(
EXPORT "${PROJECT_NAME}-targets"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake"
)
install(
FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake"
)
COMPATIBILITY AnyNewerVersion)
install(EXPORT "${PROJECT_NAME}-targets"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake")
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}/cmake")
include("${PROJECT_SOURCE_DIR}/cmake/list_sources.cmake")
......@@ -93,35 +78,28 @@ if("${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
set(c_format_sources "${format_sources}")
list(FILTER c_format_sources INCLUDE REGEX "\.(c|h|cpp|hpp)$")
add_custom_target(format-c
COMMAND
clang-format
--style=file
-i
${c_format_sources}
)
add_custom_target(
format-c
COMMAND clang-format --style=file -i ${c_format_sources}
COMMENT "Format C codes")
# Collect Fortran source files:
set(fortran_format_sources "${format_sources}")
list(FILTER fortran_format_sources INCLUDE REGEX "\.(f|F|f90|F90)$")
add_custom_target(format-fortran
COMMAND
# We do not use a config file but specify the formatting arguments on the
# command line because the feature requires an extra Python package and
# does not work for certain arguments even in the latest release
# (e.g., see https://github.com/pseewald/fprettify/issues/94):
fprettify
--case 2 2 2 1
--indent 2
--whitespace 2
--strip-comments
${fortran_format_sources}
)
add_custom_target(format
DEPENDS
format-c
format-fortran
)
add_custom_target(
format-fortran
COMMAND # We do not use a config file but specify the formatting arguments
# on the command line because the feature requires an extra Python
# package and does not work for certain arguments even in the latest
# release (e.g., see
# https://github.com/pseewald/fprettify/issues/94):
fprettify --case 2 2 2 1 --indent 2 --whitespace 2 --strip-comments
${fortran_format_sources}
COMMENT "Format Fortran codes")
add_custom_target(
format
DEPENDS format-c format-fortran
COMMENT "Format codes")
endif()
<!--
ICON
---------------------------------------------------------------
Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
Contact information: icon-model.org
See AUTHORS.TXT for a list of authors
See LICENSES/ for license information
SPDX-License-Identifier: CC-BY-4.0
---------------------------------------------------------------
-->
# Fortran-support library
This repository is an external library of ICON collecting low-level supporting modules of ICON.
[![Latest Release](https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/badges/release.svg)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/releases)
[![pipeline status](https://gitlab.dkrz.de/icon-libraries/libfortran-support/badges/master/pipeline.svg)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/pipelines/latest?ref=master)
[![coverage report](https://gitlab.dkrz.de/icon-libraries/libfortran-support/badges/master/coverage.svg)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/pipelines/latest?ref=master)
[![pipeline status](https://gitlab.dkrz.de/icon-libraries/libfortran-support/badges/master/pipeline.svg?key_text=Pipeline&key_width=55)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/pipelines/latest?ref=master)
[![coverage report](https://gitlab.dkrz.de/icon-libraries/libfortran-support/badges/master/coverage.svg?key_text=Test%20coverage&key_width=90)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/pipelines/latest?ref=master)
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/blob/master/LICENSES/BSD-3-Clause.txt)
[![License: CC BY 4.0](https://img.shields.io/badge/License-CC_BY_4.0-lightgrey.svg)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/blob/master/LICENSES/CC-BY-4.0.txt)
[![License: CC0-1.0](https://img.shields.io/badge/License-CC0_1.0-lightgrey.svg)](https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/blob/master/LICENSES/CC0-1.0.txt)
......@@ -26,14 +13,15 @@ This repository is an external library of ICON collecting low-level supporting m
The following packages/libraries are required for `libfortran-support`.
- Fortran compiler
- C compiler
- C++ compiler
- CMake 3.18+
The following requirements are optional
- C++ compiler (testing with [GoogleTest](https://github.com/google/googletest))
- OpenACC(nvhpc) for GPU support
- `fprettify` for Fortran code formatting
- [`fprettify`](https://github.com/pseewald/fprettify) for Fortran code formatting
- `clang-format` for C/C++ code formatting
- Ragel State Machine Compiler 7.0+ for C code generation from `.rl` files, used for
- [REUSE](https://reuse.software) v3.0.0+ for licensing
- [Ragel State Machine Compiler](http://www.colm.net/open-source/ragel/) 7.0+ for C code generation from `.rl` files, used for
- `nml_annotate.c`
- `util_arithmetic_expr.c`
- `util_string_parse.c`
......@@ -74,9 +62,11 @@ The `libfortran-support` library includes some general Fortran supporting module
## Some notes for developers
- The `fortran-support` library is only configured by CMake.
- Tips and standards on CMake https://gitlab.dkrz.de/icon/wiki/-/wikis/CMake-recommendations-and-requirements
- Tips and standards on CMake [ICON developer wiki/CMake recommendations and requirements](https://gitlab.dkrz.de/icon/wiki/-/wikis/CMake-recommendations-and-requirements)
- The `fortran-support` library uses `fprettify` for formatting Fortran codes. Run `make format` before you commit.
- The `fortran-support` library is unit tested. (work in progress) All merge request changes are preferable to have a unit test.
- The `fortran-support` library is unit tested. All merge request changes are required to have a unit test. See [icon-c/Wiki/Testing and building of ICON C/Unit test frameworks](https://gitlab.dkrz.de/icon/icon-c/-/wikis/ICON-C-Phase-0/Testing-and-building-of-ICON-C#unit-test-frameworks) for more information on unit testing.
- __Fortran__ unit tests are written in [FortUTF](https://github.com/artemis-beta/FortUTF). [Assertions Documentation](https://github.com/artemis-beta/FortUTF/blob/main/docs/assertions.md)
- __C__ unit tests are written in [GoogleTest](https://github.com/google/googletest). [User's Guide](https://google.github.io/googletest/)
- Fortran preprocessing is automatically applied for files with `.F90` extensions. See [\#4](https://gitlab.dkrz.de/icon-libraries/libfortran-support/-/issues/4) for more details.
## How to add modules in `fortran-support`?
......@@ -100,14 +90,18 @@ mkdir build
cd build
cmake ..
! Or the following for GPU support with OpenACC
cmake -DBUILD_OPENACC=ON ..
cmake -DFS_ENABLE_OPENACC=ON ..
make
```
4. Format the code by `make format`.
5. Make sure your code is tested. For more information on unit tests, check out this [GitLab WIKI page](https://gitlab.dkrz.de/icon/icon-c/-/wikis/ICON-C-Phase-0/Testing-and-building-of-ICON-C#unit-test-frameworks)
5. Make sure your code is tested. Check [developer note](#some-notes-for-developers).
6. Check license by `reuse lint`. Check [requirements](#requirements).
- Code snippets should have license BSD-3-Clause
- Documentations should have license CC-BY-4.0
- Files unrelated to the library itself should have license CC0-1.0
## How to contribute
Please open a merge request and select one of our templates for new features or bugfixes. Detailed instructions on how to proceed are provided there.
Please open a merge request and select one of our templates: __[feature/bugfix]__. Detailed instructions on how to proceed are provided there.
## Contact
This repository is mainly maintained by the following maintainers:
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.txt for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: CC0-1.0
# ---------------------------------------------------------------
version = 1
[[annotations]]
# Documentation and its source files:
path = [
"AUTHORS.txt",
"README.md",
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-License-Identifier = "CC-BY-4.0"
[[annotations]]
# "Unimportant" technical files:
path = [
".gitignore",
".gitlab/**",
".clang-format",
".cmake-format.py",
"_typos.toml"
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-License-Identifier = "CC0-1.0"
[[annotations]]
# GitLab CI configuration file:
path = [
".gitlab-ci.yml"
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-License-Identifier = "BSD-3-Clause"
[files]
extend-exclude = [
# Ragel generated files
"src/nml_annotate.c",
"src/util_arithmetic_expr.c",
"src/util_string_parse.c"
]
[default]
extend-ignore-re = [
# 2nd is detected as typo in the current version
".*_2nd_.*",
]
[default.extend-words]
inout = "inout" # in and out
nin = "nin" # number of inputs
ans = "ans" # short for answer
[default.extend-identifiers]
lowcase = "lowcase" # ICON legacy subroutine name
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------
# cmake-format: off
# check_macro_defined(<output>
# <macro>
# [LANG] <lang>
# [QUIET])
# cmake-format: on
# -----------------------------------------------------------------------------
# Sets <output> to ON or OFF depending on whether <macro> is already defined via
# CMAKE_${lang}_FLAGS or not. However, this only works when <lang> is Fortran
# and fails otherwise.
#
# <lang> can be set using LANG. <lang> is set as Fortran by default.
#
function(check_macro_defined output macro)
cmake_parse_arguments(PARSE_ARGV 1 ARG "QUIET" "LANG" "")
if(NOT ARG_LANG)
set(ARG_LANG "Fortran")
endif()
if(NOT ARG_LANG STREQUAL "Fortran")
message(FATAL_ERROR "check_macro_defined supports only LANG Fortran")
endif()
if(NOT ARG_QUIET)
message(CHECK_START "Checking whether ${macro} is defined")
endif()
# Write a simple Fortran program that checks for ${macro}
set(check_source_code
"
program main
implicit none
#ifdef ${macro}
integer a
#else
#endif
#ifndef ${macro}
#else
integer b
#endif
a = 4
b = 2
end
")
# Write the Fortran code to a file
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.F90"
"${check_source_code}")
# Try to compile the program
try_compile(result "${CMAKE_BINARY_DIR}"
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.F90")
if(NOT ARG_QUIET)
if(${result})
message(CHECK_PASS "yes")
else()
message(CHECK_PASS "no")
endif()
endif()
set(${output}
${result}
PARENT_SCOPE)
endfunction()
......@@ -9,10 +9,32 @@
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------
macro(add_icon_c_test test_name file_names)
add_executable("CTest_${test_name}" ${file_names})
target_link_libraries("CTest_${test_name}" PRIVATE fortran-support::fortran-support GTest::gtest_main stdc++fs)
add_test(NAME "CTest_${test_name}" COMMAND "CTest_${test_name}")
set_property(TEST "CTest_${test_name}" PROPERTY LABELS C)
set_target_properties("CTest_${test_name}" PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
endmacro()
# cmake-format: off
# fs_add_c_test(<test_name>
# [SOURCES <sources>]
# [ARGS <args>])
# cmake-format: on
# -----------------------------------------------------------------------------
# Compiles a test executable with the name <test_name> using the source code
# <source>. Specify ctest arguments in <args> if necessary. The googletest and
# libfortran-support libraries will be linked automatically.
#
# The C++ standard is set to C++17.
#
function(fs_add_c_test test_name)
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "SOURCES;ARGS")
if(NOT ARG_SOURCES)
set(ARG_SOURCES "${ARG_UNPARSED_ARGUMENTS}")
endif()
add_executable("CTest_${test_name}" ${ARG_SOURCES})
target_link_libraries(
"CTest_${test_name}" PRIVATE fortran-support::fortran-support
GTest::gtest_main stdc++fs)
add_test(NAME "CTest_${test_name}" COMMAND "CTest_${test_name}" ${ARG_ARGS})
set_property(TEST "CTest_${test_name}" PROPERTY LABELS C)
set_target_properties("CTest_${test_name}"
PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON)
endfunction()
......@@ -9,10 +9,12 @@
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------
# cmake-format: off
# list_sources(<var>
# [DIRECTORY <dir>]
# [INCLUDE_REGEX <include_regex>]
# [EXCLUDE_GENERATED])
# cmake-format: on
# ------------------------------------------------------------------------------
# Sets <var> to a list of absolute paths to the source files of all targets in
# all subdirectories of <dir> (defaults to the current source directory). The
......@@ -25,18 +27,22 @@
# are excluded from the result.
#
function(list_sources var)
cmake_parse_arguments(PARSE_ARGV 1 ARG
"EXCLUDE_GENERATED"
"DIRECTORY;INCLUDE_REGEX"
""
)
cmake_parse_arguments(PARSE_ARGV 1 ARG "EXCLUDE_GENERATED"
"DIRECTORY;INCLUDE_REGEX" "")
if(ARG_EXCLUDE_GENERATED AND "${CMAKE_VERSION}" VERSION_LESS "3.18")
message(AUTHOR_WARNING
"The generated source files can be automatically excluded only with CMake 3.18 or newer.")
message(
AUTHOR_WARNING
"The generated source files can be automatically excluded only with CMake 3.18 or newer."
)
set(ARG_EXCLUDE_GENERATED FALSE)
endif()
# list_sources_recurse(<var> <dir>)
# ----------------------------------------------------------------------------
# This is a local function that finds the sources recursively. Do not use this
# function directly. Use list_sources instead.
#
function(list_sources_recurse var dir)
get_directory_property(dir_path DIRECTORY ${dir} SOURCE_DIR)
get_directory_property(targets DIRECTORY ${dir} BUILDSYSTEM_TARGETS)
......@@ -54,7 +60,8 @@ function(list_sources var)
if(sources)
foreach(source ${sources})
if(${ARG_EXCLUDE_GENERATED})
get_source_file_property(source_generated ${source} DIRECTORY ${dir} GENERATED)
get_source_file_property(source_generated ${source} DIRECTORY
${dir} GENERATED)
if(source_generated)
continue()
endif()
......@@ -69,7 +76,9 @@ function(list_sources var)
list_sources_recurse(subdir_sources ${subdir} ${ARG_EXCLUDE_GENERATED})
list(APPEND result ${subdir_sources})
endforeach()
set(${var} ${result} PARENT_SCOPE)
set(${var}
${result}
PARENT_SCOPE)
endfunction()
if(NOT ARG_DIRECTORY)
......@@ -83,5 +92,7 @@ function(list_sources var)
endif()
list(REMOVE_DUPLICATES result)
set(${var} ${result} PARENT_SCOPE)
set(${var}
${result}
PARENT_SCOPE)
endfunction()
......@@ -15,26 +15,18 @@ check_include_files("link.h" HAVE_LINK_H)
check_include_files("unwind.h" HAVE_UNWIND_H)
check_include_files("sys/resource.h" HAVE_GETRUSAGE)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
if (BUILD_OPENACC)
message(VERBOSE "Compiler id is ${CMAKE_Fortran_COMPILER_ID}")
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray")
set(OpenACC_FLAGS "-hacc")
else () # Compiler ID for NVHPC is only supported after CMake 3.20
set(OpenACC_FLAGS "-Minfo=all -acc=gpu")
endif ()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenACC_FLAGS}")
endif ()
if (BUILD_OMP)
find_package(OpenMP QUIET)
if(FS_ENABLE_OMP)
find_package(OpenMP REQUIRED)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif ()
endif()
add_library(fortran-support
add_library(
fortran-support
${CMAKE_CURRENT_BINARY_DIR}/config.h
fortran_support.F90
mo_exception.F90
mo_expression.F90
mo_fortran_tools.F90
......@@ -69,48 +61,64 @@ add_library(fortran-support
util_string_parse.c
util_sysinfo.c
util_system.c
util_timer.c
${CMAKE_CURRENT_BINARY_DIR}/config.h
)
util_timer.c)
add_library(${PROJECT_NAME}::fortran-support ALIAS fortran-support)
set(Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mod")
set_target_properties(fortran-support
PROPERTIES
Fortran_PREPROCESS ON
Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}"
C_STANDARD 99
C_STANDARD_REQUIRED ON
EXPORT_NAME ${PROJECT_NAME}::fortran-support
)
set_target_properties(
fortran-support
PROPERTIES Fortran_PREPROCESS ON
Fortran_MODULE_DIRECTORY "${Fortran_MODULE_DIRECTORY}"
C_STANDARD 99
C_STANDARD_REQUIRED ON
EXPORT_NAME ${PROJECT_NAME}::fortran-support)
if (MIXED_PRECISION)
if(FS_ENABLE_MIXED_PRECISION)
target_compile_definitions(fortran-support PRIVATE __MIXED_PRECISION)
endif ()
endif()
include("${PROJECT_SOURCE_DIR}/cmake/check_macro.cmake")
check_macro_defined(HAS_OPENACC_MACRO _OPENACC QUIET)
if(FS_ENABLE_OPENACC)
# If _OPENACC is defined, assume that the required compiler flags are already
# provided, e.g. in CMAKE_Fortran_FLAGS:
if(NOT HAS_OPENACC_MACRO)
# On LUMI, we only have OpenACC_Fortran, but no OpenACC_C
find_package(OpenACC QUIET)
if(NOT OpenACC_Fortran_FOUND)
message(FATAL_ERROR "Could NOT find OpenACC_Fortran.")
endif()
target_compile_options(fortran-support PRIVATE ${OpenACC_Fortran_OPTIONS})
# This make sures that unit tests (FortUTF) compiles without the need of
# passing OpenACC compile option.
target_link_libraries(fortran-support PRIVATE OpenACC::OpenACC_Fortran)
endif()
else()
if(HAS_OPENACC_MACRO)
message(
FATAL_ERROR
"The OpenACC support is disabled but the _OPENACC macro is defined")
endif()
endif()
target_include_directories(fortran-support
target_include_directories(
fortran-support
PUBLIC
# Path to the Fortran modules:
# Path to the Fortran modules:
$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:Fortran>:${Fortran_MODULE_DIRECTORY}>>
$<INSTALL_INTERFACE:$<$<COMPILE_LANGUAGE:Fortran>:${CMAKE_INSTALL_INCLUDEDIR}>>
$<INSTALL_INTERFACE:$<$<COMPILE_LANGUAGE:Fortran>:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>>
INTERFACE
# Path to the internal C/C++ headers (for testing):
# Requires CMake 3.15+ for multiple compile languages https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html
# Path to the internal C/C++ headers (for testing): Requires CMake 3.15+ for
# multiple compile languages
# https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html
$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:C,CXX>:${CMAKE_CURRENT_SOURCE_DIR}>>
PRIVATE
# Path to config.h (for C and C++ only):
# Requires CMake 3.15+ for multiple compile languages https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html
$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:C,CXX>:${CMAKE_CURRENT_BINARY_DIR}>>
)
# Path to config.h (for C and C++ only): Requires CMake 3.15+ for multiple
# compile languages
# https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html
$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:C,CXX>:${CMAKE_CURRENT_BINARY_DIR}>>)
install(
TARGETS fortran-support
EXPORT "${PROJECT_NAME}-targets"
)
install(TARGETS fortran-support EXPORT "${PROJECT_NAME}-targets")
install(
DIRECTORY
"${Fortran_MODULE_DIRECTORY}/"
TYPE INCLUDE
)
install(DIRECTORY "${Fortran_MODULE_DIRECTORY}/" TYPE INCLUDE)
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
! See LICENSES/ for license information
! SPDX-License-Identifier: BSD-3-Clause
! ---------------------------------------------------------------
! Public interface for the fortran-support library
MODULE fortran_support
USE mo_exception, ONLY: init_logger, debug_on, debug_off, &
& set_msg_timestamp, enable_logging, message, warning, finish, &
& print_value, message_to_own_unit, message_text
USE mo_expression, ONLY: expression, parse_expression_string
USE mo_fortran_tools, ONLY: assign_if_present, t_ptr_2d3d, t_ptr_2d3d_vp, &
& assign_if_present_allocatable, if_associated, t_ptr_1d, t_ptr_1d_sp, &
& t_ptr_1d_int, t_ptr_1d_ptr_1d, t_ptr_2d, t_ptr_2d_sp, t_ptr_2d_int, &
& t_ptr_3d, t_ptr_3d_sp, t_ptr_3d_int, t_ptr_i2d3d, t_ptr_4d, t_ptr_4d_sp, &
& t_ptr_4d_int, t_ptr_tracer, copy, init, swap, negative2zero, var_scale, &
& var_add, init_zero_contiguous_dp, init_zero_contiguous_sp, &
& init_contiguous_dp, init_contiguous_sp, init_contiguous_i4, &
& init_contiguous_l, minval_1d, minval_2d, resize_arr_c1d, DO_DEALLOCATE, &
& DO_PTR_DEALLOCATE, insert_dimension, assert_acc_host_only, &
& assert_acc_device_only, assert_lacc_equals_i_am_accel_node, &
& set_acc_host_or_device
USE mo_hash_table, ONLY: t_HashTable, hashTable_make, t_HashIterator
USE mo_io_units, ONLY: filename_max, nerr, nlog, nnml, nstat, ngmt, nin, &
& nout, nnml_output, find_next_free_unit
USE mo_namelist, ONLY: position_nml, open_nml, close_nml, POSITIONED, &
& MISSING, LENGTH_ERROR, READ_ERROR, open_nml_output, close_nml_output
USE mo_octree, ONLY: octree_init, octree_finalize, octree_count_point, &
& octree_query_point, t_range_octree, OCTREE_DEPTH
USE mo_simple_dump, ONLY: dump2text
USE mo_util_backtrace, ONLY: ftn_util_backtrace
USE mo_util_file, ONLY: util_symlink, util_unlink, util_islink, util_rename, &
& util_tmpnam, util_filesize, util_file_is_writable, createSymlink, &
& get_filename, get_filename_noext, get_path
USE mo_util_libc, ONLY: memset_f, memcmp_f, memcpy_f, strerror
USE mo_util_nml, ONLY: util_annotate_nml
USE mo_util_rusage, ONLY: add_rss_list, add_rss_usage, print_rss_usage, &
& close_rss_lists
USE mo_util_sort, ONLY: quicksort, insertion_sort
#ifdef __SX__
USE mo_util_sort, ONLY: radixsort, radixsort_int
#endif
USE mo_util_stride, ONLY: util_stride_1d, util_stride_2d, util_get_ptrdiff
USE mo_util_string, ONLY: tolower, lowcase, toupper, separator, int2string, &
& real2string, logical2string, split_string, string_contains_word, &
& tocompact, str_replace, t_keyword_list, associate_keyword, &
& with_keywords, remove_duplicates, difference, add_to_list, one_of, &
& insert_group, delete_keyword_list, sort_and_compress_list, tohex, &
& remove_whitespace, pretty_print_string_list, find_trailing_number, &
& toCharArray, toCharacter, c2f_char, charArray_dup, charArray_equal, &
& charArray_toLower, normal, bold, fg_black, fg_red, fg_green, fg_yellow, &
& fg_blue, fg_magenta, fg_cyan, fg_white, fg_default, bg_black, bg_red, &
& bg_green, bg_yellow, bg_blue, bg_magenta, bg_cyan, bg_white, bg_default, &
& new_list
USE mo_util_string_parse, ONLY: util_do_parse_intlist
USE mo_util_system, ONLY: util_exit, util_abort, util_system
#ifdef __XT3__
USE mo_util_system, ONLY: util_base_iobuf
#endif
USE mo_util_table, ONLY: initialize_table, finalize_table, add_table_column, &
& set_table_entry, print_table, t_table, t_column
USE mo_util_texthash, ONLY: text_hash, text_hash_c, text_isEqual, sel_char
#if defined(__PGI) || defined(__FLANG)
USE mo_util_texthash, ONLY: t_char_workaround
#endif
USE mo_util_timer, ONLY: util_cputime, util_walltime, util_gettimeofday, &
& util_init_real_time, util_get_real_time_size, util_read_real_time, &
& util_diff_real_time
! From mo_exception
PUBLIC :: init_logger, debug_on, debug_off, set_msg_timestamp, &
& enable_logging, message, warning, finish, print_value, &
& message_to_own_unit, message_text
! From mo_expression
PUBLIC :: expression, parse_expression_string
! From mo_fortran_tools
PUBLIC :: assign_if_present, t_ptr_2d3d, t_ptr_2d3d_vp, &
& assign_if_present_allocatable, if_associated, t_ptr_1d, t_ptr_1d_sp, &
& t_ptr_1d_int, t_ptr_1d_ptr_1d, t_ptr_2d, t_ptr_2d_sp, t_ptr_2d_int, &
& t_ptr_3d, t_ptr_3d_sp, t_ptr_3d_int, t_ptr_i2d3d, t_ptr_4d, t_ptr_4d_sp, &
& t_ptr_4d_int, t_ptr_tracer, copy, init, swap, negative2zero, var_scale, &
& var_add, init_zero_contiguous_dp, init_zero_contiguous_sp, &
& init_contiguous_dp, init_contiguous_sp, init_contiguous_i4, &
& init_contiguous_l, minval_1d, minval_2d, resize_arr_c1d, DO_DEALLOCATE, &
& DO_PTR_DEALLOCATE, insert_dimension, assert_acc_host_only, &
& assert_acc_device_only, assert_lacc_equals_i_am_accel_node, &
& set_acc_host_or_device
! From mo_hash_table
PUBLIC :: t_HashTable, hashTable_make, t_HashIterator
! From mo_io_units
PUBLIC :: filename_max, nerr, nlog, nnml, nstat, ngmt, nin, nout, &
& nnml_output, find_next_free_unit
! From mo_namelist
PUBLIC :: position_nml, open_nml, close_nml, POSITIONED, MISSING, &
& LENGTH_ERROR, READ_ERROR, open_nml_output, close_nml_output
! From mo_octree
PUBLIC :: octree_init, octree_finalize, octree_count_point, &
& octree_query_point, t_range_octree, OCTREE_DEPTH
! From mo_simple_dump
PUBLIC :: dump2text
! From mo_util_backtrace
PUBLIC :: ftn_util_backtrace
! From mo_util_file
PUBLIC :: util_symlink, util_unlink, util_islink, util_rename, util_tmpnam, &
& util_filesize, util_file_is_writable, createSymlink, get_filename, &
& get_filename_noext, get_path
! From mo_util_libc
PUBLIC :: memset_f, memcmp_f, memcpy_f, strerror
! From mo_util_nml
PUBLIC :: util_annotate_nml
! From mo_util_rusage
PUBLIC :: add_rss_list, add_rss_usage, print_rss_usage, close_rss_lists
! From mo_util_sort
PUBLIC :: quicksort, insertion_sort
#ifdef __SX__
PUBLIC :: radixsort, radixsort_int
#endif
! From mo_util_stride
PUBLIC :: util_stride_1d, util_stride_2d, util_get_ptrdiff
! From mo_util_string
PUBLIC :: tolower, lowcase, toupper, separator, int2string, real2string, &
& logical2string, split_string, string_contains_word, tocompact, &
& str_replace, t_keyword_list, associate_keyword, with_keywords, &
& remove_duplicates, difference, add_to_list, one_of, insert_group, &
& delete_keyword_list, sort_and_compress_list, tohex, remove_whitespace, &
& pretty_print_string_list, find_trailing_number, toCharArray, &
& toCharacter, c2f_char, charArray_dup, charArray_equal, &
& charArray_toLower, normal, bold, fg_black, fg_red, fg_green, fg_yellow, &
& fg_blue, fg_magenta, fg_cyan, fg_white, fg_default, bg_black, bg_red, &
& bg_green, bg_yellow, bg_blue, bg_magenta, bg_cyan, bg_white, bg_default, &
& new_list
! From mo_util_string_parse
PUBLIC :: util_do_parse_intlist
! From mo_util_system
PUBLIC :: util_exit, util_abort, util_system
#ifdef __XT3__
PUBLIC :: util_base_iobuf
#endif
! From mo_util_table
PUBLIC :: initialize_table, finalize_table, add_table_column, &
& set_table_entry, print_table, t_table, t_column
! From mo_util_texthash
PUBLIC :: text_hash, text_hash_c, text_isEqual, sel_char
#if defined(__PGI) || defined(__FLANG)
PUBLIC :: t_char_workaround
#endif
! From mo_util_timer
PUBLIC :: util_cputime, util_walltime, util_gettimeofday, &
& util_init_real_time, util_get_real_time_size, util_read_real_time, &
& util_diff_real_time
END MODULE
......@@ -15,7 +15,7 @@
! Machine (FSM) and Dijkstra's shunting yard algorithm.
! It is possible to include mathematical functions, operators, and
! constants, see the LaTeX documentation for this module in the
! appendix of the namelist documentaion. Besides, Fortran variables
! appendix of the namelist documentation. Besides, Fortran variables
! can be linked to the expression and used in the evaluation. The
! implementation supports scalar input variables as well as 2D and 3D
! fields, where it is implicitly assumed that 2D fields are embedded
......@@ -442,7 +442,7 @@ CONTAINS
SELECT CASE (cqueue%list(i)%etype)
CASE (VALUE)
ALLOCATE (op_value)
op_value%val = REAL(cqueue%list(i)%val)
op_value%val = REAL(cqueue%list(i)%val, KIND=real_kind)
expr_list%list(i)%p => op_value
CASE (VARIABLE)
ALLOCATE (op_variable)
......@@ -1053,8 +1053,8 @@ CONTAINS
INTEGER :: exponent
CALL result_stack%pop(arg2)
CALL result_stack%pop(arg1)
exponent = arg2
IF (arg2 == exponent) THEN
exponent = NINT(arg2)
IF (arg2 == REAL(exponent, real_kind)) THEN
arg1 = arg1**exponent
ELSE
arg1 = arg1**arg2
......@@ -1070,8 +1070,8 @@ CONTAINS
INTEGER, DIMENSION(:, :), ALLOCATABLE :: exponent
CALL result_stack%pop(arg2)
CALL result_stack%pop(arg1)
exponent = arg2
IF (ALL(arg2 == exponent)) THEN
exponent = NINT(arg2)
IF (ALL(arg2 == REAL(exponent, real_kind))) THEN
arg1 = arg1**exponent
ELSE
arg1 = arg1**arg2
......@@ -1087,8 +1087,8 @@ CONTAINS
INTEGER, DIMENSION(:, :, :), ALLOCATABLE :: exponent
CALL result_stack%pop(arg2)
CALL result_stack%pop(arg1)
exponent = arg2
IF (ALL(arg2 == exponent)) THEN
exponent = NINT(arg2)
IF (ALL(arg2 == REAL(exponent, real_kind))) THEN
arg1 = arg1**exponent
ELSE
arg1 = arg1**arg2
......
......@@ -467,6 +467,8 @@ CONTAINS
END SUBROUTINE swap_int
!>
!! Expand array by given size
!!
!! Expand a 1D character array by given size.
!!
SUBROUTINE resize_arr_c1d(arr, nelem)
......@@ -513,7 +515,7 @@ CONTAINS
SUBROUTINE copy_1d_dp(src, dest, lacc, opt_acc_async)
REAL(dp), INTENT(IN) :: src(:)
REAL(dp), INTENT(OUT) :: dest(:)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, m1
LOGICAL :: lzacc
......@@ -537,7 +539,7 @@ CONTAINS
SUBROUTINE copy_2d_dp(src, dest, lacc, opt_acc_async)
REAL(dp), INTENT(IN) :: src(:, :)
REAL(dp), INTENT(OUT) :: dest(:, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, m1, m2
LOGICAL :: lzacc
......@@ -567,7 +569,7 @@ CONTAINS
SUBROUTINE copy_3d_dp(src, dest, lacc, opt_acc_async)
REAL(dp), INTENT(IN) :: src(:, :, :)
REAL(dp), INTENT(OUT) :: dest(:, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
LOGICAL :: lzacc
......@@ -600,7 +602,7 @@ CONTAINS
SUBROUTINE copy_4d_dp(src, dest, lacc, opt_acc_async)
REAL(dp), INTENT(IN) :: src(:, :, :, :)
REAL(dp), INTENT(OUT) :: dest(:, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, m1, m2, m3, m4
LOGICAL :: lzacc
......@@ -636,7 +638,7 @@ CONTAINS
SUBROUTINE copy_5d_dp(src, dest, lacc, opt_acc_async)
REAL(dp), INTENT(IN) :: src(:, :, :, :, :)
REAL(dp), INTENT(OUT) :: dest(:, :, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
LOGICAL :: lzacc
......@@ -675,7 +677,7 @@ CONTAINS
SUBROUTINE copy_5d_sp(src, dest, lacc, opt_acc_async)
REAL(sp), INTENT(IN) :: src(:, :, :, :, :)
REAL(sp), INTENT(OUT) :: dest(:, :, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
LOGICAL :: lzacc
......@@ -714,7 +716,7 @@ CONTAINS
SUBROUTINE copy_2d_spdp(src, dest, lacc, opt_acc_async)
REAL(sp), INTENT(IN) :: src(:, :)
REAL(dp), INTENT(OUT) :: dest(:, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, m1, m2
LOGICAL :: lzacc
......@@ -744,7 +746,7 @@ CONTAINS
SUBROUTINE copy_3d_spdp(src, dest, lacc, opt_acc_async)
REAL(sp), INTENT(IN) :: src(:, :, :)
REAL(dp), INTENT(OUT) :: dest(:, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
LOGICAL :: lzacc
......@@ -777,7 +779,7 @@ CONTAINS
SUBROUTINE copy_4d_spdp(src, dest, lacc, opt_acc_async)
REAL(sp), INTENT(IN) :: src(:, :, :, :)
REAL(dp), INTENT(OUT) :: dest(:, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, m1, m2, m3, m4
LOGICAL :: lzacc
......@@ -813,7 +815,7 @@ CONTAINS
SUBROUTINE copy_5d_spdp(src, dest, lacc, opt_acc_async)
REAL(sp), INTENT(IN) :: src(:, :, :, :, :)
REAL(dp), INTENT(OUT) :: dest(:, :, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
LOGICAL :: lzacc
......@@ -852,7 +854,7 @@ CONTAINS
SUBROUTINE copy_2d_i4(src, dest, lacc, opt_acc_async)
INTEGER(ik4), INTENT(IN) :: src(:, :)
INTEGER(ik4), INTENT(OUT) :: dest(:, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, m1, m2
LOGICAL :: lzacc
......@@ -882,7 +884,7 @@ CONTAINS
SUBROUTINE copy_3d_i4(src, dest, lacc, opt_acc_async)
INTEGER(ik4), INTENT(IN) :: src(:, :, :)
INTEGER(ik4), INTENT(OUT) :: dest(:, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
LOGICAL :: lzacc
......@@ -915,7 +917,7 @@ CONTAINS
SUBROUTINE copy_5d_i4(src, dest, lacc, opt_acc_async)
INTEGER(ik4), INTENT(IN) :: src(:, :, :, :, :)
INTEGER(ik4), INTENT(OUT) :: dest(:, :, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
LOGICAL :: lzacc
......@@ -954,7 +956,7 @@ CONTAINS
SUBROUTINE copy_5d_l(src, dest, lacc, opt_acc_async)
LOGICAL, INTENT(IN) :: src(:, :, :, :, :)
LOGICAL, INTENT(OUT) :: dest(:, :, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
LOGICAL :: lzacc
......@@ -991,7 +993,7 @@ CONTAINS
SUBROUTINE init_zero_1d_dp(init_var, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, m1
LOGICAL :: lzacc
......@@ -1011,7 +1013,7 @@ CONTAINS
SUBROUTINE init_zero_1d_sp(init_var, lacc, opt_acc_async)
REAL(sp), INTENT(OUT) :: init_var(:)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, m1
LOGICAL :: lzacc
......@@ -1031,7 +1033,7 @@ CONTAINS
SUBROUTINE init_zero_2d_dp(init_var, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, m1, m2
LOGICAL :: lzacc
......@@ -1059,7 +1061,7 @@ CONTAINS
SUBROUTINE init_zero_2d_i4(init_var, lacc, opt_acc_async)
INTEGER(ik4), INTENT(OUT) :: init_var(:, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, m1, m2
LOGICAL :: lzacc
......@@ -1087,7 +1089,7 @@ CONTAINS
SUBROUTINE init_zero_3d_dp(init_var, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
LOGICAL :: lzacc
......@@ -1118,7 +1120,7 @@ CONTAINS
SUBROUTINE init_zero_3d_sp(init_var, lacc, opt_acc_async)
REAL(sp), INTENT(OUT) :: init_var(:, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
LOGICAL :: lzacc
......@@ -1150,7 +1152,7 @@ CONTAINS
SUBROUTINE init_zero_3d_i4(init_var, lacc, opt_acc_async)
INTEGER(ik4), INTENT(OUT) :: init_var(:, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
LOGICAL :: lzacc
......@@ -1181,7 +1183,7 @@ CONTAINS
SUBROUTINE init_zero_4d_dp(init_var, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, m1, m2, m3, m4
LOGICAL :: lzacc
......@@ -1199,6 +1201,7 @@ CONTAINS
#else
!$omp do collapse(4)
#endif
!NEC$ forced_collapse
DO i4 = 1, m4
DO i3 = 1, m3
DO i2 = 1, m2
......@@ -1215,7 +1218,7 @@ CONTAINS
SUBROUTINE init_zero_4d_sp(init_var, lacc, opt_acc_async)
REAL(sp), INTENT(OUT) :: init_var(:, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, m1, m2, m3, m4
LOGICAL :: lzacc
......@@ -1233,6 +1236,7 @@ CONTAINS
#else
!$omp do collapse(4)
#endif
!NEC$ forced_collapse
DO i4 = 1, m4
DO i3 = 1, m3
DO i2 = 1, m2
......@@ -1249,7 +1253,7 @@ CONTAINS
SUBROUTINE init_zero_4d_i4(init_var, lacc, opt_acc_async)
INTEGER(ik4), INTENT(OUT) :: init_var(:, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, m1, m2, m3, m4
LOGICAL :: lzacc
......@@ -1267,6 +1271,7 @@ CONTAINS
#else
!$omp do collapse(4)
#endif
!NEC$ forced_collapse
DO i4 = 1, m4
DO i3 = 1, m3
DO i2 = 1, m2
......@@ -1284,7 +1289,7 @@ CONTAINS
SUBROUTINE init_1d_dp(init_var, init_val, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:)
REAL(dp), INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, m1
LOGICAL :: lzacc
......@@ -1306,7 +1311,7 @@ CONTAINS
SUBROUTINE init_2d_dp(init_var, init_val, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:, :)
REAL(dp), INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, m1, m2
......@@ -1336,7 +1341,7 @@ CONTAINS
SUBROUTINE init_3d_dp(init_var, init_val, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:, :, :)
REAL(dp), INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
......@@ -1369,7 +1374,7 @@ CONTAINS
SUBROUTINE init_3d_spdp(init_var, init_val, lacc, opt_acc_async)
REAL(sp), INTENT(OUT) :: init_var(:, :, :)
REAL(dp), INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
......@@ -1402,7 +1407,7 @@ CONTAINS
SUBROUTINE init_5d_dp(init_var, init_val, lacc, opt_acc_async)
REAL(dp), INTENT(OUT) :: init_var(:, :, :, :, :)
REAL(dp), INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
......@@ -1441,7 +1446,7 @@ CONTAINS
SUBROUTINE init_5d_sp(init_var, init_val, lacc, opt_acc_async)
REAL(sp), INTENT(OUT) :: init_var(:, :, :, :, :)
REAL(sp), INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
......@@ -1480,7 +1485,7 @@ CONTAINS
SUBROUTINE init_5d_i4(init_var, init_val, lacc, opt_acc_async)
INTEGER(ik4), INTENT(OUT) :: init_var(:, :, :, :, :)
INTEGER(ik4), INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
......@@ -1519,7 +1524,7 @@ CONTAINS
SUBROUTINE init_5d_l(init_var, init_val, lacc, opt_acc_async)
LOGICAL, INTENT(OUT) :: init_var(:, :, :, :, :)
LOGICAL, INTENT(IN) :: init_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, i5, m1, m2, m3, m4, m5
......@@ -1558,7 +1563,7 @@ CONTAINS
SUBROUTINE var_scale_3d_dp(var, scale_val, lacc, opt_acc_async)
REAL(dp), INTENT(inout) :: var(:, :, :)
REAL(dp), INTENT(in) :: scale_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
......@@ -1592,7 +1597,7 @@ CONTAINS
SUBROUTINE var_addc_3d_dp(var, add_val, lacc, opt_acc_async)
REAL(dp), INTENT(inout) :: var(:, :, :)
REAL(dp), INTENT(in) :: add_val
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, m1, m2, m3
......@@ -1624,7 +1629,7 @@ CONTAINS
SUBROUTINE negative2zero_4d_dp(var, lacc, opt_acc_async)
REAL(dp), INTENT(inout) :: var(:, :, :, :)
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i1, i2, i3, i4, m1, m2, m3, m4
......@@ -1659,12 +1664,12 @@ CONTAINS
CALL acc_wait_if_requested(1, opt_acc_async)
END SUBROUTINE negative2zero_4d_dp
SUBROUTINE init_contiguous_dp(var, n, v, opt_acc_async, lacc)
SUBROUTINE init_contiguous_dp(var, n, v, lacc, opt_acc_async)
INTEGER, INTENT(IN) :: n
REAL(dp), INTENT(OUT) :: var(n)
REAL(dp), INTENT(IN) :: v
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
INTEGER :: i
LOGICAL :: lzacc
......@@ -1681,21 +1686,21 @@ CONTAINS
CALL acc_wait_if_requested(1, opt_acc_async)
END SUBROUTINE init_contiguous_dp
SUBROUTINE init_zero_contiguous_dp(var, n, opt_acc_async, lacc)
SUBROUTINE init_zero_contiguous_dp(var, n, lacc, opt_acc_async)
INTEGER, INTENT(IN) :: n
REAL(dp), INTENT(OUT) :: var(n)
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
CALL init_contiguous_dp(var, n, 0.0_dp, opt_acc_async, lacc)
CALL init_contiguous_dp(var, n, 0.0_dp, lacc, opt_acc_async)
END SUBROUTINE init_zero_contiguous_dp
SUBROUTINE init_contiguous_sp(var, n, v, opt_acc_async, lacc)
SUBROUTINE init_contiguous_sp(var, n, v, lacc, opt_acc_async)
INTEGER, INTENT(IN) :: n
REAL(sp), INTENT(OUT) :: var(n)
REAL(sp), INTENT(IN) :: v
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
INTEGER :: i
LOGICAL :: lzacc
......@@ -1712,21 +1717,21 @@ CONTAINS
END SUBROUTINE init_contiguous_sp
SUBROUTINE init_zero_contiguous_sp(var, n, opt_acc_async, lacc)
SUBROUTINE init_zero_contiguous_sp(var, n, lacc, opt_acc_async)
INTEGER, INTENT(IN) :: n
REAL(sp), INTENT(OUT) :: var(n)
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
CALL init_contiguous_sp(var, n, 0.0_sp, opt_acc_async, lacc=lacc)
CALL init_contiguous_sp(var, n, 0.0_sp, lacc, opt_acc_async)
END SUBROUTINE init_zero_contiguous_sp
SUBROUTINE init_contiguous_i4(var, n, v, opt_acc_async, lacc)
SUBROUTINE init_contiguous_i4(var, n, v, lacc, opt_acc_async)
INTEGER, INTENT(IN) :: n
INTEGER(ik4), INTENT(OUT) :: var(n)
INTEGER(ik4), INTENT(IN) :: v
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
INTEGER :: i
LOGICAL :: lzacc
......@@ -1743,12 +1748,12 @@ CONTAINS
CALL acc_wait_if_requested(1, opt_acc_async)
END SUBROUTINE init_contiguous_i4
SUBROUTINE init_contiguous_l(var, n, v, opt_acc_async, lacc)
SUBROUTINE init_contiguous_l(var, n, v, lacc, opt_acc_async)
INTEGER, INTENT(IN) :: n
LOGICAL, INTENT(OUT) :: var(n)
LOGICAL, INTENT(IN) :: v
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
INTEGER :: i
LOGICAL :: lzacc
......@@ -1769,7 +1774,7 @@ CONTAINS
!! Computes the MINVAL(var)
!! This wrapper enables the use of OpenACC without using ACC-KERNELS
INTEGER, INTENT(IN) :: var(:) ! input array
LOGICAL, INTENT(IN), OPTIONAL :: lacc ! if true, use OpenACC
LOGICAL, INTENT(IN) :: lacc ! if true, use OpenACC
LOGICAL :: lzacc ! non-optional version of lacc
INTEGER :: minval_1d, i, s1
......@@ -1780,12 +1785,11 @@ CONTAINS
minval_1d = HUGE(minval_1d)
!$ACC PARALLEL DEFAULT(PRESENT) COPY(minval_1d) ASYNC(1) REDUCTION(MIN: minval_1d) IF(lacc)
!$ACC LOOP GANG VECTOR
!$ACC PARALLEL LOOP GANG VECTOR DEFAULT(PRESENT) ASYNC(1) REDUCTION(MIN: minval_1d) IF(lzacc) COPY(minval_1d)
DO i = 1, s1
minval_1d = MIN(minval_1d, var(i)) ! The loop is equivalent to MINVAL(var(:))
END DO
!$ACC END PARALLEL
!$ACC END PARALLEL LOOP
!$ACC WAIT ! required to sync result back to CPU
#else
minval_1d = MINVAL(var(:))
......@@ -1797,7 +1801,7 @@ CONTAINS
!! Computes the MINVAL(var)
!! This wrapper enables the use of OpenACC without using ACC-KERNELS
INTEGER, INTENT(IN) :: var(:, :) ! input array
LOGICAL, INTENT(IN), OPTIONAL :: lacc ! if true, use OpenACC
LOGICAL, INTENT(IN) :: lacc ! if true, use OpenACC
LOGICAL :: lzacc ! non-optional version of lacc
INTEGER :: minval_2d, i, j, s1, s2
......@@ -1809,7 +1813,7 @@ CONTAINS
minval_2d = HUGE(minval_2d)
!$ACC PARALLEL LOOP GANG VECTOR DEFAULT(PRESENT) ASYNC(1) REDUCTION(MIN: minval_2d) IF(lacc)
!$ACC PARALLEL LOOP GANG VECTOR DEFAULT(PRESENT) ASYNC(1) COLLAPSE(2) REDUCTION(MIN: minval_2d) IF(lzacc) COPY(minval_2d)
DO j = 1, s2
DO i = 1, s1
minval_2d = MIN(minval_2d, var(i, j)) ! The loop is equivalent to MINVAL(var(:,:))
......@@ -2325,8 +2329,10 @@ CONTAINS
LOGICAL, INTENT(IN), OPTIONAL :: lacc
#ifdef _OPENACC
IF (PRESENT(lacc) .AND. lacc) THEN
CALL finish(routine_name, ' not supported on ACC device.')
IF (PRESENT(lacc)) THEN
IF (lacc) THEN
CALL finish(routine_name, ' not supported on ACC device.')
END IF
END IF
#endif
END SUBROUTINE assert_acc_host_only
......@@ -2336,22 +2342,24 @@ CONTAINS
LOGICAL, INTENT(IN), OPTIONAL :: lacc
#ifdef _OPENACC
IF ((.NOT. PRESENT(lacc)) .OR. (.NOT. lacc)) THEN
CALL finish(routine_name, ' not supported on ACC host.')
IF (.NOT. PRESENT(lacc)) THEN
CALL finish(routine_name, ' must not be called without lacc.')
ELSE
IF (.NOT. lacc) THEN
CALL finish(routine_name, ' not supported in ACC host mode.')
END IF
END IF
#endif
END SUBROUTINE assert_acc_device_only
SUBROUTINE assert_lacc_equals_i_am_accel_node(routine_name, lacc, i_am_accel_node)
CHARACTER(len=*), INTENT(IN) :: routine_name
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: i_am_accel_node
LOGICAL, INTENT(IN) :: lacc
LOGICAL, INTENT(IN) :: i_am_accel_node
#ifdef _OPENACC
IF (PRESENT(lacc) .AND. PRESENT(i_am_accel_node)) THEN
IF (lacc .NEQV. i_am_accel_node) THEN
CALL finish(routine_name, 'lacc /= i_am_accel_node')
END IF
IF (lacc .NEQV. i_am_accel_node) THEN
CALL finish(routine_name, 'lacc /= i_am_accel_node')
END IF
#endif
......
......@@ -70,7 +70,7 @@ MODULE mo_hash_table
TYPE(t_HashEntry), POINTER :: curEntry => NULL()
CONTAINS
PROCEDURE :: init => hashIterator_init
PROCEDURE :: nextEntry => hashIterator_nextEntry ! returns .TRUE. IF the operation was successfull
PROCEDURE :: nextEntry => hashIterator_nextEntry ! returns .TRUE. IF the operation was successful
PROCEDURE :: reset => hashIterator_reset
END TYPE
......