Re: help: when wrapit comes across allocatable array

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Sep 29 2011 - 21:44:19 MDT

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 Thu Sep 29 21:44:24 2011

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