Last change
on this file since 13395 was 13395, checked in by Mathieu Morlighem, 12 years ago |
merged trunk-jpl and trunk for revision 13393
|
File size:
723 bytes
|
Line | |
---|
1 | import os
|
---|
2 | from issmdir import *
|
---|
3 | from MatlabFuncs import *
|
---|
4 |
|
---|
5 | def petscversion():
|
---|
6 | """
|
---|
7 | PETSCVERSION - recover petsc version number, inside config.h file
|
---|
8 |
|
---|
9 | Usage:
|
---|
10 | PETSC_VERSION=petscversion();
|
---|
11 | """
|
---|
12 |
|
---|
13 | #default
|
---|
14 | PETSC_VERSION=3
|
---|
15 |
|
---|
16 | configfile=os.path.join(issmdir(),'config.h')
|
---|
17 | if not os.path.exists(configfile):
|
---|
18 | raise RuntimeError("File '%s' not found. ISSM has not been configured yet!" % configfile)
|
---|
19 |
|
---|
20 | #go through the file, and recover the line we want
|
---|
21 | try:
|
---|
22 | fid=open(configfile,'r')
|
---|
23 | except IOError as e:
|
---|
24 | raise IOerror("could not open file: '%s'" % configfile)
|
---|
25 |
|
---|
26 | for tline in fid:
|
---|
27 | if strncmp(tline,'#define _PETSC_MAJOR_',21):
|
---|
28 | PETSC_VERSION=int(tline[22])
|
---|
29 | break
|
---|
30 |
|
---|
31 | fid.close()
|
---|
32 |
|
---|
33 | return PETSC_VERSION
|
---|
34 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.