diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 82f9caff4..8855c73c1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -7,6 +7,7 @@ env: CMAKE_BUILD_PARALLEL_LEVEL: "2" # 2 cores on each GHA VM, enable parallel builds CTEST_OUTPUT_ON_FAILURE: "ON" # This way we don't need a flag to ctest CTEST_PARALLEL_LEVEL: "2" + CTEST_TIME_TIMEOUT: "5" # some failures hang forever HOMEBREW_NO_ANALYTICS: "ON" # Make Homebrew installation a little quicker HOMEBREW_NO_AUTO_UPDATE: "ON" HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK: "ON" @@ -55,10 +56,15 @@ jobs: run: cmake -Wdev -DCMAKE_BUILD_TYPE=Release -S . -B build - name: Build and compile - run: cmake --build build || cmake --build build --verbose --parallel 1 + run: cmake --build build + + - name: catch build fail + run: cmake --build build --verbose --parallel 1 + if: failure() - name: test - run: cmake --build build --target test + run: ctest --parallel --output-on-failure + working-directory: build - name: Test in-tree builds if: contains( matrix.gcc_v, '9') # Only test one compiler on each platform diff --git a/.github/workflows/ci_windows.yml b/.github/workflows/ci_windows.yml index 077db6bb2..0d34a9a5d 100644 --- a/.github/workflows/ci_windows.yml +++ b/.github/workflows/ci_windows.yml @@ -4,6 +4,7 @@ on: [push, pull_request] env: CI: "ON" + CTEST_TIME_TIMEOUT: "5" # some failures hang forever jobs: Build: @@ -24,7 +25,8 @@ jobs: - name: CMake build run: cmake --build build --parallel - - run: cmake --build build --verbose --parallel 1 + - name: catch build fail + run: cmake --build build --verbose --parallel 1 if: failure() - name: CTest diff --git a/CMakeLists.txt b/CMakeLists.txt index ffd1c0def..a99f32292 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,11 +2,6 @@ cmake_minimum_required(VERSION 3.14.0) project(stdlib Fortran) enable_testing() -# this avoids stdlib and projects using stdlib from having to introspect stdlib's directory structure -# FIXME: this eventually needs to be handled more precisely, as this spills all .mod/.smod into one directory -# and thereby can clash if module/submodule names are the same in different parts of library -set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}) - # --- compiler options if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU) add_compile_options(-fimplicit-none) @@ -20,6 +15,7 @@ endif() include(CheckFortranSourceCompiles) include(CheckFortranSourceRuns) check_fortran_source_compiles("error stop i; end" f18errorstop SRC_EXT f90) +check_fortran_source_compiles("real, allocatable :: array(:, :, :, :, :, :, :, :, :, :); end" f03rank SRC_EXT f90) check_fortran_source_runs("use, intrinsic :: iso_fortran_env, only : real128; real(real128) :: x; x = x+1; end" f03real128) add_subdirectory(src) diff --git a/README.md b/README.md index 817a082b1..ed29e2350 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,24 @@ # Fortran Standard Library +[![Actions Status](https://github.com/fortran-lang/stdlib/workflows/CI/badge.svg)](https://github.com/fortran-lang/stdlib/actions) +[![Actions Status](https://github.com/fortran-lang/stdlib/workflows/CI_windows/badge.svg)](https://github.com/fortran-lang/stdlib/actions) + + +## Goals and Motivation + +The Fortran Standard, as published by the ISO (https://wg5-fortran.org/), does +not have a Standard Library. The goal of this project is to provide a community +driven and agreed upon *de facto* "standard" library for Fortran, called a +Fortran Standard Library (`stdlib`). We have a rigorous process how `stdlib` is +developed as documented in our [Workflow](WORKFLOW.md). `stdlib` is both a +specification and a reference implementation. We are cooperating with the +Fortran Standards Committee (e.g., the effort +[started](https://github.com/j3-fortran/fortran_proposals/issues/104) at the J3 +committee repository) and the plan is to continue working with the Committee in +the future (such as in the step 5. in the [Workflow](WORKFLOW.md) document), so +that if the Committee wants to standardize some feature already available in `stdlib`, it would +base it on `stdlib`'s implementation. + ## Scope The goal of the Fortran Standard Library is to achieve the following general scope: @@ -16,19 +35,19 @@ The goal of the Fortran Standard Library is to achieve the following general sco ### Get the code -``` +```sh git clone https://github.com/fortran-lang/stdlib cd stdlib ``` ### Build with CMake -``` -mkdir build -cd build -cmake .. -make -ctest +```sh +cmake -B build + +cmake --build build + +cmake --build build --target test ``` ### Build with make diff --git a/WORKFLOW.md b/WORKFLOW.md index 8c1672af4..b2ddb233e 100644 --- a/WORKFLOW.md +++ b/WORKFLOW.md @@ -1,5 +1,57 @@ # Workflow for the Fortran stdlib contributors -This document will describe the workflow we'll follow when developing the Fortran stdlib. -It's largely to be discussed and decided. -For now, take a look at the [issues](https://github.com/fortran-lang/stdlib). +This document describes our current workflow. + +We welcome everyone and anyone to participate and propose additions to stdlib. +It is okay if you do not have experience for specification or implementation, +but have an idea for stdlib. If the idea is popular among the community, more +experienced contributors will help it through all 5 steps. + + +1. **Idea**: You have an idea or a proposal. Open an + [issue](https://github.com/fortran-lang/stdlib/issues) to discuss it. This + is on the level of "is there interest in having image reader/writer + functions in stdlib?" The goal of this step is to find out if the community + is interested in having this functionality as part of stdlib. + +2. **API**: When there seems to be significant interest in the proposal (vast + majority of participants think it is a good idea), move on to discuss the + specific API. It's OK to propose the API off the bat if you already have an + idea for it. This step is exploratory and its goal is to find out what the + API should *look* and *feel* like. + +3. **Specification**: Discuss the API and iterate. When there is vast majority + approval for the API, move on to implement it and submit a PR. Small PRs are + always better than large. It is OK to implement only a few functions of a + new module, and continue work on the others in a later PR. All new + functionality goes into an "experimental" namespace + (`stdlib_experimental_*.f90`). As part of the PR, when submitting a new + public facing API, please provide the initial draft of the specification + document as well as the the initial reference implementation of this + specification. The specification is a document that describes the API and + the functionality, so that anyone can use it to create an implementation + from scratch without looking at `stdlib`. The `stdlib` library then provides + the reference implementation. + +4. **Implementation** in experimental: When opening a PR, request reviews from + one or more people that are most relevant to it. These are likely to be + people involved in prior steps of the workflow. Other contributors (not + explicitly invited) are encouraged to provide reviews and suggestions as + well. Iterate until all (or most) participants are on the same page. + We can merge when there is vast majority approval of the PR. + +5. **Release**: Moving from experimental to release. The experimental + "namespace" contains new functionality together with its specification. In + order to move from experimental to release, the specification document must + be approved by the wide community and the standards committee (informally). + If that happens, it has now been blessed for broad use and we can move the + code into the main section of `stdlib`, and the particular specification + document becomes part of the Fortran Standard Library. + + +Note: the general term "vast majority" above means at least 80%, but ultimately +it is left to our best judgement to ensure that the community agrees that each +PR and proposal was approved by "vast majority". + +You are welcome to propose changes to this workflow by opening an +[issue](https://github.com/fortran-lang/stdlib/issues). diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee5a7aa22..32e46f617 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,18 +2,35 @@ set(SRC stdlib_experimental_ascii.f90 stdlib_experimental_io.f90 stdlib_experimental_error.f90 - stdlib_experimental_optval.f90 stdlib_experimental_kinds.f90 + stdlib_experimental_optval.f90 + stdlib_experimental_system.F90 ) add_library(fortran_stdlib ${SRC}) +set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/mod_files/) +set_target_properties(fortran_stdlib PROPERTIES + Fortran_MODULE_DIRECTORY ${LIB_MOD_DIR}) +target_include_directories(fortran_stdlib PUBLIC + $ + $ +) + if(f18errorstop) target_sources(fortran_stdlib PRIVATE f18estop.f90) else() target_sources(fortran_stdlib PRIVATE f08estop.f90) endif() +if(f03rank) + target_sources(fortran_stdlib PRIVATE f03_stdlib_experimental_stats.f90) + target_sources(fortran_stdlib PRIVATE f03_stdlib_experimental_stats_mean.f90) +else() + target_sources(fortran_stdlib PRIVATE f90_stdlib_experimental_stats.f90) + target_sources(fortran_stdlib PRIVATE f90_stdlib_experimental_stats_mean.f90) +endif() + add_subdirectory(tests) install(TARGETS fortran_stdlib @@ -21,3 +38,4 @@ install(TARGETS fortran_stdlib ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) +install(DIRECTORY ${LIB_MOD_DIR} DESTINATION include) diff --git a/src/Makefile.manual b/src/Makefile.manual index 0807f3ff1..e61ee5a08 100644 --- a/src/Makefile.manual +++ b/src/Makefile.manual @@ -3,7 +3,9 @@ SRC = stdlib_experimental_ascii.f90 \ stdlib_experimental_io.f90 \ stdlib_experimental_optval.f90 \ stdlib_experimental_kinds.f90 \ - f18estop.f90 + f18estop.f90 \ + f03_stdlib_experimental_stats.f90 \ + f03_stdlib_experimental_stats_mean.f90 LIB = libstdlib.a @@ -34,3 +36,7 @@ stdlib_experimental_io.o: \ stdlib_experimental_optval.o \ stdlib_experimental_kinds.o stdlib_experimental_optval.o: stdlib_experimental_kinds.o +f03_stdlib_experimental_stats_mean.o: \ + stdlib_experimental_optval.o \ + stdlib_experimental_kinds.o \ + f03_stdlib_experimental_stats.o diff --git a/src/f03_stdlib_experimental_stats.f90 b/src/f03_stdlib_experimental_stats.f90 new file mode 100644 index 000000000..7685b49a5 --- /dev/null +++ b/src/f03_stdlib_experimental_stats.f90 @@ -0,0 +1,1667 @@ +module stdlib_experimental_stats + + +use stdlib_experimental_kinds, only: sp, dp, qp, & + int8, int16, int32, int64 +implicit none +private +! Public API +public :: mean + +interface mean + module function mean_1_sp_sp(x) result(res) + real(sp), intent(in) :: x(:) + real(sp) :: res + end function mean_1_sp_sp + module function mean_1_dp_dp(x) result(res) + real(dp), intent(in) :: x(:) + real(dp) :: res + end function mean_1_dp_dp + module function mean_1_qp_qp(x) result(res) + real(qp), intent(in) :: x(:) + real(qp) :: res + end function mean_1_qp_qp + + module function mean_1_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int8_dp + module function mean_1_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int16_dp + module function mean_1_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int32_dp + module function mean_1_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int64_dp + + + module function mean_2_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:) + real(sp) :: res + end function mean_2_all_sp_sp + module function mean_2_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_dp_dp + module function mean_2_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:) + real(qp) :: res + end function mean_2_all_qp_qp + + module function mean_2_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int8_dp + module function mean_2_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int16_dp + module function mean_2_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int32_dp + module function mean_2_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int64_dp + + module function mean_2_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(sp) :: res(size(x)/size(x, dim)) + end function mean_2_sp_sp + module function mean_2_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_dp_dp + module function mean_2_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(qp) :: res(size(x)/size(x, dim)) + end function mean_2_qp_qp + + module function mean_2_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int8_dp + module function mean_2_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int16_dp + module function mean_2_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int32_dp + module function mean_2_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int64_dp + + + + + +module function mean_3_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:) + real(sp) :: res +end function mean_3_all_sp_sp +module function mean_4_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:) + real(sp) :: res +end function mean_4_all_sp_sp +module function mean_5_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + real(sp) :: res +end function mean_5_all_sp_sp +module function mean_6_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + real(sp) :: res +end function mean_6_all_sp_sp +module function mean_7_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + real(sp) :: res +end function mean_7_all_sp_sp +module function mean_8_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_8_all_sp_sp +module function mean_9_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_9_all_sp_sp +module function mean_10_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_10_all_sp_sp +module function mean_11_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_11_all_sp_sp +module function mean_12_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_12_all_sp_sp +module function mean_13_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_13_all_sp_sp +module function mean_14_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_14_all_sp_sp +module function mean_15_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res +end function mean_15_all_sp_sp +module function mean_3_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_dp_dp +module function mean_4_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_dp_dp +module function mean_5_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_dp_dp +module function mean_6_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_dp_dp +module function mean_7_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_dp_dp +module function mean_8_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_8_all_dp_dp +module function mean_9_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_9_all_dp_dp +module function mean_10_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_10_all_dp_dp +module function mean_11_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_11_all_dp_dp +module function mean_12_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_12_all_dp_dp +module function mean_13_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_13_all_dp_dp +module function mean_14_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_14_all_dp_dp +module function mean_15_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_15_all_dp_dp +module function mean_3_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:) + real(qp) :: res +end function mean_3_all_qp_qp +module function mean_4_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:) + real(qp) :: res +end function mean_4_all_qp_qp +module function mean_5_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + real(qp) :: res +end function mean_5_all_qp_qp +module function mean_6_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + real(qp) :: res +end function mean_6_all_qp_qp +module function mean_7_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + real(qp) :: res +end function mean_7_all_qp_qp +module function mean_8_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_8_all_qp_qp +module function mean_9_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_9_all_qp_qp +module function mean_10_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_10_all_qp_qp +module function mean_11_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_11_all_qp_qp +module function mean_12_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_12_all_qp_qp +module function mean_13_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_13_all_qp_qp +module function mean_14_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_14_all_qp_qp +module function mean_15_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res +end function mean_15_all_qp_qp + +module function mean_3_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int8_dp +module function mean_4_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int8_dp +module function mean_5_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int8_dp +module function mean_6_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int8_dp +module function mean_7_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int8_dp +module function mean_8_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_8_all_int8_dp +module function mean_9_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_9_all_int8_dp +module function mean_10_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_10_all_int8_dp +module function mean_11_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_11_all_int8_dp +module function mean_12_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_12_all_int8_dp +module function mean_13_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_13_all_int8_dp +module function mean_14_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_14_all_int8_dp +module function mean_15_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_15_all_int8_dp +module function mean_3_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int16_dp +module function mean_4_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int16_dp +module function mean_5_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int16_dp +module function mean_6_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int16_dp +module function mean_7_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int16_dp +module function mean_8_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_8_all_int16_dp +module function mean_9_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_9_all_int16_dp +module function mean_10_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_10_all_int16_dp +module function mean_11_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_11_all_int16_dp +module function mean_12_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_12_all_int16_dp +module function mean_13_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_13_all_int16_dp +module function mean_14_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_14_all_int16_dp +module function mean_15_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_15_all_int16_dp +module function mean_3_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int32_dp +module function mean_4_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int32_dp +module function mean_5_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int32_dp +module function mean_6_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int32_dp +module function mean_7_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int32_dp +module function mean_8_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_8_all_int32_dp +module function mean_9_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_9_all_int32_dp +module function mean_10_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_10_all_int32_dp +module function mean_11_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_11_all_int32_dp +module function mean_12_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_12_all_int32_dp +module function mean_13_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_13_all_int32_dp +module function mean_14_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_14_all_int32_dp +module function mean_15_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_15_all_int32_dp +module function mean_3_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int64_dp +module function mean_4_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int64_dp +module function mean_5_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int64_dp +module function mean_6_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int64_dp +module function mean_7_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int64_dp +module function mean_8_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_8_all_int64_dp +module function mean_9_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_9_all_int64_dp +module function mean_10_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_10_all_int64_dp +module function mean_11_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_11_all_int64_dp +module function mean_12_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_12_all_int64_dp +module function mean_13_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_13_all_int64_dp +module function mean_14_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_14_all_int64_dp +module function mean_15_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res +end function mean_15_all_int64_dp + +module function mean_3_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_sp_sp +module function mean_4_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_sp_sp +module function mean_5_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_sp_sp +module function mean_6_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_sp_sp +module function mean_7_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_sp_sp +module function mean_8_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) +end function mean_8_sp_sp +module function mean_9_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) +end function mean_9_sp_sp +module function mean_10_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) +end function mean_10_sp_sp +module function mean_11_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) +end function mean_11_sp_sp +module function mean_12_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) +end function mean_12_sp_sp +module function mean_13_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) +end function mean_13_sp_sp +module function mean_14_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) +end function mean_14_sp_sp +module function mean_15_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) +end function mean_15_sp_sp +module function mean_3_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_dp_dp +module function mean_4_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_dp_dp +module function mean_5_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_dp_dp +module function mean_6_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_dp_dp +module function mean_7_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_dp_dp +module function mean_8_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) +end function mean_8_dp_dp +module function mean_9_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) +end function mean_9_dp_dp +module function mean_10_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) +end function mean_10_dp_dp +module function mean_11_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) +end function mean_11_dp_dp +module function mean_12_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) +end function mean_12_dp_dp +module function mean_13_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) +end function mean_13_dp_dp +module function mean_14_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) +end function mean_14_dp_dp +module function mean_15_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) +end function mean_15_dp_dp +module function mean_3_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_qp_qp +module function mean_4_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_qp_qp +module function mean_5_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_qp_qp +module function mean_6_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_qp_qp +module function mean_7_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_qp_qp +module function mean_8_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) +end function mean_8_qp_qp +module function mean_9_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) +end function mean_9_qp_qp +module function mean_10_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) +end function mean_10_qp_qp +module function mean_11_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) +end function mean_11_qp_qp +module function mean_12_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) +end function mean_12_qp_qp +module function mean_13_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) +end function mean_13_qp_qp +module function mean_14_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) +end function mean_14_qp_qp +module function mean_15_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) +end function mean_15_qp_qp + +module function mean_3_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int8_dp +module function mean_4_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int8_dp +module function mean_5_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int8_dp +module function mean_6_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int8_dp +module function mean_7_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int8_dp +module function mean_8_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) +end function mean_8_int8_dp +module function mean_9_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) +end function mean_9_int8_dp +module function mean_10_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) +end function mean_10_int8_dp +module function mean_11_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) +end function mean_11_int8_dp +module function mean_12_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) +end function mean_12_int8_dp +module function mean_13_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) +end function mean_13_int8_dp +module function mean_14_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) +end function mean_14_int8_dp +module function mean_15_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) +end function mean_15_int8_dp +module function mean_3_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int16_dp +module function mean_4_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int16_dp +module function mean_5_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int16_dp +module function mean_6_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int16_dp +module function mean_7_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int16_dp +module function mean_8_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) +end function mean_8_int16_dp +module function mean_9_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) +end function mean_9_int16_dp +module function mean_10_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) +end function mean_10_int16_dp +module function mean_11_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) +end function mean_11_int16_dp +module function mean_12_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) +end function mean_12_int16_dp +module function mean_13_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) +end function mean_13_int16_dp +module function mean_14_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) +end function mean_14_int16_dp +module function mean_15_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) +end function mean_15_int16_dp +module function mean_3_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int32_dp +module function mean_4_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int32_dp +module function mean_5_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int32_dp +module function mean_6_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int32_dp +module function mean_7_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int32_dp +module function mean_8_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) +end function mean_8_int32_dp +module function mean_9_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) +end function mean_9_int32_dp +module function mean_10_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) +end function mean_10_int32_dp +module function mean_11_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) +end function mean_11_int32_dp +module function mean_12_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) +end function mean_12_int32_dp +module function mean_13_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) +end function mean_13_int32_dp +module function mean_14_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) +end function mean_14_int32_dp +module function mean_15_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) +end function mean_15_int32_dp +module function mean_3_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int64_dp +module function mean_4_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int64_dp +module function mean_5_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int64_dp +module function mean_6_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int64_dp +module function mean_7_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int64_dp +module function mean_8_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) +end function mean_8_int64_dp +module function mean_9_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) +end function mean_9_int64_dp +module function mean_10_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) +end function mean_10_int64_dp +module function mean_11_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) +end function mean_11_int64_dp +module function mean_12_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) +end function mean_12_int64_dp +module function mean_13_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) +end function mean_13_int64_dp +module function mean_14_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) +end function mean_14_int64_dp +module function mean_15_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) +end function mean_15_int64_dp + +end interface + +end module diff --git a/src/f03_stdlib_experimental_stats_mean.f90 b/src/f03_stdlib_experimental_stats_mean.f90 new file mode 100644 index 000000000..e4a0069a7 --- /dev/null +++ b/src/f03_stdlib_experimental_stats_mean.f90 @@ -0,0 +1,25896 @@ +submodule (stdlib_experimental_stats) stdlib_experimental_stats_mean + + +use stdlib_experimental_error, only: error_stop +implicit none + +contains + +module function mean_1_sp_sp(x) result(res) + real(sp), intent(in) :: x(:) + real(sp) :: res + + integer :: i + + res = 0.0_sp + do i = 1, size(x) + res = res + x(i) + enddo + res = res / real(size(x), sp) + +end function mean_1_sp_sp +module function mean_1_dp_dp(x) result(res) + real(dp), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + x(i) + enddo + res = res / real(size(x), dp) + +end function mean_1_dp_dp +module function mean_1_qp_qp(x) result(res) + real(qp), intent(in) :: x(:) + real(qp) :: res + + integer :: i + + res = 0.0_qp + do i = 1, size(x) + res = res + x(i) + enddo + res = res / real(size(x), qp) + +end function mean_1_qp_qp + +module function mean_1_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int8_dp +module function mean_1_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int16_dp +module function mean_1_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int32_dp +module function mean_1_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int64_dp + + +module function mean_2_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:) + real(sp) :: res + + integer :: i, i_ + + res = 0.0_sp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_) + enddo + enddo + res = res / real(size(x), sp) + +end function mean_2_all_sp_sp +module function mean_2_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_dp_dp +module function mean_2_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:) + real(qp) :: res + + integer :: i, i_ + + res = 0.0_qp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_) + enddo + enddo + res = res / real(size(x), qp) + +end function mean_2_all_qp_qp + +module function mean_2_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int8_dp +module function mean_2_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int16_dp +module function mean_2_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int32_dp +module function mean_2_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int64_dp + +module function mean_2_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(sp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_sp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + x(i, i_) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + x(i, i_) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_2_sp_sp +module function mean_2_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + x(i, i_) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + x(i, i_) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_dp_dp +module function mean_2_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(qp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_qp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + x(i, i_) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + x(i, i_) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_2_qp_qp + +module function mean_2_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int8_dp +module function mean_2_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int16_dp +module function mean_2_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int32_dp +module function mean_2_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int64_dp + + + + + + + +module function mean_3_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:) + real(sp) :: res + + integer :: i,i_,i__ + + res = 0.0_sp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__) + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_3_all_sp_sp +module function mean_4_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_sp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___) + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_4_all_sp_sp +module function mean_5_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_sp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_5_all_sp_sp +module function mean_6_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_sp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_6_all_sp_sp +module function mean_7_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_sp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_7_all_sp_sp +module function mean_8_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_sp + + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_8_all_sp_sp +module function mean_9_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_sp + + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_9_all_sp_sp +module function mean_10_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_sp + + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_10_all_sp_sp +module function mean_11_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_sp + + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_11_all_sp_sp +module function mean_12_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_sp + + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_12_all_sp_sp +module function mean_13_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_sp + + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_________& + &___) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_13_all_sp_sp +module function mean_14_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_sp + + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_14_all_sp_sp +module function mean_15_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_sp + + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_15_all_sp_sp +module function mean_3_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_dp_dp +module function mean_4_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_dp_dp +module function mean_5_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_dp_dp +module function mean_6_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_dp_dp +module function mean_7_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_dp_dp +module function mean_8_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_8_all_dp_dp +module function mean_9_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_9_all_dp_dp +module function mean_10_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_10_all_dp_dp +module function mean_11_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_11_all_dp_dp +module function mean_12_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_12_all_dp_dp +module function mean_13_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_________& + &___) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_13_all_dp_dp +module function mean_14_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_14_all_dp_dp +module function mean_15_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_15_all_dp_dp +module function mean_3_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:) + real(qp) :: res + + integer :: i,i_,i__ + + res = 0.0_qp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__) + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_3_all_qp_qp +module function mean_4_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_qp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___) + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_4_all_qp_qp +module function mean_5_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_qp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_5_all_qp_qp +module function mean_6_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_qp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_6_all_qp_qp +module function mean_7_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_qp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_7_all_qp_qp +module function mean_8_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_qp + + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_8_all_qp_qp +module function mean_9_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_qp + + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_9_all_qp_qp +module function mean_10_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_qp + + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_10_all_qp_qp +module function mean_11_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_qp + + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_11_all_qp_qp +module function mean_12_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_qp + + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_12_all_qp_qp +module function mean_13_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_qp + + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_________& + &___) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_13_all_qp_qp +module function mean_14_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_qp + + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_14_all_qp_qp +module function mean_15_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_qp + + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_15_all_qp_qp + +module function mean_3_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int8_dp +module function mean_4_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int8_dp +module function mean_5_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int8_dp +module function mean_6_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int8_dp +module function mean_7_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int8_dp +module function mean_8_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_8_all_int8_dp +module function mean_9_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_9_all_int8_dp +module function mean_10_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_10_all_int8_dp +module function mean_11_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_11_all_int8_dp +module function mean_12_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_12_all_int8_dp +module function mean_13_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_13_all_int8_dp +module function mean_14_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i___& + &_________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_14_all_int8_dp +module function mean_15_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_15_all_int8_dp +module function mean_3_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int16_dp +module function mean_4_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int16_dp +module function mean_5_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int16_dp +module function mean_6_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int16_dp +module function mean_7_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int16_dp +module function mean_8_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_8_all_int16_dp +module function mean_9_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_9_all_int16_dp +module function mean_10_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_10_all_int16_dp +module function mean_11_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_11_all_int16_dp +module function mean_12_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_12_all_int16_dp +module function mean_13_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_13_all_int16_dp +module function mean_14_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i___& + &_________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_14_all_int16_dp +module function mean_15_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_15_all_int16_dp +module function mean_3_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int32_dp +module function mean_4_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int32_dp +module function mean_5_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int32_dp +module function mean_6_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int32_dp +module function mean_7_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int32_dp +module function mean_8_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_8_all_int32_dp +module function mean_9_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_9_all_int32_dp +module function mean_10_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_10_all_int32_dp +module function mean_11_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_11_all_int32_dp +module function mean_12_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_12_all_int32_dp +module function mean_13_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_13_all_int32_dp +module function mean_14_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i___& + &_________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_14_all_int32_dp +module function mean_15_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_15_all_int32_dp +module function mean_3_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int64_dp +module function mean_4_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int64_dp +module function mean_5_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int64_dp +module function mean_6_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int64_dp +module function mean_7_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int64_dp +module function mean_8_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_8_all_int64_dp +module function mean_9_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_9_all_int64_dp +module function mean_10_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_10_all_int64_dp +module function mean_11_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_11_all_int64_dp +module function mean_12_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_12_all_int64_dp +module function mean_13_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_13_all_int64_dp +module function mean_14_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i___& + &_________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_14_all_int64_dp +module function mean_15_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_15_all_int64_dp + +module function mean_3_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_sp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + x(i,i_,i__) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + x(i,i_,i__) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + x(i,i_,i__) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_3_sp_sp +module function mean_4_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_sp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + x(i,i_,i__,i___) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_4_sp_sp +module function mean_5_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_sp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_5_sp_sp +module function mean_6_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_sp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_6_sp_sp +module function mean_7_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_sp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_7_sp_sp +module function mean_8_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_sp + + select case(dim) + case(1) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______) = res(i_,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______) = res(i,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______) = res(i,i_,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______) = res(i,i_,i__,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______) = res(i,i_,i__,i___,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______) = res(i,i_,i__,i___,i____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______) = res(i,i_,i__,i___,i____,i_____,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______) = res(i,i_,i__,i___,i____,i_____,i______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_8_sp_sp +module function mean_9_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_sp + + select case(dim) + case(1) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i__,i___,i____,i_____,i______,i_______,i________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i___,i____,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i____,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______) = res(i,i_,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_9_sp_sp +module function mean_10_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_sp + + select case(dim) + case(1) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i___,i____,i_____,i______,i_______,i_& + &_______,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i____,i_____,i______,i_______,i___& + &_____,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i_____,i______,i_______,i_____& + &___,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i______,i_______,i_______& + &_,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,& + &i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_& + &________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_10_sp_sp +module function mean_11_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_sp + + select case(dim) + case(1) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_11_sp_sp +module function mean_12_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_sp + + select case(dim) + case(1) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_12_sp_sp +module function mean_13_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_sp + + select case(dim) + case(1) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________& + &) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_________& + &___) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_13_sp_sp +module function mean_14_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_sp + + select case(dim) + case(1) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i____& + &______,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i& + &____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i______& + &____,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i________& + &__,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________& + &,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i______& + &______,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i& + &___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &_________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i_________& + &____) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i__________& + &__,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i__________& + &___) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________& + &,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i______& + &_____,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i___________& + &__) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i& + &_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i________& + &___,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i____________& + &_) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i__& + &___________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__________& + &_,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i_____________& + &) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____& + &_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,& + &i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i______& + &_______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_& + &___________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i___& + &_________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_14_sp_sp +module function mean_15_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_sp + + select case(dim) + case(1) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i__& + &___________,i______________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,& + &i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________,i______________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_& + &______,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________,i______________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i___& + &____,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________,i______________) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_____& + &__,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______,i______________) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______& + &,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______,i______________) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i& + &________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____,i______________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i__& + &______,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i_________& + &____,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i_______& + &____,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i__________& + &___,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i_________& + &__,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i______& + &__,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i___________& + &__,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________& + &,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________& + &,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____________& + &_,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i& + &____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i& + &_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________& + &,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &__________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__& + &_______,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________,& + &i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i____& + &_____,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i______& + &___,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(15) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &_____________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i________& + &_,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_15_sp_sp +module function mean_3_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + x(i,i_,i__) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + x(i,i_,i__) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + x(i,i_,i__) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_dp_dp +module function mean_4_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + x(i,i_,i__,i___) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_dp_dp +module function mean_5_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_dp_dp +module function mean_6_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_dp_dp +module function mean_7_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_dp_dp +module function mean_8_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + select case(dim) + case(1) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______) = res(i_,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______) = res(i,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______) = res(i,i_,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______) = res(i,i_,i__,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______) = res(i,i_,i__,i___,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______) = res(i,i_,i__,i___,i____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______) = res(i,i_,i__,i___,i____,i_____,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______) = res(i,i_,i__,i___,i____,i_____,i______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_8_dp_dp +module function mean_9_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + select case(dim) + case(1) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i__,i___,i____,i_____,i______,i_______,i________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i___,i____,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i____,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______) = res(i,i_,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_9_dp_dp +module function mean_10_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + select case(dim) + case(1) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i___,i____,i_____,i______,i_______,i_& + &_______,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i____,i_____,i______,i_______,i___& + &_____,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i_____,i______,i_______,i_____& + &___,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i______,i_______,i_______& + &_,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,& + &i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_& + &________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_10_dp_dp +module function mean_11_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + select case(dim) + case(1) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_11_dp_dp +module function mean_12_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + select case(dim) + case(1) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_12_dp_dp +module function mean_13_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + select case(dim) + case(1) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________& + &) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_________& + &___) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_13_dp_dp +module function mean_14_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i____& + &______,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i& + &____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i______& + &____,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i________& + &__,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________& + &,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i______& + &______,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i& + &___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &_________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i_________& + &____) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i__________& + &__,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i__________& + &___) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________& + &,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i______& + &_____,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i___________& + &__) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i& + &_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i________& + &___,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i____________& + &_) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i__& + &___________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__________& + &_,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i_____________& + &) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____& + &_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,& + &i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i______& + &_______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_& + &___________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i___& + &_________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_14_dp_dp +module function mean_15_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + select case(dim) + case(1) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i__& + &___________,i______________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,& + &i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________,i______________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_& + &______,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________,i______________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i___& + &____,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________,i______________) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_____& + &__,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______,i______________) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______& + &,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______,i______________) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i& + &________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____,i______________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i__& + &______,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i_________& + &____,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i_______& + &____,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i__________& + &___,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i_________& + &__,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i______& + &__,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i___________& + &__,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________& + &,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________& + &,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____________& + &_,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i& + &____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i& + &_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________& + &,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &__________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__& + &_______,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________,& + &i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i____& + &_____,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i______& + &___,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(15) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &_____________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i________& + &_,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_15_dp_dp +module function mean_3_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_qp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + x(i,i_,i__) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + x(i,i_,i__) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + x(i,i_,i__) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_3_qp_qp +module function mean_4_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_qp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + x(i,i_,i__,i___) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_4_qp_qp +module function mean_5_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_qp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_5_qp_qp +module function mean_6_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_qp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_6_qp_qp +module function mean_7_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_qp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_7_qp_qp +module function mean_8_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_qp + + select case(dim) + case(1) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______) = res(i_,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______) = res(i,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______) = res(i,i_,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______) = res(i,i_,i__,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______) = res(i,i_,i__,i___,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______) = res(i,i_,i__,i___,i____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______) = res(i,i_,i__,i___,i____,i_____,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______) = res(i,i_,i__,i___,i____,i_____,i______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______) + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_8_qp_qp +module function mean_9_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_qp + + select case(dim) + case(1) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i__,i___,i____,i_____,i______,i_______,i________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i___,i____,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i____,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i_____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i______,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i_______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______) = res(i,i_,i__,i___,i____,i_____,i______,i_______) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_9_qp_qp +module function mean_10_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_qp + + select case(dim) + case(1) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i___,i____,i_____,i______,i_______,i_& + &_______,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i____,i_____,i______,i_______,i___& + &_____,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i_____,i______,i_______,i_____& + &___,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i______,i_______,i_______& + &_,i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,& + &i_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_& + &________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_10_qp_qp +module function mean_11_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_qp + + select case(dim) + case(1) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_11_qp_qp +module function mean_12_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_qp + + select case(dim) + case(1) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_12_qp_qp +module function mean_13_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_qp + + select case(dim) + case(1) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________& + &) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_________& + &___) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__________& + &__) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_13_qp_qp +module function mean_14_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_qp + + select case(dim) + case(1) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i____& + &______,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i& + &____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i______& + &____,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i________& + &__,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________& + &,i___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i______& + &______,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i& + &___________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &_________,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i_________& + &____) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i__________& + &__,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i__________& + &___) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________& + &,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i______& + &_____,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i___________& + &__) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i& + &_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i________& + &___,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i____________& + &_) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i__& + &___________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__________& + &_,i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i_____________& + &) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____& + &_________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,& + &i____________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i______& + &_______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_& + &___________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &______) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i___& + &_________,i_____________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_14_qp_qp +module function mean_15_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_qp + + select case(dim) + case(1) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i__& + &___________,i______________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,& + &i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________,i______________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_& + &______,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________,i______________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i___& + &____,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________,i______________) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_____& + &__,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______,i______________) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______& + &,i________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______,i______________) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i& + &________,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____,i______________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i__& + &______,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i_________& + &____,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i_______& + &____,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i__________& + &___,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i_________& + &__,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i______& + &__,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i___________& + &__,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________& + &,i____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________& + &,i_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____________& + &_,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i& + &____________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i& + &_________,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________& + &,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &__________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__& + &_______,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________,& + &i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i_____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i____& + &_____,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i______________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i______& + &___,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(15) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &_____________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________) + x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i________& + &_,i__________,i___________,i____________,i_____________,i______________) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_15_qp_qp + +module function mean_3_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int8_dp +module function mean_4_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int8_dp +module function mean_5_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int8_dp +module function mean_6_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int8_dp +module function mean_7_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int8_dp +module function mean_8_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + select case(dim) + case(1) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______) = res(i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______) = res(i,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______) = res(i,i_,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______) = res(i,i_,i__,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______) = res(i,i_,i__,i___,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______) = res(i,i_,i__,i___,i____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______) = res(i,i_,i__,i___,i____,i_____,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______) = res(i,i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_8_int8_dp +module function mean_9_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + select case(dim) + case(1) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i___,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______) = res(i,i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_9_int8_dp +module function mean_10_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + select case(dim) + case(1) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i___,i____,i_____,i______,i_______,i_& + &_______,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i____,i_____,i______,i_______,i___& + &_____,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i_____,i______,i_______,i_____& + &___,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i______,i_______,i_______& + &_,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,& + &i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_& + &________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_10_int8_dp +module function mean_11_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + select case(dim) + case(1) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_11_int8_dp +module function mean_12_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + select case(dim) + case(1) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_12_int8_dp +module function mean_13_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + select case(dim) + case(1) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________& + &) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_13_int8_dp +module function mean_14_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,& + &i__________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i& + &____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_& + &_________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___& + &_______,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i______& + &______,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i_________& + &____) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i__________& + &__,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i__________& + &___) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________& + &,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i___________& + &__) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i& + &_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i____________& + &_) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i__& + &___________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i_____________& + &) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____& + &_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_______& + &____,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i______& + &_______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_________& + &__,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__________& + &_,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_14_int8_dp +module function mean_15_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + select case(dim) + case(1) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i__& + &___________,i______________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i__& + &____,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________& + &), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________,i______________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i____& + &__,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________,i______________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______& + &,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________,i______________) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i& + &_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______,i______________) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i__& + &_____,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______,i______________) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i____& + &___,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____,i______________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i_________& + &____,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i_______& + &____,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i__________& + &___,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i_________& + &__,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_& + &_______,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i___________& + &__,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________& + &,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &_____,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____________& + &_,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i& + &____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_____& + &___,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________& + &,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &__________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_______& + &_,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________,& + &i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,& + &i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_& + &________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(15) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &_____________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i___& + &______,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_15_int8_dp +module function mean_3_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int16_dp +module function mean_4_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int16_dp +module function mean_5_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int16_dp +module function mean_6_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int16_dp +module function mean_7_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int16_dp +module function mean_8_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + select case(dim) + case(1) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______) = res(i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______) = res(i,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______) = res(i,i_,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______) = res(i,i_,i__,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______) = res(i,i_,i__,i___,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______) = res(i,i_,i__,i___,i____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______) = res(i,i_,i__,i___,i____,i_____,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______) = res(i,i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_8_int16_dp +module function mean_9_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + select case(dim) + case(1) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i___,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______) = res(i,i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_9_int16_dp +module function mean_10_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + select case(dim) + case(1) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i___,i____,i_____,i______,i_______,i_& + &_______,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i____,i_____,i______,i_______,i___& + &_____,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i_____,i______,i_______,i_____& + &___,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i______,i_______,i_______& + &_,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,& + &i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_& + &________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_10_int16_dp +module function mean_11_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + select case(dim) + case(1) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_11_int16_dp +module function mean_12_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + select case(dim) + case(1) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_12_int16_dp +module function mean_13_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + select case(dim) + case(1) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________& + &) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_13_int16_dp +module function mean_14_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,& + &i__________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i& + &____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_& + &_________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___& + &_______,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i______& + &______,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i_________& + &____) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i__________& + &__,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i__________& + &___) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________& + &,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i___________& + &__) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i& + &_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i____________& + &_) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i__& + &___________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i_____________& + &) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____& + &_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_______& + &____,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i______& + &_______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_________& + &__,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__________& + &_,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_14_int16_dp +module function mean_15_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + select case(dim) + case(1) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i__& + &___________,i______________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i__& + &____,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________& + &), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________,i______________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i____& + &__,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________,i______________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______& + &,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________,i______________) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i& + &_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______,i______________) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i__& + &_____,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______,i______________) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i____& + &___,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____,i______________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i_________& + &____,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i_______& + &____,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i__________& + &___,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i_________& + &__,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_& + &_______,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i___________& + &__,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________& + &,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &_____,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____________& + &_,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i& + &____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_____& + &___,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________& + &,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &__________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_______& + &_,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________,& + &i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,& + &i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_& + &________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(15) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &_____________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i___& + &______,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_15_int16_dp +module function mean_3_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int32_dp +module function mean_4_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int32_dp +module function mean_5_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int32_dp +module function mean_6_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int32_dp +module function mean_7_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int32_dp +module function mean_8_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + select case(dim) + case(1) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______) = res(i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______) = res(i,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______) = res(i,i_,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______) = res(i,i_,i__,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______) = res(i,i_,i__,i___,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______) = res(i,i_,i__,i___,i____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______) = res(i,i_,i__,i___,i____,i_____,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______) = res(i,i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_8_int32_dp +module function mean_9_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + select case(dim) + case(1) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i___,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______) = res(i,i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_9_int32_dp +module function mean_10_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + select case(dim) + case(1) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i___,i____,i_____,i______,i_______,i_& + &_______,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i____,i_____,i______,i_______,i___& + &_____,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i_____,i______,i_______,i_____& + &___,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i______,i_______,i_______& + &_,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,& + &i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_& + &________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_10_int32_dp +module function mean_11_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + select case(dim) + case(1) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_11_int32_dp +module function mean_12_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + select case(dim) + case(1) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_12_int32_dp +module function mean_13_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + select case(dim) + case(1) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________& + &) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_13_int32_dp +module function mean_14_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,& + &i__________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i& + &____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_& + &_________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___& + &_______,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i______& + &______,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i_________& + &____) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i__________& + &__,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i__________& + &___) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________& + &,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i___________& + &__) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i& + &_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i____________& + &_) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i__& + &___________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i_____________& + &) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____& + &_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_______& + &____,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i______& + &_______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_________& + &__,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__________& + &_,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_14_int32_dp +module function mean_15_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + select case(dim) + case(1) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i__& + &___________,i______________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i__& + &____,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________& + &), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________,i______________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i____& + &__,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________,i______________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______& + &,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________,i______________) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i& + &_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______,i______________) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i__& + &_____,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______,i______________) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i____& + &___,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____,i______________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i_________& + &____,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i_______& + &____,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i__________& + &___,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i_________& + &__,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_& + &_______,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i___________& + &__,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________& + &,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &_____,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____________& + &_,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i& + &____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_____& + &___,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________& + &,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &__________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_______& + &_,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________,& + &i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,& + &i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_& + &________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(15) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &_____________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i___& + &______,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_15_int32_dp +module function mean_3_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int64_dp +module function mean_4_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int64_dp +module function mean_5_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int64_dp +module function mean_6_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int64_dp +module function mean_7_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int64_dp +module function mean_8_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______ + + res = 0.0_dp + + select case(dim) + case(1) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______) = res(i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______) = res(i,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______) = res(i,i_,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______) = res(i,i_,i__,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______) = res(i,i_,i__,i___,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______) = res(i,i_,i__,i___,i____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______) = res(i,i_,i__,i___,i____,i_____,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______) = res(i,i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_8_int64_dp +module function mean_9_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________ + + res = 0.0_dp + + select case(dim) + case(1) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i__,i___,i____,i_____,i______,i_______,i________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i___,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i____,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i_____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i______,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i_______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______) = res(i,i_,i__,i___,i____,i_____,i______,i_______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_9_int64_dp +module function mean_10_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________ + + res = 0.0_dp + + select case(dim) + case(1) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i___,i____,i_____,i______,i_______,i_& + &_______,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i____,i_____,i______,i_______,i___& + &_____,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i_____,i______,i_______,i_____& + &___,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i______,i_______,i_______& + &_,i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,& + &i_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_& + &________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i____& + &____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_10_int64_dp +module function mean_11_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________ + + res = 0.0_dp + + select case(dim) + case(1) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_11_int64_dp +module function mean_12_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________ + + res = 0.0_dp + + select case(dim) + case(1) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_12_int64_dp +module function mean_13_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________ + + res = 0.0_dp + + select case(dim) + case(1) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________& + &) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____& + &_______), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) =& + & res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________) +& + & real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_13_int64_dp +module function mean_14_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,& + &i__________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i& + &____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_& + &_________,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i__& + &__________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___& + &_______,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____& + &________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i______& + &______,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i________& + &____,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i_________& + &____) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i__________& + &__,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i__________& + &___) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________& + &,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i___________& + &__) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i& + &_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i____________& + &_) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i__& + &___________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i_____________& + &) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____& + &_________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_______& + &____,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i______& + &_______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_________& + &__,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &______) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__________& + &_,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________)& + & = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_______& + &_____) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________& + &,i____________,i_____________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_14_int64_dp +module function mean_15_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:,:,:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ), & + merge(size(x,7),size(x,8),mask = 7 < dim ), & + merge(size(x,8),size(x,9),mask = 8 < dim ), & + merge(size(x,9),size(x,10),mask = 9 < dim ), & + merge(size(x,10),size(x,11),mask = 10 < dim ), & + merge(size(x,11),size(x,12),mask = 11 < dim ), & + merge(size(x,12),size(x,13),mask = 12 < dim ), & + merge(size(x,13),size(x,14),mask = 13 < dim ), & + merge(size(x,14),size(x,15),mask = 14 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___________& + &__,i______________ + + res = 0.0_dp + + select case(dim) + case(1) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i__& + &___________,i______________) = res(i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_____& + &_____,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i__& + &____,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________& + &), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i___& + &__________,i______________) = res(i,i__,i___,i____,i_____,i______,i_______,i________,i_________,i_______& + &___,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i____& + &__,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i____& + &_________,i______________) = res(i,i_,i___,i____,i_____,i______,i_______,i________,i_________,i_________& + &_,i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______& + &,i_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________),& + & dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_____& + &________,i______________) = res(i,i_,i__,i____,i_____,i______,i_______,i________,i_________,i__________,& + &i___________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i& + &_______,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i______& + &_______,i______________) = res(i,i_,i__,i___,i_____,i______,i_______,i________,i_________,i__________,i_& + &__________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i__& + &_____,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___________,i____________,i_______& + &______,i______________) = res(i,i_,i__,i___,i____,i______,i_______,i________,i_________,i__________,i___& + &________,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i____& + &___,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i___________,i____________,i________& + &_____,i______________) = res(i,i_,i__,i___,i____,i_____,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i______& + &_,i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(8) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i___________,i____________,i_________& + &____,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i________,i_________,i__________,i_______& + &____,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,& + &i________,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(9) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i___________,i____________,i__________& + &___,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i_________,i__________,i_________& + &__,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_& + &_______,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(10) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________,i____________,i___________& + &__,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i__________,i___________& + &,i____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i___& + &_____,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(11) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i____________,i____________& + &_,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i___________,i& + &____________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_____& + &___,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(12) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____________,i_____________& + &,i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i__& + &__________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i_______& + &_,i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(13) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i_____________,& + &i______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___& + &________,i_____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,& + &i_________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(14) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &______________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i____& + &_______,i____________,i______________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_& + &________,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case(15) + do i______________ = 1, size(x, 15) + do i_____________ = 1, size(x, 14) + do i____________ = 1, size(x, 13) + do i___________ = 1, size(x, 12) + do i__________ = 1, size(x, 11) + do i_________ = 1, size(x, 10) + do i________ = 1, size(x, 9) + do i_______ = 1, size(x, 8) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i___________,i____________,i& + &_____________) = res(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i_________,i__________,i_____& + &______,i____________,i_____________) + real(x(i,i_,i__,i___,i____,i_____,i______,i_______,i________,i___& + &______,i__________,i___________,i____________,i_____________,i______________), dp) + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_15_int64_dp + +end submodule diff --git a/src/f90_stdlib_experimental_stats.f90 b/src/f90_stdlib_experimental_stats.f90 new file mode 100644 index 000000000..861efe174 --- /dev/null +++ b/src/f90_stdlib_experimental_stats.f90 @@ -0,0 +1,575 @@ +module stdlib_experimental_stats + + +use stdlib_experimental_kinds, only: sp, dp, qp, & + int8, int16, int32, int64 +implicit none +private +! Public API +public :: mean + +interface mean + module function mean_1_sp_sp(x) result(res) + real(sp), intent(in) :: x(:) + real(sp) :: res + end function mean_1_sp_sp + module function mean_1_dp_dp(x) result(res) + real(dp), intent(in) :: x(:) + real(dp) :: res + end function mean_1_dp_dp + module function mean_1_qp_qp(x) result(res) + real(qp), intent(in) :: x(:) + real(qp) :: res + end function mean_1_qp_qp + + module function mean_1_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int8_dp + module function mean_1_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int16_dp + module function mean_1_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int32_dp + module function mean_1_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:) + real(dp) :: res + end function mean_1_int64_dp + + + module function mean_2_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:) + real(sp) :: res + end function mean_2_all_sp_sp + module function mean_2_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_dp_dp + module function mean_2_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:) + real(qp) :: res + end function mean_2_all_qp_qp + + module function mean_2_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int8_dp + module function mean_2_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int16_dp + module function mean_2_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int32_dp + module function mean_2_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_int64_dp + + module function mean_2_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(sp) :: res(size(x)/size(x, dim)) + end function mean_2_sp_sp + module function mean_2_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_dp_dp + module function mean_2_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(qp) :: res(size(x)/size(x, dim)) + end function mean_2_qp_qp + + module function mean_2_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int8_dp + module function mean_2_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int16_dp + module function mean_2_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int32_dp + module function mean_2_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_int64_dp + + + + + +module function mean_3_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:) + real(sp) :: res +end function mean_3_all_sp_sp +module function mean_4_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:) + real(sp) :: res +end function mean_4_all_sp_sp +module function mean_5_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + real(sp) :: res +end function mean_5_all_sp_sp +module function mean_6_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + real(sp) :: res +end function mean_6_all_sp_sp +module function mean_7_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + real(sp) :: res +end function mean_7_all_sp_sp +module function mean_3_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_dp_dp +module function mean_4_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_dp_dp +module function mean_5_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_dp_dp +module function mean_6_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_dp_dp +module function mean_7_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_dp_dp +module function mean_3_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:) + real(qp) :: res +end function mean_3_all_qp_qp +module function mean_4_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:) + real(qp) :: res +end function mean_4_all_qp_qp +module function mean_5_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + real(qp) :: res +end function mean_5_all_qp_qp +module function mean_6_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + real(qp) :: res +end function mean_6_all_qp_qp +module function mean_7_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + real(qp) :: res +end function mean_7_all_qp_qp + +module function mean_3_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int8_dp +module function mean_4_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int8_dp +module function mean_5_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int8_dp +module function mean_6_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int8_dp +module function mean_7_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int8_dp +module function mean_3_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int16_dp +module function mean_4_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int16_dp +module function mean_5_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int16_dp +module function mean_6_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int16_dp +module function mean_7_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int16_dp +module function mean_3_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int32_dp +module function mean_4_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int32_dp +module function mean_5_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int32_dp +module function mean_6_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int32_dp +module function mean_7_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int32_dp +module function mean_3_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:) + real(dp) :: res +end function mean_3_all_int64_dp +module function mean_4_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + real(dp) :: res +end function mean_4_all_int64_dp +module function mean_5_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + real(dp) :: res +end function mean_5_all_int64_dp +module function mean_6_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res +end function mean_6_all_int64_dp +module function mean_7_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res +end function mean_7_all_int64_dp + +module function mean_3_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_sp_sp +module function mean_4_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_sp_sp +module function mean_5_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_sp_sp +module function mean_6_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_sp_sp +module function mean_7_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_sp_sp +module function mean_3_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_dp_dp +module function mean_4_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_dp_dp +module function mean_5_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_dp_dp +module function mean_6_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_dp_dp +module function mean_7_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_dp_dp +module function mean_3_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_qp_qp +module function mean_4_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_qp_qp +module function mean_5_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_qp_qp +module function mean_6_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_qp_qp +module function mean_7_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_qp_qp + +module function mean_3_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int8_dp +module function mean_4_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int8_dp +module function mean_5_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int8_dp +module function mean_6_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int8_dp +module function mean_7_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int8_dp +module function mean_3_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int16_dp +module function mean_4_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int16_dp +module function mean_5_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int16_dp +module function mean_6_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int16_dp +module function mean_7_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int16_dp +module function mean_3_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int32_dp +module function mean_4_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int32_dp +module function mean_5_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int32_dp +module function mean_6_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int32_dp +module function mean_7_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int32_dp +module function mean_3_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) +end function mean_3_int64_dp +module function mean_4_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) +end function mean_4_int64_dp +module function mean_5_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) +end function mean_5_int64_dp +module function mean_6_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) +end function mean_6_int64_dp +module function mean_7_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) +end function mean_7_int64_dp + +end interface + +end module diff --git a/src/f90_stdlib_experimental_stats_mean.f90 b/src/f90_stdlib_experimental_stats_mean.f90 new file mode 100644 index 000000000..991199e19 --- /dev/null +++ b/src/f90_stdlib_experimental_stats_mean.f90 @@ -0,0 +1,4225 @@ +submodule (stdlib_experimental_stats) stdlib_experimental_stats_mean + + +use stdlib_experimental_error, only: error_stop +implicit none + +contains + +module function mean_1_sp_sp(x) result(res) + real(sp), intent(in) :: x(:) + real(sp) :: res + + integer :: i + + res = 0.0_sp + do i = 1, size(x) + res = res + x(i) + enddo + res = res / real(size(x), sp) + +end function mean_1_sp_sp +module function mean_1_dp_dp(x) result(res) + real(dp), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + x(i) + enddo + res = res / real(size(x), dp) + +end function mean_1_dp_dp +module function mean_1_qp_qp(x) result(res) + real(qp), intent(in) :: x(:) + real(qp) :: res + + integer :: i + + res = 0.0_qp + do i = 1, size(x) + res = res + x(i) + enddo + res = res / real(size(x), qp) + +end function mean_1_qp_qp + +module function mean_1_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int8_dp +module function mean_1_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int16_dp +module function mean_1_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int32_dp +module function mean_1_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_int64_dp + + +module function mean_2_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:) + real(sp) :: res + + integer :: i, i_ + + res = 0.0_sp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_) + enddo + enddo + res = res / real(size(x), sp) + +end function mean_2_all_sp_sp +module function mean_2_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_dp_dp +module function mean_2_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:) + real(qp) :: res + + integer :: i, i_ + + res = 0.0_qp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_) + enddo + enddo + res = res / real(size(x), qp) + +end function mean_2_all_qp_qp + +module function mean_2_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int8_dp +module function mean_2_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int16_dp +module function mean_2_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int32_dp +module function mean_2_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_int64_dp + +module function mean_2_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(sp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_sp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + x(i, i_) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + x(i, i_) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_2_sp_sp +module function mean_2_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + x(i, i_) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + x(i, i_) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_dp_dp +module function mean_2_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(qp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_qp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + x(i, i_) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + x(i, i_) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_2_qp_qp + +module function mean_2_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int8_dp +module function mean_2_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int16_dp +module function mean_2_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int32_dp +module function mean_2_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_int64_dp + + + + + + + +module function mean_3_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:) + real(sp) :: res + + integer :: i,i_,i__ + + res = 0.0_sp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__) + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_3_all_sp_sp +module function mean_4_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_sp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___) + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_4_all_sp_sp +module function mean_5_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_sp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_5_all_sp_sp +module function mean_6_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_sp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_6_all_sp_sp +module function mean_7_all_sp_sp(x) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + real(sp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_sp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), sp) + +end function mean_7_all_sp_sp +module function mean_3_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_dp_dp +module function mean_4_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_dp_dp +module function mean_5_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_dp_dp +module function mean_6_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_dp_dp +module function mean_7_all_dp_dp(x) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_dp_dp +module function mean_3_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:) + real(qp) :: res + + integer :: i,i_,i__ + + res = 0.0_qp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__) + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_3_all_qp_qp +module function mean_4_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_qp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___) + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_4_all_qp_qp +module function mean_5_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_qp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_5_all_qp_qp +module function mean_6_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_qp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_6_all_qp_qp +module function mean_7_all_qp_qp(x) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + real(qp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_qp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), qp) + +end function mean_7_all_qp_qp + +module function mean_3_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int8_dp +module function mean_4_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int8_dp +module function mean_5_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int8_dp +module function mean_6_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int8_dp +module function mean_7_all_int8_dp(x) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int8_dp +module function mean_3_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int16_dp +module function mean_4_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int16_dp +module function mean_5_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int16_dp +module function mean_6_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int16_dp +module function mean_7_all_int16_dp(x) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int16_dp +module function mean_3_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int32_dp +module function mean_4_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int32_dp +module function mean_5_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int32_dp +module function mean_6_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int32_dp +module function mean_7_all_int32_dp(x) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int32_dp +module function mean_3_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:) + real(dp) :: res + + integer :: i,i_,i__ + + res = 0.0_dp + + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__), dp) + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_3_all_int64_dp +module function mean_4_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_4_all_int64_dp +module function mean_5_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_5_all_int64_dp +module function mean_6_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_6_all_int64_dp +module function mean_7_all_int64_dp(x) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + real(dp) :: res + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + + res = res / real(size(x), dp) + +end function mean_7_all_int64_dp + +module function mean_3_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_sp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + x(i,i_,i__) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + x(i,i_,i__) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + x(i,i_,i__) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_3_sp_sp +module function mean_4_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_sp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + x(i,i_,i__,i___) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_4_sp_sp +module function mean_5_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_sp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_5_sp_sp +module function mean_6_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_sp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_6_sp_sp +module function mean_7_sp_sp(x, dim) result(res) + real(sp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(sp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_sp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), sp) + +end function mean_7_sp_sp +module function mean_3_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + x(i,i_,i__) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + x(i,i_,i__) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + x(i,i_,i__) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_dp_dp +module function mean_4_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + x(i,i_,i__,i___) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_dp_dp +module function mean_5_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_dp_dp +module function mean_6_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_dp_dp +module function mean_7_dp_dp(x, dim) result(res) + real(dp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_dp_dp +module function mean_3_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_qp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + x(i,i_,i__) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + x(i,i_,i__) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + x(i,i_,i__) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_3_qp_qp +module function mean_4_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_qp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + x(i,i_,i__,i___) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + x(i,i_,i__,i___) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_4_qp_qp +module function mean_5_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_qp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + x(i,i_,i__,i___,i____) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_5_qp_qp +module function mean_6_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_qp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + x(i,i_,i__,i___,i____,i_____) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_6_qp_qp +module function mean_7_qp_qp(x, dim) result(res) + real(qp), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(qp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_qp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + x(i,i_,i__,i___,i____,i_____,i______) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), qp) + +end function mean_7_qp_qp + +module function mean_3_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int8_dp +module function mean_4_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int8_dp +module function mean_5_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int8_dp +module function mean_6_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int8_dp +module function mean_7_int8_dp(x, dim) result(res) + integer(int8), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int8_dp +module function mean_3_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int16_dp +module function mean_4_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int16_dp +module function mean_5_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int16_dp +module function mean_6_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int16_dp +module function mean_7_int16_dp(x, dim) result(res) + integer(int16), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int16_dp +module function mean_3_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int32_dp +module function mean_4_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int32_dp +module function mean_5_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int32_dp +module function mean_6_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int32_dp +module function mean_7_int32_dp(x, dim) result(res) + integer(int32), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int32_dp +module function mean_3_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ) ) + + integer :: i,i_,i__ + + res = 0.0_dp + + select case(dim) + case(1) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__) = res(i_,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(2) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__) = res(i,i__) + real(x(i,i_,i__), dp) + end do + end do + end do + case(3) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_) = res(i,i_) + real(x(i,i_,i__), dp) + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_3_int64_dp +module function mean_4_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ) ) + + integer :: i,i_,i__,i___ + + res = 0.0_dp + + select case(dim) + case(1) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___) = res(i_,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(2) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___) = res(i,i__,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(3) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___) = res(i,i_,i___) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case(4) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__) = res(i,i_,i__) + real(x(i,i_,i__,i___), dp) + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_4_int64_dp +module function mean_5_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ) ) + + integer :: i,i_,i__,i___,i____ + + res = 0.0_dp + + select case(dim) + case(1) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____) = res(i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(2) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____) = res(i,i__,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(3) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____) = res(i,i_,i___,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(4) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____) = res(i,i_,i__,i____) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case(5) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___) = res(i,i_,i__,i___) + real(x(i,i_,i__,i___,i____), dp) + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_5_int64_dp +module function mean_6_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____ + + res = 0.0_dp + + select case(dim) + case(1) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____) = res(i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(2) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____) = res(i,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(3) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____) = res(i,i_,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(4) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____) = res(i,i_,i__,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(5) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____) = res(i,i_,i__,i___,i_____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case(6) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____) = res(i,i_,i__,i___,i____) + real(x(i,i_,i__,i___,i____,i_____), dp) + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_6_int64_dp +module function mean_7_int64_dp(x, dim) result(res) + integer(int64), intent(in) :: x(:,:,:,:,:,:,:) + integer, intent(in) :: dim + real(dp) :: res( & + merge(size(x,1),size(x,2),mask = 1 < dim ), & + merge(size(x,2),size(x,3),mask = 2 < dim ), & + merge(size(x,3),size(x,4),mask = 3 < dim ), & + merge(size(x,4),size(x,5),mask = 4 < dim ), & + merge(size(x,5),size(x,6),mask = 5 < dim ), & + merge(size(x,6),size(x,7),mask = 6 < dim ) ) + + integer :: i,i_,i__,i___,i____,i_____,i______ + + res = 0.0_dp + + select case(dim) + case(1) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_,i__,i___,i____,i_____,i______) = res(i_,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(2) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i__,i___,i____,i_____,i______) = res(i,i__,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(3) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i___,i____,i_____,i______) = res(i,i_,i___,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(4) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i____,i_____,i______) = res(i,i_,i__,i____,i_____,i______) +& + & real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(5) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i_____,i______) = res(i,i_,i__,i___,i_____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______),& + & dp) + end do + end do + end do + end do + end do + end do + end do + case(6) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i______) = res(i,i_,i__,i___,i____,i______) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case(7) + do i______ = 1, size(x, 7) + do i_____ = 1, size(x, 6) + do i____ = 1, size(x, 5) + do i___ = 1, size(x, 4) + do i__ = 1, size(x, 3) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i,i_,i__,i___,i____,i_____) = res(i,i_,i__,i___,i____,i_____) + real(x(i,i_,i__,i___,i____,i_____,i______), dp) + end do + end do + end do + end do + end do + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_7_int64_dp + +end submodule diff --git a/src/stdlib_experimental_io.f90 b/src/stdlib_experimental_io.f90 index f6e4a505c..8a0058c20 100644 --- a/src/stdlib_experimental_io.f90 +++ b/src/stdlib_experimental_io.f90 @@ -218,9 +218,12 @@ subroutine qsavetxt(filename, d) ! call savetxt("log.txt", data) integer :: s, i +character(len=14) :: format_string + +write(format_string, '(a1,i06,a7)') '(', size(d, 2), 'f40.34)' s = open(filename, "w") do i = 1, size(d, 1) - write(s, *) d(i, :) + write(s, format_string) d(i, :) end do close(s) end subroutine @@ -332,15 +335,15 @@ integer function open(filename, mode, iostat) result(u) select case (mode_(3:3)) case('t') - access_='sequential' form_='formatted' -case('b', 's') - access_='stream' +case('b') form_='unformatted' case default call error_stop("Unsupported mode: "//mode_(3:3)) end select +access_ = 'stream' + if (present(iostat)) then open(newunit=u, file=filename, & action = action_, position = position_, status = status_, & diff --git a/src/stdlib_experimental_optval.f90 b/src/stdlib_experimental_optval.f90 index 6672d414c..c2f9a0f46 100644 --- a/src/stdlib_experimental_optval.f90 +++ b/src/stdlib_experimental_optval.f90 @@ -34,7 +34,7 @@ module stdlib_experimental_optval contains - pure function optval_sp(x, default) result(y) + pure elemental function optval_sp(x, default) result(y) real(sp), intent(in), optional :: x real(sp), intent(in) :: default real(sp) :: y @@ -47,7 +47,7 @@ pure function optval_sp(x, default) result(y) end function optval_sp - pure function optval_dp(x, default) result(y) + pure elemental function optval_dp(x, default) result(y) real(dp), intent(in), optional :: x real(dp), intent(in) :: default real(dp) :: y @@ -60,7 +60,7 @@ pure function optval_dp(x, default) result(y) end function optval_dp - pure function optval_qp(x, default) result(y) + pure elemental function optval_qp(x, default) result(y) real(qp), intent(in), optional :: x real(qp), intent(in) :: default real(qp) :: y @@ -73,7 +73,7 @@ pure function optval_qp(x, default) result(y) end function optval_qp - pure function optval_int8(x, default) result(y) + pure elemental function optval_int8(x, default) result(y) integer(int8), intent(in), optional :: x integer(int8), intent(in) :: default integer(int8) :: y @@ -86,7 +86,7 @@ pure function optval_int8(x, default) result(y) end function optval_int8 - pure function optval_int16(x, default) result(y) + pure elemental function optval_int16(x, default) result(y) integer(int16), intent(in), optional :: x integer(int16), intent(in) :: default integer(int16) :: y @@ -99,7 +99,7 @@ pure function optval_int16(x, default) result(y) end function optval_int16 - pure function optval_int32(x, default) result(y) + pure elemental function optval_int32(x, default) result(y) integer(int32), intent(in), optional :: x integer(int32), intent(in) :: default integer(int32) :: y @@ -112,7 +112,7 @@ pure function optval_int32(x, default) result(y) end function optval_int32 - pure function optval_int64(x, default) result(y) + pure elemental function optval_int64(x, default) result(y) integer(int64), intent(in), optional :: x integer(int64), intent(in) :: default integer(int64) :: y @@ -125,7 +125,7 @@ pure function optval_int64(x, default) result(y) end function optval_int64 - pure function optval_logical(x, default) result(y) + pure elemental function optval_logical(x, default) result(y) logical, intent(in), optional :: x logical, intent(in) :: default logical :: y diff --git a/src/stdlib_experimental_stats.fypp b/src/stdlib_experimental_stats.fypp new file mode 100644 index 000000000..385177564 --- /dev/null +++ b/src/stdlib_experimental_stats.fypp @@ -0,0 +1,124 @@ +module stdlib_experimental_stats + +#:set VERSION90 = defined('VERSION90') +#:set REALKINDS = ["sp", "dp", "qp"] +#:set INTKINDS = ["int8", "int16", "int32", "int64"] +#:set REALTYPES = ["real({})".format(k) for k in REALKINDS] +#:set INTTYPES = ["integer({})".format(k) for k in INTKINDS] +#:set iktr = list(zip(range(len(REALKINDS)), REALKINDS, REALTYPES)) +#:set ikti = list(zip(range(len(INTKINDS)), INTKINDS, INTTYPES)) + +use stdlib_experimental_kinds, only: sp, dp, qp, & + int8, int16, int32, int64 +implicit none +private +! Public API +public :: mean + +interface mean +#:for i1, k1, t1 in iktr + module function mean_1_${k1}$_${k1}$(x) result(res) + ${t1}$, intent(in) :: x(:) + ${t1}$ :: res + end function mean_1_${k1}$_${k1}$ +#:endfor + +#:for i1, k1, t1 in ikti + module function mean_1_${k1}$_dp(x) result(res) + ${t1}$, intent(in) :: x(:) + real(dp) :: res + end function mean_1_${k1}$_dp +#:endfor + + +#:for i1, k1, t1 in iktr + module function mean_2_all_${k1}$_${k1}$(x) result(res) + ${t1}$, intent(in) :: x(:,:) + ${t1}$ :: res + end function mean_2_all_${k1}$_${k1}$ +#:endfor + +#:for i1, k1, t1 in ikti + module function mean_2_all_${k1}$_dp(x) result(res) + ${t1}$, intent(in) :: x(:,:) + real(dp) :: res + end function mean_2_all_${k1}$_dp +#:endfor + +#:for i1, k1, t1 in iktr + module function mean_2_${k1}$_${k1}$(x, dim) result(res) + ${t1}$, intent(in) :: x(:,:) + integer, intent(in) :: dim + ${t1}$ :: res(size(x)/size(x, dim)) + end function mean_2_${k1}$_${k1}$ +#:endfor + +#:for i1, k1, t1 in ikti + module function mean_2_${k1}$_dp(x, dim) result(res) + ${t1}$, intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + end function mean_2_${k1}$_dp +#:endfor + + +#:def ranksuffix(rank) +#{if rank > 0}#(${":" + ",:" * (rank - 1)}$)#{endif}# +#:enddef + +#:if VERSION90 +#:set ranks = range(3,8) +#:else +#:set ranks = range(3,16) +#:endif + + +#:for i1, k1, t1 in iktr +#:for rank in ranks +module function mean_${rank}$_all_${k1}$_${k1}$(x) result(res) + ${t1}$, intent(in) :: x${ranksuffix(rank)}$ + ${t1}$ :: res +end function mean_${rank}$_all_${k1}$_${k1}$ +#:endfor +#:endfor + +#:for i1, k1, t1 in ikti +#:for rank in ranks +module function mean_${rank}$_all_${k1}$_dp(x) result(res) + ${t1}$, intent(in) :: x${ranksuffix(rank)}$ + real(dp) :: res +end function mean_${rank}$_all_${k1}$_dp +#:endfor +#:endfor + +#:for i1, k1, t1 in iktr +#:for rank in ranks +module function mean_${rank}$_${k1}$_${k1}$(x, dim) result(res) + ${t1}$, intent(in) :: x${ranksuffix(rank)}$ + integer, intent(in) :: dim + ${t1}$ :: res( & +#:for imerge in range(1,rank-1) + merge(size(x,${imerge}$),size(x,${imerge + 1}$),mask = ${imerge}$ < dim ), & +#:endfor + merge(size(x,${rank-1}$),size(x,${rank}$),mask = ${rank-1}$ < dim ) ) +end function mean_${rank}$_${k1}$_${k1}$ +#:endfor +#:endfor + +#:for i1, k1, t1 in ikti +#:for rank in ranks +module function mean_${rank}$_${k1}$_dp(x, dim) result(res) + ${t1}$, intent(in) :: x${ranksuffix(rank)}$ + integer, intent(in) :: dim + real(dp) :: res( & +#:for imerge in range(1,rank-1) + merge(size(x,${imerge}$),size(x,${imerge + 1}$),mask = ${imerge}$ < dim ), & +#:endfor + merge(size(x,${rank-1}$),size(x,${rank}$),mask = ${rank-1}$ < dim ) ) +end function mean_${rank}$_${k1}$_dp +#:endfor +#:endfor + +end interface + +end module diff --git a/src/stdlib_experimental_stats.md b/src/stdlib_experimental_stats.md new file mode 100644 index 000000000..00d06b801 --- /dev/null +++ b/src/stdlib_experimental_stats.md @@ -0,0 +1,43 @@ +# Descriptive statistics + +## Implemented + + * `mean` + +## MEAN - mean of array elements + +### Description: + +Returns the mean of all the elements of *array*, or of the elements of *array* along dimension *dim*. + +### Syntax: + +RESULT = mean(*array*) + +RESULT = mean(*array*, *dim*) + +### Arguments: + +*array*: Shall be an array of type INTEGER, or REAL. + +*dim* (optional): Shall be a scalar of type INTEGER with a value in the range from 1 to n, where n is the rank of *array*. + +### Return value: + +If *array* is of type REAL, the result is of the same type as array. +If *array* is of type INTEGER, the result is of type as *double precision*. + +If *dim* is absent, a scalar with the mean of all elements in *array* is returned. Otherwise, an array of rank n-1, where n equals the rank of *array*, and a shape similar to that of *array* with dimension *dim* dropped is returned. + +### Example: + +```fortran +program test + use stdlib_experimental_stats, only: mean + implicit none + real :: x(1:6) = [ 1., 2., 3., 4., 5., 6. ] + print *, mean(x) !returns 21. + print *, mean( reshape(x, [ 2, 3 ] )) !returns 21. + print *, mean( reshape(x, [ 2, 3 ] ), 1) !returns [ 3., 7., 11. ] +end program +``` diff --git a/src/stdlib_experimental_stats_mean.fypp b/src/stdlib_experimental_stats_mean.fypp new file mode 100644 index 000000000..615b72de1 --- /dev/null +++ b/src/stdlib_experimental_stats_mean.fypp @@ -0,0 +1,293 @@ +submodule (stdlib_experimental_stats) stdlib_experimental_stats_mean + +#:set VERSION90 = defined('VERSION90') +#:set REALKINDS = ["sp", "dp", "qp"] +#:set INTKINDS = ["int8", "int16", "int32", "int64"] +#:set REALTYPES = ["real({})".format(k) for k in REALKINDS] +#:set INTTYPES = ["integer({})".format(k) for k in INTKINDS] +#:set iktr = list(zip(range(len(REALKINDS)), REALKINDS, REALTYPES)) +#:set ikti = list(zip(range(len(INTKINDS)), INTKINDS, INTTYPES)) + +use stdlib_experimental_error, only: error_stop +implicit none + +contains + +#:for i1, k1, t1 in iktr +module function mean_1_${k1}$_${k1}$(x) result(res) + ${t1}$, intent(in) :: x(:) + ${t1}$ :: res + + integer :: i + + res = 0.0_${k1}$ + do i = 1, size(x) + res = res + x(i) + enddo + res = res / real(size(x), ${k1}$) + +end function mean_1_${k1}$_${k1}$ +#:endfor + +#:for i1, k1, t1 in ikti +module function mean_1_${k1}$_dp(x) result(res) + ${t1}$, intent(in) :: x(:) + real(dp) :: res + + integer :: i + + res = 0.0_dp + do i = 1, size(x) + res = res + real(x(i), dp) + enddo + res = res / real(size(x), dp) + +end function mean_1_${k1}$_dp +#:endfor + + +#:for i1, k1, t1 in iktr +module function mean_2_all_${k1}$_${k1}$(x) result(res) + ${t1}$, intent(in) :: x(:,:) + ${t1}$ :: res + + integer :: i, i_ + + res = 0.0_${k1}$ + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + x(i,i_) + enddo + enddo + res = res / real(size(x), ${k1}$) + +end function mean_2_all_${k1}$_${k1}$ +#:endfor + +#:for i1, k1, t1 in ikti +module function mean_2_all_${k1}$_dp(x) result(res) + ${t1}$, intent(in) :: x(:,:) + real(dp) :: res + + integer :: i, i_ + + res = 0.0_dp + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res = res + real(x(i,i_), dp) + enddo + enddo + res = res / real(size(x), dp) + +end function mean_2_all_${k1}$_dp +#:endfor + +#:for i1, k1, t1 in iktr +module function mean_2_${k1}$_${k1}$(x, dim) result(res) + ${t1}$, intent(in) :: x(:,:) + integer, intent(in) :: dim + ${t1}$ :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_${k1}$ + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + x(i, i_) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + x(i, i_) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), ${k1}$) + +end function mean_2_${k1}$_${k1}$ +#:endfor + +#:for i1, k1, t1 in ikti +module function mean_2_${k1}$_dp(x, dim) result(res) + ${t1}$, intent(in) :: x(:,:) + integer, intent(in) :: dim + real(dp) :: res(size(x)/size(x, dim)) + + integer :: i, i_ + + res = 0.0_dp + + select case(dim) + case(1) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i_) = res(i_) + real(x(i, i_), dp) + end do + end do + case(2) + do i_ = 1, size(x, 2) + do i = 1, size(x, 1) + res(i) = res(i) + real(x(i, i_), dp) + end do + end do + case default + call error_stop("ERROR (mean): wrong dimension") + end select + + res = res / real(size(x, dim), dp) + +end function mean_2_${k1}$_dp +#:endfor + + +#:def ranksuffix(rank) +#{if rank > 0}#(${":" + ",:" * (rank - 1)}$)#{endif}# +#:enddef + +#:def isuffix(rank) +#:if rank > 0 +i#{for i in range(2,rank)}#${",i"+"_" * (i-1)}$#{endfor}# +#:endif +#:enddef + +#:def ressuffix(rank,dim) +#:if rank > 0 +#{for i in range(1,dim-1)}#${"i" + "_" * (i-1)+","}$#{endfor}##{if dim-1 >0}#i${"_"*(dim-2) }$#{endif}##{if dim -1 >0 and dim 350) +set_tests_properties(Sleep PROPERTIES TIMEOUT 1) \ No newline at end of file diff --git a/src/tests/system/test_sleep.f90 b/src/tests/system/test_sleep.f90 new file mode 100644 index 000000000..f17182fa6 --- /dev/null +++ b/src/tests/system/test_sleep.f90 @@ -0,0 +1,33 @@ +program test_sleep +use, intrinsic :: iso_fortran_env, only : int64, real64 +use stdlib_experimental_system, only : sleep + +implicit none + +integer :: ierr, millisec +character(8) :: argv +integer(int64) :: tic, toc, trate +real(real64) :: t_ms + +call system_clock(count_rate=trate) + +millisec = 780 +call get_command_argument(1, argv, status=ierr) +if (ierr==0) read(argv,*) millisec + +if (millisec<0) millisec=0 + +call system_clock(count=tic) +call sleep(millisec) +call system_clock(count=toc) + +t_ms = (toc-tic) * 1000._real64 / trate + +if (millisec > 0) then + if (t_ms < 0.5 * millisec) error stop 'actual sleep time was too short' + if (t_ms > 2 * millisec) error stop 'actual sleep time was too long' +endif + +print '(A,F8.3)', 'OK: test_sleep: slept for (ms): ',t_ms + +end program \ No newline at end of file