[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 21:30:00 EDT 2010
After you create the ctl file for your new 3-D variable, put in your script the line
'open arr3.ctl'
at any point after 'disable fwrite'. (It is important to disable (close) the fwrite file before you try to read the data in it.) You can then use the variable arr3 (or whatever you decide to name it) like any other grads data variable. Of course, when you open arr3.ctl, the new variable will be in a new data file, and grads will assign it a file number according to the number of files you currently have open. If it is the second file you have opened, you can access it using 'arr3.2' in expressions (keeping in mind the current default file and dimension environment and whether it is compatible with the dimension ranges specified in arr3.ctl), or you could 'set dfile 2', modify the dimension environment if necessary, and proceed from there.
----- Original Message -----
From: "jfj" <jfj at ntnu.edu.tw>
To: "Eric Altshuler" <ela at cola.iges.org>, "GrADS Users Forum" <gradsusr at gradsusr.org>
Sent: Monday, May 17, 2010 8:52:54 PM
Subject: RE: [gradsusr] How to assign a 2-D array at many levels to a 3-D array
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