source: palm/trunk/SOURCE/pmc_general_mod.f90 @ 4828

Last change on this file since 4828 was 4828, checked in by Giersch, 4 years ago

Copyright updated to year 2021, interface pmc_sort removed to accelarate the nesting code

  • Property svn:keywords set to Id
File size: 6.5 KB
Line 
1 MODULE pmc_general
2
3!--------------------------------------------------------------------------------------------------!
4! This file is part of the PALM model system.
5!
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.
9!
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.
13!
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/>.
16!
17! Copyright 1997-2021 Leibniz Universitaet Hannover
18!--------------------------------------------------------------------------------------------------!
19!
20!
21! Current revisions:
22! -----------------
23!
24!
25! Former revisions:
26! -----------------
27! $Id: pmc_general_mod.f90 4828 2021-01-05 11:21:41Z Giersch $
28! Interface pmc_sort removed. Subroutine description added.
29!
30! 4649 2020-08-25 12:11:17Z raasch
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!
36! 4360 2020-01-07 11:25:50Z suehring
37! Corrected "Former revisions" section
38!
39! 3945 2019-05-02 11:29:27Z raasch
40!
41! 2019-04-24 17:31:34Z suehring
42! Increase character length so that also chemistry variable names fully fit
43!
44! 3655 2019-01-07 16:51:22Z knoop
45! Determine number of coupled arrays dynamically.
46!
47! 1762 2016-02-25 12:31:13Z hellstea
48! Initial revision by K. Ketelsen
49!
50! Description:
51! ------------
52!
53! Structure definition and utilities of Palm Model Coupler
54!--------------------------------------------------------------------------------------------------!
55
56#if defined( __parallel )
57    USE, INTRINSIC ::  ISO_C_BINDING
58
59    USE kinds
60
61    USE MPI
62
63    IMPLICIT NONE
64
65
66    PRIVATE
67    SAVE
68
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  !<
75
76    INTEGER(iwp), PUBLIC ::  pmc_max_array  !< max # of arrays which can be coupled
77                                            !< - will be determined dynamically in pmc_interface
78
79
80    TYPE, PUBLIC :: xy_ind  !< pair of indices in horizontal plane
81       INTEGER(iwp) ::  i
82       INTEGER(iwp) ::  j
83    END TYPE
84
85    TYPE, PUBLIC ::  arraydef
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
107    END TYPE arraydef
108
109
110    TYPE(arraydef), PUBLIC, POINTER  :: next  !<
111
112
113    TYPE, PUBLIC ::  pedef
114       INTEGER(iwp) :: nr_arrays = 0  !< number of arrays which will be transfered
115       INTEGER(iwp) :: nrele          !< number of elements, same for all arrays
116
117       TYPE(arraydef), POINTER, DIMENSION(:) ::  array_list  !< list of data arrays to be transfered
118       TYPE(xy_ind), POINTER, DIMENSION(:)   ::  locInd      !< xy index local array for remote PE
119    END TYPE pedef
120
121
122    TYPE, PUBLIC ::  childdef
123       INTEGER(iwp) ::  inter_comm         !< inter communicator model and child
124       INTEGER(iwp) ::  inter_npes         !< number of PEs child model
125       INTEGER(iwp) ::  intra_comm         !< intra communicator model and child
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
129       INTEGER(iwp) ::  model_rank         !< rank of this model
130       INTEGER(idp) ::  totalbuffersize    !<
131       INTEGER(iwp) ::  win_parent_child   !< MPI RMA for preparing data on parent AND child side
132       TYPE(pedef), DIMENSION(:), POINTER ::  pes  !< list of all child PEs
133    END TYPE childdef
134
135
136    TYPE, PUBLIC ::  da_namedef  !< data array name definition
137       CHARACTER(LEN=da_desclen) ::  childdesc     !< child array description
138       CHARACTER(LEN=da_namelen) ::  nameonchild   !< name of array within child
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
142    END TYPE da_namedef
143
144    INTERFACE pmc_g_setname
145       MODULE PROCEDURE pmc_g_setname
146    END INTERFACE pmc_g_setname
147
148    PUBLIC pmc_g_setname
149
150 CONTAINS
151
152!---------------------------------------------------------------------------------------------------!
153! Description:
154! ------------
155!> Add array to list of arraydef structure. No the arra "name" is schedules for parent child transfer
156!---------------------------------------------------------------------------------------------------!
157 SUBROUTINE pmc_g_setname( mychild, couple_index, aname )
158
159    IMPLICIT NONE
160
161    CHARACTER(LEN=*)              ::  aname         !<
162
163    INTEGER(iwp), INTENT(IN)      ::  couple_index  !<
164
165    INTEGER(iwp) ::  i  !<
166
167    TYPE(childdef), INTENT(INOUT) ::  mychild       !<
168
169    TYPE(pedef), POINTER    ::  ape  !<
170
171!
172!-- Assign array to next free index in array list.
173!-- Set name of array in arraydef structure
174    DO  i = 1, mychild%inter_npes
175       ape => mychild%pes(i)
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
180
181 END SUBROUTINE pmc_g_setname
182
183#endif
184 END MODULE pmc_general
Note: See TracBrowser for help on using the repository browser.