Thanks. I do not know lisp, but i changed f90.lisp by inserting (princ
"&") in two places:
;; Split this line and print it with trailing ampersand.
;; Previous scheme to break the lines nicely had some bugs;
;; it's simpler to break at a fixed length.
(let ((line x) (break-point *f90-output-line-length-max*))
(princ (subseq line 0 break-point))
(princ "&")
(terpri)
(princ "&")
(setf line (subseq line break-point))
(loop while (> (length line) break-point) do
(princ (subseq line 0 break-point))
(princ "&")
(terpri)
(princ "&)
(setf line (subseq line break-point)))
(if (> (length line) 0)
(princ line)))
(princ x))
It solved the problem:
(%i1) load("f90");
(%o1) /usr/local/share/maxima/5.25.1/share/contrib/f90.lisp
(%i2) res:
long_name_variable_1+long_name_variable_2+long_name_variable_3+long_name_variable_4+
long_name_variable_5+long_name_variable_6+long_name_variable_7+long_name_variable_8+long_name_variable_9+long_name_variable_10
+long_name_variable_11+long_name_variable_12+long_name_variable_13;
(%o2) long_name_variable_9 + long_name_variable_8 + long_name_variable_7
+ long_name_variable_6 + long_name_variable_5 + long_name_variable_4
+ long_name_variable_3 + long_name_variable_2 + long_name_variable_13
+ long_name_variable_12 + long_name_variable_11 + long_name_variable_10
+ long_name_variable_1
(%i3) f90(res);
long_name_variable_9+long_name_variable_8+long_name_variable_7+lo&
&ng_name_variable_6+long_name_variable_5+long_name_variable_4+long&
&_name_variable_3+long_name_variable_2+long_name_variable_13+long_&
&name_variable_12+long_name_variable_11+long_name_variable_10+long&
&_name_variable_1
(%o3) false
(%i4)
I asked about possibility to make gfortran to recognize line
continuation only with "&" symbol in the end of the line on the gfortran
mailing list, the answer is:
> On Sep 20 2011, Dmitry Shkirmanov wrote:
>>
>> third_long_name_variable+second_long_name_variable+first_long_nam&
>> e_variable
>>
>> But such line continuation is not recognized by gfortran, ...
>
> It's a breach of Fortran's syntax rules, and therefore a bug in Maxima.
> The correct syntax is:
>
> a=third_long_name_variable+second_long_name_variable+first_long_nam&
> &e_variable
>
> You must use the double & form when splitting lexical tokens. You can
> easily fix up Maxima's bug by running a simple awk, Python or Perl
> script to add an & to the start of every line that follows one that is
> terminated with an &.
>
>
> Regards,
> Nick Maclaren.
So, i think that developers of maxima should change f90.lisp to add the
ampersand symbol in the beginning of the next line by default.
On 20.09.2011 15:35, Michel Talon wrote:
> Dmitry Shkirmanov wrote:
>
>
>> Hello, list. I want to use the f90 command for getting the fortran
>> code. For example:
>>
>> (%i1) load("f90")$
>> (%i2)
>>
>>
> f90(first_long_name_variable+second_long_name_variable+third_long_name_variable)$
>
>> third_long_name_variable+second_long_name_variable+first_long_nam&
>> e_variable
>> (%i3)
>>
>> But such output of f90 command is not recognized by gfortran, let's
>>
> Yes, i think it is not very difficult. The file which does the job is
> f90.lisp which you can find in
> <prefix>/share/maxima/<version>/share/contrib/f90.lisp
>
> The place where lines are broken and& added is:
> (if (>= (length x) *f90-output-line-length-max*)
>
> ;; Split this line and print it with trailing ampersand.
> ;; Previous scheme to break the lines nicely had some bugs;
> ;; it's simpler to break at a fixed length.
>
> (let ((line x) (break-point *f90-output-line-length-max*))
> (princ (subseq line 0 break-point))
> (princ "&")
> (terpri)
> (setf line (subseq line break-point))
>
> (loop while (> (length line) break-point) do
> (princ (subseq line 0 break-point))
> (princ "&")
> (terpri)
> (setf line (subseq line break-point)))
>
> (if (> (length line) 0)
> (princ line)))
>
> (princ x))
>
>
> Here (terpri) terminates line and goes to new line, break-point is for
> example 80, (subseq line 0 break-point) is the part of the line from
> first to 80th character, it is printed then a& is printed and line is reset
> to the rest of line, etc. One needs to add a (princ "&") at the correct
> place, a bit of experiment will do.
>
> You can edit f90.lisp, then reload it and run it, etc. all interactive.
>