Re: Record Variable

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 30 2013 - 14:06:56 MDT

Hi Adriane,

You need to create y as an array prior to the do loop. Try the following:

begin

   x = (/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21/)

   y = new(5, integer) ; creates a 5 element array

   yix = 0 ; you need a separate index variable for y

   ; note that NCL indexing starts at 0 so you are skipping the first element of x in the following code

   do t=1,20,4

      y(yix) = x(t) + x(t+1) + x(t+2) + x(t+3)
  
      print(y) ; this will print all elements each time through the loop (elements not yet assigned will have the fill value)

       yix = yix + 1
   end do

   asciiwrite("teste.txt",y)

end

Hope this helps. I would suggest you have a look at the mini-language manual at http://www.ncl.ucar.edu/Document/Manuals/language_man.pdf.
 -dave

On Oct 30, 2013, at 1:45 PM, Adriane Lima Brito <meteorologia.dri@gmail.com> wrote:

>
> Hi,
>
> My name is Adriane Lima Brito and I'm starting to use the NCL, excuse my English but I am not yet familiar with the language. I'm doing a simple example to test ... I wrote a vector x and the vector sum of the values that were assigned to the variable y, the variable y is inside a loop = 1,20,4. The problem is that I can not save all values of y, I can only save the last value of y. I wonder how do to keep all the y values in a file.
>
> My script:
>
> begin
>
> x = (/0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21/)
>
> do t=1,20,4
>
> y = x(t) + x(t+1) + x(t+2) + x(t+3)
>
> print(y)
>
> asciiwrite("teste.txt",y)
>
> end do
>
> end
>
>
>
> Graciously,
>
>
> ADRIANE LIMA BRITO
>
> Bacharelada em Meteorologia
>
> Universidade do Estado do Amazonas - UEA
>
> Escola Superior de Tecnologia - EST
>
> Manaus - AM
>
> adrianelb.mtr@gmail.com
>
> CV: http://lattes.cnpq.br/8651779320884815
> *******************************************************
> _______________________________________________
> 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 Wed Oct 30 14:07:05 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 01 2013 - 08:58:14 MDT