#! /usr/bin/env python
import sys
import subprocess
from basic_modeling_interface import Bmi


class BmiIlamb(Bmi):
    _command = 'ilamb-run'
    _args = None
    _env = None

    def __init__(self):
        self._time = self.get_start_time()

    @property
    def args(self):
        return [self._command] + (self._args or [])

    def get_component_name(self):
        return 'ILAMB'

    def initialize(self, filename):
        self._args = [filename or 'ilamb.cfg']

    def update(self):
        subprocess.check_call(self.args, shell=False, env=self._env)
        self._time = self.get_end_time()

    def update_until(self, time):
        self.update(time)

    def finalize(self):
        pass

    def get_input_var_names(self):
        return ()

    def get_output_var_names(self):
        return ()

    def get_start_time(self):
        return 0.0

    def get_end_time(self):
        return 1.0

    def get_current_time(self):
        return self._time

    def get_time_step(self):
        return 1.0

    def get_time_units(self):
        return 's'

@@ -1,34 +1,81 @@
-#! /usr/bin/env python
+%22%22%22Basic Model Interface (BMI) for the ILAMB benchmarking system.%22%22%22%0A
 %0Aimport 
 sys%0A
@@ -70,18 +70,17 @@
 %0Aimport 
-sy
+o
 s%0Aimport
@@ -136,30 +136,94 @@
 Bmi%0A
-%0A%0Aclass BmiIlamb(Bmi):
+from .config import Configuration%0A%0A%0Aclass BmiIlamb(Bmi):%0A    _component_name = 'ILAMB'
 %0A   
@@ -266,24 +266,8 @@
 None
-%0A    _env = None
 %0A%0A  
@@ -326,24 +326,62 @@
 start_time()
+%0A        self.config = Configuration()
 %0A%0A    @prope
@@ -506,23 +506,36 @@
  return 
-'ILAMB'
+self._component_name
 %0A%0A    de
@@ -581,65 +581,251 @@
 elf.
-_args = %5Bfilename or 'ilamb.cfg'%5D%0A%0A    def update(self):%0A
+config.load(filename)%0A        os.environ%5B'ILAMB_ROOT'%5D = self.config.get_ilamb_root()%0A        os.environ%5B'MPLBACKEND'%5D = 'Agg'%0A        self._args = self.config.get_arguments()%0A%0A    def update(self):%0A        with open('stdout', 'w') as fp:%0A    
     
@@ -866,33 +866,16 @@
 s, s
-hell=False, env=self._env
+tdout=fp
 )%0A  
@@ -968,20 +968,16 @@
 .update(
-time
 )%0A%0A    d

Update ILAMB BMI to use Configuration