source: issm/trunk-jpl/src/py/model/petscversion.2.py@ 12075

Last change on this file since 12075 was 12075, checked in by Eric.Larour, 13 years ago

Handle version 2 vs 3 for python scripts. Prototype.

File size: 753 bytes
Line 
1#PETSCVERSION - recover petsc version number, inside config.h file
2#
3# Usage:
4# PETSC_VERSION=petscversion();
5
6#Module imports {{{
7import os
8import sys
9from issmtier import *
10#}}}
11
12def petscversion():
13
14 #default
15 PETSC_VERSION=3;
16
17 configfile=issmtier() + "/bin/config.h" #should find it in the install target
18
19 if not os.path.isfile(configfile):
20 raise RuntimeError("%s%s%s"%("File ",configfile," not found. ISSM has not been configured yet!"))
21
22 #go through the file, and recover the line we want
23 fid=open(configfile,'r');
24
25 tline=fid.readline()
26 while tline:
27
28 if tline=='':
29 break
30
31 if tline[0:21]=="#define _PETSC_MAJOR_":
32 PETSC_VERSION=int(tline[22])
33 break
34
35 tline=fid.readline()
36
37 fid.close();
38
39 return PETSC_VERSION
Note: See TracBrowser for help on using the repository browser.