Fortran free-form and a code generator

I have now implemented and uploaded to github an improvement to the Fortran code printer which provides an option for free source form, as opposed to fixed source form.  Relying on the free source form option, I also put together a working a Fortran code generator.

The free-form option necessiated a few changes in the exisiting FCodePrinter.  The most substantial change being that the line breaking code, which used to be a standalone function, is now a method of the printer instance.  This was necessary to make the line breaking algorithm aware of the printer settings, in particular the new ‘source_format’ setting.

I used the existing CCodeGen class as a template for my implementation of the Fortran code generator.  So with respect to functionality, it should be on par with the C code generator that I described earlier.  Real life testing remains of course, and the C code generator is implemented with an explicit goal of following the ANSI C standard.  I know that the Fortran generator works with Intel’s ifort compiler, but I have yet to check the standard compliance of the generated Fortran code.

Provided you have ifort in your $PATH, and have checked out the branch fortran_codegen from github, the compilation and correct execution of fortran code can be tested with the command:

bin/test sympy/test_external/test_codegen_f95_ifort.py

During the next week, I hope that I will be able to implement array functionality for both the C and Fortran code generators.

Advertisements
This entry was posted in sympy. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s