-
Notifications
You must be signed in to change notification settings - Fork 9
/
fieldType.py
executable file
·49 lines (36 loc) · 1.6 KB
/
fieldType.py
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
# (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.
class fieldType (object):
def __init__ (self, **kwargs):
self.__dict__ = kwargs
self.suffix = self.kind[2:]
tt = self.suffix[0]
ss = self.suffix[1]
th = {'R': 'REAL', 'I': 'INTEGER', 'L': 'LOGICAL'}
td = {'R': '0.0', 'I': '0', 'L': '.FALSE.'}
self.type = th[tt] + '(KIND=' + self.kind + ')'
self.default = td[tt] + '_' + self.kind
self.name = 'FIELD_%s%s' % (self.rank, self.suffix);
self.rank = int (self.rank)
self.shape = ','.join ([':'] * int (self.rank))
self.viewRank = self.rank-1
self.viewShape = ','.join ([':'] * (self.rank-1))
self.lbptr = ', '.join (list (map (lambda i: "LBOUNDS(" + str (i+1) + "):", range (0, self.rank))))
self.hasView = self.rank > 1
self.ganged = self.rank > 2
kinds = ['JPRM', 'JPRD', 'JPIM', 'JPLM']
def getFieldTypeList (ranks=[1,2,3,4,5], kinds=kinds, hasView=None, ganged=None):
l = [fieldType (kind=kind, rank=rank) for (kind) in kinds for rank in ranks]
if hasView != None:
l = [ft for ft in l if ft.hasView == hasView]
if ganged != None:
l = [ft for ft in l if ft.ganged == ganged]
return l
def useParkind1 (kinds=kinds):
return 'USE PARKIND1, ONLY : ' + ', '.join (kinds)