Robert Dodier | 22 Jan 2006 19:01
Picon

f2cl trouble with common block -- function make-<block name> undefined

Hello,

I'm trying to translate a program which has a named common block.
I'm using current cvs version of f2cl with clisp 2.34.
A simple example which shows the problem is

      PROGRAM FOO
      INTEGER BAR
      COMMON /MYCOMN/BAR

      BAR=12345
      WRITE(6,10)BAR
   10 FORMAT('BAR IS ', I5)
      RETURN
      END

g77 compiles this program and when executed it yields BAR IS 12345.
I translate this with (f2cl::f2cl "tmp.f" :declare-common t)
(same problem with (f2cl::f2cl "tmp.f" :declare-common t :common-as-array t)
by the way). The translation is apparently successful.
However, (load "tmp.lisp") complains "undefined function
FORTRAN-TO-LISP::MAKE-MYCOMN".

I looked at f2cl5.lisp and it looks like the stuff in create-sym-macros-array
is relevant in the :common-as-array case. However it appears that the
make-array at line 774 is never executed. I couldn't figure out anything else.

I searched the clocc-list and clocc-devel archives and checked the
bug reports (open and closed) but I didn't see anything about this problem.
Hopefully there is something simple I'm overlooking. Thanks for your help.
(Continue reading)

Raymond Toy | 23 Jan 2006 15:05
Picon
Favicon

Re: f2cl trouble with common block -- function make-<block name> undefined

>>>>> "Robert" == Robert Dodier <robert.dodier <at> gmail.com> writes:

Hello, Robert!

    Robert> g77 compiles this program and when executed it yields BAR IS 12345.
    Robert> I translate this with (f2cl::f2cl "tmp.f" :declare-common t)
    Robert> (same problem with (f2cl::f2cl "tmp.f" :declare-common t :common-as-array t)
    Robert> by the way). The translation is apparently successful.
    Robert> However, (load "tmp.lisp") complains "undefined function
    Robert> FORTRAN-TO-LISP::MAKE-MYCOMN".

Does the result work?  I also get these warnings when I compile the
lisp code with cmucl.  But the resulting compiled code does work.

    Robert> I looked at f2cl5.lisp and it looks like the stuff in create-sym-macros-array
    Robert> is relevant in the :common-as-array case. However it appears that the
    Robert> make-array at line 774 is never executed. I couldn't figure out anything else.

The generated code looks the same as that generated by cmucl.

Ray

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
Robert Dodier | 26 Jan 2006 16:27
Picon

Re: f2cl trouble with common block -- function make-<block name> undefined

Hi Ray, thanks for your help.

On 1/23/06, Raymond Toy <raymond.toy <at> ericsson.com> wrote:

>     Robert> g77 compiles this program and when executed it yields BAR IS 12345.
>     Robert> I translate this with (f2cl::f2cl "tmp.f" :declare-common t)
>     Robert> (same problem with (f2cl::f2cl "tmp.f" :declare-common t :common-as-array t)
>     Robert> by the way). The translation is apparently successful.
>     Robert> However, (load "tmp.lisp") complains "undefined function
>     Robert> FORTRAN-TO-LISP::MAKE-MYCOMN".
>
> Does the result work?  I also get these warnings when I compile the
> lisp code with cmucl.  But the resulting compiled code does work.

When I try (load "tmp.lisp") in Clisp,
I get the error message, it dumps me into the debugger.
If I skip over the offending form, there aren't any more
errors, but then if I try (FORTRAN-TO-LISP::FOO) to run
the program I get "undefined function FORTRAN-TO-LISP::MYCOMN-PART-0".
Examining tmp.lisp, I don't see a definition for MYCOMN-PART-0.

SBCL doesn't get that far; FOO is undefined.
GCL fails to load f2cl1.l so that's not in the running.

Are there some examples (containing common blocks or not)
which are known to work? I looked around in the cvs
repository but I didn't find anything like that.

Thanks for your help,
Robert Dodier
(Continue reading)

Raymond Toy | 26 Jan 2006 16:37
Picon
Favicon

Re: f2cl trouble with common block -- function make-<block name> undefined

>>>>> "Robert" == Robert Dodier <robert.dodier <at> gmail.com> writes:

    Robert> When I try (load "tmp.lisp") in Clisp,
    Robert> I get the error message, it dumps me into the debugger.

Ok.  I'll try with clisp.

    Robert> SBCL doesn't get that far; FOO is undefined.

Hmm.  How can FOO be undefined?

    Robert> GCL fails to load f2cl1.l so that's not in the running.

I haven't tried gcl with f2cl in ages.  But can gcl load the lisp
file?

    Robert> Are there some examples (containing common blocks or not)
    Robert> which are known to work? I looked around in the cvs

In packages/minpack, there are some common blocks.  These work for me
with cmucl, but I haven't tried anything else.

Ray

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
(Continue reading)

Robert Dodier | 26 Jan 2006 16:57
Picon

Re: f2cl trouble with common block -- function make-<block name> undefined

Hi Ray,

>     Robert> GCL fails to load f2cl1.l so that's not in the running.
>
> I haven't tried gcl with f2cl in ages.  But can gcl load the lisp
> file?

(load "tmp.lisp") => There is no package with the name FORTRAN-TO-LISP.

Maybe I'm not understanding how f2cl is supposed to work.

I try loading "tmp.lisp" (with clisp, sbcl, or gcl) and I get a
complaint about the package FORTRAN-TO-LISP being
undefined. OK, maybe I'm supposed to (load "macros.l")
and then (load "tmp.lisp"). Nope, complaints about F2CL-LIB.
OK, I'll try loading f2cl0.l through f2cl8.l and then macros.l.
Well, clisp is happy with that, sbcl complains a lot but
apparently succeeds, and gcl can't get through f2cl1.l.

I looked at f2cl/NOTES but it doesn't seem to have any
instructions or examples. I looked for other README-type
files but I didn't see any.

How is this supposed to work?

>     Robert> Are there some examples (containing common blocks or not)
>     Robert> which are known to work? I looked around in the cvs
>
> In packages/minpack, there are some common blocks.  These work for me
> with cmucl, but I haven't tried anything else.
(Continue reading)

Raymond Toy | 26 Jan 2006 20:45
Picon
Favicon

Re: f2cl trouble with common block -- function make-<block name> undefined

>>>>> "Robert" == Robert Dodier <robert.dodier <at> gmail.com> writes:

    Robert> I try loading "tmp.lisp" (with clisp, sbcl, or gcl) and I get a
    Robert> complaint about the package FORTRAN-TO-LISP being
    Robert> undefined. OK, maybe I'm supposed to (load "macros.l")

Got a chance to try this with clisp (2.35).  Something is broken in
either clisp or f2cl (more likely).  The generated code seems wrong.

However, when I use cmucl to generate the code, clisp compiles and
loads the code just find and (foo) produces the expected output.

Is it important for you to be able to generate the code via clisp?  I
usually use cmucl for that.

In any case, I'll look into making f2cl work with clisp.  I'm pretty
sure this used to work, but I haven't tried clisp in a long time.

GCl 2.7.0 ansi from 11/2004 compiles, loads, and runs the
cmucl-generated lisp file just fine.  This gcl seems incapable of
generating the lisp file, but it does load the f2cl*.l files just
fine.

Ray

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
(Continue reading)

Robert Dodier | 27 Jan 2006 16:50
Picon

Re: f2cl trouble with common block -- function make-<block name> undefined

Ray, thanks for your help. I've made some progress.

(1) SBCL loads f2cl successfully (although with many complaints),
and f2cl::f2cl executes successfully, and SBCL loads the
resulting translation successfully. Terrific!

(2) Variables mentioned in DATA statements within
BLOCK DATA aren't initialized. A function named
/BLOCKDATA-<WHATEVER>/ is defined
to initialize the data, but it is not automatically called;
if I call the block data function by hand, then the variables are initialized.

(3) The program of interest at the moment is LBFGS,
a minimization program. If I call the blockdata function to
initialize the common variables, the LBFGS test program
runs successfully. That's really good news.

Here is an example which exhibits the
problem with initializing common variables.
After loading tmp2.lisp,
(foo) =>
OUTPUT 1: BAR IS     0
OUTPUT 2: BAR IS 12345
However, I can force BAR to get initialized --
(/blockdata-mybloc/)
Then
(foo) =>
OUTPUT 1: BAR IS 98765
OUTPUT 2: BAR IS 12345

(Continue reading)

Raymond Toy | 27 Jan 2006 17:20
Picon
Favicon

Re: f2cl trouble with common block -- function make-<block name> undefined

>>>>> "Robert" == Robert Dodier <robert.dodier <at> gmail.com> writes:

    Robert> Ray, thanks for your help. I've made some progress.
    Robert> (1) SBCL loads f2cl successfully (although with many complaints),
    Robert> and f2cl::f2cl executes successfully, and SBCL loads the
    Robert> resulting translation successfully. Terrific!

I've checked in a change for clisp.  Clisp (2.35) works fine for me
with your test case now.

I also get quite a few errors from cmucl, but I'm too lazy to fix
them, because I think they're harmless.

    Robert> (2) Variables mentioned in DATA statements within
    Robert> BLOCK DATA aren't initialized. A function named
    Robert> /BLOCKDATA-<WHATEVER>/ is defined
    Robert> to initialize the data, but it is not automatically called;
    Robert> if I call the block data function by hand, then the variables are initialized.

Yes, that's a problem, but I'm not sure what the right solution is.
Currently, it's expected that you know what you're doing and how the
Fortran code works so that you call the block data initializer as
needed.

With Fortran, it's pretty easy to do this automatically at "load" time
because programs run just once.  But with Lisp, it's not so clear when
you have a repl and the program can be run many times.  I tend to put
wrappers around stuff as needed, so that the block data is initialized
everytime I run the main program.  Since f2cl may not know about the
block data when it's compiling the main program, there's no way for
(Continue reading)

Robert Dodier | 28 Jan 2006 02:26
Picon

Re: f2cl trouble with common block -- function make-<block name> undefined

Hi Ray,

> Yes, that's a problem, but I'm not sure what the right solution is.
> Currently, it's expected that you know what you're doing and how the
> Fortran code works so that you call the block data initializer as
> needed.

I think the current policy should be mentioned in the comment
for :DECLARE-COMMON in F2CL-COMPILE (f2cl1.l),
and elsewhere if there is somewhere else to put it.

About LBFGS, I'm not seeing a need to include it in the f2cl test suite.

Thanks a lot for your help -- I'll probably commit lbfgs.lisp
to Maxima sometime soon ...

Robert Dodier

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
Raymond Toy | 26 Jan 2006 19:43
Picon
Favicon

Re: f2cl trouble with common block -- function make-<block name> undefined

>>>>> "Robert" == Robert Dodier <robert.dodier <at> gmail.com> writes:

    Robert> Hi Ray,
    Robert> GCL fails to load f2cl1.l so that's not in the running.
    >> 
    >> I haven't tried gcl with f2cl in ages.  But can gcl load the lisp
    >> file?

    Robert> (load "tmp.lisp") => There is no package with the name FORTRAN-TO-LISP.

    Robert> Maybe I'm not understanding how f2cl is supposed to work.

    Robert> I try loading "tmp.lisp" (with clisp, sbcl, or gcl) and I get a
    Robert> complaint about the package FORTRAN-TO-LISP being
    Robert> undefined. OK, maybe I'm supposed to (load "macros.l")
    Robert> and then (load "tmp.lisp"). Nope, complaints about F2CL-LIB.
    Robert> OK, I'll try loading f2cl0.l through f2cl8.l and then macros.l.
    Robert> Well, clisp is happy with that, sbcl complains a lot but
    Robert> apparently succeeds, and gcl can't get through f2cl1.l.

Ok.  It's certainly a problem that there's no file describing what to
do.  My fault.  I'll add a README file that explains some of this.

So, if you want to do a conversion, you need to load all of the files,
of course.  Use the f2cl/f2cl.system or f2cl/f2cl.asd file to load
f2cl via mk:defsys or asdf.

Once a conversion is done, you don't need to load all of f2cl.  You
basically just need f2cl0.l to define the packages needed, and
macros.l to define the stuff that f2cl-lib needs.
(Continue reading)


Gmane