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 (7)
Showing with 282 additions and 74 deletions
......@@ -42,7 +42,7 @@ nag:
- ctest --output-on-failure
tags:
- levante-fake, hpc, dkrz
needs: ["Check OpenACC Style", "Check Style", "Check License"]
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check License"]
gcc11:
stage: build_and_test
......@@ -57,7 +57,7 @@ gcc11:
- ctest --output-on-failure
tags:
- levante-fake, hpc, dkrz
needs: ["Check OpenACC Style", "Check Style", "Check License"]
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check License"]
intel22:
stage: build_and_test
......@@ -72,7 +72,7 @@ intel22:
- ctest --output-on-failure
tags:
- levante-fake, hpc, dkrz
needs: ["Check OpenACC Style", "Check Style", "Check License"]
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check License"]
nvhpc:
stage: build_and_test
......@@ -87,7 +87,7 @@ nvhpc:
- ctest --output-on-failure
tags:
- levante-fake, hpc, dkrz
needs: ["Check OpenACC Style", "Check Style", "Check License"]
needs: ["Check Typo", "Check OpenACC Style", "Check Style", "Check License"]
OpenACC:
stage: build_OpenACC
......@@ -103,6 +103,17 @@ OpenACC:
- levante-fake, hpc, dkrz
needs: ["nvhpc"]
Check Typo:
stage: lint
before_script:
# install typo check package
- conda install typos
script: typos
tags:
# choose conda available runner
- conda
needs: []
Check OpenACC Style:
extends: .colorized
stage: lint
......@@ -110,10 +121,8 @@ Check OpenACC Style:
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/
......@@ -127,11 +136,9 @@ Check OpenACC Style:
(see artifacts).${DEFAULT}\n" >&2
exit 1
}
tags:
# choose python capable runner:
- sphinx
artifacts:
paths:
- acc_style.patch
......@@ -140,7 +147,6 @@ Check OpenACC Style:
when: on_failure
needs: []
Check Style:
stage: lint
before_script:
......
......@@ -10,6 +10,7 @@
# ---------------------------------------------------------------
# A more complete author list is provided in the ICON repository.
Daniel Hupp
Daniel Reinert
Daniel Rieger
Florian Prill
......
......@@ -13,8 +13,6 @@ cmake_minimum_required(VERSION 3.18)
project(fortran-support VERSION 0.1.0 LANGUAGES Fortran C)
find_package(OpenACC QUIET)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(BUILD_TESTING "Build tests" ON)
......
......@@ -15,8 +15,8 @@ SPDX-License-Identifier: CC-BY-4.0
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 +26,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`
......@@ -50,6 +51,7 @@ The `libfortran-support` library includes some general Fortran supporting module
- `mo_io_units`: io unit definitions
- `mo_namelist`: open/close namelist files
- `mo_octree`: octree data structure and operations
- `mo_random_number_generators`: generators for pseudo random numbers (should be moved to math-support once available)
- `mo_simple_dump`: array value dumping
- `mo_util_backtrace`: function backtrace
- `mo_util_file`: file operations
......@@ -74,9 +76,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`?
......@@ -104,10 +108,14 @@ 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
# ---------------------------------------------------------------
[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
......@@ -32,6 +32,7 @@ add_library(fortran-support
mo_io_units.F90
mo_namelist.F90
mo_octree.F90
mo_random_number_generators.F90
mo_simple_dump.F90
mo_util_backtrace.F90
mo_util_file.F90
......@@ -84,8 +85,13 @@ 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)
find_package(OpenACC REQUIRED)
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.
......
......@@ -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
......
......@@ -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)
......@@ -1659,12 +1661,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), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i
LOGICAL :: lzacc
......@@ -1681,21 +1683,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), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
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), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i
LOGICAL :: lzacc
......@@ -1712,21 +1714,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), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
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), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i
LOGICAL :: lzacc
......@@ -1743,12 +1745,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), OPTIONAL :: opt_acc_async
LOGICAL, INTENT(IN), OPTIONAL :: lacc
LOGICAL, INTENT(IN), OPTIONAL :: opt_acc_async
INTEGER :: i
LOGICAL :: lzacc
......@@ -1780,12 +1782,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(lacc)
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(:))
......@@ -2325,8 +2326,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 +2339,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
......
......@@ -25,7 +25,7 @@ MODULE mo_io_units
PUBLIC
! This paramter is taken from /usr/include/stdio.h (ANSI C standard). If problems
! This parameter is taken from /usr/include/stdio.h (ANSI C standard). If problems
! with filename length appear, check the before mentioned file.
INTEGER, PARAMETER :: filename_max = 1024
......
! 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
! ---------------------------------------------------------------
MODULE mo_random_number_generators
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: wp => real64
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int32, int64, real64
IMPLICIT NONE
PRIVATE
PUBLIC :: random_normal_values, clip, initialize_random_number_generator, generate_uniform_random_number
INTERFACE generate_uniform_random_number
MODULE PROCEDURE generate_uniform_random_number_wp
END INTERFACE generate_uniform_random_number
INTERFACE random_normal_values
MODULE PROCEDURE random_normal_values_wp
END INTERFACE random_normal_values
INTERFACE clip
MODULE PROCEDURE clip_wp
END INTERFACE clip
! integer parameters for using revised minstd parameters as in
! https://en.wikipedia.org/wiki/Lehmer_random_number_generator#Parameters_in_common_use
INTEGER(KIND=int64), PARAMETER :: minstd_A0 = 16807
INTEGER(KIND=int64), PARAMETER :: minstd_A = 48271
INTEGER(KIND=int64), PARAMETER :: minstd_M = 2147483647
REAL(KIND=real64), PARAMETER :: minstd_Scale = 1.0_real64/REAL(minstd_M, real64)
CONTAINS
! initializes Lehmer random number generator
PURE FUNCTION initialize_random_number_generator(iseed, jseed) RESULT(minstd_state)
INTEGER(KIND=int32), INTENT(IN) :: iseed
INTEGER(KIND=int32), INTENT(IN) :: jseed
INTEGER(KIND=int32) :: minstd_state
! doing kind of an xorshift32 see https://en.wikipedia.org/wiki/Xorshift
minstd_state = iseed
minstd_state = IEOR(minstd_state, jseed*2**13)
minstd_state = IEOR(minstd_state, jseed/2**17)
minstd_state = IEOR(minstd_state, jseed*2**5)
minstd_state = MOD(minstd_A0*minstd_state, minstd_M)
minstd_state = MOD(minstd_A*minstd_state, minstd_M)
END FUNCTION initialize_random_number_generator
! generated Lehmer random number generator https://en.wikipedia.org/wiki/Lehmer_random_number_generator
FUNCTION generate_uniform_random_number_wp(minstd_state) RESULT(random_number)
INTEGER(KIND=int32), INTENT(INOUT) :: minstd_state
REAL(KIND=real64) :: random_number
minstd_state = MOD(minstd_A*minstd_state, minstd_M)
random_number = ABS(minstd_Scale*minstd_state)
END FUNCTION generate_uniform_random_number_wp
SUBROUTINE clip_wp(values_range, values)
! Subroutine arguments (in/out/inout)
REAL(wp), INTENT(IN) :: values_range ! allowed range of random numbers
REAL(wp), DIMENSION(:), INTENT(INOUT) :: values ! array of value to be filled with random numbers
! Limit random number range
WHERE (values(:) > values_range)
values(:) = values_range
ELSEWHERE(values(:) < -values_range)
values(:) = -values_range
END WHERE
END SUBROUTINE clip_wp
SUBROUTINE random_normal_values_wp(seed, values_range, values, mean, stdv)
! Subroutine arguments (in/out/inout)
INTEGER, INTENT(IN) :: seed ! seed to be used
REAL(wp), INTENT(IN) :: values_range ! allowed range of random numbers
REAL(wp), DIMENSION(:), INTENT(INOUT) :: values ! array of value to be filled with random numbers
REAL(wp), INTENT(IN), OPTIONAL :: mean
REAL(wp), INTENT(IN), OPTIONAL :: stdv
REAL(wp), PARAMETER :: pi = 3.141592653589793238_wp ! replace with math constants from math-support once available
! Local variables
INTEGER(KIND=int32) :: i, rng_state, n
REAL(KIND=wp) :: u1, u2, z0, z1, magnitude, theta, mu, sigma
IF (PRESENT(mean)) THEN
mu = mean
ELSE
mu = 0.0_wp
END IF
IF (PRESENT(stdv)) THEN
sigma = stdv
ELSE
sigma = 1.0_wp
END IF
n = SIZE(values)
! -----------------------------------------------------------------------
! Initialize a random number generator, by using the MINSTD linear
! congruential generator (LCG). "nmaxstreams" indicates that random
! numbers will be requested in blocks of this length. The generator
! is seeded with "seed".
!-------------------------------------------------------------------------
DO i = 1, n/2 + 1
rng_state = initialize_random_number_generator(seed, i)
u1 = generate_uniform_random_number(rng_state)
DO WHILE (u1 <= EPSILON(0.0_wp))
u1 = generate_uniform_random_number(rng_state)
END DO
u2 = generate_uniform_random_number(rng_state)
! using the Box-Muller transform https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
magnitude = sigma*SQRT(-2.0_wp*LOG(u1));
theta = 2.0_wp*pi*u2
z0 = magnitude*COS(theta) + mu;
z1 = magnitude*SIN(theta) + mu;
values(2*i - 1) = z0
IF (2*i <= n) values(2*i) = z1
END DO
CALL clip(values_range, values)
END SUBROUTINE random_normal_values_wp
END MODULE mo_random_number_generators
......@@ -93,7 +93,7 @@ CONTAINS
CHARACTER(len=10), INTENT(INOUT), OPTIONAL :: tag
TYPE(rss_list), ALLOCATABLE :: tmp_rss_lists(:)
INTEGER :: ist
INTEGER :: iostat
IF (.NOT. ALLOCATED(rss_lists)) THEN
ALLOCATE (rss_lists(max_lists))
......@@ -118,7 +118,7 @@ CONTAINS
IF (PRESENT(tag)) THEN
rss_lists(idx)%filename = TRIM(name)//'_'//TRIM(tag)//'.log'
rss_lists(idx)%fileunit = find_next_free_unit(10, 999)
OPEN (UNIT=rss_lists(idx)%fileunit, FILE=rss_lists(idx)%filename, IOSTAT=ist, Recl=line_length)
OPEN (UNIT=rss_lists(idx)%fileunit, FILE=rss_lists(idx)%filename, IOSTAT=iostat, Recl=line_length)
WRITE (rss_lists(idx)%fileunit, '(1x,a)') 'idx maxrss majflt minflt nvcsw nivcsw'
ELSE
rss_lists(idx)%filename = ''
......
......@@ -130,7 +130,7 @@ CONTAINS
CHARACTER(len=*), INTENT(IN) :: uppercase
CHARACTER(len=LEN_TRIM(uppercase)) :: tolower
!
INTEGER, PARAMETER :: idel = ICHAR('a') - ICHAR('A')
INTEGER, PARAMETER :: idiff = ICHAR('a') - ICHAR('A')
INTEGER, PARAMETER :: ia = ICHAR('A')
INTEGER, PARAMETER :: iz = ICHAR('Z')
INTEGER :: i, ic
......@@ -138,7 +138,7 @@ CONTAINS
DO i = 1, LEN_TRIM(uppercase)
ic = ICHAR(uppercase(i:i))
IF (ic >= ia .AND. ic <= iz) THEN
tolower(i:i) = CHAR(ic + idel)
tolower(i:i) = CHAR(ic + idiff)
ELSE
tolower(i:i) = uppercase(i:i)
END IF
......@@ -151,7 +151,7 @@ CONTAINS
!!
ELEMENTAL SUBROUTINE lowcase(s)
CHARACTER(len=*), INTENT(INOUT) :: s
INTEGER, PARAMETER :: idel = ICHAR('a') - ICHAR('A')
INTEGER, PARAMETER :: idiff = ICHAR('a') - ICHAR('A')
INTEGER, PARAMETER :: ia = ICHAR('A')
INTEGER, PARAMETER :: iz = ICHAR('Z')
INTEGER :: i, ic, n
......@@ -159,7 +159,7 @@ CONTAINS
n = LEN_TRIM(s)
DO i = 1, n
ic = ICHAR(s(i:i))
s(i:i) = CHAR(ic + MERGE(idel, 0, ic >= ia .AND. ic <= iz))
s(i:i) = CHAR(ic + MERGE(idiff, 0, ic >= ia .AND. ic <= iz))
END DO
END SUBROUTINE lowcase
!------------------------------------------------------------------------------------------------
......@@ -170,7 +170,7 @@ CONTAINS
CHARACTER(len=*), INTENT(IN) :: lowercase
CHARACTER(len=LEN_TRIM(lowercase)) :: toupper
!
INTEGER, PARAMETER :: idel = ICHAR('A') - ICHAR('a')
INTEGER, PARAMETER :: idiff = ICHAR('A') - ICHAR('a')
INTEGER, PARAMETER :: ia = ICHAR('a')
INTEGER, PARAMETER :: iz = ICHAR('z')
INTEGER :: i, ic
......@@ -178,7 +178,7 @@ CONTAINS
DO i = 1, LEN_TRIM(lowercase)
ic = ICHAR(lowercase(i:i))
IF (ic >= ia .AND. ic <= iz) THEN
toupper(i:i) = CHAR(ic + idel)
toupper(i:i) = CHAR(ic + idiff)
ELSE
toupper(i:i) = lowercase(i:i)
END IF
......
......@@ -9,7 +9,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
/* lookup3 by Bob Jekins, May 2006, Public Domain.
/* lookup3 by Bob Jenkins, May 2006, Public Domain.
* Original version downloaded from: http://burtleburtle.net/bob/
* -------------------------------------------------------------------------------
* lookup3.c, by Bob Jenkins, May 2006, Public Domain.
......@@ -93,7 +93,7 @@
#else
#error "Couldn't determine endianess."
#error "Couldn't determine endianness."
#endif
......@@ -273,7 +273,7 @@ uint32_t util_hashword(const void *key, size_t length, uint32_t initval) {
* rest of the string. Every machine with memory protection I've seen
* does it on word boundaries, so is OK with this. But VALGRIND will
* still catch it and complain. The masking trick does make the hash
* noticably faster for short strings (like English words).
* noticeably faster for short strings (like English words).
*/
#ifndef VALGRIND
......@@ -487,7 +487,7 @@ uint32_t util_hashword(const void *key, size_t length, uint32_t initval) {
* rest of the string. Every machine with memory protection I've seen
* does it on word boundaries, so is OK with this. But VALGRIND will
* still catch it and complain. The masking trick does make the hash
* noticably faster for short strings (like English words).
* noticeably faster for short strings (like English words).
*/
#ifndef VALGRIND
......
......@@ -9,7 +9,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
// Fortan interface to the following functions is
// Fortran interface to the following functions is
// implemented in ../src/shared/mo_util_stride.f90
#include <stddef.h>
......
......@@ -29,7 +29,7 @@
#include <sys/systemcfg.h>
#endif
/* funcion implemetations */
/* function implementations */
void util_user_name(char *name, int *actual_len) {
struct passwd *current;
......
......@@ -9,7 +9,7 @@
// SPDX-License-Identifier: BSD-3-Clause
// ---------------------------------------------------------------
// Fortan interface to the following functions is
// Fortran interface to the following functions is
// implemented in ../src/shared/mo_util_system.f90
#include <stdlib.h>
......
......@@ -11,7 +11,7 @@
/* Portable CPU-timer (User + Sys); also WALL CLOCK-timer */
// Fortan interface to the following functions is
// Fortran interface to the following functions is
// implemented in ../src/shared/mo_util_timer.f90
#include <unistd.h>
......
......@@ -46,7 +46,7 @@ TEST_F(UtilStringParseTest, ParseIntListIsCorrect) {
std::string parse_line = "1,2,3;nlev";
std::vector<int> result = { 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1 };
// One extra index [0] unused becuase Fortran index starts from 1
// One extra index [0] unused because Fortran index starts from 1
std::vector<int> output(nlev + 1);
int ierr;
......@@ -64,7 +64,7 @@ TEST_F(UtilStringParseTest, ParseIntListIsCorrect2) {
std::string parse_line = "1;3,4...7";
std::vector<int> result = { 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0 };
// One extra index [0] unused becuase Fortran index starts from 1
// One extra index [0] unused because Fortran index starts from 1
std::vector<int> output(nlev + 1);
int ierr;
......@@ -86,7 +86,7 @@ TEST_F(UtilStringParseTest, ParseIntListIsCorrect3) {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
// clang-format on
// One extra index [0] unused becuase Fortran index starts from 1
// One extra index [0] unused because Fortran index starts from 1
std::vector<int> output(nlev + 1);
int ierr;
......@@ -108,7 +108,7 @@ TEST_F(UtilStringParseTest, ParseIntListIsCorrect4) {
1, 1, 0, 0, 0, 0, 0, 1, 0, 0 };
// clang-format on
// One extra index [0] unused becuase Fortran index starts from 1
// One extra index [0] unused because Fortran index starts from 1
std::vector<int> output(nlev + 1);
int ierr;
......
......@@ -15,8 +15,8 @@ if ("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.24")
endif()
include(FetchContent)
FetchContent_Declare(fortutf
URL https://github.com/artemis-beta/FortUTF/archive/694afc80a5362d0711a99f248a25b1b5edd668f5.tar.gz
URL_HASH MD5=1cc90b741c89436b4711b6dd1ea05980
URL https://github.com/artemis-beta/FortUTF/archive/bf749de0f710e0dd7f6d00a4f5104d78fefb94e9.tar.gz
URL_HASH MD5=1246c176d0f543acf040facc26d24d54
)
FetchContent_MakeAvailable(fortutf)
message(CHECK_PASS "done")
......