[gradsusr] How to assign a 2-D array at many levels to a 3-D array

jfj jfj at ntnu.edu.tw
Mon May 17 20:52:54 EDT 2010


Thank you, Erik. 
Sorry that I did not say it clearly. The 2-D arrays are at 10 different levels with different values. But, it is very easy to fix according to the idea you provided. However, I actually need to use the 3-D array for calculation right away in the same script. Do you know how to read it in right after I fwrite it out? Thank you again.


-----Original Message-----
From: Eric Altshuler [mailto:ela at cola.iges.org] 
Sent: Tuesday, May 18, 2010 2:32 AM
To: jfj at ntnu.edu.tw; GrADS Users Forum
Subject: Re: [gradsusr] How to assign a 2-D array at many levels to a 3-D array

Hello jfj,

You could do this using the fwrite capability in grads:

'set gxout fwrite'
'set fwrite arr3.dat'
k=1
while (k<=10)
'd arr2'
k=k+1
endwhile
'disable fwrite'

After doing this, you'll have a binary file 'arr3.dat'. Make a ctl file 'arr3.ctl' for this data file similar to the one below (make the appropriate changes for your data):

dset arr3.dat
title arr3
undef -9.99e8
xdef 100 linear 0 0.25
ydef 100 linear 0 0.25
zdef 10 levels 1000 925 850 700 600 500 400 300 200 100
tdef 1 linear 00z01jan2010 6hr
vars 1
arr3 10 99 arr3
endvars

When you open arr3.ctl, the variable 'arr3' will be a 3-D variable with the values of arr2 copied to all 10 vertical levels.

Best regards,

Eric L. Altshuler
Assistant Research Scientist
Center for Ocean-Land-Atmosphere Studies
4041 Powder Mill Road, Suite 302
Calverton, MD 20705-3106
USA

E-mail: ela at cola.iges.org
Phone: (301) 902-1257
Fax: (301) 595-9793

----- Original Message -----
From: "jfj" <jfj at ntnu.edu.tw>
To: gradsusr at gradsusr.org
Sent: Friday, May 14, 2010 10:56:53 PM
Subject: [gradsusr] How to assign a 2-D array at many levels to a 3-D array

I am more familiar with fortran program than grads script. In Fortran,
it is
very easy to assign a 2-D array at many levels to a 3-D array. For
example, Do k=1,10
Do i=....
Do j=....
Arr3(i,j,k)=arr2(i,j) Enddo
Enddo Enddo

However, in Grads, I don't know if there is a similar way to do so.
"Define" seems not work in this situation. Could anybody help me out on
this issue?
Thank you very much.

jfj at ntnu.edu.tw



_______________________________________________ gradsusr mailing list
gradsusr at gradsusr.org
http://gradsusr.org/mailman/listinfo/gradsusr





More information about the gradsusr mailing list