The TELEMAC-MASCARET system  trunk
org_charac_type1.F
Go to the documentation of this file.
1 ! ***************************
2  SUBROUTINE org_charac_type1
3 ! ***************************
4 !
5  &(nomb,characteristic)
6 !
7 !***********************************************************************
8 ! PARALLEL V6P3 21/08/2010
9 !***********************************************************************
10 !
11 !brief MPI TYPE FOR TYPE CHARAC_TYPE - CHARACTERISTICS /
12 !
13 !history C. DENIS
14 !+ 01/07/2011
15 !+ V6P1
16 !+
17 !
18 !history N.DURAND (HRW), S.E.BOURBAN (HRW)
19 !+ 13/07/2010
20 !+ V6P0
21 !+ Translation of French comments within the FORTRAN sources into
22 !+ English comments
23 !
24 !history N.DURAND (HRW), S.E.BOURBAN (HRW)
25 !+ 21/08/2010
26 !+ V6P0
27 !+ Creation of DOXYGEN tags for automated documentation and
28 !+ cross-referencing of the FORTRAN sources
29 !
30 !history J-M HERVOUET
31 !+ 22/06/2012
32 !+ V6P2
33 !+ DX,DY and DZ added. Problem of integer 8 treated as a double
34 !+ solved. Much clearer now.
35 !+
36 !history J-M HERVOUET
37 !+ 04/10/2012
38 !+ V6P3
39 !+ NOMB = 0 now allowed
40 !
41 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42 !| NOMB |<---| NUMBER OF VARIABLES
43 !| CHARACTERISTIC |--->| DATATYPE FOR CHARACTERISTIC
44 !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45 !
50  IMPLICIT NONE
51 !
52 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 !
54  INTEGER, INTENT(IN) :: NOMB
55  INTEGER, INTENT(INOUT) :: CHARACTERISTIC
56 !
57 !+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 !
59 #if defined HAVE_MPI
60  INTEGER, PARAMETER :: MAX_BASKET_SIZE=10
61 !
62 ! ARRAY OF DISPLACEMENTS BETWEEN BASIC COMPONENTS, HERE INITIALISED ONLY
63 !
64 ! INTEGER (KIND=MPI_ADDRESS_KIND), DIMENSION(18) :: CH_DELTA
65  INTEGER (KIND=MY_ADDRESS_KIND), DIMENSION(18) :: CH_DELTA
66 !
67 ! ARRAY OF BLOCKLENGTHS OF TYPE COMPONENTS, BASKET INITIALISED TO 1
68 !
69  INTEGER, DIMENSION(18) :: CH_BLENGTH
70 ! ARRAY OF COMPONENT TYPES IN TERMS OF THE MPI COMMUNICATION
71  INTEGER, DIMENSION(18) :: CH_TYPES
72  INTEGER IER
73 ! INTEGER (KIND=MPI_ADDRESS_KIND) :: EXTENT,ILB,IUB,INTEX
74  INTEGER (KIND=MY_ADDRESS_KIND) :: EXTENT,ILB,IUB,INTEX
75 !
76  INTEGER I
77 !
78  ch_blength=(/1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1/)
79  ch_delta= (/0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0/)
80 !
81 ! TERMINATE ON MPI PARTS NOT HANDLED BY COMPAD
82 # if defined COMPAD
83  WRITE(lu,*) 'ORG_CHARAC_TYPE1: COMPAD MAYBE CRITICAL',
84  & 'MPI OPERATION'
85  WRITE(lu,*) ' PLEASE CONTACT JR @ ADJOINTWARE'
86  CALL plante(1)
87  stop
88 # endif
89 ! INTEGERS IN THE STRUCTURE
90 !
91  CALL p_mpi_type_get_extent(mpi_integer,ilb,intex,ier)
92  ch_delta(1)=0
93 ! 9 IS THE FIRST DOUBLE PRECISION THAT COMES AFTER AN INTEGER
94  DO i=2,9
95  ch_delta(i)=ch_delta(i-1)+intex
96  ENDDO
97 !
98 ! DOUBLE PRECISION IN THE STRUCTURE
99 !
100 ! Handle components of active data type correctly
101 # if defined COMPAD
102  CALL p_mpi_type_get_extent(ampi_type,ilb,intex,ier)
103 # else
104  CALL p_mpi_type_get_extent(mpi_double_precision,ilb,intex,ier)
105 # endif
106 ! THE SIX REMAINING DOUBLE PRECISION (INCLUDING BASKET)
107  DO i=10,17
108  ch_delta(i)=ch_delta(i-1)+intex
109  ENDDO
110 ! ADDRESS AFTER THE BASKET
111  ch_delta(18)=ch_delta(17)+intex*max_basket_size
112 !
113  IF(nomb.GE.0.AND.nomb.LE.max_basket_size) THEN
114  ch_blength(17) = nomb ! CH%BASKET RANGE APPLIED FOR COMMUNICATION
115  ELSE
116  WRITE(lu,*) ' PARALLEL::ORG_CHARAC_TYPE1::',
117  & ' NOMB NOT IN RANGE [0..MAX_BASKET_SIZE]'
118  WRITE(lu,*) ' MAX_BASKET_SIZE, NOMB: ',max_basket_size,nomb
119  CALL plante(1)
120  stop
121  ENDIF
122  ch_types(1)=mpi_integer
123  ch_types(2)=mpi_integer
124  ch_types(3)=mpi_integer
125  ch_types(4)=mpi_integer
126  ch_types(5)=mpi_integer
127  ch_types(6)=mpi_integer
128  ch_types(7)=mpi_integer
129  ch_types(8)=mpi_integer
130 ! Handle components of active data type correctly
131 # if defined COMPAD
132  ch_types(9)=ampi_type
133  ch_types(10)=ampi_type
134  ch_types(11)=ampi_type
135  ch_types(12)=ampi_type
136  ch_types(13)=ampi_type
137  ch_types(14)=ampi_type
138  ch_types(15)=ampi_type
139  ch_types(16)=ampi_type
140  ch_types(17)=ampi_type
141 # else
142  ch_types(9)=mpi_double_precision
143  ch_types(10)=mpi_double_precision
144  ch_types(11)=mpi_double_precision
145  ch_types(12)=mpi_double_precision
146  ch_types(13)=mpi_double_precision
147  ch_types(14)=mpi_double_precision
148  ch_types(15)=mpi_double_precision
149  ch_types(16)=mpi_double_precision
150  ch_types(17)=mpi_double_precision
151 # endif
152  ch_types(18)=mpi_ub ! THE TYPE UPPER BOUND MARKER
153  CALL p_mpi_type_create_struct(18,ch_blength,ch_delta,ch_types,
154  & characteristic,ier)
155  CALL p_mpi_type_commit(characteristic,ier)
156  CALL p_mpi_type_get_extent(characteristic,ilb,extent,ier)
157  iub=ilb+extent
158 !
159  IF(ilb.NE.ch_delta(1).OR.iub.NE.ch_delta(18)) THEN
160  WRITE(lu,*) ' PARALLEL::ORG_CHARAC_TYPE1:'
161  WRITE(lu,*) ' MEMORY PROBLEM WITH THIS COMPILER: '
162  WRITE(lu,*) ' ILB=',ilb,' NOT EQUAL TO CH_DELTA(1)=',
163  & ch_delta(1)
164  WRITE(lu,*) ' OR'
165  WRITE(lu,*) ' IUB=',iub,' NOT EQUAL TO CH_DELTA(18)=',
166  & ch_delta(18)
167  CALL plante(1)
168  stop
169  ENDIF
170 #else
171  WRITE(lu,*) 'CALL OF ORG_CHARAC_TYPE1, VOID VERSION'
172 #endif
173 !
174 !----------------------------------------------------------------------
175 !
176  RETURN
177  END SUBROUTINE org_charac_type1
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)
subroutine org_charac_type1(NOMB, CHARACTERISTIC)
integer, parameter mpi_ub
subroutine p_mpi_type_commit(DATA_TYPE, IERR)
integer, parameter ampi_type