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

Eric Altshuler ela at cola.iges.org
Mon May 17 14:32:29 EDT 2010


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