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 (3)
Showing with 686 additions and 210 deletions
ICON
---------------------------------------------------------------
Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
Contact information: icon-model.org
See AUTHORS.TXT for a list of authors
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
......@@ -23,6 +23,7 @@ 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)
option(FS_ENABLE_SINGLE_PRECISION "Use single precision" OFF)
include(GNUInstallDirs)
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.txt for a list of authors
......@@ -18,7 +18,7 @@ path = [
"README.md",
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-FileCopyrightText = "2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-License-Identifier = "CC-BY-4.0"
[[annotations]]
......@@ -31,7 +31,7 @@ path = [
"_typos.toml"
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-FileCopyrightText = "2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-License-Identifier = "CC0-1.0"
[[annotations]]
......@@ -40,5 +40,5 @@ path = [
".gitlab-ci.yml"
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-FileCopyrightText = "2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss"
SPDX-License-Identifier = "BSD-3-Clause"
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
......
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
......@@ -27,6 +27,7 @@ add_library(
fortran-support
${CMAKE_CURRENT_BINARY_DIR}/config.h
fortran_support.F90
mo_iconlib_kind.F90
mo_exception.F90
mo_expression.F90
mo_fortran_tools.F90
......@@ -75,7 +76,15 @@ set_target_properties(
EXPORT_NAME ${PROJECT_NAME}::fortran-support)
if(FS_ENABLE_MIXED_PRECISION)
target_compile_definitions(fortran-support PRIVATE __MIXED_PRECISION)
if(FS_ENABLE_SINGLE_PRECISION)
# Do not enable MIXED_PRECISION if SINGLE_PRECISION enabled
else()
target_compile_definitions(fortran-support PRIVATE __MIXED_PRECISION)
endif()
endif()
if(FS_ENABLE_SINGLE_PRECISION)
target_compile_definitions(fortran-support PRIVATE __SINGLE_PRECISION)
endif()
include("${PROJECT_SOURCE_DIR}/cmake/check_macro.cmake")
......
// ICON
//
// ---------------------------------------------------------------
// Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
// Contact information: icon-model.org
//
// See AUTHORS.TXT for a list of authors
......
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......@@ -16,17 +16,41 @@ MODULE fortran_support
& 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, &
USE mo_fortran_tools, ONLY: assign_if_present, assign_if_present_allocatable, if_associated, &
& t_ptr_1d_dp, t_ptr_1d_sp, t_ptr_1d_int, &
& t_ptr_2d_dp, t_ptr_2d_sp, t_ptr_2d_int, &
& t_ptr_3d_dp, t_ptr_3d_sp, t_ptr_3d_int, t_ptr_i2d3d, &
& t_ptr_4d_dp, t_ptr_4d_sp, t_ptr_4d_int, &
& t_ptr_2d3d, t_ptr_2d3d_vp, t_ptr_tracer, &
& copy, init, swap, negative2zero, var_scale, &
& var_add, init_zero_contiguous, init_contiguous, &
& 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
& assert_acc_device_only, set_acc_host_or_device
#ifdef __SINGLE_PRECISION
USE mo_fortran_tools, ONLY: &
& t_ptr_1d_wp => t_ptr_1d_sp, &
& t_ptr_2d_wp => t_ptr_2d_sp, &
& t_ptr_3d_wp => t_ptr_3d_sp, &
& t_ptr_4d_wp => t_ptr_4d_sp, &
& t_ptr_1d => t_ptr_1d_sp, &
& t_ptr_2d => t_ptr_2d_sp, &
& t_ptr_3d => t_ptr_3d_sp, &
& t_ptr_4d => t_ptr_4d_sp
#else
USE mo_fortran_tools, ONLY: &
& t_ptr_1d_wp => t_ptr_1d_dp, &
& t_ptr_2d_wp => t_ptr_2d_dp, &
& t_ptr_3d_wp => t_ptr_3d_dp, &
& t_ptr_4d_wp => t_ptr_4d_dp, &
& t_ptr_1d => t_ptr_1d_dp, &
& t_ptr_2d => t_ptr_2d_dp, &
& t_ptr_3d => t_ptr_3d_dp, &
& t_ptr_4d => t_ptr_4d_dp
#endif
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
......@@ -83,17 +107,19 @@ MODULE fortran_support
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, &
PUBLIC :: assign_if_present, assign_if_present_allocatable, if_associated, &
& t_ptr_1d, t_ptr_1d_wp, t_ptr_1d_dp, t_ptr_1d_sp, t_ptr_1d_int, &
& t_ptr_2d, t_ptr_2d_wp, t_ptr_2d_dp, t_ptr_2d_sp, t_ptr_2d_int, &
& t_ptr_3d, t_ptr_3d_wp, t_ptr_3d_dp, t_ptr_3d_sp, t_ptr_3d_int, t_ptr_i2d3d, &
& t_ptr_4d, t_ptr_4d_wp, t_ptr_4d_dp, t_ptr_4d_sp, t_ptr_4d_int, &
& t_ptr_2d3d, t_ptr_2d3d_vp, t_ptr_tracer, &
& copy, init, swap, negative2zero, var_scale, &
& var_add, init_zero_contiguous, init_contiguous, &
& 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
& assert_acc_device_only, set_acc_host_or_device
! From mo_hash_table
PUBLIC :: t_HashTable, hashTable_make, t_HashIterator
......
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......@@ -38,8 +38,7 @@ MODULE mo_exception
!
! abort: routine to end the code in case finish is called
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: wp => real64, &
& i8 => int64
USE mo_iconlib_kind, ONLY: wp, dp, sp, i8
USE mo_io_units, ONLY: filename_max
USE mo_util_backtrace, ONLY: ftn_util_backtrace
......@@ -72,7 +71,8 @@ MODULE mo_exception
MODULE PROCEDURE print_lvalue !< logical
MODULE PROCEDURE print_ivalue !< integer
MODULE PROCEDURE print_i8value !< integer(i8)
MODULE PROCEDURE print_rvalue !< real
MODULE PROCEDURE print_rvalue_dp !< real64
MODULE PROCEDURE print_rvalue_sp !< real32
END INTERFACE
INTERFACE
......@@ -398,10 +398,10 @@ CONTAINS
END SUBROUTINE print_i8value
SUBROUTINE print_rvalue(mstring, rvalue, routine)
SUBROUTINE print_rvalue_dp(mstring, rvalue, routine)
CHARACTER(len=*), INTENT(IN) :: mstring
REAL(wp), INTENT(IN) :: rvalue
REAL(dp), INTENT(IN) :: rvalue
CHARACTER(len=*), TARGET, OPTIONAL, INTENT(IN) :: routine
CHARACTER(len=:), POINTER :: rtn
CHARACTER(len=1), TARGET :: dummy
......@@ -416,6 +416,26 @@ CONTAINS
WRITE (tmp, '(a60,1x,":",g12.5)') mstring, rvalue
CALL param(rtn, tmp)
END SUBROUTINE print_rvalue
END SUBROUTINE print_rvalue_dp
SUBROUTINE print_rvalue_sp(mstring, rvalue, routine)
CHARACTER(len=*), INTENT(IN) :: mstring
REAL(sp), INTENT(IN) :: rvalue
CHARACTER(len=*), TARGET, OPTIONAL, INTENT(IN) :: routine
CHARACTER(len=:), POINTER :: rtn
CHARACTER(len=1), TARGET :: dummy
CHARACTER(len=filename_max) :: tmp = ""
IF (PRESENT(routine)) THEN
rtn => routine
ELSE
dummy = ' '
rtn => dummy(1:0)
END IF
WRITE (tmp, '(a60,1x,":",g12.5)') mstring, rvalue
CALL param(rtn, tmp)
END SUBROUTINE print_rvalue_sp
END MODULE mo_exception
This diff is collapsed.
This diff is collapsed.
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2025, 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
! ---------------------------------------------------------------
!>
!! Contains real and integer kinds for libfortran-support and libiconmath
!!
MODULE mo_iconlib_kind
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: real64, real32, int32, int64
IMPLICIT NONE
PRIVATE
PUBLIC :: wp !< Selected working precision
PUBLIC :: vp !< Selected variable precision
PUBLIC :: dp !< 8 byte real (double precision)
PUBLIC :: sp !< 4 byte real (single precision)
PUBLIC :: i8 !< 8 byte integer
PUBLIC :: i4 !< 4 byte integer
INTEGER, PARAMETER :: dp = real64
INTEGER, PARAMETER :: sp = real32
INTEGER, PARAMETER :: i8 = int64
INTEGER, PARAMETER :: i4 = int32
#ifdef __SINGLE_PRECISION
INTEGER, PARAMETER :: wp = sp
#else
INTEGER, PARAMETER :: wp = dp
#endif
#ifdef __MIXED_PRECISION
INTEGER, PARAMETER :: vp = sp
#else
INTEGER, PARAMETER :: vp = wp
#endif
END MODULE mo_iconlib_kind
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......@@ -14,7 +14,7 @@
MODULE mo_octree
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: wp => real64
USE mo_iconlib_kind, ONLY: wp
USE mo_exception, ONLY: finish
USE mo_util_sort, ONLY: quicksort
#ifdef __SX__
......
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......@@ -11,7 +11,7 @@
MODULE mo_simple_dump
USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: wp => real64
USE mo_iconlib_kind, ONLY: wp
IMPLICIT NONE
......
! ICON
!
! ---------------------------------------------------------------
! Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Copyright (C) 2004-2025, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
! Contact information: icon-model.org
!
! See AUTHORS.TXT for a list of authors
......