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