~fluidity-core/fluidity/ocean_forcing

« back to all changes in this revision

Viewing changes to libspud/src/spud.cpp

  • Committer: Patrick Farrell
  • Date: 2011-08-15 09:43:30 UTC
  • mfrom: (3541.2.9 diagnostic-python-spud)
  • Revision ID: patrick.farrell06@imperial.ac.uk-20110815094330-a01flj39wfort97a
This branch contains the features that let the embedded python interpreter in fluidity access the spud dictionary of fluidity's options.

Use it as follows:

import libspud
libspud.get_option("/simulation_name")

It only works for Python >= 2.7, so if you want your code to work on 2.6 or before, you need to guard with an

if sys.version_info[1] > 6

This branch also contains some minor fixes for compiling fluidity against; sometimes things were using the system one, and sometimes things were using the libspud/ directory.

This branch also updates libspud/ to be the latest spud trunk. Those changes have been reviewed earlier in other merge requests.

A lot of the work on this was done by Nan Mao.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    return;
42
42
  }
43
43
 
 
44
  void* OptionManager::get_manager() {
 
45
    return (void*) manager.options;
 
46
  }
 
47
 
 
48
  void OptionManager::set_manager(void* m) {
 
49
    delete manager.options;
 
50
    manager.options = (Spud::OptionManager::Option*) m;
 
51
    return;
 
52
  }
 
53
 
44
54
  OptionError OptionManager::load_options(const string& filename){
45
55
    return manager.options->load_options(filename);
46
56
  }
543
553
 
544
554
  OptionManager::OptionManager(){
545
555
    options = new Option();
 
556
    deallocated = false;
546
557
 
547
558
    return;
548
559
  }
553
564
  }
554
565
 
555
566
  OptionManager::~OptionManager(){
556
 
    delete options;
 
567
    if (!deallocated)
 
568
    {
 
569
      delete options;
 
570
      deallocated = true;
 
571
    }
557
572
 
558
573
    return;
559
574
  }