# [ncl-talk] formatted print, select subscription

Fri Dec 20 04:19:45 MST 2019

```Hi,
I hope you're doing great.I have some difficulties and I'll be thankful if I could have your help.
1- Why -0.5 is written 0 (not -1) while -1.5 is written -2, with "%4.0f" in the following lines? It seems reals round to even numbers.
a := (/-0.5D0, 0.5D0, -1.5D0, 1.5D0, -2.5D0, 2.5D0, -3.5D0, 3.5D0/) print(sprintf("%4.0f", a))

output:(0)       -0(1)        0(2)       -2(3)        2(4)       -2(5)        2(6)       -4(7)        4However, this is same for gfortran.fortran code:
implicit nonereal*8 :: a(8)a = (/-0.5D0, 0.5D0, -1.5D0, 1.5D0, -2.5D0, 2.5D0, -3.5D0, 3.5D0/)print"(f4.0)", aend
output: -0.  0. -2.  2. -2.  2. -4.  4.
But for PGI compiler I see the other (expected) result:output: -1.  1. -2.  2. -3.  3. -4.  4.
I confused what happened? Back to NCL, should I use round function, as below, to write output, always?

b = round(a,0)
print(sprintf("%4.0f", b))

output:(0)       -1(1)        1(2)       -2(3)        2(4)       -3(5)        3(6)       -4(7)        4
2- How could I select (or delete) unordered subscription from a multidimensional array? For example, if there is an array (a) with following dimensions:
[lev | 34] x [lat | 361] x [lon | 720]

and I want to make other array like a, exclude a(0,:,:), a(7,:,:) and a(10,:,:), what way is better than the following line? b := a((/1,2,3,4,5,6,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33/),:,:)
3- How could I compute difference between two successive levels, instead of using following loop:FL = u at lev
ws(0,:,:) = 0.0
do i = 1, dimsizes(FL)-1
ws(i,:,:) = sqrt((u(i,:,:)-u(i-1,:,:))^2+(v(i,:,:)-v(i-1,:,:))^2)end doAs you know above lines compute wind shear.
Pardon me to ask different questions in one email.I'll be thankful for any help.
SincerelyEhsanPhD student of Meteorology,Institute of Geophysics, University of Tehran, Tehran, Iran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191220/33e01569/attachment.html>
```