Re: Inquiry for amos routine for expint

Ethan A Merritt <[email protected]> Wed, 15 Dec 2021 10:10:27 -0800
Newsgroups gmane.comp.graphics.gnuplot.devel
Organization University of Washington
Message-ID <6067076.8F6SAcFxjW@stonelion>
On Wednesday, 15 December 2021 00:43:54 PST Tatsuro MATSUOKA wrote:
> /cygdrive/f/Work/Tatsuro/cygwinwork/gnuplot/gnuplot-main/gnuplot-main/conftest.c:56: undefined reference to `zairy_'
> collect2: error: ld returned 1 exit status
> configure:8799: $? = 1
> 
> def file of libamos has  zairy_ symbol

Some fortran compilers historically used a convention that subroutine
names always ended in an underscore.   

The gcc compiler package supports either the "always use underscore"
or "never use underscore" convention, but you have to use the same
convention when compiling all the source files that will be linked
together.  That includes libraries.

For gfortran the two options are
	-funderscoring
	-fno-underscoring

This is noted in the gnuplot source for the c/fortran interface routines
in gnuplot's .../src/amos_airy.c

 * The zairy_() routine (note Fortran naming and parameter passing conventions)
 * is found, for example, in libopenspecfun.  We use it to calculate Ai(z).
 * Similarly zbiry_() is used to calcualte Bi(z).

It could be that the zairy function you compiled from source lacks the
trailing underscore because the gfortran compiler defaulted to the wrong
underscoring convention.

I would worry a bit about this part also:
> I tried to use expint on the development brach on Cygwin.
>
> amos library, 
> http://www.netlib.org/amos/
>
> i1mach.f, r1mach.f, d1mach (replacement of the above)
> http://www.netlib.org/blas/i1mach.f
> http://www.netlib.org/blas/r1mach.f
> http://www.netlib.org/blas/d1mach.f

These source files were incorrect for use on my linux machines.
I replaced them with local definitions in C in order to build a
working copy of libamos.   I do not know whether that is or is
not a problem for your Cygwin environment.

I had considered to add the relevant libamos source files
in a new subdirectory of the gnuplot source, along with a
autoconf/Makefile template so that the library can be built
automatically via ./configure; make gnuplot

I decided not to add it when I found that at least some 
linux distributions are already providing either a pre-built
version of libamos or a version of libopenspecfun, which
provides all of the needed functions except cexint.
However your story here shows that it remains a bit tricky
to find and build all the relevant source if you do not have
one of the pre-built libraries.

So do people think it would be good to add the Amos source
to the gnuplot repository and distribution package?

I have source files from the original Sandia Laboratories
work by Donald Amos.  Some, but not all, of these were
later archived in netlib.  Note that the version of cexint.f
that I have did _not_ come from the TOMS/ACM publication
collection.

Separate from discussion of including the Amos source in the
gnuplot repository, I can send you Makefiles and C versions of
the *1mach files if you like.  Just let me know.

	Ethan  


> > ----- Original Message -----
> 
> > Hello
> > 
> > I tried to use expint on the development brach on Cygwin.
> > 
> > amos library, 
> > http://www.netlib.org/amos/
> > 
> > i1mach.f, r1mach.f, d1mach (replacement of the above)
> > http://www.netlib.org/blas/i1mach.f
> > http://www.netlib.org/blas/r1mach.f
> > http://www.netlib.org/blas/d1mach.f
> > 
> > cexint, zexint
> > http://www.netlib.org/toms-2014-06-10/683
> > 
> > I have checked cexint, zexint  by cqccex.f and zqccex.f.
> >  QUICK CHECKS FOR CEXINT ARE OK.
> >  QUICK CHECKS FOR ZEXINT ARE OK.
> > 
> > all.dem runs without problem
> > 
> > However, load 'expint.dem' seems to be invaild.
> > See the below screenshot files
> > http://tmacchant33.starfree.jp/Files/expint1.png
> > http://tmacchant33.starfree.jp/Files/expint2.png
> > 
> > Any suggestions?
> > 
> > Refernce
> > confiure
> > LDFLAGS='-L/usr/local/lib -lamos' \
> > ./configure --prefix=/cygdrive/f/Work/Tatsuro/cygwinwork/gnuplot/gnuplot-main/usr/local \
> >   --with-qt=no \
> >   --disable-dependency-tracking \
> >   --enable-plugins \
> >   --with-latex \
> >   --with-kpsexpand \
> >   --with-x \
> >   --with-readline=gnu \
> >   --with-gd \
> >   --with-lua \
> >   --with-bitmap-terminals \
> >   --enable-history-file \
> >   --enable-stats \
> >   --without-ggi \
> >   --without-gpic \
> >   --without-mif
> > 
> > config.log
> > http://tmacchant33.starfree.jp/Files/config.log
> > 
> > Tatsuro
> 
> Sorry I did see config.log in details.
> 
> gnuplot will be compiled with the following configurable features:
> 
>   Mouse support in interactive terminals: yes
>   Typing <space> in plot window raises console: yes
>   Readline library: GNU readline library with  -lncurses
>   Command-line history file: yes
>   Check current directory for .gnuplot file: no (use --with-cwdrc to enable)
>   Sort help/subtopic tables by column: no (use --without-row-help to enable)
>   cerf() and other special functions from libcerf: yes
>   Airy and Bessel functions from libopenspecfun or libamos: yes
>   Complex exponential integral cexint from libamos: yes
>   plugin support for loading external functions: yes
>   Statistical summary of data ("stats" command): yes
> 
> But config.log says 
> 
> configure:8714: gcc -o conftest.exe -g -O2  -I/include  -L/usr/local/lib -lamos -L/lib -lcerf  conftest.c -lcerf   >&5
> configure:8714: $? = 0
> configure:8734: result: -lcerf
> configure:8766: checking for amos libraries using LDFLAGS: -L/usr/local/lib -lamos -L/lib -lcerf   
> configure:8769: checking for library containing zairy_
> configure:8799: gcc -o conftest.exe -g -O2  -I/include  -L/usr/local/lib -lamos -L/lib -lcerf   conftest.c -lcerf  >&5
> /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: /tmp/ccYZXooH.o: in function `main':
> /cygdrive/f/Work/Tatsuro/cygwinwork/gnuplot/gnuplot-main/gnuplot-main/conftest.c:56: undefined reference to `zairy_'
> collect2: error: ld returned 1 exit status
> configure:8799: $? = 1
> 
> def file of libamos has  zairy_ symbol
> 
> Hmmmm?
> 
> Tatsuro
> 
> 
> 
> _______________________________________________
> gnuplot-beta mailing list
> [email protected]
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
> 


-- 
Ethan A Merritt
Biomolecular Structure Center,  K-428 Health Sciences Bldg
MS 357742,   University of Washington, Seattle 98195-7742




_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta