Re: help: when wrapit comes across allocatable array

From: Sha Feng <sfeng_at_nyahnyahspammersnyahnyah>
Date: Fri Sep 30 2011 - 12:15:10 MDT

Hi Dennis,

After revision that just declare the argument being passed to from ncl, files can be successfully linked. However, there are still errors as follows when I run ncl script

======================
$ ncl test.ncl
.....
warning:An error occurred loading the external file ./tropo.so, file not loaded
dlopen(./tropo.so, 2): Symbol not found: _tropo_
  Referenced from: .../tropo.so
  Expected in: flat namespace
 in .../tropo.so
warning:error at line 12 in file test.ncl

fatal:syntax error: line 33 in file test.ncl before or near :
            TROPO:
-----------------^

fatal:error in statement
fatal:Syntax Error in block, block not executed
fatal:error at line 40 in file test.ncl

arctic:code shafeng$ nm tropo.so
0000000000000ec0 s stub helpers
0000000000000598 T _Init
                 U _NclGetArgValue
                 U _NclRegisterProc
                 U _NewArgs
                 U _NhlPError
                 U _SetArgTemplate
0000000000000000 t __mh_bundle_header
                 U _tropo_
00000000000007e4 T _tropo_W
                 U dyld_stub_binder
=====================

Thanks,
Sha

On Sep 29, 2011, at 11:44 PM, Dennis Shea wrote:

> Just the arguments being pased to/from ncl
>
> On 9/29/11 8:49 PM, sfeng@marine.usf.edu wrote:
>> Dennis,
>>
>> So, as far as I know, the stub file just need to declare the parameters as
>> arguments of subroutine, and it doesn't have to declare all of the
>> variables in the subroutine. Right?
>>
>> Regards,
>> Sha
>>
>>> See: http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml
>>>
>>> You would just need one f77 style stub file [ mystub.f].
>>> Stub files should be created only for subroutines
>>> invoked from within NCL explicitly.
>>>
>>> C NCLFORTSTART
>>> subroutine cstub(nlev,temp,pres,alt,pliml, plimu,plimlex,mis
>>> + ,numtp,tp,tt,ta)
>>> implicit none
>>> integer nlev
>>> real temp(nlev), pres(nlev), alt(nlev), pliml, plimu,plimlex,mis
>>> integer numtp
>>> real tp(nlev), tt(nlev), ta(nlev)
>>> C NCLEND
>>>
>>> %> WRAPIT mystub.f ShaFeng.f90
>>>
>>> external CSTUB "./mystub.so"
>>>
>>> CSTUB::cstub(...)
>>>
>>> On 9/29/11 3:32 PM, Sha Feng wrote:
>>>> Dennis,
>>>>
>>>> My code is .f90. So I don't have to use the same declaration with the
>>>> .f90 files in the .stub, do I?
>>>>
>>>> A snippet of my code is also follows.
>>>> !==================================
>>>> subroutine C(...)
>>>> implicit none
>>>> integer,intent(in) :: nlev
>>>> real,intent(in),dimension(nlev) :: temp
>>>> real,intent(in),dimension(nlev) :: pres
>>>> real,intent(in),dimension(nlev) :: alt
>>>> real, intent(in) :: pliml, plimu,plimlex
>>>> integer,intent(out) :: numtp
>>>> real,intent(in) ::mis
>>>> real,intent(out),dimension(nlev) :: tp,tt,ta
>>>>
>>>> integer :: i, j, validrow
>>>> real,dimension(nlev) :: t,p,a
>>>> real, dimension(:), allocatable :: t1,p1,a1
>>>> real :: trp
>>>> ....
>>>> call A(...)
>>>> ...
>>>> call B(...)
>>>> ...
>>>> end subroutine C
>>>>
>>>> subroutine A(...)
>>>> ...
>>>> end subroutine A
>>>>
>>>> subroutine B(....)
>>>> ...
>>>> end subroutine B
>>>> !==================================
>>>>
>>>>
>>>> BTW, this subroutine includes three subroutines (three subroutine in one
>>>> .f90 file). Should I make declaration for all of them in the .stub file.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Sep 29, 2011, at 5:10 PM, Dennis Shea wrote:
>>>>
>>>>> It would be good to see a snippet of your f90 code.
>>>>>
>>>>> As along as the 'allocateable' is not between the
>>>>> C NCLFORTSTART
>>>>> C NCLEND
>>>>>
>>>>> Also, is the f90 code .f or .f90?
>>>>>
>>>>> C ----------Sample for .f file -----------------------------------
>>>>> C NCLFORTSTART
>>>>> subroutine wgt_runave (x,npts,wgt,nwgt,kopt,xmsg,ier)
>>>>> integer npts, nwgt,kopt,ier
>>>>> real x(npts), wgt(nwgt), xmsg
>>>>> C NCLEND
>>>>> integer lwork
>>>>> real, allocatable, dimension(:) :: work
>>>>>
>>>>> nhalf = nwgt/2
>>>>> lwork = npts+2*nhalf
>>>>> allocate (work(lwork), stat=ier)
>>>>>
>>>>> call wrunavx77 (x,npts,wgt,nwgt,kopt,xmsg,work,lwork,ier)
>>>>>
>>>>> deallocate (work)
>>>>>
>>>>> return ! NCL return (wrunwgt[x])
>>>>> end
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 9/29/11 12:19 PM, Sha Feng wrote:
>>>>>> Hi ncl-talker,
>>>>>>
>>>>>> How can I deal with the codes which are related with allocatable
>>>>>> arrays when I use WRAPIT to combine Fortran 90 subroutines with NCL
>>>>>> scripts?
>>>>>>
>>>>>> Any suggestion is very much appreciated.
>>>>>>
>>>>>> Sha
>>>>>> _______________________________________________
>>>>>> ncl-talk mailing list
>>>>>> List instructions, subscriber options, unsubscribe:
>>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Sep 30 12:16:13 2011

This archive was generated by hypermail 2.1.8 : Sun Oct 09 2011 - 13:05:26 MDT