Abstract
Many problems of Applied Mechanics or Physics are made of collection of objects in interactions, e.g. frictional contact, cohesion, etc. The shapes as the bulk and interaction behaviors may be complex, coupled with various physics. Moreover, the number of interacting bodies may be very large. Consequently, finding the motion of such a collection of bodies is quite complex. The LMGC90 platform is an academic open-source software designed to solve such problems, used by academics and industrial researchers. The core of this software is written in FORTRAN 90 due to its well known performance in numerical computing applications.
For such research software, which need a high level of flexibility, the design of a user interface raises many issues, some of them due to the FORTRAN language. Python, with its capabilities in scripting, object-oriented programming and other programming language interfacing, arises as an attractive complement. At the beginning we tried an automatic FORTRAN wrapping tool (f2py). However major drawbacks such as proper compiler version detection, management of compiler options, etc led us to find another solution.
After various trials, we developed our own recipe using the ISO C binding features offered by FORTRAN 2003 (implemented in the latest versions of compilers) which enables us wrapping LMGC90 using SWIG. The generated Python module is used to write scripts necessary to run each simulation. A script finely describes all stages of a simulation, moreover it provides new possibilities:
After these positive results we are using Python to reengineer the pre-processing part of our software, which is dedicated to the definition of our physical models. Previously many specific pieces of software dedicated to different tasks were developed with no possibility of interoperability. We developed a generic Python framework in order to plug these different libraries (wrapped using SWIG) and to add native Python code for new features. This Python module is:
Authors: Bagneris M., Dubois F., Iceta D., Martin A. and Mozul R.
For such research software, which need a high level of flexibility, the design of a user interface raises many issues, some of them due to the FORTRAN language. Python, with its capabilities in scripting, object-oriented programming and other programming language interfacing, arises as an attractive complement. At the beginning we tried an automatic FORTRAN wrapping tool (f2py). However major drawbacks such as proper compiler version detection, management of compiler options, etc led us to find another solution.
After various trials, we developed our own recipe using the ISO C binding features offered by FORTRAN 2003 (implemented in the latest versions of compilers) which enables us wrapping LMGC90 using SWIG. The generated Python module is used to write scripts necessary to run each simulation. A script finely describes all stages of a simulation, moreover it provides new possibilities:
- we can use all control structures provided by Python which were absent of our initial homemade scripting language (e.g. while loops, etc),
- we can use features of various Python modules (e.g NumPy, SciPy, etc),
- LMGC90 arrays can be accessed (through copy/pointer) as NumPy arrays, which offers new capabilities to manage (or couple) simulation.
After these positive results we are using Python to reengineer the pre-processing part of our software, which is dedicated to the definition of our physical models. Previously many specific pieces of software dedicated to different tasks were developed with no possibility of interoperability. We developed a generic Python framework in order to plug these different libraries (wrapped using SWIG) and to add native Python code for new features. This Python module is:
- easy to use and intuitive, as the physical objects are represented by Python objects,
- richer, as it mixes old features and new ones,
- extensible, since Python is powerful.
Authors: Bagneris M., Dubois F., Iceta D., Martin A. and Mozul R.


euroscipy2010_lmgc90_slides.pdf