Re: C Wrapper functions

From: Mary Haley (haley AT
Date: Fri Feb 18 2005 - 09:05:08 MST

  • Next message: "How to compute surface pressure (ps)"

    Hi Anne,

    I believe the instructions you were following were for creating a new
    built-in function, which does require all these additional libraries.

    Since you are just creating a wrapper, you can generate a shared
    object from this, and then you don't need to build NCL or link in all
    these additional libraries. The instructions for this are at:

    Since we don't really have any C examples on our website, I'm going to
    attach four files that show a simple C example:

          cquad.c - A C file containing a C function and procedure, both
                         of which are to be wrapped and callable from NCL.

          cquad_wrap.c - The wrapper for these two C routines.

          ex01.ncl - An NCL script that loads the shared object and calls
                         these two routines.

          Makefile - A simple Makefile for generating the "" file
                         on a Sun. It will need to be modified depending on
                         what kind of system you have.

    Once you modify the Makefile to work for your system, you should
    be able to type:

           ncl ex01.ncl

    If creating the "cquad_wrap.c" file for your C function is causing
    grief, then you could cheat by creating a Fortran stub file as
    documented in the link above. You then use "wrapit77" on this stub
    file, and it generates a C wrapper for you. You will need to modify
    this C wrapper to fix it so that it's calling a C subroutine and not a
    Fortran subroutine, but most of the other work will be done for you.

    If you have any further questions, please feel free to email me


    On Thu, 17 Feb 2005 wrote:

    > Hi
    > I would like to write wrappers for C functions and I'm following the
    > instructions "Extending the NCL function and procedure set".
    > I have downloaded the free versions of NCL and NCAR graphics.
    > When I run
    > system("ls " + ncargpath("lib"))
    > I get a list of libraries (not including libncl.a) and then a Segmentation
    > fault:
    > libcgm.a
    > libncarg.a
    > libncarg_c.a
    > libncarg_gks.a
    > libncarg_ras.a
    > libnclapi.a
    > libngmath.a
    > ncarg
    > Segmentation fault
    > Searching my system I cannot find libncl.a
    > Does the free version of NCL not come with libncl.a - therefore I cannot write
    > wrappers?
    > Thanks
    > Anne Jones
    > _______________________________________________
    > ncl-talk mailing list

    ncl-talk mailing list

    This archive was generated by hypermail 2b29 : Fri Feb 18 2005 - 09:16:39 MST