How to use the fwrite function to get a specific time range and variable?

Henri Pinheiro henri.inpe at GMAIL.COM
Fri Apr 9 08:21:02 EDT 2010


Dear Eric,

a new file was created after I made the changes you suggested. I got no
message error.
However, to ensure that the output file is correct I used the same .ctl, but
I made some changes to the commands "dset", "tdef" and "vars" in order to
determine the correct syntax.
Then the figure plotted by grads it showed a strange zonal wind distribution
.

Does anyone have any idea what changes I should do in the file.ctl?

Thanks in advance
Henri

## original file.ctl

dset 19500117_1989.bin
title file created by grads using lats4d
undef 1e+20
options big_endian template
xdef 192 linear 0.000000 1.875000
ydef 96 levels
-88.572 -86.723
-84.862 -82.999 -81.135 -79.271 -77.406 -75.541 -73.676 -71.811 -69.946
-68.081
-66.216 -64.351 -62.486 -60.620 -58.755 -56.890 -55.025 -53.160 -51.294
-49.429
-47.564 -45.699 -43.833 -41.968 -40.103 -38.238 -36.372 -34.507 -32.642
-30.777
-28.911 -27.046 -25.181 -23.316 -21.450 -19.585 -17.720 -15.855 -13.989
-12.124
-10.259  -8.394  -6.528  -4.663  -2.798  -0.933   0.933   2.798   4.663
6.528
  8.394  10.259  12.124  13.989  15.855  17.720  19.585  21.450  23.316
25.181
 27.046  28.911  30.777  32.642  34.507  36.372  38.238  40.103  41.968
43.833
 45.699  47.564  49.429  51.294  53.160  55.025  56.890  58.755  60.620
62.486
 64.351  66.216  68.081  69.946  71.811  73.676  75.541  77.406  79.271
81.135
 82.999  84.862  86.723
88.572
zdef 1 linear 1 1
tdef 1459 linear 00Z01jan1989  6hr
vars 16
ghmt500      0  99   TIME MEAN GEOPOTENTIAL HEIGHT500hpa (M ) [] []
ghmt200      0  99   TIME MEAN GEOPOTENTIAL HEIGHT200hpa (M ) [] []
spmt         0  99   TIME MEAN SEA LEVEL PRESSURE (Mb ) []
u850         0  99   TIME MEAN ZONAL WIND (U850hpa) (M/Sec ) []
u300         0  99   TIME MEAN ZONAL WIND (U300hpa) (M/Sec ) []
u200         0  99   TIME MEAN ZONAL WIND (U200hpa) (M/Sec ) []
v850         0  99   TIME MEAN MERIDIONAL WIND (U850hpa) (M/Sec ) []
v300         0  99   TIME MEAN MERIDIONAL WIND (U300hpa) (M/Sec ) []
v200         0  99   TIME MEAN MERIDIONAL WIND (U200hpa) (M/Sec ) []
fcmt200      0  99   TIME MEAN STREAM FUNCTION (M**2/Sec ) []
pvmt200      0  99   TIME MEAN VELOCITY POTENTIAL (M**2/Sec ) []
prec         0  99   TOTAL PRECIPITATION (Kg M**-2 Day**-1) []
rhmt850      0  99   TIME MEAN RELATIVE HUMIDITY850hpa (No Dim ) []
rhmt700      0  99   TIME MEAN RELATIVE HUMIDITY700hpa (No Dim ) []
swos         0  99   SOIL WETNESS OF SURFACE (No Dim ) []
role         0  99   OUTGOING LONG WAVE AT TOP (W M**-2 ) []
endvars

## new file.ctl

dset u300_MAM1989.dat
title file created by grads using lats4d
undef 1e+20
options big_endian template
xdef 192 linear 0.000000 1.875000
ydef 96 levels
-88.572 -86.723
-84.862 -82.999 -81.135 -79.271 -77.406 -75.541 -73.676 -71.811 -69.946
-68.081
-66.216 -64.351 -62.486 -60.620 -58.755 -56.890 -55.025 -53.160 -51.294
-49.429
-47.564 -45.699 -43.833 -41.968 -40.103 -38.238 -36.372 -34.507 -32.642
-30.777
-28.911 -27.046 -25.181 -23.316 -21.450 -19.585 -17.720 -15.855 -13.989
-12.124
-10.259  -8.394  -6.528  -4.663  -2.798  -0.933   0.933   2.798   4.663
6.528
  8.394  10.259  12.124  13.989  15.855  17.720  19.585  21.450  23.316
25.181
 27.046  28.911  30.777  32.642  34.507  36.372  38.238  40.103  41.968
43.833
 45.699  47.564  49.429  51.294  53.160  55.025  56.890  58.755  60.620
62.486
 64.351  66.216  68.081  69.946  71.811  73.676  75.541  77.406  79.271
81.135
 82.999  84.862  86.723
88.572
zdef 1 linear 1 1
tdef 367 linear 00Z1mar1989  6hr
vars 1
u300         0  99   TIME MEAN ZONAL WIND (U300hpa) (M/Sec ) []
endvars





2010/4/8 Eric Altshuler <ela at cola.iges.org>

> Dear Henri,
>
> Your 'set fwrite' command is inside your while loop. So it gets executed
> every time through the loop. Move it outside the loop (just below 'set gxout
> fwrite'). This should fix your problem.
>
> 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: "Henri Pinheiro" <henri.inpe at GMAIL.COM>
> To: GRADSUSR at LIST.CINECA.IT
> Sent: Thursday, April 8, 2010 4:19:13 PM
> Subject: How to use the fwrite function to get a specific time range and
> variable?
>
> Dear grads users,
>
> I have a binary data set and would want an output from a specific time
> range and variable.
> The input has 1459 time steps and 16 variables and I used a fwrite script
> to get a smaller period.
>
> The error message was
> SET FWrite Error: fwrite file is open
> Use DISABLE FWRITE command to close file
>
> Please, does anybody have any suggestion?
> the fwrite.gs and file.ctl files are beneath
>
> Best Regards
> Henri
>
> ## fwrite.gs
>
> 'reinit'
> 'open diaro.ctl'
> 'set gxout fwrite'
> 'set y 1 96'
> 'set x 1 192'
>
> t=237
> while (t<=604)
>
> 'set t 't
>
> 'set fwrite u300_MAM1989.dat'
> 'd u300'
> t=t+1
> endwhile
>
> 'disable fwrite'
> 'set gxout shaded'
> 'set gxout contour'
>
> 'quit'
>
>
>
> ## file.ctl
>
> dset /rede/cycledi/diarioAGCM50/17/17/19500117_1989.bin
> title file created by grads using lats4d
> undef 1e+20
> options big_endian template
> xdef 192 linear 0.000000 1.875000
> ydef 96 levels
> -88.572 -86.723
> -84.862 -82.999 -81.135 -79.271 -77.406 -75.541 -73.676 -71.811 -69.946
> -68.081
> -66.216 -64.351 -62.486 -60.620 -58.755 -56.890 -55.025 -53.160 -51.294
> -49.429
> -47.564 -45.699 -43.833 -41.968 -40.103 -38.238 -36.372 -34.507 -32.642
> -30.777
> -28.911 -27.046 -25.181 -23.316 -21.450 -19.585 -17.720 -15.855 -13.989
> -12.124
> -10.259 -8.394 -6.528 -4.663 -2.798 -0.933 0.933 2.798 4.663 6.528
> 8.394 10.259 12.124 13.989 15.855 17.720 19.585 21.450 23.316 25.181
> 27.046 28.911 30.777 32.642 34.507 36.372 38.238 40.103 41.968 43.833
> 45.699 47.564 49.429 51.294 53.160 55.025 56.890 58.755 60.620 62.486
> 64.351 66.216 68.081 69.946 71.811 73.676 75.541 77.406 79.271 81.135
> 82.999 84.862 86.723 88.572
> zdef 1 linear 1 1
> tdef 1459 linear 00Z01jan1989 6hr
> vars 16
> ghmt500 0 99 TIME MEAN GEOPOTENTIAL HEIGHT500hpa (M ) [] []
> ghmt200 0 99 TIME MEAN GEOPOTENTIAL HEIGHT200hpa (M ) [] []
> spmt 0 99 TIME MEAN SEA LEVEL PRESSURE (Mb ) []
> u850 0 99 TIME MEAN ZONAL WIND (U850hpa) (M/Sec ) []
> u300 0 99 TIME MEAN ZONAL WIND (U300hpa) (M/Sec ) []
> u200 0 99 TIME MEAN ZONAL WIND (U200hpa) (M/Sec ) []
> v850 0 99 TIME MEAN MERIDIONAL WIND (U850hpa) (M/Sec ) []
> v300 0 99 TIME MEAN MERIDIONAL WIND (U300hpa) (M/Sec ) []
> v200 0 99 TIME MEAN MERIDIONAL WIND (U200hpa) (M/Sec ) []
> fcmt200 0 99 TIME MEAN STREAM FUNCTION (M**2/Sec ) []
> pvmt200 0 99 TIME MEAN VELOCITY POTENTIAL (M**2/Sec ) []
> prec 0 99 TOTAL PRECIPITATION (Kg M**-2 Day**-1) []
> rhmt850 0 99 TIME MEAN RELATIVE HUMIDITY850hpa (No Dim ) []
> rhmt700 0 99 TIME MEAN RELATIVE HUMIDITY700hpa (No Dim ) []
> swos 0 99 SOIL WETNESS OF SURFACE (No Dim ) []
> role 0 99 OUTGOING LONG WAVE AT TOP (W M**-2 ) []
> endvars
>
>
>
> --
> Henri Rossi Pinheiro
> Meteorology Master Student
> National Institute for Space Research (INPE)
> Weather Forecast and Climate Studies Center (CPTEC)
> Cachoeira Paulista, SP/Brazil, 12630-000 Tel.:+55-12-3186-8607
> e-mails: henri.pinheiro at cptec.inpe.br
> henri.inpe at gmail.com
>



-- 
Henri Rossi Pinheiro
Meteorology Master Student
National Institute for Space Research (INPE)
Weather Forecast and Climate Studies Center (CPTEC)
Cachoeira Paulista, SP/Brazil, 12630-000 Tel.:+55-12-3186-8607
e-mails: henri.pinheiro at cptec.inpe.br
              henri.inpe at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20100409/79cdcdef/attachment.html 


More information about the gradsusr mailing list