File: Ninfo.py.test.in

package info (click to toggle)
cdo 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 49,836 kB
  • sloc: cpp: 185,271; ansic: 95,766; sh: 7,192; f90: 6,147; makefile: 1,977; ruby: 1,078; csh: 1,028; python: 995; fortran: 319; pascal: 219; perl: 9
file content (81 lines) | stat: -rw-r--r-- 2,036 bytes parent folder | download | duplicates (5)
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
#! @PYTHON@

from cdoTest import *

HAS_NETCDF=cdo_check_req("has-nc")
HAS_THREADS=cdo_check_req("has-threads")

OPERATOR="ngridpoints"
GRIDS=["r18x9","ni4","ni96","global_10","t63grid"]

expected_results={
"r18x9" : 162,
"ni4" : 250,
"ni96" : 94090,
"global_10" : 648,
"t63grid" : 18432
}

test_module = TestModule()

for grid in GRIDS:
    if (not HAS_THREADS):
        test_module.add_skip("POSIX threads not enabled")
        continue

    OFILE=f'{OPERATOR}_res'
    RFILE=f'{OPERATOR}_ref'

    t=TAPTest(f'{OPERATOR} {grid}')
    t.add(f'echo {expected_results[grid]} > {RFILE}')
    t.add(f'{CDO}  -s {OPERATOR} -topo,{grid} > {OFILE}')
    t.add(f'diff {OFILE} {RFILE}')
    t.clean(OFILE,RFILE)
    test_module.add(t)


OPERATOR="ngrids"
OFILE=f'{OPERATOR}_res'
RFILE=f'{OPERATOR}_ref'
# some addional test for operator: ngrids
if (not HAS_THREADS):
    test_module.add_skip("POSIX threads not enabled")
else:
    t=TAPTest(f'{OPERATOR} global_10')
    t.add(f'{CDO} -O -s {OPERATOR} -topo,global_10')
    t.clean(OFILE,RFILE)
    test_module.add(t)


for grid in ["r1x1","global_1"]:
    if (not HAS_THREADS):
        test_module.add_skip("POSIX threads not enabled")
        continue

    t=TAPTest(f'{OPERATOR} {grid}')
    t.add(f'echo 1 > {RFILE}')
    t.add(f'{CDO} -O -s {OPERATOR} -topo,{grid} > {OFILE}')
    t.add(f'diff {OFILE} {RFILE}')
    t.clean(OFILE,RFILE)
    test_module.add(t)


# create temporary data
if (not HAS_THREADS):
    test_module.add_skip("POSIX threads not enabled")
elif (not HAS_NETCDF):
    test_module.add_skip("NetCDF not enabled")
else:
    t=TAPTest(OPERATOR)
    t.add(f'{CDO} -O -f nc -temp,r18x9 temp.small')
    t.add(f'{CDO} -O -f nc -temp,global_10 temp.global')
    t.add(f'{CDO} -O -f nc -merge temp.small temp.global temp.2grids')

    t.add(f'echo 2 > {RFILE}')
    t.add(f'{CDO} -O -s {OPERATOR} temp.2grids > {OFILE}')
    t.add(f'diff {OFILE} {RFILE}')
    t.clean(OFILE,RFILE)
    t.clean("temp.small","temp.global","temp.2grids")
    test_module.add(t)

test_module.run()