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

Last change on this file since 2000 was 2000, checked in by knoop, 5 years ago

Forced header and separation lines into 80 columns

  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1 MODULE pmc_general
2
3!------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the
7! terms of the GNU General Public License as published by the Free Software
8! Foundation, either version 3 of the License, or (at your option) any later
9! version.
10!
11! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
12! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14!
15! You should have received a copy of the GNU General Public License along with
16! PALM. If not, see <http://www.gnu.org/licenses/>.
17!
18! Copyright 1997-2016 Leibniz Universitaet Hannover
19!------------------------------------------------------------------------------!
20!
21! Current revisions:
22! ------------------
23! Forced header and separation lines into 80 columns
24!
25! Former revisions:
26! -----------------
27! $Id: pmc_general_mod.f90 2000 2016-08-20 18:09:15Z knoop $
28!
29! 1901 2016-05-04 15:39:38Z raasch
30! Code clean up. The words server/client changed to parent/child.
31!
32! 1900 2016-05-04 15:27:53Z raasch
33! re-formatted to match PALM style, file renamed again
34!
35! 1808 2016-04-05 19:44:00Z raasch
36! MPI module used by default on all machines
37!
38! 1786 2016-03-08 05:49:27Z raasch
39! change in child-parent data transfer: parent now gets data from child
40! instead of that child puts it to the parent
41!
42! 1779 2016-03-03 08:01:28Z raasch
43! PMC_MPI_REAL removed, dim_order removed from type arraydef,
44! array management changed from linked list to sequential loop
45!
46! 1766 2016-02-29 08:37:15Z raasch
47! +po_data in type arraydef
48!
49! 1764 2016-02-28 12:45:19Z raasch
50! cpp-statement added (nesting can only be used in parallel mode),
51! all kinds given in PALM style
52!
53! 1762 2016-02-25 12:31:13Z hellstea
54! Initial revision by K. Ketelsen
55!
56! Description:
57! ------------
58!
59! Structure definition and utilities of Palm Model Coupler
60!------------------------------------------------------------------------------!
61
62#if defined( __parallel )
63    USE, INTRINSIC ::  ISO_C_BINDING
64
65    USE kinds
66
67#if defined( __mpifh )
68    INCLUDE "mpif.h"
69#else
70    USE MPI
71#endif
72
73    IMPLICIT NONE
74
75    PRIVATE
76    SAVE
77
78    INTEGER, PARAMETER, PUBLIC :: da_desclen       =  8  !<
79    INTEGER, PARAMETER, PUBLIC :: da_namelen       = 16  !<
80    INTEGER, PARAMETER, PUBLIC :: pmc_da_name_err  = 10  !<
81    INTEGER, PARAMETER, PUBLIC :: pmc_max_array    = 32  !< max # of arrays which can be coupled
82    INTEGER, PARAMETER, PUBLIC :: pmc_max_models   = 64  !<
83    INTEGER, PARAMETER, PUBLIC :: pmc_status_ok    =  0  !<
84    INTEGER, PARAMETER, PUBLIC :: pmc_status_error = -1  !<
85
86
87    TYPE, PUBLIC :: xy_ind  !< pair of indices in horizontal plane
88       INTEGER ::  i
89       INTEGER ::  j
90    END TYPE
91
92    TYPE, PUBLIC ::  arraydef
93       INTEGER                   :: coupleindex  !<
94       INTEGER                   :: nrdims       !< number of dimensions
95       INTEGER, DIMENSION(4)     :: a_dim        !< size of dimensions
96       TYPE(C_PTR)               :: data         !< pointer of data in parent space
97       TYPE(C_PTR), DIMENSION(2) :: po_data      !< base pointers,
98                                                 !< pmc_s_set_active_data_array
99                                                 !< sets active pointer
100       INTEGER(idp)              :: SendIndex    !< index in send buffer
101       INTEGER(idp)              :: RecvIndex    !< index in receive buffer
102       INTEGER                   :: SendSize     !< size in send buffer
103       INTEGER                   :: RecvSize     !< size in receive buffer
104       TYPE(C_PTR)               :: SendBuf      !< data pointer in send buffer
105       TYPE(C_PTR)               :: RecvBuf      !< data pointer in receive buffer
106       CHARACTER(LEN=8)          :: Name         !< name of array
107       TYPE(arraydef), POINTER   :: next
108    END TYPE arraydef
109
110    TYPE(arraydef), PUBLIC, POINTER  :: next
111
112    TYPE, PUBLIC ::  pedef
113       INTEGER :: nr_arrays = 0  !< number of arrays which will be transfered
114       INTEGER :: nrele          !< number of elements, same for all arrays
115       TYPE(xy_ind), POINTER, DIMENSION(:)   ::  locInd      !< xy index local array for remote PE
116       TYPE(arraydef), POINTER, DIMENSION(:) ::  array_list  !< list of data arrays to be transfered
117    END TYPE pedef
118
119    TYPE, PUBLIC ::  childdef
120       INTEGER(idp) ::  totalbuffersize    !<
121       INTEGER      ::  model_comm         !< communicator of this model
122       INTEGER      ::  inter_comm         !< inter communicator model and child
123       INTEGER      ::  intra_comm         !< intra communicator model and child
124       INTEGER      ::  model_rank         !< rank of this model
125       INTEGER      ::  model_npes         !< number of PEs this model
126       INTEGER      ::  inter_npes         !< number of PEs child model
127       INTEGER      ::  intra_rank         !< rank within intra_comm
128       INTEGER      ::  win_parent_child   !< MPI RMA for preparing data on parent AND child side
129       TYPE(pedef), DIMENSION(:), POINTER ::  pes  !< list of all child PEs
130    END TYPE childdef
131
132    TYPE, PUBLIC ::  da_namedef  !< data array name definition
133       INTEGER                   ::  couple_index  !< unique number of array
134       CHARACTER(LEN=da_desclen) ::  parentdesc    !< parent array description
135       CHARACTER(LEN=da_namelen) ::  nameonparent  !< name of array within parent
136       CHARACTER(LEN=da_desclen) ::  childdesc     !< child array description
137       CHARACTER(LEN=da_namelen) ::  nameonchild   !< name of array within child
138    END TYPE da_namedef
139
140    INTERFACE pmc_g_setname
141       MODULE PROCEDURE pmc_g_setname
142    END INTERFACE pmc_g_setname
143
144    INTERFACE pmc_sort
145       MODULE PROCEDURE sort_2d_i
146    END INTERFACE pmc_sort
147
148    PUBLIC pmc_g_setname, pmc_sort
149
150 CONTAINS
151
152 SUBROUTINE pmc_g_setname( mychild, couple_index, aname )
153
154    IMPLICIT NONE
155
156    CHARACTER(LEN=*)               ::  aname         !<
157    INTEGER, INTENT(IN)            ::  couple_index  !<
158    TYPE(childdef), INTENT(INOUT)  ::  mychild       !<
159
160    INTEGER ::  i  !<
161
162    TYPE(arraydef), POINTER ::  ar   !<
163    TYPE(pedef), POINTER    ::  ape  !<
164
165!
166!-- Assign array to next free index in array list.
167!-- Set name of array in arraydef structure
168    DO  i = 1, mychild%inter_npes
169
170       ape => mychild%pes(i)
171       ape%nr_arrays = ape%nr_arrays + 1
172       ape%array_list(ape%nr_arrays)%name        = aname
173       ape%array_list(ape%nr_arrays)%coupleindex = couple_index
174
175    ENDDO
176
177 END SUBROUTINE pmc_g_setname
178
179
180
181 SUBROUTINE sort_2d_i( array, sort_ind )
182
183    IMPLICIT NONE
184
185    INTEGER, INTENT(IN)                    ::  sort_ind
186    INTEGER, DIMENSION(:,:), INTENT(INOUT) ::  array
187
188    INTEGER ::  i  !<
189    INTEGER ::  j  !<
190    INTEGER ::  n  !<
191
192    INTEGER, DIMENSION(SIZE(array,1)) ::  tmp  !<
193
194    n = SIZE(array,2)
195
196    DO  j = 1, n-1
197       DO  i = j+1, n
198
199          IF ( array(sort_ind,i) < array(sort_ind,j) )  THEN
200             tmp = array(:,i)
201             array(:,i) = array(:,j)
202             array(:,j) = tmp
203          ENDIF
204
205       ENDDO
206    ENDDO
207
208 END  SUBROUTINE sort_2d_i
209
210#endif
211 END MODULE pmc_general
Note: See TracBrowser for help on using the repository browser.