[4830] | 1 | !> @file pmc_general_mod.f90 |
---|
[4649] | 2 | !--------------------------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1762] | 4 | ! |
---|
[4649] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms of the GNU General |
---|
| 6 | ! Public License as published by the Free Software Foundation, either version 3 of the License, or |
---|
| 7 | ! (at your option) any later version. |
---|
[1762] | 8 | ! |
---|
[4649] | 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the |
---|
| 10 | ! implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
---|
| 11 | ! Public License for more details. |
---|
[1762] | 12 | ! |
---|
[4649] | 13 | ! You should have received a copy of the GNU General Public License along with PALM. If not, see |
---|
| 14 | ! <http://www.gnu.org/licenses/>. |
---|
[1762] | 15 | ! |
---|
[4828] | 16 | ! Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
[4649] | 17 | !--------------------------------------------------------------------------------------------------! |
---|
[1762] | 18 | ! |
---|
| 19 | ! Current revisions: |
---|
[4649] | 20 | ! ----------------- |
---|
[4629] | 21 | ! |
---|
| 22 | ! |
---|
[1762] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: pmc_general_mod.f90 4830 2021-01-06 11:25:45Z hellstea $ |
---|
[4830] | 26 | ! Reformatted to follow PALM coding standard |
---|
| 27 | ! |
---|
| 28 | ! 4828 2021-01-05 11:21:41Z Giersch |
---|
[4828] | 29 | ! Interface pmc_sort removed. Subroutine description added. |
---|
| 30 | ! |
---|
| 31 | ! 4649 2020-08-25 12:11:17Z raasch |
---|
[4649] | 32 | ! File re-formatted to follow the PALM coding standard |
---|
| 33 | ! |
---|
| 34 | ! 4629 2020-07-29 09:37:56Z raasch |
---|
| 35 | ! Support for MPI Fortran77 interface (mpif.h) removed |
---|
| 36 | ! |
---|
[4629] | 37 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4182] | 38 | ! Corrected "Former revisions" section |
---|
[3945] | 39 | ! |
---|
[4182] | 40 | ! 3945 2019-05-02 11:29:27Z raasch |
---|
| 41 | ! |
---|
[3945] | 42 | ! 2019-04-24 17:31:34Z suehring |
---|
[3943] | 43 | ! Increase character length so that also chemistry variable names fully fit |
---|
[3945] | 44 | ! |
---|
| 45 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[3592] | 46 | ! Determine number of coupled arrays dynamically. |
---|
[4649] | 47 | ! |
---|
[4182] | 48 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
| 49 | ! Initial revision by K. Ketelsen |
---|
[2716] | 50 | ! |
---|
[4830] | 51 | ! Authors: |
---|
| 52 | ! -------- |
---|
| 53 | !> @author Klaus Ketelsen (no affiliation) |
---|
| 54 | ! |
---|
[1762] | 55 | ! Description: |
---|
| 56 | ! ------------ |
---|
[4830] | 57 | !> Structure definition and utilities of Palm Model Coupler |
---|
[4649] | 58 | !--------------------------------------------------------------------------------------------------! |
---|
[4830] | 59 | MODULE pmc_general |
---|
[1762] | 60 | |
---|
[1764] | 61 | #if defined( __parallel ) |
---|
[1900] | 62 | USE, INTRINSIC :: ISO_C_BINDING |
---|
[1762] | 63 | |
---|
[1900] | 64 | USE kinds |
---|
[1764] | 65 | |
---|
| 66 | USE MPI |
---|
| 67 | |
---|
[4830] | 68 | |
---|
[1900] | 69 | IMPLICIT NONE |
---|
[1762] | 70 | |
---|
[4830] | 71 | INTEGER(iwp) :: pmc_max_array !< max # of arrays which can be coupled |
---|
| 72 | !< - will be determined dynamically in pmc_interface |
---|
[2841] | 73 | |
---|
[4830] | 74 | INTEGER(iwp), PARAMETER :: da_desclen = 8 !< |
---|
| 75 | INTEGER(iwp), PARAMETER :: da_namelen = 16 !< |
---|
| 76 | INTEGER(iwp), PARAMETER :: pmc_da_name_err = 10 !< |
---|
| 77 | INTEGER(iwp), PARAMETER :: pmc_max_models = 64 !< |
---|
| 78 | INTEGER(iwp), PARAMETER :: pmc_status_ok = 0 !< |
---|
| 79 | INTEGER(iwp), PARAMETER :: pmc_status_error = -1 !< |
---|
[1762] | 80 | |
---|
[4830] | 81 | TYPE :: xy_ind !< pair of indices in horizontal plane |
---|
| 82 | INTEGER(iwp) :: i !< |
---|
| 83 | INTEGER(iwp) :: j !< |
---|
[1900] | 84 | END TYPE |
---|
[1762] | 85 | |
---|
[4830] | 86 | TYPE :: arraydef |
---|
[4649] | 87 | CHARACTER(LEN=da_namelen) :: Name !< name of array |
---|
| 88 | |
---|
| 89 | INTEGER(iwp) :: coupleindex !< |
---|
| 90 | INTEGER(iwp) :: dimkey !< key for NR dimensions and array type |
---|
| 91 | INTEGER(iwp) :: nrdims !< number of dimensions |
---|
| 92 | INTEGER(iwp) :: RecvSize !< size in receive buffer |
---|
| 93 | INTEGER(iwp) :: SendSize !< size in send buffer |
---|
[4830] | 94 | INTEGER(idp) :: RecvIndex !< index in receive buffer |
---|
| 95 | INTEGER(idp) :: SendIndex !< index in send buffer |
---|
[4649] | 96 | |
---|
| 97 | INTEGER(iwp), DIMENSION(4) :: a_dim !< size of dimensions |
---|
| 98 | |
---|
| 99 | TYPE(C_PTR) :: data !< pointer of data in parent space |
---|
| 100 | TYPE(C_PTR) :: SendBuf !< data pointer in send buffer |
---|
| 101 | TYPE(C_PTR) :: RecvBuf !< data pointer in receive buffer |
---|
| 102 | |
---|
| 103 | TYPE(arraydef), POINTER :: next !< |
---|
| 104 | |
---|
| 105 | TYPE(C_PTR), DIMENSION(2) :: po_data !< base pointers, pmc_s_set_active_data_array |
---|
| 106 | !< sets active pointer |
---|
[1900] | 107 | END TYPE arraydef |
---|
[1762] | 108 | |
---|
[4830] | 109 | TYPE :: pedef |
---|
| 110 | INTEGER(iwp) :: nr_arrays = 0 !< number of arrays which will be transfered |
---|
| 111 | INTEGER(iwp) :: nrele !< number of elements, same for all arrays |
---|
[1762] | 112 | |
---|
[4830] | 113 | TYPE(arraydef), POINTER, DIMENSION(:) :: array_list !< list of data arrays to be transfered |
---|
[4649] | 114 | |
---|
[4830] | 115 | TYPE(xy_ind), POINTER, DIMENSION(:) :: locInd !< xy index local array for remote PE |
---|
[1900] | 116 | END TYPE pedef |
---|
[1762] | 117 | |
---|
[4830] | 118 | TYPE :: childdef |
---|
| 119 | INTEGER(iwp) :: inter_comm !< inter communicator model and child |
---|
| 120 | INTEGER(iwp) :: inter_npes !< number of PEs child model |
---|
| 121 | INTEGER(iwp) :: intra_comm !< intra communicator model and child |
---|
| 122 | INTEGER(iwp) :: intra_rank !< rank within intra_comm |
---|
| 123 | INTEGER(iwp) :: model_comm !< communicator of this model |
---|
| 124 | INTEGER(iwp) :: model_npes !< number of PEs this model |
---|
| 125 | INTEGER(iwp) :: model_rank !< rank of this model |
---|
| 126 | INTEGER(idp) :: totalbuffersize !< |
---|
| 127 | INTEGER(iwp) :: win_parent_child !< MPI RMA for preparing data on parent AND child side |
---|
[4649] | 128 | |
---|
[1933] | 129 | TYPE(pedef), DIMENSION(:), POINTER :: pes !< list of all child PEs |
---|
| 130 | END TYPE childdef |
---|
[1762] | 131 | |
---|
[4830] | 132 | TYPE :: da_namedef !< data array name definition |
---|
[1933] | 133 | CHARACTER(LEN=da_desclen) :: childdesc !< child array description |
---|
| 134 | CHARACTER(LEN=da_namelen) :: nameonchild !< name of array within child |
---|
[4649] | 135 | CHARACTER(LEN=da_namelen) :: nameonparent !< name of array within parent |
---|
| 136 | CHARACTER(LEN=da_desclen) :: parentdesc !< parent array description |
---|
[4830] | 137 | |
---|
| 138 | INTEGER(iwp) :: couple_index !< unique number of array |
---|
[1900] | 139 | END TYPE da_namedef |
---|
[1762] | 140 | |
---|
[4830] | 141 | TYPE(arraydef), POINTER :: next !< |
---|
| 142 | |
---|
| 143 | SAVE |
---|
| 144 | |
---|
| 145 | PRIVATE |
---|
| 146 | |
---|
| 147 | ! |
---|
| 148 | !-- Public functions |
---|
| 149 | PUBLIC pmc_g_setname |
---|
| 150 | |
---|
| 151 | ! |
---|
| 152 | !-- Public variables, constants and types |
---|
| 153 | PUBLIC arraydef, & |
---|
| 154 | childdef, & |
---|
| 155 | da_desclen, & |
---|
| 156 | da_namedef, & |
---|
| 157 | da_namelen, & |
---|
| 158 | next, & |
---|
| 159 | pedef, & |
---|
| 160 | pmc_da_name_err, & |
---|
| 161 | pmc_max_array, & |
---|
| 162 | pmc_max_models, & |
---|
| 163 | pmc_status_error, & |
---|
| 164 | pmc_status_ok, & |
---|
| 165 | xy_ind |
---|
| 166 | |
---|
[1900] | 167 | INTERFACE pmc_g_setname |
---|
| 168 | MODULE PROCEDURE pmc_g_setname |
---|
| 169 | END INTERFACE pmc_g_setname |
---|
[1762] | 170 | |
---|
| 171 | |
---|
| 172 | CONTAINS |
---|
| 173 | |
---|
[4830] | 174 | |
---|
[4828] | 175 | !---------------------------------------------------------------------------------------------------! |
---|
[4649] | 176 | ! Description: |
---|
| 177 | ! ------------ |
---|
[4828] | 178 | !> Add array to list of arraydef structure. No the arra "name" is schedules for parent child transfer |
---|
| 179 | !---------------------------------------------------------------------------------------------------! |
---|
[1933] | 180 | SUBROUTINE pmc_g_setname( mychild, couple_index, aname ) |
---|
[1762] | 181 | |
---|
[4830] | 182 | CHARACTER(LEN=*), INTENT(IN) :: aname !< |
---|
[1762] | 183 | |
---|
[4830] | 184 | INTEGER(iwp) :: i !< |
---|
[4649] | 185 | |
---|
[4830] | 186 | INTEGER(iwp), INTENT(IN) :: couple_index !< |
---|
[1900] | 187 | |
---|
[4830] | 188 | TYPE(childdef), INTENT(INOUT) :: mychild !< |
---|
[1900] | 189 | |
---|
[4830] | 190 | TYPE(pedef), POINTER :: ape !< |
---|
[4649] | 191 | |
---|
[1900] | 192 | |
---|
[1779] | 193 | ! |
---|
[1900] | 194 | !-- Assign array to next free index in array list. |
---|
| 195 | !-- Set name of array in arraydef structure |
---|
[1933] | 196 | DO i = 1, mychild%inter_npes |
---|
| 197 | ape => mychild%pes(i) |
---|
[1900] | 198 | ape%nr_arrays = ape%nr_arrays + 1 |
---|
| 199 | ape%array_list(ape%nr_arrays)%name = aname |
---|
| 200 | ape%array_list(ape%nr_arrays)%coupleindex = couple_index |
---|
| 201 | ENDDO |
---|
[1762] | 202 | |
---|
[1900] | 203 | END SUBROUTINE pmc_g_setname |
---|
[4830] | 204 | #endif |
---|
[1762] | 205 | |
---|
[4830] | 206 | |
---|
[1900] | 207 | END MODULE pmc_general |
---|