Re: external functions on IBM AIX

From: Mary Haley (haley AT XXXXXX)
Date: Sat Dec 29 2001 - 13:37:27 MST

  • Next message: Cheung Ping: "Re: external functions on IBM AIX"

    > I have problem using external shared object on=20
    > IBM AIX version: 4.3 with=20
    > NCL version: 4.1
    >
    > A simple sample fortran code :
    >
    > ---------------- test.f -----------------------
    > C NCLFORTSTART
    > SUBROUTINE TEST(A,B)
    > INTEGER A,B
    > C NCLEND
    > A =3D B + 2
    > END
    >
    > -------- Make a shared object by: ---------
    > wrapit77 < test.f > test_W.c
    > nhlcc -c test_W.c -I$NCARG_ROOT/include -L$NCARG_ROOT/lib
    > nhlf77 -c test.f
    > ld -G -bnoentry -bexpall -o test.so test.o test_W.o
    >
    > ---------- run ncl will get: -------------------
    > $ncl
    > ncl 0>external test "./test.so"
    > Illegal instruction(coredump)
    > $
    >
    > Anyone has any idea ? I have tried it on Linux and it worked.

    Dear Cheung Ping,

    It looks like you are doing everything correctly. But, before I
    attempt to debug the problem, I'd like to point out a very useful
    script called "WRAPIT". This script does all of the steps of creating
    an NCL shared object for you. It figures out what kind of system you
    are on, calls wrapit77, compiles both the Fortran and C files, and
    runs the appropriate "ld" command. All you have to do is give it the
    Fortran file with the appropriate NCLFORTSTART and NCLEND statements
    in it, and it will produce a ".so" file for you.

    For example, with your "test.f" file, you can do the following:

        WRAPIT test.f

    and it will produce a "test.so" file. Please try this and see if it
    fixes your problem.
      
    Meanwhile, if you want to continue to create the shared object by
    hand, you need to make sure you use either the 32-bit or 64-bit
    compiler across the board. Whichever one you are using, you should
    specify this on the "ld" line as follows:

    32-bit:

       ld -b32 -G -bnoentry -bexpall -o test.so test.o test_W.o

    64-bit:
       ld -b64 -G -bnoentry -bexpall -o test.so test.o test_W.o

    This may not fix your problem, but it's a start. Also, you don't need
    to include "-I$NCARG_ROOT/include -L$NCARG_ROOT/lib" on the "nhlcc"
    compile line because "nhlcc" should already be including these for
    you.

    In any case, I highly recommend trying the WRAPIT script. It works
    under Solaris, IRIX64, AIX, DUNIX, and the Linux operating systems.
    If you download the latest version of NCAR Graphics, you should have
    access to this script in $NCARG_ROOT/bin.

    Cheers,

    --Mary Haley



    This archive was generated by hypermail 2b29 : Sat Dec 29 2001 - 13:38:13 MST