f90 question



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.




-- 
Michel Talon