Changeset 6105


Ignore:
Timestamp:
Dec 24, 2008, 1:50:50 PM (14 years ago)
Author:
ole
Message:

Allowed attempt to use large NetCDF file support to run in
a separate process in case it segfaults as is the case with
python-scientific 2.4.11

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/config.py

    r6087 r6105  
    11"""Module where global ANUGA model parameters and default values are set
    22"""
     3
     4import os
     5import sys
    36
    47################################################################################
     
    187190netcdf_mode_r = 'r'
    188191
    189 #try:
    190 #    import tempfile
    191 #    from Scientific.IO.NetCDF import NetCDFFile
    192 #
    193 #    fname = tempfile.mktemp()
    194 #    fid = NetCDFFile(fname, 'wl')
    195 #    fid.close()
    196 #    netcdf_mode_w = 'wl'
    197 ##    log('Using NetCDF large file mode')
    198 #except IOError:
    199 #    pass
    200 
     192# Code to set the write mode depending on
     193# whether Scientific.IO supports large NetCDF files
     194s = """
     195import tempfile
     196from Scientific.IO.NetCDF import NetCDFFile
     197
     198fname = tempfile.mktemp()
     199fid = NetCDFFile(fname, 'wl')
     200fid.close()
     201netcdf_mode_w = 'wl'
     202log('Using NetCDF large file mode')
     203"""
     204
     205# Need to run in a separate process due an
     206# error with older versions of Scientific.IO
     207if sys.platform == 'win32':
     208    null = 'NUL'
     209else:
     210    null = '/dev/null'
     211err = os.system('python -c "%s" 2> %s' % (s, null))
     212
     213if err > 0:
     214    # The Python script s failed e.g. with a segfault
     215    # which means that large file support is
     216    # definitely not supported
     217    pass
     218else:   
     219    # Try the import within this process
     220    try:
     221        exec(s)
     222    except IOError:
     223        # Large file support is not supported   
     224        pass
     225
Note: See TracChangeset for help on using the changeset viewer.