
from __future__ import print_function

import sys
import numpy as np

from bmi import MyBMI

def print_var_values (bmi, var_name):
    s = ', '.join ([str (x) for x in bmi.get_value (var_name)])
    print ('%s' % s)

def run ():
    bmi = MyBMI ()

    bmi.initialize (None)

    print ('%s' % bmi.get_component_name ())

    for i in range (10):
        print ('Time %d: ' % i, end='')
        print_var_values (bmi, 'height_above_sea_floor')
        bmi.update ()

    print ('Time %d: ' % i, end='')
    print_var_values (bmi, 'height_above_sea_floor')

    bmi.finalize ()

if __name__ == '__main__':
    run ()



from __future__ import print_function

import sys
import numpy as np

from poisson import BmiPoisson


def main():
    model = BmiPoisson()

    model.initialize()

    print('%s' % model.get_component_name ())

    for i in xrange(10):
        print('Time %d' % i)
        np.savetxt(sys.stdout, model.get_value('land_surface__elevation'),
                   fmt='%.3f')
        model.update()

    print('Time %d' % i)
    np.savetxt(sys.stdout, model.get_value('land_surface__elevation'),
               fmt='%.3f')

    model.finalize()


if __name__ == '__main__':
    main()

Update to use new bmi model.
Update to use new bmi model.

  
  from __future__ import print_function
  
  import sys
  import numpy as np
  
- from bmi import MyBMI
+ from poisson import BmiPoisson
  
- def print_var_values (bmi, var_name):
-     s = ', '.join ([str (x) for x in bmi.get_value (var_name)])
-     print ('%s' % s)
  
- def run ():
-     bmi = MyBMI ()
+ def main():
+     model = BmiPoisson()
  
-     bmi.initialize (None)
+     model.initialize()
  
-     print ('%s' % bmi.get_component_name ())
+     print('%s' % model.get_component_name ())
  
-     for i in range (10):
+     for i in xrange(10):
-         print ('Time %d: ' % i, end='')
+         print('Time %d' % i)
-         print_var_values (bmi, 'height_above_sea_floor')
+         np.savetxt(sys.stdout, model.get_value('land_surface__elevation'),
+                    fmt='%.3f')
-         bmi.update ()
+         model.update()
  
-     print ('Time %d: ' % i, end='')
+     print('Time %d' % i)
-     print_var_values (bmi, 'height_above_sea_floor')
+     np.savetxt(sys.stdout, model.get_value('land_surface__elevation'),
+                fmt='%.3f')
  
-     bmi.finalize ()
+     model.finalize()
+ 
  
  if __name__ == '__main__':
-     run ()
+     main()
  
- 
Update to use new bmi model.
## Code Before:

from __future__ import print_function

import sys
import numpy as np

from bmi import MyBMI

def print_var_values (bmi, var_name):
    s = ', '.join ([str (x) for x in bmi.get_value (var_name)])
    print ('%s' % s)

def run ():
    bmi = MyBMI ()

    bmi.initialize (None)

    print ('%s' % bmi.get_component_name ())

    for i in range (10):
        print ('Time %d: ' % i, end='')
        print_var_values (bmi, 'height_above_sea_floor')
        bmi.update ()

    print ('Time %d: ' % i, end='')
    print_var_values (bmi, 'height_above_sea_floor')

    bmi.finalize ()

if __name__ == '__main__':
    run ()


## Instruction:
Update to use new bmi model.
## Code After:

from __future__ import print_function

import sys
import numpy as np

from poisson import BmiPoisson


def main():
    model = BmiPoisson()

    model.initialize()

    print('%s' % model.get_component_name ())

    for i in xrange(10):
        print('Time %d' % i)
        np.savetxt(sys.stdout, model.get_value('land_surface__elevation'),
                   fmt='%.3f')
        model.update()

    print('Time %d' % i)
    np.savetxt(sys.stdout, model.get_value('land_surface__elevation'),
               fmt='%.3f')

    model.finalize()


if __name__ == '__main__':
    main()
