I am exporting symbolic expression from Matlab to Fortran. Consider the following example,
>> syms a b c d real;
>> expr=(a+b+c)+(a+b+c)^2+(a+b+c)^3+(a+b+c)^4+(a+b+c)^5+(a+b+c)^6+(a+b+c)^7+(a+b+c)^8+(a+b+c)^9+(a+b+c)^10+(a+b+c)^11+(a+b+c)^12;
>> fortran(expr)
the output from Matlab is:
t0 = a+b+c+(a+b+c)**2+(a+b+c)**3+(a+b+c)**4+(a+b+c)**5+(a+b+c)**6+
&(a+b+c)**7+(a+b+c)**8+(a+b+c)**9+(a+b+c)**10+(a+b+c)**11+(a+b+c)**
&12
This is normal for the so-called "fixed form" of Fortran, where an ampersand appears at the beginning of each line. However, the "free form" or free-format of Fortran, requires ampersands at the end of each line as well, i.e.,
t0 = a+b+c+(a+b+c)**2+(a+b+c)**3+(a+b+c)**4+(a+b+c)**5+(a+b+c)**6+&
&(a+b+c)**7+(a+b+c)**8+(a+b+c)**9+(a+b+c)**10+(a+b+c)**11+(a+b+c)**&
&12
This is obviously annoying when using really big expressions, since one would have either to put manually every ampersand at the end of each line or make a shell script to do it. Is there any output of Matlab that exports the expressions in the latest format that I showed?