1 | !> @file pmc_general_mod.f90 |
---|
2 | !--------------------------------------------------------------------------------------------------! |
---|
3 | ! This file is part of the PALM model system. |
---|
4 | ! |
---|
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. |
---|
8 | ! |
---|
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. |
---|
12 | ! |
---|
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/>. |
---|
15 | ! |
---|
16 | ! Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
17 | !--------------------------------------------------------------------------------------------------! |
---|
18 | ! |
---|
19 | ! Current revisions: |
---|
20 | ! ----------------- |
---|
21 | ! |
---|
22 | ! |
---|
23 | ! Former revisions: |
---|
24 | ! ----------------- |
---|
25 | ! $Id: pmc_general_mod.f90 4830 2021-01-06 11:25:45Z suehring $ |
---|
26 | ! Reformatted to follow PALM coding standard |
---|
27 | ! |
---|
28 | ! 4828 2021-01-05 11:21:41Z Giersch |
---|
29 | ! Interface pmc_sort removed. Subroutine description added. |
---|
30 | ! |
---|
31 | ! 4649 2020-08-25 12:11:17Z raasch |
---|
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 | ! |
---|
37 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
38 | ! Corrected "Former revisions" section |
---|
39 | ! |
---|
40 | ! 3945 2019-05-02 11:29:27Z raasch |
---|
41 | ! |
---|
42 | ! 2019-04-24 17:31:34Z suehring |
---|
43 | ! Increase character length so that also chemistry variable names fully fit |
---|
44 | ! |
---|
45 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
46 | ! Determine number of coupled arrays dynamically. |
---|
47 | ! |
---|
48 | ! 1762 2016-02-25 12:31:13Z hellstea |
---|
49 | ! Initial revision by K. Ketelsen |
---|
50 | ! |
---|
51 | ! Authors: |
---|
52 | ! -------- |
---|
53 | !> @author Klaus Ketelsen (no affiliation) |
---|
54 | ! |
---|
55 | ! Description: |
---|
56 | ! ------------ |
---|
57 | !> Structure definition and utilities of Palm Model Coupler |
---|
58 | !--------------------------------------------------------------------------------------------------! |
---|
59 | MODULE pmc_general |
---|
60 | |
---|
61 | #if defined( __parallel ) |
---|
62 | USE, INTRINSIC :: ISO_C_BINDING |
---|
63 | |
---|
64 | USE kinds |
---|
65 | |
---|
66 | USE MPI |
---|
67 | |
---|
68 | |
---|
69 | IMPLICIT NONE |
---|
70 | |
---|
71 | INTEGER(iwp) :: pmc_max_array !< max # of arrays which can be coupled |
---|
72 | !< - will be determined dynamically in pmc_interface |
---|
73 | |
---|
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 !< |
---|
80 | |
---|
81 | TYPE :: xy_ind !< pair of indices in horizontal plane |
---|
82 | INTEGER(iwp) :: i !< |
---|
83 | INTEGER(iwp) :: j !< |
---|
84 | END TYPE |
---|
85 | |
---|
86 | TYPE :: arraydef |
---|
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 |
---|
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 |
---|
107 | END TYPE arraydef |
---|
108 | |
---|
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 |
---|
112 | |
---|
113 | TYPE(arraydef), POINTER, DIMENSION(:) :: array_list !< list of data arrays to be transfered |
---|
114 | |
---|
115 | TYPE(xy_ind), POINTER, DIMENSION(:) :: locInd !< xy index local array for remote PE |
---|
116 | END TYPE pedef |
---|
117 | |
---|
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 |
---|
128 | |
---|
129 | TYPE(pedef), DIMENSION(:), POINTER :: pes !< list of all child PEs |
---|
130 | END TYPE childdef |
---|
131 | |
---|
132 | TYPE :: da_namedef !< data array name definition |
---|
133 | CHARACTER(LEN=da_desclen) :: childdesc !< child array description |
---|
134 | CHARACTER(LEN=da_namelen) :: nameonchild !< name of array within child |
---|
135 | CHARACTER(LEN=da_namelen) :: nameonparent !< name of array within parent |
---|
136 | CHARACTER(LEN=da_desclen) :: parentdesc !< parent array description |
---|
137 | |
---|
138 | INTEGER(iwp) :: couple_index !< unique number of array |
---|
139 | END TYPE da_namedef |
---|
140 | |
---|
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 | |
---|
167 | INTERFACE pmc_g_setname |
---|
168 | MODULE PROCEDURE pmc_g_setname |
---|
169 | END INTERFACE pmc_g_setname |
---|
170 | |
---|
171 | |
---|
172 | CONTAINS |
---|
173 | |
---|
174 | |
---|
175 | !---------------------------------------------------------------------------------------------------! |
---|
176 | ! Description: |
---|
177 | ! ------------ |
---|
178 | !> Add array to list of arraydef structure. No the arra "name" is schedules for parent child transfer |
---|
179 | !---------------------------------------------------------------------------------------------------! |
---|
180 | SUBROUTINE pmc_g_setname( mychild, couple_index, aname ) |
---|
181 | |
---|
182 | CHARACTER(LEN=*), INTENT(IN) :: aname !< |
---|
183 | |
---|
184 | INTEGER(iwp) :: i !< |
---|
185 | |
---|
186 | INTEGER(iwp), INTENT(IN) :: couple_index !< |
---|
187 | |
---|
188 | TYPE(childdef), INTENT(INOUT) :: mychild !< |
---|
189 | |
---|
190 | TYPE(pedef), POINTER :: ape !< |
---|
191 | |
---|
192 | |
---|
193 | ! |
---|
194 | !-- Assign array to next free index in array list. |
---|
195 | !-- Set name of array in arraydef structure |
---|
196 | DO i = 1, mychild%inter_npes |
---|
197 | ape => mychild%pes(i) |
---|
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 |
---|
202 | |
---|
203 | END SUBROUTINE pmc_g_setname |
---|
204 | #endif |
---|
205 | |
---|
206 | |
---|
207 | END MODULE pmc_general |
---|