mhoffman / kmos

kMC on steroids: A vigorous attempt to make lattice kinetic Monte Carlo modelling easier
http://mhoffman.github.com/kmos/
GNU General Public License v3.0
55 stars 35 forks source link

No kmc_module.so generated after compiling with no errors ... errors when running kmos view #43

Open PGaneshIyer opened 8 years ago

PGaneshIyer commented 8 years ago

I followed the instructions to start my_first KMC model. While I can generate the .xml file by running the python script from ipython, that looks OK, when I compile it by typing in the command line "kmos export myfirst_kmc.xml", I see a new directory 'myfirst_kmc_local_smart/' generated, that has a 'src' directory.

The 'src' has files: assert.ppc kind_values.f90 lattice.f90 proclist.f90 base.f90 kmc_settings.py main.f90

I do not see a kmc_model.so file anywhere. So, when I run the 'kmos view' command from directory 'myfirst_kmc_local_smart/', I get errors such as this:

\ (process:47145): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'

\ (process:47145): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'

\ (process:47145): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags' Could not import matplotlib frontend for real-time plotting No module named _backend_gdk Error: No module named kmc_model Could not find the kmc module. The kmc implements the actual kmc model. This can be created from a kmos xml file using kmos export Hint: are you in a directory containing a compiled kMC model?

Error No module named kmc_settings Could import settings file The kmc_settings.py contains all changeable model parameters and descriptions for the representation on screen. Hint: are you in a directory containing a compiled kMC model?

Traceback (most recent call last): File "/Users/g5q/Library/Python/2.7/bin/kmos", line 21, in main() File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/cli.py", line 426, in main view.main(steps_per_frame=options.steps_per_frame) File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/view.py", line 452, in main viewer = KMC_Viewer(model, steps_per_frame=steps_per_frame) File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/view.py", line 398, in init self.vbox, self.window) File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/view.py", line 190, in init self.tofs = get_tof_names() File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/run.py", line 1996, in get_tof_names for process, tof_count in settings.tof_count.iteritems(): AttributeError: 'NoneType' object has no attribute 'tof_count'

mhoffman commented 8 years ago

In your directory myfirst_kmc_local_smart does it have a file named kmc_settings.py and kmc_model.so? If no, could you paste the log of the kmos export ... command? Most like numpy/f2py did not find a Fortran compiler.

If yes, could you fire up python in that directory and run

import kmos.run
model = kmos.run.KMC_Model()

and paste the response here? Thanks.

PGaneshIyer commented 8 years ago

In your directory myfirst_kmc_local_smart does it have a file named kmc_settings.py and kmc_model.so?

No

If no, could you paste the log of the kmos export ... command? Most likely numpy/f2py did not find a Fortran compiler.

mac95467:kmc_test g5q$ ls kmos_kmc_test.py myfirst_kmc.xml kmos_kmc_test.py~ myfirst_kmc_local_smart mac95467:kmc_test g5q$ kmos export myfirst_kmc.xml No export path provided. Exporting to myfirst_kmc_local_smart /Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos

If yes, could you fire up python in that directory and run

import kmos.run model = kmos.run.KMC_Model() and paste the response here?

mac95467:myfirst_kmc_local_smart g5q$ python Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import kmos.run kiwi Validation not working. Error: No module named kmc_model Could not find the kmc module. The kmc implements the actual kmc model. This can be created from a kmos xml file using kmos export Hint: are you in a directory containing a compiled kMC model?

Error No module named kmc_settings Could import settings file The kmc_settings.py contains all changeable model parameters and descriptions for the representation on screen. Hint: are you in a directory containing a compiled kMC model?

model=kmos.run.KMC_Model() Traceback (most recent call last): File "", line 1, in File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/run.py", line 129, in init self.parameters = Model_Parameters(self.print_rates) File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/run.py", line 1304, in init self.dict.update(settings.parameters) AttributeError: 'NoneType' object has no attribute 'parameters'

mhoffman commented 8 years ago

Is the first output you paste all that it says? If numpy/f2py cannot find a fortran compiler, trying to go further is futil. If I remember correctly f2py -c --help-fcompiler should tell you what it does and doesn't find. Otherwise does entering ifort or gfortran tell you anything?

PGaneshIyer commented 8 years ago

Yes, that is all it prints.

I typed f2py to see what compilers it can find. Here is the output of that.

mac95467:myfirst_kmc_local_smart g5q$ f2py-2.7 -c --help-fcompiler Gnu95FCompiler instance properties: archiver = ['/opt/local/bin/gfortran', '-cr'] compile_switch = '-c' compiler_f77 = ['/opt/local/bin/gfortran', '-Wall', '-g', '-ffixed- form', '-fno-second-underscore', '-fPIC', '-O3', '-funroll -loops'] compiler_f90 = ['/opt/local/bin/gfortran', '-Wall', '-g', '-fno-second- underscore', '-fPIC', '-O3', '-funroll-loops'] compiler_fix = ['/opt/local/bin/gfortran', '-Wall', '-g', '-ffixed- form', '-fno-second-underscore', '-Wall', '-g', '-fno- second-underscore', '-fPIC', '-O3', '-funroll-loops'] libraries = ['gfortran'] library_dirs = ['/opt/local/lib/gcc48/gcc/x86_64-apple-darwin13/4.8.3'] linker_exe = ['/opt/local/bin/gfortran', '-Wall', '-Wall'] linker_so = ['/opt/local/bin/gfortran', '-Wall', '-g', '-Wall', '- g', '-undefined', 'dynamic_lookup', '-bundle'] object_switch = '-o ' ranlib = ['/opt/local/bin/gfortran'] version = LooseVersion ('48') version_cmd = ['/opt/local/bin/gfortran', '--version'] Fortran compilers found: --fcompiler=gnu95 GNU Fortran 95 compiler (48) Compilers available for this platform, but not found: --fcompiler=absoft Absoft Corp Fortran Compiler --fcompiler=gnu GNU Fortran 77 compiler --fcompiler=ibm IBM XL Fortran Compiler --fcompiler=intel Intel Fortran Compiler for 32-bit apps --fcompiler=nag NAGWare Fortran 95 Compiler --fcompiler=pg Portland Group Fortran Compiler Compilers not available on this platform: --fcompiler=compaq Compaq Fortran Compiler --fcompiler=g95 G95 Fortran Compiler --fcompiler=hpux HP Fortran 90 Compiler --fcompiler=intele Intel Fortran Compiler for Itanium apps --fcompiler=intelem Intel Fortran Compiler for 64-bit apps --fcompiler=intelev Intel Visual Fortran Compiler for Itanium apps --fcompiler=intelv Intel Visual Fortran Compiler for 32-bit apps --fcompiler=intelvem Intel Visual Fortran Compiler for 64-bit apps --fcompiler=lahey Lahey/Fujitsu Fortran 95 Compiler --fcompiler=mips MIPSpro Fortran Compiler --fcompiler=none Fake Fortran compiler --fcompiler=pathf95 PathScale Fortran Compiler --fcompiler=sun Sun or Forte Fortran 95 Compiler --fcompiler=vast Pacific-Sierra Research Fortran 90 Compiler For compiler details, run 'config_fc --verbose' setup command. Removing build directory /var/folders/n2/b5vf0_m11s726n6vryg6p9x4m9cqdr/T/tmp4gMEmc

mhoffman commented 8 years ago

Ok, silent output is definitely a bumper. For further triage: you describe that you saw a subfolder named src. You could go into that and run kmos build and report what it says. Sometimes it is also necessary to set export F2PY_FCOMPILER=gfortran (syntax depends on your specific terminal).

PGaneshIyer commented 8 years ago

If I do 'kmos build' inside the src/ dir., then I get the kmc_model.so file. But this time, running 'kmos view' gives a different error. It says matplotlib is not available. This is strange because I have matplotlib with the installed python version. Is there another path I need to specify?

mac95467:src g5q$ kmos view

\ (process:64318): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'

\ (process:64318): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'

\ (process:64318): WARNING : Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags' Could not import matplotlib frontend for real-time plotting No module named _backend_gdk Traceback (most recent call last): File "/Users/g5q/Library/Python/2.7/bin/kmos", line 21, in main() File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/cli.py", line 426, in main view.main(steps_per_frame=options.steps_per_frame) File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/view.py", line 452, in main viewer = KMC_Viewer(model, steps_per_frame=steps_per_frame) File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/view.py", line 398, in init self.vbox, self.window) File "/Users/g5q/Library/Python/2.7/lib/python/site-packages/kmos/view.py", line 198, in init** self.data_plot = plt.figure() NameError: global name 'plt' is not defined

mhoffman commented 8 years ago

I would go with the first "real" error message. And they have less and less to do with kmos. Ignore the warnings and it says that it cannot find "backend_gdk". So matplotlib seems to work it just cannot find the GTK backend. How you get there depends a little on your specific setup. I remember that doing so with MacPorts was not terribly difficult but I am sure there are other ways

PGaneshIyer commented 8 years ago

Not sure about that. I can access all the backends in matplotlib if I import it in ipython (see below). I also see the backend_gdk.py file in the proper /path/to/python/site-package/matplotlib/backends/ directory.

What else can the above error be due to?

Thanks.

In [1]: import matplotlib as plt

In [2]: plt.rcsetup.all_backends Out[2]: [u'GTK', u'GTKAgg', u'GTKCairo', u'MacOSX', u'Qt4Agg', u'Qt5Agg', u'TkAgg', u'WX', u'WXAgg', u'CocoaAgg', u'GTK3Cairo', u'GTK3Agg', u'WebAgg', u'nbAgg', u'agg', u'cairo', u'emf', u'gdk', u'pdf', u'pgf', u'ps', u'svg', u'template']

mhoffman commented 8 years ago

Good point. For any run/view/simulation to work you need kmc_model.so and kmc_settings.py in the current directory. Sometimes these kmos view and even kmos run shadow the original error. Can you (a) make sure that you have both files in the directory? (b) You could fire up python and run import kmos.run; model = kmos.run.KMC_Model().

PGaneshIyer commented 8 years ago

I found the problem. choosing a specific backend somehow causes a problem, because it then looks for the _backend_whatever file for whatever I am looking for. It is not necessary because the backends are already available as a python file, so we don't need its c-extensions. So commenting these lines below (see below) gives no error anymore and I can fire up the GUI.

Now, to the next step....

Thanks.

Comment out the lines as shown below in /home/Library/Python/2.7/lib/python/site-packages/kmos/view.py:

try: import matplotlib

if os.name == 'posix':

matplotlib.use('GTKAgg')

elif os.name == 'nt':

matplotlib.use('wxagg')

else:

matplotlib.use('GTKAgg')

import matplotlib.pylab as plt
mhoffman commented 8 years ago

Can you tell me a bit more about your setup? From your previous message I gather that you are using Mac OS. Can you tell me a bit more about version and how you installed python/numpy/matplotlib. Maybe we can change in a way to behave more gracefully for your setup without breaking other setups.

Those lines do serve a purpose for platform independence. I remember installing kmos on Windoze once which comes with a different set of backend and automatic selection did not work properly. Maybe this has changed with more recent version of matplotlib. But even then I would think it is wrong to assume that everyone has the most recent matplotlib version installed.

Tip: the markdown syntax plays you a trick for commented out lines, turning them into H1 headers (the large ones). If you put code in between three "`" (acute) it will look nicer.

PGaneshIyer commented 8 years ago

I have OS X v 10.9.5. All packages (python/matplotlib/numpy...) were installed via macports in its default location following the recipe in your installation section of the Doc.

If we have a way of getting the c-extensions of the backend files for gtkgg and wxagg, and putting them in the appropriate folder, then these lines that involve matlab.use() will work without any problem.