/[escript]/trunk/doc/SConscript
ViewVC logotype

Contents of /trunk/doc/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5738 - (show annotations)
Mon Jul 13 07:52:05 2015 UTC (3 years, 9 months ago) by jfenwick
File size: 9528 byte(s)
Added Ralf's examples.
Tests for correctness to follow later.

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2015 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 import os
18 Import('*')
19
20 from subprocess import PIPE, Popen
21
22 haveMPL=False # do we have matplotlib?
23 haveGD=False # does matplotlib have griddata?
24
25 mplmagicversion='0.98.5'
26
27 # check for matplotlib
28 if env['pythoncmd']=='python':
29 try:
30 import matplotlib
31 haveMPL=True
32 mplversion=matplotlib.__version__
33 from matplotlib.mlab import griddata
34 haveGD=True
35 except ImportError:
36 pass
37 else:
38 # we need to fire up the external command
39 p=Popen([env['pythoncmd'], '-c', 'from __future__ import print_function;import matplotlib;print(matplotlib.__version__);from matplotlib.mlab import griddata;print("1")'], stdout=PIPE)
40 try:
41 mplversion=p.stdout.readline().strip()
42 if mplversion!='':
43 haveMPL=True
44 hgd=p.stdout.readline().strip()
45 haveGD=True
46 except IOError:
47 pass
48 p.wait()
49
50 if not haveMPL:
51 env['warnings'].append("matplotlib not found, will skip some unit tests")
52 else:
53 if mplversion<mplmagicversion:
54 env['warnings'].append("matplotlib found, but version too early. Some unit tests will be skipped.")
55
56 example_files_allow_mpi = []
57 example_files_no_mpi = []
58 example_deps = []
59 skipped_tests = []
60
61 def sortOutExample(name, needsGMSH=False, needsMPL=False, needsMagicMPL=False, needsGD=False, allowsMPI=True):
62 if needsMagicMPL: needsMPL=True
63 if needsGD: needsMPL=True
64 if needsGMSH: allowsMPI=False
65
66 if needsGMSH and not env['gmsh']:
67 skipped_tests.append(name)
68 return
69
70 if (not needsGMSH or env['gmsh']) and (not needsMPL or haveMPL) and (not needsMagicMPL or mplversion>=mplmagicversion) and (not needsGD or haveGD):
71 if allowsMPI:
72 example_files_allow_mpi.append(name)
73 else:
74 example_files_no_mpi.append(name)
75 else:
76 example_deps.append(name)
77
78 # these are the release examples in example subdirectory:
79 #
80 #_deps is for files which end in .py and are required for
81 # testing but should not be invoked directly themselves
82
83 sortOutExample('usersguide/lid_driven_cavity.py')
84 sortOutExample('usersguide/mount.py')
85 sortOutExample('usersguide/heatedblock.py')
86 sortOutExample('usersguide/helmholtz.py')
87 sortOutExample('usersguide/fluid.py')
88 sortOutExample('usersguide/poisson.py')
89 sortOutExample('usersguide/diffusion.py')
90 sortOutExample('usersguide/poisson_vtk.py')
91 sortOutExample('usersguide/darcy.py')
92 sortOutExample('usersguide/dirac.py')
93 sortOutExample('usersguide/slip.py')
94 sortOutExample('usersguide/int_save.py')
95 sortOutExample('usersguide/wave.py', needsMPL=True)
96 sortOutExample('usersguide/trapezoid.py', needsGMSH=True, allowsMPI=False)
97 sortOutExample('usersguide/quad.py', needsGMSH=True)
98 sortOutExample('usersguide/brick.py', needsGMSH=True)
99 sortOutExample('usersguide/refine.py', needsGMSH=True)
100 sortOutExample('usersguide/poisson_matplotlib.py', needsGD=True, allowsMPI=False)
101 sortOutExample('usersguide/voxet_reader.py')
102
103 sortOutExample('geotutorial/steadystate_variablek.py')
104 sortOutExample('geotutorial/steadystate.py')
105 sortOutExample('geotutorial/forward_euler.py')
106 sortOutExample('geotutorial/myfirstscript.py')
107 sortOutExample('geotutorial/backward_euler.py')
108
109 example_deps.append('cookbook/cblib.py')
110 sortOutExample('cookbook/example01a.py')
111 sortOutExample('cookbook/example01b.py', needsMPL=True)
112 sortOutExample('cookbook/example01c.py', needsMPL=True, allowsMPI=False)
113 sortOutExample('cookbook/example02.py', needsMPL=True, allowsMPI=False)
114 sortOutExample('cookbook/example03a.py', needsGD=True, allowsMPI=False)
115 sortOutExample('cookbook/example03b.py')
116 sortOutExample('cookbook/example04a.py', needsGMSH=True)
117 sortOutExample('cookbook/example04b.py', needsGMSH=True, needsGD=True)
118 sortOutExample('cookbook/example05a.py', needsGMSH=True, needsGD=True)
119 sortOutExample('cookbook/example05b.py', needsGMSH=True, needsGD=True)
120 sortOutExample('cookbook/example05c.py', needsGMSH=True, needsGD=True, needsMagicMPL=True)
121 sortOutExample('cookbook/example06.py', needsGMSH=True, needsGD=True, needsMagicMPL=True)
122 sortOutExample('cookbook/example07a.py', needsMagicMPL=True, allowsMPI=False)
123 sortOutExample('cookbook/example07b.py', needsMagicMPL=True, allowsMPI=False)
124 sortOutExample('cookbook/example08a.py', needsMagicMPL=True, allowsMPI=False)
125 sortOutExample('cookbook/example08b.py', needsMagicMPL=True, allowsMPI=False)
126 sortOutExample('cookbook/example08c.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False)
127 sortOutExample('cookbook/example09m.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False)
128 sortOutExample('cookbook/example09a.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False)
129 #sortOutExample('cookbook/example09b.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False)
130 sortOutExample('cookbook/example10a.py', needsMagicMPL=True, allowsMPI=False)
131 sortOutExample('cookbook/example10b.py', needsMagicMPL=True, allowsMPI=False)
132 sortOutExample('cookbook/example10m.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False)
133 #sortOutExample('cookbook/example10c_0.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False)
134 #sortOutExample('cookbook/example10c_1.py', needsMagicMPL=True, needsGMSH=True, allowsMPI=False)
135 sortOutExample('cookbook/example11a.py', needsMagicMPL=True, allowsMPI=False)
136 sortOutExample('cookbook/example11b.py', needsMagicMPL=True, allowsMPI=False)
137
138 sortOutExample('inversion/create_netcdf.py')
139 sortOutExample('inversion/grav_ermapper.py')
140 sortOutExample('inversion/grav_netcdf.py')
141 sortOutExample('inversion/gravmag_netcdf.py')
142 sortOutExample('inversion/gravmag_nodriver.py')
143 sortOutExample('inversion/mag_netcdf.py')
144 sortOutExample('inversion/plot_ermapper.py', needsMPL=True, allowsMPI=False)
145 sortOutExample('inversion/plot_netcdf.py', needsMPL=True, allowsMPI=False)
146 sortOutExample('inversion/dc_forward.py', needsGMSH=True)
147
148
149 sortOutExample('inversion/test_commemi1.py', needsMPL=True, allowsMPI=True)
150 sortOutExample('inversion/test_commemi4.py', needsMPL=True, allowsMPI=True)
151
152 example_deps.append('inversion/content.txt')
153 example_deps.append('inversion/data/GravitySmall')
154 example_deps.append('inversion/data/MagneticSmall')
155 example_deps.append('inversion/data/QLDWestGravity')
156 example_deps.append('inversion/data/QLDWestMagnetic')
157 example_deps.append('inversion/data/GravitySmall.ers')
158 example_deps.append('inversion/data/MagneticSmall.ers')
159 example_deps.append('inversion/data/QLDWestGravity.ers')
160 example_deps.append('inversion/data/QLDWestMagnetic.ers')
161 example_deps.append('inversion/data/GravitySmall.nc')
162 example_deps.append('inversion/data/MagneticSmall.nc')
163 example_deps.append('inversion/data/QLDWestGravity.nc')
164 example_deps.append('inversion/data/QLDWestMagnetic.nc')
165 example_deps.append('inversion/data/HalfSphere_v1.4.msh')
166
167
168
169
170 if len(skipped_tests)>0:
171 env['warnings'].append("gmsh not available. Skipping tests %s!"%' '.join(skipped_tests))
172
173 example_files = example_files_allow_mpi + example_files_no_mpi + example_deps
174
175 wave_examples = ['inversion/synthetic_HTI.py',
176 'inversion/synthetic_VTI.py',
177 'inversion/synthetic_TTI.py',
178 'inversion/synthetic_sonic.py',
179 'inversion/synthetic_sonicHTI.py']
180
181 for i in wave_examples:
182 sortOutExample(i)
183
184 ex2=[os.path.join("examples", str(x)) for x in example_files]#+wave_examples]
185
186 #=============================================================================
187
188 local_env = env.Clone()
189 src_dir = local_env.Dir('.').srcnode().abspath
190 release_dir=os.path.join(env['prefix'],'release','doc')
191 Export('release_dir')
192
193 dir_cmd = "cd "+src_dir+" && "
194
195 # Need to use explicit tar/zip rather than the builder due to problems getting
196 # it not to put unwanted path components in the archive file
197 # --transform on tar is not supported on savanna
198 zip_path=os.path.join(release_dir, 'escript_examples.zip')
199 zip = local_env.Command(zip_path, None, dir_cmd+"zip "+zip_path+" "+" ".join(ex2))
200 env.Alias('examples_zipfile', zip)
201
202 tar_path=os.path.join(release_dir, 'escript_examples.tar.gz')
203 tar = local_env.Command(tar_path, None, dir_cmd+"tar -czf "+tar_path+" "+" ".join(ex2))
204 env.Alias('examples_tarfile', tar)
205
206 #env=Environment(TARFLAGS = "-c -z",chdir=src_dir)
207 #if 'Tar' in dir(env):
208 # tar=env.Tar(tar_path, example_files, chdir=src_dir)
209 # env.Alias('examples_tarfile', tar)
210
211 local_env.SConscript(dirs = ['#/doc/cookbook'], variant_dir='cookbook', duplicate=1)
212 local_env.SConscript(dirs = ['#/doc/user'], variant_dir='user', duplicate=1)
213 local_env.SConscript(dirs = ['#/doc/inversion'], variant_dir='inversion', duplicate=1)
214 local_env.SConscript(dirs = ['#/doc/epydoc'], variant_dir='epydoc', duplicate=1)
215 local_env.SConscript(dirs = ['#/doc/sphinx_api'], variant_dir='sphinx_api', duplicate=1)
216 local_env.SConscript(dirs = ['#/doc/doxygen'], variant_dir='doxygen', duplicate=1)
217 local_env.SConscript(dirs = ['#/doc/install'], variant_dir='install', duplicate=1)
218 local_env.SConscript(dirs = ['#/doc/examples'], variant_dir='examples', duplicate=1, exports=['example_files_allow_mpi', 'example_files_no_mpi', 'example_deps'])
219

  ViewVC Help
Powered by ViewVC 1.1.26