problem plotting u,v winds from binary file

Eric Altshuler ela at COLA.IGES.ORG
Wed Mar 19 14:34:50 EDT 2008


Unfortunately, all of the suggestions given so far on how to write the file are incorrect.

The correct way to write the file is:

      WRITE (16,REC=1) ((UX(I,J),I=1,360),J=1,181)
      WRITE (16,REC=2) ((VY(I,J),I=1,360),J=1,181)

I am assuming that you mean 181 instead of 191 in your code, since your ctl file indicates the grid is 360 x 181. I am also assuming that your UX and VY arrays are dimensioned (360,181) rather than (181,360). If they are dimensioned (181,360) then the statements should be

      WRITE (16,REC=1) ((UX(I,J),J=1,360),I=1,181)
      WRITE (16,REC=2) ((VY(I,J),J=1,360),I=1,181)

in order to follow the grads convention of having longitude varying fastest, followed by latitude.

In fact, if your arrays are dimensioned (360,181), you can omit the implied DO loop and write the statements as:

      WRITE (16,REC=1) UX
      WRITE (16,REC=2) VY

Although it is possible to write the file correctly by having a separate WRITE statement for each latitude (181 records each containing 360 values) it seems clearer to me if the entire grid is written in one record containing 360x181 values. The latter would be mandatory if the file is to be written sequentially instead of direct access.

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: "Ricardo Marcelo" <ricardom at ACD.UFRJ.BR>
To: GRADSUSR at LIST.CINECA.IT
Sent: Wednesday, March 19, 2008 9:49:23 AM GMT -05:00 US/Canada Eastern
Subject: Re: problem plotting u,v winds from binary file






Use this:

INTEGER IREC




         IREC=1


         DO 110 I=1,191

             write(16,rec=IREC) (Ux(I,J),J=1,360)  ! writes the u component to file

             IREC=IREC+1


  110    CONTINUE

Â

         DO 115 I=1,191

          write(16,rec=I) (Vy(I,J),J=1,360) ! writes the v component to file.

          IREC=IREC+1


115 Â Â Â Â Â Â Â  CONTINUE

Â
since rec is a pointer to record file, when you use "I" as a pointer (rec=I) in the write, actually you rewind your file to rec=1 and start over until rec=191, overwritting the old field (U).


On Wed, Mar 19, 2008 at 10:31 AM, Brad Navarro < brad.navarro at wni.com > wrote:






Greetings,

Â

Despite my persistent efforts, I cannot seem to solve this particular problem. Perhaps someone out there will know how. I have generated a binary file with U and V wind components for only one level and timestamp, and I have provided the piece of code that writes this data to file:

Â

         DO 110 I=1,191

             write(16,rec=I) (Ux(I,J),J=1,360)  ! writes the u component to file

  110    CONTINUE

Â

         DO 115 I=1,191

          write(16,rec=I) (Vy(I,J),J=1,360) ! writes the v component to file.

115 Â Â Â Â Â Â Â  CONTINUE

Â

So, in essence, each component is written for each latitude, I, and for each longitude, J, at 1 degree intervals. So my control file then looks like this:

Â

DSETÂ  /home/bradn/WINDVERIF/TEST/windcompgridded.dat

TITLEÂ  Qscat 10m wind

UNDEFÂ  -0.9999E4

XDEF 360 LINEAR 0 1

YDEF 181 LINEAR -90 1

ZDEF 1 LEVELS 1 1

TDEF 1 LINEAR 15Z17JUN07 3hr

VARS 2

 u 0 99 u component

 v 0 99 v component

ENDVARS

Â

Â

However, when trying to plot the U component, it looks as if GrADS uses the V data in the binary file as the U data, and then gives me this error message when trying to plot the V component:

Â

Low Level I/O Error:Â  Read error on data file

  Data file name = /home/bradn/WINDVERIF/TEST/DIR/windcompgridded.dat

  Error reading 360 bytes at location 68760

Data Request Error:Â  Error for variable 'v'

  Error ocurred at column 1

DISPLAY error:Â  Invalid expression

  Expression = v

Â

Anyone have any ideas what I might be doing wrong? Any help would be much appreciated.

Â

Thanks,

Brad


--
============================================================
Ricardo Marcelo da Silva
LAMMA - Laboratório de Modelagem de Processos Marinhos e Atmosféricos
Depto de Meteorologia - Instituto de Geociências
Centro de Ciências Matemáticas e da Natureza
Universidade Federal do Rio de Janeiro
e-mail: ricardom at acd.ufrj.br
phone: 55 21 2598-9470 r 24
============================================================



More information about the gradsusr mailing list