swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

magPack runs (was Re: problem with code and compilation


From: Paul Johnson
Subject: magPack runs (was Re: problem with code and compilation
Date: Mon, 18 Nov 2002 10:09:56 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020918

It seems to me this is a problem you could take up with the author of Mag, but I'm going to give it a look. Since I'm a professor, I can't resist teaching you while I fix this.

First I see:

$ make
gcc3 -c -g -O2 -march=i386 -mcpu=i686 -Wall -Wno-import -Wno-protocol -Werror -D_GNU_SOURCE -DAPPNAME=Mag -I/usr/include/swarm Mag.m
cc1obj: warnings being treated as errors
Mag.m: In function `-[Mag step]':
Mag.m:173: warning: unused variable `d'
Mag.m:175: warning: unused variable `r'
Mag.m:167: warning: `absX' might be used uninitialized in this function
Mag.m:167: warning: `absY' might be used uninitialized in this function
Mag.m:168: warning: `minStockIndex' might be used uninitialized in this function Mag.m:169: warning: `minStockValue' might be used uninitialized in this function
Mag.m: At top level:
Mag.m:452: warning: incomplete implementation of class `Mag'
Mag.m:452: warning: method definition for `-getMagNutriFracs' not found
make: *** [Mag.o] Error 1


I comment out the method -getMagNutriFracs in Mag.h. Fix the unused variables, initialize absX, absY=999 (a silly number I took from the top of my head), set minStockIndex=0 and minStockValue=0.0 (cause I thought that's what the author intended)


Then I try to make again, I get this.

gcc3 -c -g -O2 -march=i386 -mcpu=i686 -Wall -Wno-import -Wno-protocol -Werror -D_GNU_SOURCE -DAPPNAME=Mag -I/usr/include/swarm ObserverSwarm.m
ObserverSwarm.m: In function `-[ObserverSwarm buildObjects]':
ObserverSwarm.m:131: `ObjectLoader' undeclared (first use in this function)
ObserverSwarm.m:131: (Each undeclared identifier is reported only once
ObserverSwarm.m:131: for each function it appears in.)
cc1obj: warnings being treated as errors
ObserverSwarm.m:596: warning: method `setNumBins:' not implemented by protocol.
ObserverSwarm.m:596: warning: return type defaults to id
ObserverSwarm.m:632: warning: method `setNumBins:' not implemented by protocol.
ObserverSwarm.m:632: warning: return type defaults to id
ObserverSwarm.m:652: warning: method `setBinNum:' not implemented by protocol.
ObserverSwarm.m:652: warning: return type defaults to id
ObserverSwarm.m: In function `-[ObserverSwarm saveSetup]':
ObserverSwarm.m:807: `ObjectSaver' undeclared (first use in this function)
ObserverSwarm.m: In function `-[ObserverSwarm saveModel]':
ObserverSwarm.m:825: void value not ignored as it ought to be
ObserverSwarm.m:815: warning: `pixId' might be used uninitialized in this function
ObserverSwarm.m: In function `-[ObserverSwarm checkStop]':
ObserverSwarm.m:839: warning: unused variable `text'
make: *** [ObserverSwarm.o] Error 1

Fix for ObjectLoader problem is insert:
#import <simtools.h>
"setNumBins" problem fixed by updating usage to match swarm manual, setBinCount:

The error on line 825 is due to a style change in new Swarm, should rewrite like so:
  pixId = [Pixmap createBegin:[self getZone]];
  [pixId setWidget: nil];             // ('nil'=>root window)
  pixId = [pixId createEnd];
  [pixId save: filename];
  [pixId drop];


After that, i get a bunch of warnings on unused variables. I have no idea why they are in there, so I comment them out:

cc1obj: warnings being treated as errors
ObserverSwarm.m: In function `-[ObserverSwarm checkStop]':
ObserverSwarm.m:840: warning: unused variable `text'
make: *** [ObserverSwarm.o] Error 1
gcc3 -c -g -O2 -march=i386 -mcpu=i686 -Wall -Wno-import -Wno-protocol -Werror -D_GNU_SOURCE -DAPPNAME=Mag -I/usr/include/swarm BatchObserverSwarm.m
cc1obj: warnings being treated as errors
BatchObserverSwarm.m: In function `-[BatchObserverSwarm buildObjects]':
BatchObserverSwarm.m:68: warning: unused variable `maxNutri'
BatchObserverSwarm.m:69: warning: unused variable `filename'
BatchObserverSwarm.m: In function `-[BatchObserverSwarm checkStop]':
BatchObserverSwarm.m:429: warning: unused variable `text'
make: *** [BatchObserverSwarm.o] Error 1


After making those go away, then this is the compiler error:

cc1obj: warnings being treated as errors
ModelSwarm.m: In function `-[ModelSwarm buildObjects]':
ModelSwarm.m:405: warning: int format, long int arg (arg 2)
ModelSwarm.m:408: warning: int format, long int arg (arg 2)
ModelSwarm.m:411: warning: int format, long int arg (arg 2)
ModelSwarm.m:414: warning: int format, long int arg (arg 2)
ModelSwarm.m: In function `-[ModelSwarm convertStr:toLongArr:]':
ModelSwarm.m:502: warning: int format, long int arg (arg 3)
ModelSwarm.m:509: warning: int format, long int arg (arg 3)
ModelSwarm.m: In function `-[ModelSwarm addRandMagAtX:Y:]':
ModelSwarm.m:994: warning: unused variable `magNutriUtils'
ModelSwarm.m:996: warning: unused variable `inpNum'
make: *** [ModelSwarm.o] Error 1
gcc3 -c -g -O2 -march=i386 -mcpu=i686 -Wall -Wno-import -Wno-protocol -Werror -D_GNU_SOURCE -DAPPNAME=Mag -I/usr/include/swarm MultiScaled2d.m
cc1obj: warnings being treated as errors
MultiScaled2d.m: In function `-[MultiScaled2d takeValue:atX:Y:atIndex:]':
MultiScaled2d.m:215: warning: unused variable `newVal'
MultiScaled2d.m: In function `-[MultiScaled2d takeValueUpd:atX:Y:atIndex:]':
MultiScaled2d.m:233: warning: unused variable `newVal'
MultiScaled2d.m: In function `-[MultiScaled2d takeUnscaledValueUpd:atX:Y:atIndex:]':
MultiScaled2d.m:248: warning: unused variable `newVal'
MultiScaled2d.m: In function `-[MultiScaled2d updateInFlowBy:atIndex:]':
MultiScaled2d.m:285: warning: int format, long int arg (arg 3)
MultiScaled2d.m: In function `-[MultiScaled2d updateOutFlowBy:atIndex:]':
MultiScaled2d.m:343: warning: double format, different type arg (arg 3)
MultiScaled2d.m:367: warning: double format, different type arg (arg 2)
MultiScaled2d.m:367: warning: double format, different type arg (arg 4)
MultiScaled2d.m:374: warning: double format, different type arg (arg 2)
MultiScaled2d.m:374: warning: double format, different type arg (arg 4)
make: *** [MultiScaled2d.o] Error 1
gcc3 -c -g -O2 -march=i386 -mcpu=i686 -Wall -Wno-import -Wno-protocol -Werror -D_GNU_SOURCE -DAPPNAME=Mag -I/usr/include/swarm GeneticsFloat.m
cc1obj: warnings being treated as errors
GeneticsFloat.m: In function `-[GeneMap getGeneWithName:]':
GeneticsFloat.m:108: warning: control reaches end of non-void function
GeneticsFloat.m: In function `-[GeneMap getValueOfGene:ofGenome:]':
GeneticsFloat.m:155: warning: `floatVal' might be used uninitialized in this function

I have to change %d to %ld to make the "long int arg" errors go away. Comment out more unused variables. The double format errors are caused by mistaken %f instead of %ld.

Concerning the GeneticsFloat line 108, I have no idea what this method is supposed to return, so I put in a return nil at the end, hoping the program will crash if that's not a good default.

Warning on line 155: problem is that floatVal does not have a value unless the if statement is true, and then it gets returned. It has an InvalidCombination to catch that problem, so I just initialized floatVal to 999.9 for fun.

So, after all those changes, the Mag program compiles.  And what do I see?


STARTING Swarm
INITSWARM ..DONE
CREATING OS (interactive mode)..
  OS: createBegin ..Done
  OS: createEnd     Done
DONE
BUILDING OS Objects, Actions, ActivateIn ..
  OS: buildObjects ..
    MS: CreateBegin ..Done

    MS: createEnd ..Done

    MS: buildObjects ..
initEnzymeGenes: 0.00, 0.00, 0.00, 0.00,
optFracs:        0.40, 0.30, 0.20, 0.10,
n_utils:         1.00, 1.00, 1.00, 1.00,
iSeed:            160,  160,  160,  160,
inFlow:          2000, 1000,  400,  200,
outFlow:            1,    1,    1,    1,
outTresh:       100000,100000,100000,100000,Done
*** event raised for error: InvalidCombination
ActiveOutFile not initialized properly*** execution terminating due to error
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.140.20020514/src/defobj/Symbol.m:187 -[Error(c) _raiseEvent:]
Aborted (core dumped)

So I ran the program inside the gnu debugger:

$ gdb ./Mag
GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
(gdb) run
Starting program: /tmp/download/Mag/Mag

STARTING Swarm
INITSWARM ..DONE
CREATING OS (interactive mode)..
  OS: createBegin ..Done
  OS: createEnd     Done
DONE
BUILDING OS Objects, Actions, ActivateIn ..
  OS: buildObjects ..
    MS: CreateBegin ..Done

    MS: createEnd ..Done

    MS: buildObjects ..
initEnzymeGenes: 0.00, 0.00, 0.00, 0.00,
optFracs:        0.40, 0.30, 0.20, 0.10,
n_utils:         1.00, 1.00, 1.00, 1.00,
iSeed:            160,  160,  160,  160,
inFlow:          2000, 1000,  400,  200,
outFlow:            1,    1,    1,    1,
outTresh:       100000,100000,100000,100000,Done
*** event raised for error: InvalidCombination
ActiveOutFile not initialized properly*** execution terminating due to error
/home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.140.20020514/src/defobj/Symbol.m:187 -[
Error(c) _raiseEvent:]

Program received signal SIGABRT, Aborted.
0x42029331 in kill () from /lib/i686/libc.so.6
(gdb) bt
#0  0x42029331 in kill () from /lib/i686/libc.so.6
#1  0x4202911a in raise () from /lib/i686/libc.so.6
#2  0x4202a8c2 in abort () from /lib/i686/libc.so.6
#3  0x4027cf0b in debugabort ()
at /home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.140.20020514/src/misc/debugabort
.c:9
#4  0x401f221d in _i_Error_c__raiseEvent_ ()
at /home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.140.20020514/src/defobj/Symbol.m
:187
#5 0x40038780 in _i_ActiveOutFile__createEnd (self=0x823d8f8, _cmd=0x40044d88) at /home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.140.20020514/src/analysis/Active
OutFile.m:47
#6 0x4003b958 in _i_EZGraph__createGraphSequence_forSequence_withFeedFrom_andSelector_ ( self=0x822fac8, _cmd=0x40044da8, aName=0x80590e8 "Population", aSeq=0x823bc98,
    anObj=0x81e7c08, aSel=0x805e258)
at /home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.140.20020514/src/analysis/EZGrap
h.m:349
#7 0x4003ba15 in _i_EZGraph__createSequence_withFeedFrom_andSelector_ (self=0x822fac8, _cmd=0x805e260, aName=0x80590e8 "Population", anObj=0x81e7c08, aSel=0x805e258) at /home/pauljohn/LinuxDownloads/redhat/BUILD/swarm-2.1.140.20020514/src/analysis/EZGrap
h.m:367
#8 0x0804d96b in _i_ObserverSwarm__buildObjects (self=0x815c808, _cmd=0x805d720)
    at ObserverSwarm.m:312
#9  0x0804aa67 in main (argc=1, argv=0xbffff904) at main.m:39
#10 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6
(gdb)

The problem is in the ObserverSwarm.m:312, where a graph sequence is created. Actually, the problem is in the way it tries to create the output file of the graph. So to make some progress, I comment out the part about saving a file, and I figure I can fix that later if the model ever runs. After commenting out the file save code in several (about 10) places, I compile and run.

And it works.

This is a neat looking model. It has an extra button on the control panel, some swell data archiving things I have not seen before.

So I look back at the source code to fix the data archiving problem and the problem appears just to be that my run directory did not have a data subdirectory, and the setFileName method was assuming I alread had a data directory. Fixing that, it appears to me the Mag model runs fine.

Since it is GPL'd, I put copies of the fixed up program here:

ftp://ftp.swarm.org/pub/swarm/apps/objc/contrib/magPack-2.0-Swarm2.1.141.tar.gz

http://lark.cc.ku.edu/~pauljohn/Swarm/OtherPeoplesCode/magPack-2.0-Swarm2.1.141.tar.gz

And here.

Please note I assigned the version number to magPack of 2.0 and the Swarm version I'm using is the second part of the file name.


In the README I just inserted this:

Paul Johnson <address@hidden> Nov 18, 2002.

Updated code to run with Swarm-2.1.141.
Since this is under GPL, I'm making the changes available freely.


Whew. That's my good deed for the day.

Here is what you do in return, OK? For files we put up in the contrib ftp, we want a text file that describes what the program is, what it is supposed to do, who did it, and so forth.

If you browse this directory in a web browser:
ftp://ftp.swarm.org/pub/swarm/apps
you will see some files that explain how to create these "lsm" (lsm=linux software map) files and there is a template.

Would you please make one of these "lsm" files for me and email it to me. I'll post it. Its file name should be "magPack-2.0-Swarm2.1.141.lsm" and you can see examples of some lsm files here:

ftp://ftp.swarm.org/pub/swarm/apps/objc/sdg/




address@hidden wrote:
Dear techenical support,

               I have download the a source code of Mag simulation from
http://alife.tuke.sk/projekty/mag_html/download/magPack.tar.gz by Peter Zvirinsky and have modify some code for porting from 1.4.1 to 2.0, (setNumBins to setBinCount) but I still have a number of warning when I compile it with make.

I have send a email to the author of hte code but he hasn't reply. So just wonder could you help me out,

Problem: 1. in ObserverSwarm.m(663) [sizeDistGraph setBinNum: 10]; the setBinNum is a method but I cannot find the method on the document
is it a bug/typing error?

2.
There are many warning in the compilation, I have ignore these warning and compiled the code, but it crash everytime the button is pressed second time on the menu. Also when clicking on the blue tab on the table, it will say segmentation fault.

Yours sincerely,
Chi Wai Wong
.



--
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ku.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700


                 ==================================
  Swarm-Support is for discussion of the technical details of the day
  to day usage of Swarm.  For list administration needs (esp.
  [un]subscribing), please send a message to <address@hidden>
  with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]