source: issm/trunk/src/m/os/petscversion.py@ 13395

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
RevLine 
[12762]1import os
2from issmdir import *
3from MatlabFuncs import *
4
5def petscversion():
[12827]6 """
7 PETSCVERSION - recover petsc version number, inside config.h file
8
[12944]9 Usage:
10 PETSC_VERSION=petscversion();
[12827]11 """
[12762]12
13 #default
14 PETSC_VERSION=3
15
[12766]16 configfile=os.path.join(issmdir(),'config.h')
[12762]17 if not os.path.exists(configfile):
18 raise RuntimeError("File '%s' not found. ISSM has not been configured yet!" % configfile)
19
[12766]20 #go through the file, and recover the line we want
[12762]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
[12766]33 return PETSC_VERSION
34
Note: See TracBrowser for help on using the repository browser.