~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to bin/code_saturne.in

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!@cs_python@
 
1
#!@PYTHON@
 
2
# -*- coding: utf-8 -*-
2
3
# @configure_input@
3
 
#-------------------------------------------------------------------------------
4
 
#   This file is part of the Code_Saturne Solver.
5
 
#
6
 
#   Copyright (C) 2009  EDF
7
 
#
8
 
#   The Code_Saturne Preprocessor is free software; you can redistribute it
9
 
#   and/or modify it under the terms of the GNU General Public License
10
 
#   as published by the Free Software Foundation; either version 2 of
11
 
#   the License, or (at your option) any later version.
12
 
#
13
 
#   The Code_Saturne Preprocessor is distributed in the hope that it will be
14
 
#   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15
 
#   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
#   GNU General Public License for more details.
17
 
#
18
 
#   You should have received a copy of the GNU General Public Licence
19
 
#   along with the Code_Saturne Preprocessor; if not, write to the
20
 
#   Free Software Foundation, Inc.,
21
 
#   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22
 
#-------------------------------------------------------------------------------
23
 
 
24
 
import os
25
 
import sys
 
4
 
 
5
#-------------------------------------------------------------------------------
 
6
 
 
7
# This file is part of Code_Saturne, a general-purpose CFD tool.
 
8
#
 
9
# Copyright (C) 1998-2011 EDF S.A.
 
10
#
 
11
# This program is free software; you can redistribute it and/or modify it under
 
12
# the terms of the GNU General Public License as published by the Free Software
 
13
# Foundation; either version 2 of the License, or (at your option) any later
 
14
# version.
 
15
#
 
16
# This program is distributed in the hope that it will be useful, but WITHOUT
 
17
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
18
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
19
# details.
 
20
#
 
21
# You should have received a copy of the GNU General Public License along with
 
22
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
23
# Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
24
 
 
25
#-------------------------------------------------------------------------------
 
26
 
 
27
import os, sys
26
28
 
27
29
# Trick so that one doesn't have to set the PYTHONPATH variable
28
30
cspath = '@pkgpythondir@'
29
 
 
30
 
# Similar trick for the MEI library
31
 
# (consistent with autoconf/automake behavior for MEI)
32
 
try:
33
 
   from distutils import sysconfig
34
 
   meipath = os.path.join(sysconfig.get_python_lib(0, 0, prefix='@mei_prefix@'),
35
 
                          'mei')
36
 
except Exception:
37
 
   meipath = ''
38
 
 
39
 
for p in [meipath, cspath]:
40
 
   if os.path.isdir(p) and not p in sys.path:
41
 
      sys.path.insert(0, p)
42
 
 
43
 
#-------------------------------------------------------------------------------
44
 
 
45
 
def usage(argv):
46
 
    usage = \
47
 
    """Usage: %(prog)s <topic>
48
 
 
49
 
Topics:
50
 
  help
51
 
  check_consistency
52
 
  check_mesh
53
 
  compile
54
 
  config
55
 
  create
56
 
  gui
57
 
  info
58
 
  plot_probes
59
 
 
60
 
Options:
61
 
  -h, --help  show this help message and exit"""
62
 
 
63
 
    print usage % {'prog':sys.argv[0]}
64
 
 
65
 
def check_consistency(argv):
66
 
    import cs_check_consistency
67
 
    cs_check_consistency.main(argv)
68
 
 
69
 
def check_mesh(argv):
70
 
    import cs_check_mesh
71
 
    cs_check_mesh.main(argv)
72
 
 
73
 
def compile(argv):
74
 
    import cs_compile
75
 
    cs_compile.main(argv)
76
 
 
77
 
def config(argv):
78
 
    import cs_config
79
 
    cs_config.main(argv)
80
 
 
81
 
def create(argv):
82
 
    import cs_create
83
 
    cs_create.main(argv)
84
 
 
85
 
def gui(argv):
86
 
    import cs_gui
87
 
    cs_gui.main(argv)
88
 
 
89
 
def info(argv):
90
 
    import cs_info
91
 
    cs_info.main(argv)
92
 
 
93
 
def plot_probes(argv):
94
 
    import cs_plot_probes
95
 
    cs_plot_probes.main(argv)
96
 
 
97
 
#-------------------------------------------------------------------------------
98
 
 
99
 
def main(argv):
100
 
    """
101
 
    Main function.
102
 
    """
103
 
 
104
 
    commands = {'help':usage, '--help':usage, '-h':usage,
105
 
                'check_consistency':check_consistency,
106
 
                'check_mesh':check_mesh,
107
 
                'compile':compile,
108
 
                'config':config,
109
 
                'create':create,
110
 
                'gui':gui,
111
 
                'info':info,
112
 
                'plot_probes':plot_probes}
113
 
 
114
 
    retcode = 1
115
 
 
116
 
    if (len(argv) < 1) or (argv[0] not in commands):
117
 
        usage(argv)
118
 
    else:
119
 
        command = argv[0]
120
 
        sys.argv[0] = sys.argv[0] + ' ' + command
121
 
        sys.argv.remove(command)
122
 
        commands[command](argv[1:])
 
31
if os.path.isdir(cspath) and not cspath in sys.path:
 
32
    sys.path.insert(0, cspath)
 
33
 
 
34
from cs_script import master_script
 
35
 
 
36
#-------------------------------------------------------------------------------
 
37
# Main
 
38
#-------------------------------------------------------------------------------
 
39
 
 
40
if __name__ == '__main__':
 
41
 
 
42
    # Retrieve package information (name, version, installation dirs, ...)
 
43
    from cs_package import package
 
44
    pkg = package()
 
45
 
 
46
    # Create an instance of the main script
 
47
    cs = master_script(sys.argv[1:], pkg)
 
48
 
 
49
    retcode = cs.execute()
 
50
 
 
51
    if retcode == None:
 
52
        retcode = 0
123
53
 
124
54
    sys.exit(retcode)
125
55
 
126
 
if __name__ == '__main__':
127
 
    main(sys.argv[1:])
 
56
#-------------------------------------------------------------------------------
 
57
# End
 
58
#-------------------------------------------------------------------------------