Comment #8 on issue 1487 by ryanlists: fcode: print sympy expressions as Fortran code http://code.google.com/p/sympy/issues/detail?id=1487
I think two printers with as much core in common as possible makes a lot of sense. I see myself using this code in the future and I see Fortran code generation as happening in several stages. First, you need to generate valid strings that handle the common expressions and assignments. Things like using ** for exponents and other fortran nuances. This code would probably be common to both printers. Some of it may also be common to Python code generation. For my thesis, I used Maxima to do the symoblic heavy lifting and then used Python and Fortran to do numeric stuff. It was nice to have both options and for my work there wasn't much difference between the code. The Pytohn was easier to debug and that helped me find the Fortan bugs. Next you need to wrap lines and add the Fortran leading spaces. Then I needed to add function definitions and the comments necessary to make f2py happy. I think we should definitely assume that our users are using f2py with this. In the end, I wanted a list of lines that I could append to and then dump to a file for later compiling. I will throw this in as a random thought that will probably be a later enhancement patch, but I needed complex sinh and cosh for my work. I had to define my own functions and search and replace regular sinh and cosh with my own function names and include the code for my complex versions at the beginning of my files (I am not a Fortran guru and don't know how to link in a library for this or whatever). All this to say, if we can go anything now to design in options for users to define their own functions even for things we think Fortran supports, that would be great. In the end, I had my own Fortran header that I inserted before the raw output from Maxima. For what it is worth, I am attaching the raw output file (fortran_model_bode0.f) and the version that is ready to be compiled (fortran_model_bode0_out.f). This is the kind of thing I would want to do. I have the Python code laying around that did some of this work, but it is kind of rough. Attachments: fortran_model_bode0.f 2.9 KB fortran_model_bode0_out.f 5.9 KB -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-issues" group. To post to this group, send email to sympy-issues@googlegroups.com To unsubscribe from this group, send email to sympy-issues+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-issues?hl=en -~----------~----~----~----~------~----~------~--~---