The TELEMAC-MASCARET system  trunk
org_charac_type_alg.F
Go to the documentation of this file.
1 ! ******************************
2  SUBROUTINE org_charac_type_alg
3 ! ******************************
4 !
5  &(alg_char,nomb)
6 !
7 !***********************************************************************
8 ! PARALLEL V6P3 21/08/2010
9 !***********************************************************************
10 !
11 !brief RETURNS THE MPI TYPE FOR TYPE ALG_CHAR
12 !
13 !history A. JOLY
14 !+ 22/05/2013
15 !+ V6P3
16 !+ First version
17 !
18 !history M.S.TURNBULL (HRW)
19 !+ 18/11/2019
20 !+ V8P2
21 !+ Updated to include ICLASS, DISLODGE and TEFF
22 !
23 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 !| ALG_CHAR |<-->| MPI TYPE FOR TYPE CHARAC_TYPE - ALG_CHAR
25 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26 !
31  IMPLICIT NONE
32 !
33 !
34 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 !
36  INTEGER, INTENT(INOUT) :: ALG_CHAR
37  INTEGER, INTENT(IN) :: NOMB
38 !
39 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 !
41 ! ARRAY OF DISPLACEMENTS BETWEEN BASIC COMPONENTS, HERE INITIALISED ONLY
42 !
43 #if defined HAVE_MPI
44  INTEGER (KIND=MY_ADDRESS_KIND), DIMENSION(21) :: CH_DELTA
45 !
46 ! ARRAY OF BLOCKLENGTHS OF TYPE COMPONENTS, BASKET INITIALISED TO 1
47 !
48  INTEGER, DIMENSION(21) :: CH_BLENGTH
49 ! ARRAY OF COMPONENT TYPES IN TERMS OF THE MPI COMMUNICATION
50  INTEGER, DIMENSION(21) :: CH_TYPES
51  INTEGER IER,I
52  INTEGER (KIND=MY_ADDRESS_KIND) :: EXTENT,ILB,IUB,INTEX
53 !
54 !----------------------------------------------------------------------
55 !
56 ! THE CODE BELOW HERE MUST BE CONSISTENT WITH THIS TYPE:
57 !
58 ! TYPE ALG_TYPE
59 ! SEQUENCE ! NECESSARY TO DEFINE MPI TYPE
60 ! INTEGER :: MYPID ! PARTITION OF THE TRACEBACK ORIGIN (HEAD)
61 ! INTEGER :: NEPID ! THE NEIGHBOUR PARTITION THE TRACEBACK ENTERS TO
62 ! INTEGER :: IGLOB ! THE GLOBAL NUMBER OF THE PARTICLES
63 ! INTEGER :: FLAG ! USED TO ALIGN FIELDS
64 ! INTEGER :: ICLASS ! THE ALGAE CLASS
65 ! INTEGER :: DISLODGE ! 0 : NOT DISLODGED. 1 : DISLODGED.
66 ! DOUBLE PRECISION :: VX,VY,VZ ! THE (X,Y,Z) PARTICLE VELOCITY
67 ! DOUBLE PRECISION :: UX,UY,UZ ! THE (X,Y,Z) FLUID VELOCITY
68 ! DOUBLE PRECISION :: UX_AV,UY_AV,UZ_AV ! THE (X,Y,Z) AVERAGE FLUID VELOCITY
69 ! DOUBLE PRECISION :: K_AV,EPS_AV ! THE VALUES OF K AND EPS
70 ! DOUBLE PRECISION :: H_FLU ! THE WATER DEPTH AT POSITION OF VELOCITY
71 ! DOUBLE PRECISION :: TEFF ! EFFECTIVE TIME OF ALGAE DEGRADATION
72 ! DOUBLE PRECISION :: PSI(3*101) ! VARIABLE PSI USED FOR THE BASSET FORCE
73 ! END TYPE ALG_TYPE
74 !
75  ch_blength=1
76  ch_delta=0
77 !
78 ! TERMINATE ON MPI PARTS NOT HANDLED BY COMPAD
79 # if defined COMPAD
80  WRITE(lu,*) 'ORG_CHARAC_TYPE_ALG: COMPAD MAYBE CRITICAL',
81  & 'MPI OPERATION'
82  WRITE(lu,*) ' PLEASE CONTACT JR @ ADJOINTWARE'
83  CALL plante(1)
84  stop
85 # endif
86 ! INTEGERS IN THE STRUCTURE
87 !
88  CALL p_mpi_type_get_extent(mpi_integer,ilb,intex,ier)
89  ch_delta(1)=ilb
90 ! 7 IS THE FIRST DOUBLE PRECISION THAT COMES AFTER AN INTEGER
91  DO i=2,7
92  ch_delta(i)=ch_delta(i-1)+intex
93  ENDDO
94 !
95 ! DOUBLE PRECISION IN THE STRUCTURE
96 !
97 ! Handle components of active data type correctly
98 # if defined COMPAD
99  CALL p_mpi_type_get_extent(ampi_type,ilb,intex,ier)
100 # else
101  CALL p_mpi_type_get_extent(mpi_double_precision,ilb,intex,ier)
102 # endif
103 ! THE 14 REMAINING DOUBLE PRECISION (INCLUDING BASKET)
104  DO i=8,19
105  ch_delta(i)=ch_delta(i-1)+intex
106  ENDDO
107 !
108 ! INDEX FOR PSI
109 !
110  ch_delta(20)=ch_delta(19)+intex
111 ! ADDRESS AFTER THE THE LAST DOUBLE PRECISION
112  ch_delta(21)=ch_delta(20)+intex*3*101
113 !
114 ! CHECKING NOMB
115 !
116  IF(nomb.GT.3*101) THEN
117  WRITE (lu,*) 'PARALLEL::ORG_CHARAC_TYPE_ALG'
118  WRITE (lu,*) 'NOMB>3*101 ==> NWIN OR NDIR BADLY DEFINED'
119  WRITE (lu,*) 'NWIN SHOULD BE 100'
120  WRITE (lu,*) 'NDIR SHOULD BE 2 OR 3'
121 ! CALL PLANTE(1)
122  stop
123  ENDIF
124  ch_blength(20) = nomb
125 !
126  ch_types(1) =mpi_integer !MYPID
127  ch_types(2) =mpi_integer !NEPID
128  ch_types(3) =mpi_integer !IGLOB
129  ch_types(4) =mpi_integer !FLAG
130  ch_types(5) =mpi_integer !ICLASS
131  ch_types(6) =mpi_integer !DISLODGE
132 ! Handle components of active data type correctly
133 # if defined COMPAD
134  ch_types(7) =ampi_type !VX
135  ch_types(8) =ampi_type !VY
136  ch_types(9) =ampi_type !VZ
137  ch_types(10) =ampi_type !UX
138  ch_types(11) =ampi_type !UY
139  ch_types(12)=ampi_type !UZ
140  ch_types(13)=ampi_type !UX_AV
141  ch_types(14)=ampi_type !UY_AV
142  ch_types(15)=ampi_type !UZ_AV
143  ch_types(16)=ampi_type !K_AV
144  ch_types(17)=ampi_type !EPS_AV
145  ch_types(18)=ampi_type !H_FLU
146  ch_types(19)=ampi_type !TEFF
147  ch_types(20)=ampi_type !PSI
148 # else
149  ch_types(7) =mpi_double_precision !VX
150  ch_types(8) =mpi_double_precision !VY
151  ch_types(9) =mpi_double_precision !VZ
152  ch_types(10) =mpi_double_precision !UX
153  ch_types(11) =mpi_double_precision !UY
154  ch_types(12)=mpi_double_precision !UZ
155  ch_types(13)=mpi_double_precision !UX_AV
156  ch_types(14)=mpi_double_precision !UY_AV
157  ch_types(15)=mpi_double_precision !UZ_AV
158  ch_types(16)=mpi_double_precision !K_AV
159  ch_types(17)=mpi_double_precision !EPS_AV
160  ch_types(18)=mpi_double_precision !H_FLU
161  ch_types(19)=mpi_double_precision !TEFF
162  ch_types(20)=mpi_double_precision !PSI
163 # endif
164  ch_types(21)=mpi_ub !THE TYPE UPPER BOUND MARKER
165  CALL p_mpi_type_create_struct(21,ch_blength,ch_delta,ch_types,
166  & alg_char,ier)
167 
168  CALL p_mpi_type_commit(alg_char,ier)
169 
170  CALL p_mpi_type_get_extent(alg_char,ilb,extent,ier)
171 
172  iub=ilb+extent
173 !
174  IF(ilb.NE.ch_delta(1).OR.iub.NE.ch_delta(21)) THEN
175  WRITE(lu,*) ' PARALLEL::ORG_CHARAC_TYPE_ALG:'
176  WRITE(lu,*) ' MEMORY PROBLEM WITH THIS COMPILER: '
177  WRITE(lu,*) ' ILB=',ilb,' NOT EQUAL TO CH_DELTA(1)=',
178  & ch_delta(1)
179  WRITE(lu,*) ' OR'
180  WRITE(lu,*) ' IUB=',iub,' NOT EQUAL TO CH_DELTA(21)=',
181  & ch_delta(21)
182  CALL plante(1)
183  stop
184  ENDIF
185  RETURN
186 #else
187  WRITE(lu,*) 'CALL OF P_SYNC IN ITS VOID VERSION'
188 #endif
189 !
190 !----------------------------------------------------------------------
191 !
192  END SUBROUTINE org_charac_type_alg
integer, parameter mpi_double_precision
subroutine p_mpi_type_get_extent(DATATYPE, LOWER_BOUND, EXTENT, IERR)
integer, parameter mpi_integer
subroutine p_mpi_type_create_struct(NBLOCK, NELEM, DISPL, ELEM_TYPE, NEW_DATATYPE, IERR)
integer, parameter mpi_ub
subroutine p_mpi_type_commit(DATA_TYPE, IERR)
integer, parameter ampi_type
subroutine org_charac_type_alg(ALG_CHAR, NOMB)