Commit 8951ca11 authored by Sebastian Müller's avatar Sebastian Müller 🐈
Browse files

Merge branch 'update_mo_kind' into develop

parents 4311be53 234d7b17
Pipeline #61566 passed with stages
in 11 minutes and 6 seconds
......@@ -28,7 +28,15 @@ endif()
# add sources
add_library(${LIB_NAME} ${sources} ${fyppOutFiles})
target_include_directories(${LIB_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
# add pre-processor flag (-cpp or -fpp)
# control mo_kind
option(FORCES_WITH_ISO_FORTRAN_ENV "build the module with kind definitions of ISO_FORTRAN_ENV instead of ISO_C_BINDING" OFF)
if (FORCES_WITH_ISO_FORTRAN_ENV)
message(STATUS "FORCES: use ISO_FORTRAN_ENV for mo_kind")
target_compile_definitions(${LIB_NAME} PRIVATE FORCES_WITH_ISO_FORTRAN_ENV)
else()
message(STATUS "FORCES: use ISO_C_BINDING for mo_kind")
endif()
# find the netcdf and netcdf-fortran libraries quietly, taken from ecmwf project
find_package(NetCDF COMPONENTS Fortran QUIET)
......
!> \file mo_kind.f90
!> \copydoc mo_kind
!> \brief Define number representations
!> \details This module declares the desired ranges and precisions of the number representations,
!! such as single precision or double precision, 32-bit or 64-bit integer, etc.
!> \copyright GNU Lesser General Public License http://www.gnu.org/licenses/
!> \authors Juliane Mai, Matthias Cuntz
!> \date 2011-2014
!> \author Sebastian Mueller
!> \date Jan 2022
!! - added option for ISO_FORTRAN ENV
!! - added quad precision for real and complex
MODULE mo_kind
#ifdef FORCES_WITH_ISO_FORTRAN_ENV
use, intrinsic :: iso_fortran_env, only: &
int8, int16, int32, int64, real32, real64, real128
#else
use, intrinsic :: iso_c_binding, only: &
int8 => c_int8_t, &
int16 => c_short, & ! c_int16_t
int32 => c_int, & ! c_int32_t
int64 => c_long_long, & ! c_int64_t
real32 => c_float, &
real64 => c_double, &
real128 => c_long_double
#endif
IMPLICIT NONE
!> 1 Byte Integer Kind
INTEGER, PARAMETER :: i1 = int8
!> 2 Byte Integer Kind
INTEGER, PARAMETER :: i2 = int16
!> 4 Byte Integer Kind
INTEGER, PARAMETER :: i4 = int32
!> 8 Byte Integer Kind
INTEGER, PARAMETER :: i8 = int64
!> Single Precision Real Kind
INTEGER, PARAMETER :: sp = real32
!> Double Precision Real Kind
INTEGER, PARAMETER :: dp = real64
!> Quad Precision Real Kind
INTEGER, PARAMETER :: qp = real128
!> Single Precision Complex Kind
INTEGER, PARAMETER :: spc = real32
!> Double Precision Complex Kind
INTEGER, PARAMETER :: dpc = real64
!> Quad Precision Complex Kind
INTEGER, PARAMETER :: qpc = real128
!> Logical Kind
INTEGER, PARAMETER :: lgt = KIND(.true.)
END MODULE mo_kind
!> \file mo_kind.f90
!> \copydoc mo_kind
!> \brief Define number representations
!> \details This module declares the desired ranges and precisions of the number representations,
!> such as single precision or double precision, 32-bit or 46-bit integer, etc.
!> It confirms mostly with the nrtype module of Numerical Recipes in f90.
!> \authors Juliane Mai, Matthias Cuntz, Nov 2011
!> \date 2011-2014
!> \copyright GNU Lesser General Public License http://www.gnu.org/licenses/
! Number model from which the SELECTED_REAL_KIND are requested:
! 4 byte REAL 8 byte REAL
! IEEE: precision => 6 precision => 15
! exponent => 37 exponent => 307
! CRAY: - precision => 13
! exponent => 2465
! Written Juliane Mai, Matthias Cuntz, Nov 2011
! Modified Matthias Cuntz, Nov 2011 - private/public
! - documentation
! - removed tab characters
! Matthias Cuntz, May 2014 - iso_fortran_env and iso_c_binding
! S. Mueller, Dec 2019 - remove NR specific types
! License
! -------
! This file is part of the UFZ Fortran library.
! The UFZ Fortran library is free software: you can redistribute it and/or modify
! it under the terms of the GNU Lesser General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
! The UFZ Fortran library is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU Lesser General Public License for more details.
! You should have received a copy of the GNU Lesser General Public License
! along with the UFZ Fortran library (LICENSE).
! If not, see <http://www.gnu.org/licenses/>.
! Copyright 2011-2014 Matthias Cuntz, Juliane Mai
MODULE mo_kind
! ! this is defined here https://github.com/fortran-lang/stdlib/ like so
! use iso_fortran_env, only: sp=>real32, dp=>real64, qp=>real128
! use iso_fortran_env, only: i1=>int8, i2=>int16, i4=>int32, i8=>int64
use, intrinsic :: iso_c_binding, only: &
i2=>c_short, &
i4=>c_int, &
i8=>c_long_long, &
sp=>c_float, &
dp=>c_double, &
spc=>c_float_complex, &
dpc=>c_double_complex
implicit none
private
!public sp, dp, qp, int8, int16, int32, int64
public sp, dp, i2, i4, i8, spc, dpc
integer, parameter, public :: lgt = kind(.true.)
integer, parameter, public :: i1 = selected_int_kind(2)
END MODULE mo_kind
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment