Re: Problems with WRAPIT

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 03 2010 - 10:47:06 MDT

NCL will always use functions located in the various binary libraries
distributed with NCL. It is always best to create a unique name.
As noted "mygamma" works because there is no existing 'mygamma' function.

===

There are a number of math functions 'under the hood' that have not
been made available as NCL functions. The 'gamma' function is
one of them.

NOTE: We will make an NCL level 'gamma' function for NCL v6.0.0.

====

I am sure people will say "Why not make all of these functions
available at the NCL level?" Nice idea!! However, to make functions
and distributions [eg, Gumbel, Weibul, etc] available at the NCL level
requires that "someone": write test code, write documentation, write
interfaces, and support the function(s). This process is time consuming.
NCL team members just do not have the time to do this.

I am sure the NCL team would welcome volunteers to do the above. :-)
====

As an example of using one of the math functions that is part of a
'under the hood' library, I am attaching a fortran driver to the SLATEC
gamma function. Note that the name is unique [ 'gammacomplete' ]
and a very basic interface to the double precision
'dgammaslatec' fortran function.

Then, a simple NCL script that invokes the shared object gamma function
is used for testing.

The shared object was created via:

   %> WRAPIT -L $NCARG_ROOT/lib -l nfpfort gamma_interface.f

Then, after doing this

    %> ncl gam.ncl

Good luck

On 08/03/2010 09:58 AM, Mary Haley wrote:
> Andrew, good suggestion on your part! There is indeed a "gamma" function
> defined internally by NCL, in the "chiin_dp.f" routine, which is used
> for the "chiinv" built-in function.
>
> You can also verify this by doing an "nm" on the libnfpfort.a library:
>
> nm $NCARG_ROOT/lib/libnfpfort.a | grep -i gamma
>
> --Mary
>
> On Aug 3, 2010, at 9:42 AM, Andrea Hahmann wrote:
>
>> Dear Andrew
>>
>> That fixed it! Thank you. Now, why did it work when I called it with a
>> Fortran main program?
>> Regards,
>>
>> Andrea
>> --

>> ------------------------------------------------------------------------
>> *From: *Andrew Dawson <andrew.dawson@uea.ac.uk
>> <x-msg://136/andrew.dawson_at_uea.ac.uk>>
>> *Date: *Tue, 03 Aug 2010 16:35:58 +0100
>> *To: *"Andrea N. Hahmann" <ahah@risoe.dtu.dk
>> <x-msg://136/ahah_at_risoe.dtu.dk>>
>> *Cc: *ncl forum <ncl-talk_at_ucar.edu <x-msg://136/ncl-talk_at_ucar.edu>>
>> *Subject: *Re: [ncl-talk] Problems with WRAPIT
>>
>> I think this will produce correct results if you change the name of
>> your function 'GAMMA' to something else, I used 'MYGAMMA' for
>> convenience. I assume this is some kind of conflict with a fortran
>> built in function gamma. Perhaps some one else can expand...
>>
>> Andrew
>>
>> On 3 August 2010 15:59, Andrea Hahmann <ahah@risoe.dtu.dk
>> <x-msg://136/ahah_at_risoe.dtu.dk>> wrote:
>>> Thanks Guangshan
>>>
>>> I was hopping somebody had had the same problem before...
>>> Attached are the gamma function and a test NCL script to call it.
>>>
>>> Andrea
>>> --
>>>
>>> *Andrea N. Hahmann
>>> *Senior Scientist
>>> Wind Energy Division
>>> Risø DTU
>>>
>>> *Technical University of Denmark
>>> *Risø National Laboratory for Sustainable Energy
>>> Frederikborgvej 399, P.O. Box 49
>>> 4000 Roskilde, Denmark
>>>
>>> Direct +45 4677 5471
>>> Mobil: +45 2133 0550
>>> ahah_at_risoe.dtu.dk <x-msg://136/ahah_at_risoe.dtu.dk>
>>> <http://ahah@risoe.dtu.dk <http://ahah@risoe.dtu.dk/>>
>>> www.risoe.dtu.dk <http://www.risoe.dtu.dk> <http://www.risoe.dtu.dk
>>> <http://www.risoe.dtu.dk/>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>> *From: *guangshan chen <gchen9@gmail.com
>>> <x-msg://136/gchen9_at_gmail.com> <http://gchen9@gmail.com
>>> <http://gchen9@gmail.com/>> >
>>> *Date: *Tue, 03 Aug 2010 09:45:09 -0500
>>> *To: *"Andrea N. Hahmann" <ahah@risoe.dtu.dk
>>> <x-msg://136/ahah_at_risoe.dtu.dk> <http://ahah@risoe.dtu.dk
>>> <http://ahah@risoe.dtu.dk/>> >
>>> *Cc: *ncl forum <ncl-talk_at_ucar.edu <x-msg://136/ncl-talk_at_ucar.edu>
>>> <http://ncl-talk@ucar.edu <http://ncl-talk@ucar.edu/>> >
>>> *Subject: *Re: [ncl-talk] Problems with WRAPIT
>>>
>>>
>>> Hi Andrea,
>>>
>>> I think it is better for you to attache your NCL script and the gamma
>>> function with the email. It is easy for others to help you.
>>>
>>> Guangshan
>>>
>>> On Aug 3, 2010, at 9:31 AM, Andrea Hahmann wrote:
>>>
>>>> Good afternoon.
>>>>
>>>> I am having some problems when running WRAPIT. I have programmed a
>>>> gamma function in Fortran and incorporated it into NCL using WRAPIT.
>>>> When I call the function using regular Fortran I get its value. When
>>>> I called within NCL I get “inf”. The Fortran code that contains the
>>>> gamma function also contains other functions that work fine in NCL.
>>>> Any ideas?
>>>>
>>>> Regards,
>>>> Andrea
>>>> --
>>>>
>>>> *Andrea N. Hahmann
>>>> *Senior Scientist
>>>> Wind Energy Division
>>>> Risø DTU
>>>>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Tue Aug 3 10:47:12 2010

This archive was generated by hypermail 2.1.8 : Tue Aug 03 2010 - 15:09:38 MDT