[ncl-talk] Convert Matlab code to NCL
Dennis Shea
shea at ucar.edu
Fri Oct 6 11:36:59 MDT 2017
FTR:
https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclStatements.shtml
See the 'do' section.
[snip]
The following form is also necessary* to loop backwards*. With this form,
if start is greater than end, then the identifier is decremented by the
stride value, which must always be positive. If the start is less than the
end, then the identifier is incremented by the stride value.
do *loop_identifier* = *scalar_start_expr* , *scalar_end_expr* , *
scalar_stride_expr*
* statement list *
end do
[snip]
Given my fortran background, I found this a bit unusual but 'it-is-what-it-is'
D
On Fri, Oct 6, 2017 at 11:24 AM, Dave Allured - NOAA Affiliate <
dave.allured at noaa.gov> wrote:
> Oops. Please ignore my correction. Dennis's version was correct. The
> stride parameter is different between fortran and NCL.
>
> --Dave
>
>
> On Fri, Oct 6, 2017 at 11:21 AM, Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> Correction to Dennis's line 1:
>>
>> Old: do m=4,0,1
>> New: do m=4,0,-1
>>
>> I can't confirm the rest of the code.
>>
>> --Dave
>>
>>
>> On Fri, Oct 6, 2017 at 11:08 AM, Dennis Shea <shea at ucar.edu> wrote:
>>
>>> A person sent me the following offline:
>>>
>>> do m=4,0,1
>>> R(:,:,:,m) = dim_sum_n_Wrap(Q(:,:,:,m::,m::,m::),(/3,4,5/))
>>> if m.lt.4 then
>>> R(:,:,:,m) = R(:,:,:,m) - dim_sum_n_Wrap(R(:,:,:,(m+1)::),3)
>>> end if
>>> end do
>>>
>>>
>>> On Thu, Oct 5, 2017 at 5:37 PM, <Arnold.Sullivan at csiro.au> wrote:
>>>
>>>> Dear all ncl users,
>>>>
>>>>
>>>>
>>>> Could someone help me to convert Matlab code using sum to NCL
>>>>
>>>>
>>>>
>>>> *R is [time] [lat] [lon] [m1]*
>>>>
>>>>
>>>>
>>>> *Q is [time] [lat] [lon] [m1] [m2] [m3]*
>>>>
>>>>
>>>>
>>>> *For m=5:-1:1*
>>>>
>>>> * R(:,:,:,m) = sum( sum( sum( Q(:,:,:,m:end,m:end,m:end), 4), 5),
>>>> 6);*
>>>>
>>>> * if m < 5*
>>>>
>>>> * R(:,:,:,m) = R(:,:,:,m) - sum( R(:,:,:,(m+1):end), 4);*
>>>>
>>>> *end*
>>>>
>>>> *end*
>>>>
>>>>
>>>>
>>>> Is that the same way to use dim_sum_n_Wrap ?
>>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>>
>>>>
>>>> Arnold
>>>>
>>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171006/fb008130/attachment.html>
More information about the ncl-talk
mailing list