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

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

Forced header and separation lines into 80 columns

  • Property svn:keywords set to Id
File size: 7.1 KB
RevLine 
[1900]1 MODULE pmc_general
[1762]2
[2000]3!------------------------------------------------------------------------------!
[1762]4! This file is part of PALM.
5!
[2000]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.
[1762]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!
[1818]18! Copyright 1997-2016 Leibniz Universitaet Hannover
[2000]19!------------------------------------------------------------------------------!
[1762]20!
21! Current revisions:
22! ------------------
[2000]23! Forced header and separation lines into 80 columns
[1933]24!
[1762]25! Former revisions:
26! -----------------
27! $Id: pmc_general_mod.f90 2000 2016-08-20 18:09:15Z knoop $
28!
[1933]29! 1901 2016-05-04 15:39:38Z raasch
30! Code clean up. The words server/client changed to parent/child.
31!
[1901]32! 1900 2016-05-04 15:27:53Z raasch
33! re-formatted to match PALM style, file renamed again
34!
[1809]35! 1808 2016-04-05 19:44:00Z raasch
36! MPI module used by default on all machines
37!
[1787]38! 1786 2016-03-08 05:49:27Z raasch
[1933]39! change in child-parent data transfer: parent now gets data from child
40! instead of that child puts it to the parent
[1787]41!
[1780]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!
[1767]46! 1766 2016-02-29 08:37:15Z raasch
47! +po_data in type arraydef
48!
[1765]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!
[1763]53! 1762 2016-02-25 12:31:13Z hellstea
54! Initial revision by K. Ketelsen
[1762]55!
56! Description:
57! ------------
58!
59! Structure definition and utilities of Palm Model Coupler
60!------------------------------------------------------------------------------!
61
[1764]62#if defined( __parallel )
[1900]63    USE, INTRINSIC ::  ISO_C_BINDING
[1762]64
[1900]65    USE kinds
[1764]66
[1808]67#if defined( __mpifh )
68    INCLUDE "mpif.h"
69#else
[1764]70    USE MPI
71#endif
72
[1900]73    IMPLICIT NONE
[1762]74
[1900]75    PRIVATE
76    SAVE
[1762]77
[1900]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  !<
[1762]85
86
[1900]87    TYPE, PUBLIC :: xy_ind  !< pair of indices in horizontal plane
88       INTEGER ::  i
89       INTEGER ::  j
90    END TYPE
[1762]91
[1900]92    TYPE, PUBLIC ::  arraydef
93       INTEGER                   :: coupleindex  !<
94       INTEGER                   :: nrdims       !< number of dimensions
95       INTEGER, DIMENSION(4)     :: a_dim        !< size of dimensions
[1933]96       TYPE(C_PTR)               :: data         !< pointer of data in parent space
[1900]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
[1762]109
[1900]110    TYPE(arraydef), PUBLIC, POINTER  :: next
[1762]111
[1900]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
[1762]118
[1933]119    TYPE, PUBLIC ::  childdef
[1900]120       INTEGER(idp) ::  totalbuffersize    !<
121       INTEGER      ::  model_comm         !< communicator of this model
[1933]122       INTEGER      ::  inter_comm         !< inter communicator model and child
123       INTEGER      ::  intra_comm         !< intra communicator model and child
[1900]124       INTEGER      ::  model_rank         !< rank of this model
125       INTEGER      ::  model_npes         !< number of PEs this model
[1933]126       INTEGER      ::  inter_npes         !< number of PEs child model
[1900]127       INTEGER      ::  intra_rank         !< rank within intra_comm
[1933]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
[1762]131
[1900]132    TYPE, PUBLIC ::  da_namedef  !< data array name definition
133       INTEGER                   ::  couple_index  !< unique number of array
[1933]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
[1900]138    END TYPE da_namedef
[1762]139
[1900]140    INTERFACE pmc_g_setname
141       MODULE PROCEDURE pmc_g_setname
142    END INTERFACE pmc_g_setname
[1762]143
[1900]144    INTERFACE pmc_sort
145       MODULE PROCEDURE sort_2d_i
146    END INTERFACE pmc_sort
[1762]147
[1900]148    PUBLIC pmc_g_setname, pmc_sort
[1762]149
150 CONTAINS
151
[1933]152 SUBROUTINE pmc_g_setname( mychild, couple_index, aname )
[1762]153
[1900]154    IMPLICIT NONE
[1762]155
[1900]156    CHARACTER(LEN=*)               ::  aname         !<
157    INTEGER, INTENT(IN)            ::  couple_index  !<
[1933]158    TYPE(childdef), INTENT(INOUT)  ::  mychild       !<
[1900]159
160    INTEGER ::  i  !<
161
162    TYPE(arraydef), POINTER ::  ar   !<
163    TYPE(pedef), POINTER    ::  ape  !<
164
[1779]165!
[1900]166!-- Assign array to next free index in array list.
167!-- Set name of array in arraydef structure
[1933]168    DO  i = 1, mychild%inter_npes
[1762]169
[1933]170       ape => mychild%pes(i)
[1900]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
[1762]174
[1900]175    ENDDO
[1762]176
[1900]177 END SUBROUTINE pmc_g_setname
[1762]178
179
180
[1900]181 SUBROUTINE sort_2d_i( array, sort_ind )
[1762]182
[1900]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
[1764]210#endif
[1900]211 END MODULE pmc_general
Note: See TracBrowser for help on using the repository browser.