Re: help: WRAPIT

From: Sha Feng <sfeng_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 18 2011 - 09:29:07 MDT

Dennis and Mary,

All issues are fixed. Very appreciated your help and thank you both.

Regards,

Sha

On Jul 18, 2011, at 11:07 AM, Dennis Shea wrote:

> In your f90 code you use 'implicit none' and you explicitly specify
> the type:
>
> > implicit none
> > integer, intent(in) :: dim1, dim2
> > real, intent(in) :: cptz1(dim1), lrtz1(dim1), cptz2(dim2), lrtz2(dim2)
> > integer :: i, dim
>
> However in your stub file, you do not do this
>
> % [389] cat writeNCLascii.stub
> > C NCLFORTSTART
> > subroutine writeNCLascii(cptz1, lrtz1, cptz2, lrtz2, dim1, dim2)
> > integer dim1, dim2
> > dimension cptz1(dim1), lrtz1(dim1), cptz2(dim2), lrtz2(dim2)
> > C NCLEND
>
> As noted in the documentation, NCL's f77 parser understands fortran
> default typing. Hence, variables starting with i,j,k,l,m,n are type
> integer by default. When you pass a type float to a type integer,
> NCL explicitly acknowledges that it will not coerce a flot to an integer.
>
> Change your stub to
>
> C NCLFORTSTART
> subroutine writeNCLascii(cptz1, lrtz1, cptz2, lrtz2, dim1, dim2)
> implicit none
> integer dim1, dim2
> real cptz1(dim1), lrtz1(dim1), cptz2(dim2), lrtz2(dim2)
> C NCLEND
>
>
>
>
> On 7/18/11 8:56 AM, Sha Feng wrote:
>> Mary,
>>
>> Syntax error is fixed, but new issue has been exposed.
>>
>> fatal:Argument type mismatch on argument (1) of (writenclascii) can not coerce
>> fatal:Execute: Error occurred at or near line 145 in file test.ncl
>>
>> I checked the arguments, both are floats in the fortran subroutine and the ncl script. Details are shown below.
>>
>> NCL:
>>
>> writeNCLascii::writenclascii(CPTh_mon_ts(0,:), LRTh_mon_ts(0,:), CPTh_mon_ts(1,:), LRTh_mon_ts(1,:), dims, dims)
>>
>> Variable: dims
>> Type: integer
>> Total Size: 4 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [1]
>>
>> Variable: CPTh_mon_ts (subsection)
>> Type: float
>> Total Size: 180 bytes
>> 45 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [45]
>> Coordinates:
>> Number Of Attributes: 2
>> _FillValue : -999
>> runave_op_ncl : runave_n: nave=3
>>
>>
>> Variable: LRTh_mon_ts (subsection)
>> Type: float
>> Total Size: 180 bytes
>> 45 values
>> Number of Dimensions: 1
>> Dimensions and sizes: [45]
>> Coordinates:
>> Number Of Attributes: 2
>> _FillValue : -999
>> runave_op_ncl : runave_n: nave=3
>> ----------------------
>>
>> writeNCLascii.f90:
>>
>> subroutine writeNCLascii(cptz1, lrtz1, cptz2, lrtz2, dim1, dim2)
>> implicit none
>> integer, intent(in) :: dim1, dim2
>> real, intent(in) :: cptz1(dim1), lrtz1(dim1), cptz2(dim2), lrtz2(dim2)
>> integer :: i, dim
>>
>>
>> Sha
>>
>>
>>
>> On Jul 18, 2011, at 10:38 AM, Mary Haley wrote:
>>
>>> Sha,
>>>
>>> The error:
>>>
>>> fatal:syntax error: procedure writeNCLascii is not defined in package writeNCLascii
>>>
>>> is indicating that it can't find "writeNCLascii" in your compiled file.
>>>
>>> When I do an "nm" on the *.so file:
>>>
>>> nm writeNCLascii.so
>>>
>>> I see this:
>>>
>>> 0000000000000000 T _writenclascii_
>>>
>>> Note that the "ncl" is lower case. This lead me to believe this was a case-insensitivity issue.
>>>
>>> So, instead of this:
>>>
>>> writeNCLascii::writeNCLascii(CPTh_mon_ts(0,:),LRTh_mon_ts(0,:), CPTh_mon_ts(\
>>>
>>> Try:
>>>
>>> writeNCLascii::writenclascii(CPTh_mon_ts(0,:),LRTh_mon_ts(0,:), CPTh_mon_ts(\
>>>
>>>
>>> --Mary
>>>
>>> On Jul 15, 2011, at 2:03 PM, Sha Feng wrote:
>>>
>>>> Mary,
>>>>
>>>> This column problem had been fixed before I asked you about the syntax error. I also can created the wrapper without any problem. Now, the problem is in the NCL script, I think. So I attached the ncl script here, could you help me to fix it please?
>>>>
>>>> $ ncl test.ncl
>>>>
>>>> Copyright (C) 1995-2010 - All Rights Reserved
>>>> University Corporation for Atmospheric Research
>>>> NCAR Command Language Version 5.2.1
>>>> The use of this software is governed by a License Agreement.
>>>> See http://www.ncl.ucar.edu/ for more details.
>>>> fatal:syntax error: procedure writeNCLascii is not defined in package writeNCLascii
>>>>
>>>> fatal:error at line 145 in file test.ncl
>>>>
>>>> fatal:Syntax Error in block, block not executed
>>>> fatal:error at line 186 in file test.ncl
>>>> -----------------
>>>>
>>>> The code is a sort of long. Sorry for troubling you so much and Very appreciated your help,
>>>>
>>>> Sha
>>>>
>>>>
>>>>
>>>> <test.ncl>
>>>>
>>>>
>>>> On Jul 15, 2011, at 3:50 PM, Mary Haley wrote:
>>>>
>>>>> Sha,
>>>>>
>>>>> As Dennis mentioned before, you need to make sure that in your *stub file, the "subroutine", "integer", "dimension" lines all start in the 7th column. In the file you listed below, the lines all start in the 6th column.
>>>>>
>>>>> Once I made this fix, I was able to create the wrapper with no problem:
>>>>>
>>>>> % [389] cat writeNCLascii.stub
>>>>> C NCLFORTSTART
>>>>> subroutine writeNCLascii(cptz1, lrtz1, cptz2, lrtz2, dim1, dim2)
>>>>> integer dim1, dim2
>>>>> dimension cptz1(dim1), lrtz1(dim1), cptz2(dim2), lrtz2(dim2)
>>>>> C NCLEND
>>>>>
>>>>> % [390] WRAPIT -m64 writeNCLascii.stub writeNCLascii.f90
>>>>>
>>>>> WRAPIT Version: 110125
>>>>> COMPILING writeNCLascii.f90
>>>>> LINKING
>>>>> END WRAPIT
>>>>>
>>>>> % [391] ncl
>>>>> Copyright (C) 1995-2011 - All Rights Reserved
>>>>> University Corporation for Atmospheric Research
>>>>> NCAR Command Language Version 6.1.0-15Jul2011_0149
>>>>> The use of this software is governed by a License Agreement.
>>>>> See http://www.ncl.ucar.edu/ for more details.
>>>>> ncl 0> external writeNCLascii "./writeNCLascii.so"
>>>>> ncl 1>
>>>>>
>>>>> --Mary
>>>>>
>>>>>
>>>>> On Jul 15, 2011, at 1:23 PM, Sha Feng wrote:
>>>>>
>>>>>> Mary,
>>>>>>
>>>>>> There are just several lines in my stub file
>>>>>>
>>>>>> C NCLFORTSTART
>>>>>> subroutine writeNCLascii(cptz1, lrtz1, cptz2, lrtz2, dim1, dim2)
>>>>>> integer dim1, dim2
>>>>>> dimension cptz1(dim1), lrtz1(dim1), cptz2(dim2), lrtz2(dim2)
>>>>>> C NCLEND
>>>>>>
>>>>>> and I copied the word "writeNCLascii". It still did not work.
>>>>>>
>>>>>> Sha
>>>>>>
>>>>>> On Jul 15, 2011, at 3:17 PM, Mary Haley wrote:
>>>>>>
>>>>>>> Sha,
>>>>>>>
>>>>>>> Double-check your *.stub file to make sure you have "writeNCLascii" spelled correctly.
>>>>>>>
>>>>>>> It looks okay in the *.f90 file, but the stub file needs to have it spelled the exact same way.
>>>>>>>
>>>>>>> --Mary
>>>>>>>
>>>>>>> On Jul 15, 2011, at 12:21 PM, Sha Feng wrote:
>>>>>>>
>>>>>>>>
>>>>>>>> Hi all,
>>>>>>>>
>>>>>>>> I tried to call a Fortran subroutine from NCL using WRAPIT. The pre-files are created:
>>>>>>>>
>>>>>>>> writeNCLascii.stub
>>>>>>>> writeNCLascii.so
>>>>>>>> writeNCLascii.f90
>>>>>>>>
>>>>>>>> $ ncl test.ncl
>>>>>>>>
>>>>>>>> fatal:syntax error: procedure writeNCLascii is not defined in package writeNCLascii
>>>>>>>>
>>>>>>>> fatal:error at line 145 in file test.ncl
>>>>>>>>
>>>>>>>> fatal:Syntax Error in block, block not executed
>>>>>>>> fatal:error at line 186 in file test.ncl
>>>>>>>>
>>>>>>>> ----------
>>>>>>>> In test.ncl script, I added external writeNCLascii "./writeNCLascii.so" before "begin".
>>>>>>>>
>>>>>>>> line 145: writeNCLascii::writeNCLascii(CPTh_mon_ts(0,:),LRTh_mon_ts(0,:), CPTh_mon_ts(1,:), LRTh_mon_ts(1,:), 45, 45)
>>>>>>>> line 186: end
>>>>>>>> --------------
>>>>>>>>
>>>>>>>> Attached please find the fortran 90 subroutine.
>>>>>>>>
>>>>>>>> Any help is appreciated,
>>>>>>>>
>>>>>>>> Sha
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> <writeNCLascii.f90>_______________________________________________
>>>>>>>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 18 09:30:09 2011

This archive was generated by hypermail 2.1.8 : Mon Jul 18 2011 - 15:57:57 MDT