Reading output from GENPACK

49 views
Skip to first unread message

Laurence Holmes

unread,
Jul 23, 2012, 11:06:16 AM7/23/12
to tango-...@googlegroups.com
Hi I'm trying to adapt the genpack.f file in the GENPACK package to solve my own problems, taking input from a text file which is generated by a Java GUI.

The values for the constraints etc. will be fields in the text file which are read via Fortran I/O.

I'm having some problems returning the output to view in gsview - I'm not sure what I should be editing in the drawsol subroutine.

Currently the Fortran code can be executed by the Java code via cmd, but I'm having trouble getting a solution returned. 

Has anyone tried something like this before?

Any help is much appreciated.

Ernesto G. Birgin

unread,
Jul 23, 2012, 11:26:25 AM7/23/12
to tango-...@googlegroups.com
Dear Laurence,

Thank you very much for your interest in our work.

Drawsol subroutine generates a metapost file. We compile it using Metapost with the commnad line

mpost solution.mp

It generates a postcript file that we then include in a latex file for visualization. You can find an example of a tex file that includes an image generated in the way I described, for example, here:

http://www.ime.usp.br/~egbirgin/sources/genpack-circles/

I am not sure if this answers your question.

I hope it helps.

Regards,
Ernesto.

Laurence Holmes

unread,
Jul 23, 2012, 4:59:09 PM7/23/12
to tango-...@googlegroups.com
Hi Ernesto, thanks for your response.

I call all of the command line compilation you mention via Java, and it works fine, just the solution it returns in gsview does not change based on inputs. 
Instead I just get the same shape returned every time.

I think maybe it's a problem with the I/O in the drawsol subroutine to draw the convex shape.

I'm developing an area planning tool for use by architects for a research paper, and was just wondering if anyone else had done similar work calling GENPACK from Java.

Thanks for your help and producing the package, it's great!

Regards,

Laurence

Ernesto G. Birgin

unread,
Jul 23, 2012, 5:04:35 PM7/23/12
to tango-...@googlegroups.com
Dear Lawrence,

Your application seems to be very interesting. Please, let us know about the progress of your work.

Regarding, your I/O problem, well, I do not know. It may be a problem of gsview, that is not being able to recognize the file has been changed.

Regards,
Ernesto.

Laurence Holmes

unread,
Jul 29, 2012, 7:35:00 AM7/29/12
to tango-...@googlegroups.com
Hi,

I've now got everything working a bit better thanks - I can return the solution.ps file for any of the test problems via a call from Java.
The only problem I'm having is with using IO in genpack.f to solve my own problem.

I'm not a FORTRAN77 expert - is there anything unexpected in genpack.f which could affect my editing of the subroutines to take input from file? 

From testing I know the defpro subroutine is fine, so I think the problem is in evalw or evaldw.

When I try to select problem 1 at runtime, the command prompt just freezes. 

Again, I appreciate any help!

Anyway, here is what I have for evalw and evaldw:

evalw:

C     LOCAL SCALARS
      double precision tmp,a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4 

      if ( probid .eq. 1 ) then
 
         open(unit=8, file="c:\\users\\laurence\\vals.txt")
         read(8, *) a1
         read(8, *) a2
         read(8, *) a3
         read(8, *) a4
         read(8, *) b1
         read(8, *) b2
         read(8, *) b3
         read(8, *) b4
         read(8, *) c1
         read(8, *) c2
         read(8, *) c3
         read(8, *) c4
         close(8)
         w(1) = a1 * p(1) + b1 * p(2) + c1
         w(2) = a2 * p(1) + b2 * p(2) + c2
         w(3) = a3 * p(1) + b3 * p(2) + c3
         w(4) = a4 * p(1) + b4 * p(2) + c4
    ...

evaldw:

      if ( probid .eq. 1 ) then

         open(UNIT=4, FILE="c:\\users\\laurence\\diffs.txt")
         read(4, *) dwdp1(1)
         read(4, *) dwdp1(2)
         read(4, *) dwdp1(3)
         read(4, *) dwdp1(4)
         read(4, *) dwdp2(1)
         read(4, *) dwdp2(2)
         read(4, *) dwdp2(3)
         read(4, *) dwdp2(4)
         close(4)
      ...
Reply all
Reply to author
Forward
0 new messages