-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfield_RANKSUFF_util_module.fypp
261 lines (178 loc) · 5.66 KB
/
field_RANKSUFF_util_module.fypp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#! (C) Copyright 2022- ECMWF.
#! (C) Copyright 2022- Meteo-France.
#!
#! This software is licensed under the terms of the Apache Licence Version 2.0
#! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
#! In applying this licence, ECMWF does not waive the privileges and immunities
#! granted to it by virtue of its status as an intergovernmental organisation
#! nor does it submit to any jurisdiction.
MODULE FIELD_${RANK}$${SUFF}$_UTIL_MODULE
#:set fieldTypeList = fieldType.getFieldTypeList (ranks=[RANK], kinds=['JP' + SUFF])
USE FIELD_${RANK}$${SUFF}$_MODULE
USE FIELD_${RANK}$${SUFF}$_ACCESS_MODULE
${fieldType.useParkind1 ()}$
IMPLICIT NONE
#:if defined('WITH_FIAT')
#:set method_list = ['LOAD', 'SAVE', 'DIFF', 'COPY', 'WIPE', 'HOST', 'LEGACY', 'CRC64']
#:else
#:set method_list = ['LOAD', 'SAVE', 'DIFF', 'COPY', 'WIPE', 'HOST', 'LEGACY']
#:endif
#:for method in method_list
INTERFACE ${method}$
#:for ft in fieldTypeList
MODULE PROCEDURE ${method}$_${ft.name}$
#:if method not in ['DIFF', 'CRC64', 'LEGACY']
MODULE PROCEDURE ${method}$_${ft.name}$_PTR
#:if ft.hasView
MODULE PROCEDURE ${method}$_${ft.name}$_VIEW
#:endif
#:endif
#:endfor
END INTERFACE
#:endfor
CONTAINS
#:for ft in fieldTypeList
#:if defined('WITH_FIAT')
INTEGER*8 FUNCTION CRC64_${ft.name}$ (YD)
CLASS (${ft.name}$), POINTER :: YD
INTEGER*8 :: ICRC
ICRC = 0
IF (ASSOCIATED (YD)) THEN
ICRC = YD%CRC64 ()
ENDIF
CRC64_${ft.name}$ = ICRC
END FUNCTION
#:endif
SUBROUTINE LOAD_${ft.name}$ (KLUN, YD)
USE FIELD_ABORT_MODULE
USE PARKIND1, ONLY : JPIM
INTEGER (KIND=JPIM), INTENT (IN) :: KLUN
CLASS (${ft.name}$), POINTER :: YD
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE SAVE_${ft.name}$ (KLUN, YD)
USE FIELD_ABORT_MODULE
USE PARKIND1, ONLY : JPIM
INTEGER (KIND=JPIM), INTENT (IN) :: KLUN
CLASS (${ft.name}$), POINTER :: YD
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE DIFF_${ft.name}$ (CDMESS, YD, YO)
USE FIELD_ABORT_MODULE
CHARACTER (LEN=*), INTENT(IN) :: CDMESS
CLASS (${ft.name}$), POINTER :: YD, YO
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE COPY_${ft.name}$ (SELF, LDCREATED)
USE FIELD_ABORT_MODULE
CLASS (${ft.name}$), POINTER :: SELF
LOGICAL, INTENT (IN), OPTIONAL :: LDCREATED
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE WIPE_${ft.name}$ (SELF, LDDELETED)
USE FIELD_ABORT_MODULE
CLASS (${ft.name}$) :: SELF
LOGICAL, INTENT (IN), OPTIONAL :: LDDELETED
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE HOST_${ft.name}$ (SELF)
CLASS (${ft.name}$), POINTER :: SELF
CALL SELF%SYNC_HOST_RDWR ()
END SUBROUTINE
SUBROUTINE LEGACY_${ft.name}$ (SELF, KADDRL, KADDRU, KDIR)
USE ${ft.name}$_ACCESS_MODULE
USE FIELD_CONSTANTS_MODULE
CLASS (${ft.name}$), POINTER :: SELF
INTEGER*8, INTENT (IN) :: KADDRL
INTEGER*8, INTENT (IN) :: KADDRU
INTEGER, INTENT (IN) :: KDIR
${ft.type}$, POINTER :: PTR (${ft.shape}$), DEVPTR (${ft.shape}$)
INTEGER*8 :: IADDRL
INTEGER*8 :: IADDRU
INTEGER (KIND=JPIM) :: ILBOUNDS (${ft.rank}$)
INTEGER (KIND=JPIM) :: IUBOUNDS (${ft.rank}$)
IF (ASSOCIATED (SELF)) THEN
CALL SELF%GET_DIMS (LBOUNDS=ILBOUNDS, UBOUNDS=IUBOUNDS)
PTR => SELF%PTR
IADDRL = LOC (PTR (${",".join (map (lambda i: "ILBOUNDS(" + str (i) + ")", range (1, ft.rank+1)))}$))
IADDRU = LOC (PTR (${",".join (map (lambda i: "IUBOUNDS(" + str (i) + ")", range (1, ft.rank+1)))}$))
IF ((KADDRL <= IADDRL) .AND. (IADDRU <= KADDRU)) THEN
IF (KDIR == NF2L) THEN
DEVPTR => GET_DEVICE_DATA_RDONLY (SELF)
CALL LEGACY_${ft.name}$_ASSIGN (PTR, DEVPTR)
ELSEIF (KDIR == NL2F) THEN
DEVPTR => GET_DEVICE_DATA_RDWR (SELF)
CALL LEGACY_${ft.name}$_ASSIGN (DEVPTR, PTR)
ENDIF
ENDIF
ENDIF
CONTAINS
SUBROUTINE LEGACY_${ft.name}$_ASSIGN (PTR_RHS, PTR_LHS)
${ft.type}$ :: PTR_RHS (${ft.shape}$), PTR_LHS (${ft.shape}$)
!$acc kernels present (PTR_RHS, PTR_LHS)
PTR_RHS = PTR_LHS
!$acc end kernels
END SUBROUTINE
END SUBROUTINE
#:if ft.hasView
SUBROUTINE LOAD_${ft.name}$_VIEW (KLUN, YD)
USE PARKIND1, ONLY : JPIM
INTEGER (KIND=JPIM), INTENT (IN) :: KLUN
CLASS (${ft.name}$_VIEW) :: YD
! Do nothing
END SUBROUTINE
SUBROUTINE SAVE_${ft.name}$_VIEW (KLUN, YD)
USE PARKIND1, ONLY : JPIM
INTEGER (KIND=JPIM), INTENT (IN) :: KLUN
CLASS (${ft.name}$_VIEW) :: YD
! Do nothing
END SUBROUTINE
SUBROUTINE COPY_${ft.name}$_VIEW (SELF, LDCREATED)
CLASS (${ft.name}$_VIEW) :: SELF
LOGICAL, INTENT (IN), OPTIONAL :: LDCREATED
! Do nothing
END SUBROUTINE
SUBROUTINE WIPE_${ft.name}$_VIEW (SELF, LDDELETED)
CLASS (${ft.name}$_VIEW) :: SELF
LOGICAL, INTENT (IN), OPTIONAL :: LDDELETED
! Do nothing
END SUBROUTINE
SUBROUTINE HOST_${ft.name}$_VIEW (SELF)
CLASS (${ft.name}$_VIEW) :: SELF
! Do nothing
END SUBROUTINE
#:endif
SUBROUTINE LOAD_${ft.name}$_PTR (KLUN, YD)
USE FIELD_ABORT_MODULE
USE PARKIND1, ONLY : JPIM
INTEGER (KIND=JPIM), INTENT (IN) :: KLUN
CLASS (${ft.name}$_PTR) :: YD
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE SAVE_${ft.name}$_PTR (KLUN, YD)
USE FIELD_ABORT_MODULE
USE PARKIND1, ONLY : JPIM
INTEGER (KIND=JPIM), INTENT (IN) :: KLUN
CLASS (${ft.name}$_PTR) :: YD
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE COPY_${ft.name}$_PTR (SELF, LDCREATED)
USE FIELD_ABORT_MODULE
CLASS (${ft.name}$_PTR) :: SELF
LOGICAL, INTENT (IN), OPTIONAL :: LDCREATED
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE WIPE_${ft.name}$_PTR (SELF, LDDELETED)
USE FIELD_ABORT_MODULE
CLASS (${ft.name}$_PTR) :: SELF
LOGICAL, INTENT (IN), OPTIONAL :: LDDELETED
CALL FIELD_ABORT ('NOT IMPLEMENTED')
END SUBROUTINE
SUBROUTINE HOST_${ft.name}$_PTR (SELF)
CLASS (${ft.name}$_PTR) :: SELF
IF (ASSOCIATED (SELF%PTR)) THEN
CALL HOST (SELF%PTR)
ENDIF
END SUBROUTINE
#:endfor
END MODULE