Re: External function name with underscore ( _ ) on LINUX (ia32)

From: Mary Haley (haley AT XXXXXX)
Date: Wed May 29 2002 - 20:47:11 MDT

  • Next message: Dave Newman: "b&w eps file coming out reversed?"

    >
    > Dear Sir.
    >
    >
    > I am trying to use the external function on the LINUX (ia32) platform, the external function name has the underscore is not working.
    >
    >
    > 1. My example external function test.f
    >
    > C NCLFORTSTART
    >       SUBROUTINE compute_one(N,X,Y,Z)
    >       REAL X(N),Y(N),Z(N)
    > C NCLEND
    > .
    > .
    > .
    > How to fix this?
    >
    > With best regards
    >
    > Boonlert  Archevarahuprok

    Dear Boonlert,

    I will describe the problem in some detail below. If you are just
    interested in the answer, then don't read beyond this paragraph. Just
    rename "compute_one" in your Fortran file to a name that doesn't have
    any underscores (like "computeone"), and rerun WRAPIT on your file.

    Now for the long explanation: when you use g77 on Linux systems to
    compile a Fortran subroutine, an underscore is automatically appended
    to the name ("compute" becomes "compute_", for example). Thus, in the
    C wrapper routine that is generated by WRAPIT, it knows to call
    "compute_".

    However, for some odd reason, if your Fortran subroutine has an
    underscore in the name, then g77 will append two underscores. Thus,
    "compute_one" becomes "compute_one__". The C wrapper routine is still
    trying to call "compute_one_" (just one underscore at the end), and
    thus you are getting the message about "compute_one_" being undefined.

    This is actually a bug in g77 that was reported awhile back. I can
    ask the author of WRAPIT to put a work-around in WRAPIT, but
    meanwhile, if you rename "compute_one" to a name without any
    underscores and rerun WRAPIT, it should fix your problem.

    --Mary

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Wed May 29 2002 - 20:50:49 MDT