1# This is a automake file, part of Unidata's netCDF package.
2# Copyright 2019, see the COPYRIGHT file for more information.
3
4# This file builds and runs tests for the netCDF-4 features in the F77
5# API.
6
7# Ed Hartnett, 2019
8
9AM_CPPFLAGS = -I../fortran
10
11# All tests need to link to fortran library.
12LDADD = ${top_builddir}/fortran/libnetcdff.la
13
14# These programs test the F77 netCDF-4 API using include netcdf.inc.
15NF77_TESTS = ftst_groups ftst_vars ftst_vars2 ftst_vars3 ftst_vars4	\
16ftst_vars5 ftst_vars6 ftst_types ftst_types2 ftst_types3 ftst_path	\
17ftst_rengrps f03tst_open_mem ftst_var_compact
18
19# Compile and run the F77 API tests.
20check_PROGRAMS = $(NF77_TESTS)
21TESTS = $(NF77_TESTS)
22
23# Each test depdends on its source.
24ftst_groups_SOURCES = ftst_groups.F
25ftst_vars_SOURCES = ftst_vars.F
26ftst_vars2_SOURCES = ftst_vars2.F
27ftst_vars3_SOURCES = ftst_vars3.F
28ftst_vars4_SOURCES = ftst_vars4.F
29ftst_vars5_SOURCES = ftst_vars5.F
30ftst_vars6_SOURCES = ftst_vars6.F
31ftst_types_SOURCES = ftst_types.F
32ftst_types2_SOURCES = ftst_types2.F
33ftst_types3_SOURCES = ftst_types3.F
34ftst_path_SOURCES = ftst_path.F
35ftst_rengrps_SOURCES = ftst_rengrps.F
36f03tst_open_mem_SOURCES = f03tst_open_mem.F
37ftst_var_compact_SOURCES = ftst_var_compact.F
38
39# This is a netCDF-4 V2 F77 test program.
40if BUILD_V2
41check_PROGRAMS += ftst_v2
42TESTS += ftst_v2
43ftst_v2_SOURCES = ftst_v2.F
44endif # BUILD_V2
45
46# Test parallel I/O for F77.
47if TEST_PARALLEL
48check_PROGRAMS += ftst_parallel ftst_parallel_nasa
49TESTS += run_f77_par_test.sh
50ftst_parallel_SOURCES = ftst_parallel.F
51ftst_parallel_nasa_SOURCES = ftst_parallel_nasa.F
52endif # TEST_PARALLEL
53
54# Test filters.
55if TEST_FILTERS
56check_PROGRAMS += ftst_filter
57ftst_filter_SOURCES = ftst_filter.F
58TESTS += run_tst_filter.sh
59endif
60
61# Test szip if write capability is present in C library.
62if TEST_SZIP_WRITE
63check_PROGRAMS += ftst_var_szip
64ftst_var_szip_SOURCES = ftst_var_szip.F
65TESTS += ftst_var_szip
66endif
67
68# If sed is present, generate these tests at build time. They are the
69# same tests as the F77 netCDF-4 tests above, but using the "use
70# netcdf4_f03" statement.
71if USE_SED
72
73# These test fortran codes will be created using sed.
74F03_TEST_CODES = f03tst_groups.F f03tst_vars.F f03tst_vars2.F	\
75f03tst_vars3.F f03tst_vars4.F f03tst_vars5.F f03tst_vars6.F	\
76f03tst_types.F f03tst_types2.F f03tst_types3.F
77
78# The fortran codes will compile into these tests.
79F03_TESTS = f03tst_groups f03tst_vars f03tst_vars2 f03tst_vars3		\
80f03tst_vars4 f03tst_vars5 f03tst_vars6 f03tst_types f03tst_types2	\
81f03tst_types3
82
83# This is a netCDF-4 V2 F77 test program.
84if BUILD_V2
85F03_TEST_CODES += f03tst_v2.F
86F03_TESTS += f03tst_v2
87f03tst_v2_SOURCES = f03tst_v2.F
88endif # BUILD_V2
89
90# Convert the parallel test.
91if TEST_PARALLEL
92F03_TEST_CODES += f03tst_parallel.F
93check_PROGRAMS += f03tst_parallel
94f03tst_parallel_SOURCES = f03tst_parallel.F
95TESTS += run_f77_par_test_03.sh
96endif # TEST_PARALLEL
97
98# Convert the szip test.
99if TEST_SZIP_WRITE
100F03_TEST_CODES += f03tst_var_szip.F
101F03_TESTS += f03tst_var_szip
102f03tst_var_szip_SOURCES = f03tst_var_szip.F
103endif # TEST_SZIP_WRITE
104
105# Note that all these fortran programs are built at compile-time on
106# the user system.
107BUILT_SOURCES = $(F03_TEST_CODES)
108
109# Compile and run the generated tests.
110check_PROGRAMS += $(F03_TESTS)
111TESTS += $(F03_TESTS)
112
113# Each generated test code depends on its source.
114f03tst_groups_SOURCES = f03tst_groups.F
115f03tst_vars_SOURCES = f03tst_vars.F
116f03tst_vars2_SOURCES = f03tst_vars2.F
117f03tst_vars3_SOURCES = f03tst_vars3.F
118f03tst_vars4_SOURCES = f03tst_vars4.F
119f03tst_vars5_SOURCES = f03tst_vars5.F
120f03tst_vars6_SOURCES = f03tst_vars6.F
121f03tst_types_SOURCES = f03tst_types.F
122f03tst_types2_SOURCES = f03tst_types2.F
123f03tst_types3_SOURCES = f03tst_types3.F
124
125# Use sed to generate the f03 versions of the test codes.
126f03tst_groups.F: ftst_groups.F
127	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
128	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
129	$(SED) "s|ftst_groups.nc|f03tst_groups.nc|" $@.tmp2 > $@
130
131f03tst_vars.F: ftst_vars.F
132	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
133	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
134	$(SED) "s|ftst_vars.nc|f03tst_vars.nc|" $@.tmp2 > $@
135
136f03tst_vars2.F: ftst_vars2.F
137	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
138	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
139	$(SED) "s|ftst_vars2.nc|f03tst_vars2.nc|" $@.tmp2 > $@
140
141f03tst_vars3.F: ftst_vars3.F
142	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
143	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
144	$(SED) "s|ftst_vars3.nc|f03tst_vars3.nc|" $@.tmp2 > $@
145
146f03tst_vars4.F: ftst_vars4.F
147	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
148	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
149	$(SED) "s|ftst_vars4.nc|f03tst_vars4.nc|" $@.tmp2 > $@
150
151f03tst_vars5.F: ftst_vars5.F
152	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
153	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
154	$(SED) "s|ftst_vars5.nc|f03tst_vars5.nc|" $@.tmp2 > $@
155
156f03tst_vars6.F: ftst_vars6.F
157	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
158	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
159	$(SED) "s|ftst_vars6.nc|f03tst_vars6.nc|" $@.tmp2 > $@
160
161f03tst_types.F: ftst_types.F
162	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
163	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
164	$(SED) "s|ftst_types.nc|f03tst_types.nc|" $@.tmp2 > $@
165
166f03tst_types2.F: ftst_types2.F
167	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
168	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
169	$(SED) "s|ftst_types2.nc|f03tst_types2.nc|" $@.tmp2 > $@
170
171f03tst_types3.F: ftst_types3.F
172	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
173	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
174	$(SED) "s|ftst_types3.nc|f03tst_types3.nc|" $@.tmp2 > $@
175
176f03tst_v2.F: ftst_v2.F
177	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
178	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
179	$(SED) "s|ftst_v2.nc|f03tst_v2.nc|" $@.tmp2 > $@
180
181f03tst_parallel.F: ftst_parallel.F
182	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
183	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
184	$(SED) "s|ftst_parallel.nc|f03tst_parallel.nc|" $@.tmp2 > $@
185
186f03tst_var_szip.F: ftst_var_szip.F
187	$(SED) "s|implicit none|USE netcdf4_f03|" $< > $@.tmp
188	$(SED) "s|include 'netcdf.inc'|implicit none|" $@.tmp > $@.tmp2
189	$(SED) "s|ftst_var_szip.nc|f03tst_var_szip.nc|" $@.tmp2 > $@
190
191endif #USE_SED
192
193# If valgrind is present on this machine, this will enable
194# check-valgrind target, which runs all tests with valgrind.
195@VALGRIND_CHECK_RULES@
196
197EXTRA_DIST = CMakeLists.txt run_f77_par_test.sh	\
198run_f77_par_test_03.sh
199
200# Cleaning up files created during the testing.
201CLEANFILES = ftst_*.nc f03tst_*.nc *.tmp *.tmp2 $(F03_TEST_CODES)
202