Re: converting SYNOP meteorological code into readable observations

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 02 2011 - 09:08:51 MDT

Chris,

When writing nested do loops, it helps if you consistently indent code
inside do loop so you can more easily tell what do loop a section of
code falls in.

The probem is that "datafile" is opened after the first do loop, but
then you delete inside the second do loop. When you hit the next
iteration of the second do loop, then, "datafile" is undefined.

  I believe you simply need to move the "delete(datafile)" line to
right before the last "end do" in your script:

; delete(length)

     end do
     asciiwrite("temp" + j + ".txt",temp_long_string)
     asciiwrite("dtemp" + j + ".txt",dtemp_long_string)
     asciiwrite("pres" + j + ".txt",pres_long_string)
     asciiwrite("wdir" + j + ".txt",wdir_long_string)
     asciiwrite("wspd" + j + ".txt",temp_long_string)

     delete(temp_long_string)
     delete(dtemp_long_string)
     delete(pres_long_string)
     delete(wdir_long_string)
     delete(wspd_long_string)

    delete(datafile)

end do

On Nov 2, 2011, at 7:09 AM, Christopher Steele wrote:

> Forgot to attach the new code
>
> Chris
>
> On Wed, Nov 2, 2011 at 1:08 PM, Christopher Steele <christopher.steele@uea.ac.uk
> > wrote:
> Hi again,
>
> I'm running into further problems with this code when I try to link
> the outputs together. I keep getting the following error message but
> I'm not sure why.
>
>
> fatal:Undefined identifier: (datafile) is undefined, can't continue
> fatal:Execute: Error occurred at or near line 64 in file
> read_synop.ncl
>
> I'm not sure how "datafile" has become undefined
>
> cheers
>
> Chris
>
>
>
> On Tue, Nov 1, 2011 at 1:17 PM, Andrew Dawson <dawson@atm.ox.ac.uk>
> wrote:
> Hi Chris,
>
> When you use str_index_of_substr to set pres_test you have opt set
> to 0, which means you get an array of the indexes of all matches. If
> there is more than one match then pres_test will not be a scalar.
> This means that the following if statement is invalid because it is
> expecting a scalar. You need to refine your test for substrings I
> think, perhaps through appropriate use of the any or all functions,
> or if you are only interested in the first match then change the
> setting of opt (the last argument to str_index_substr).
>
> Anyway, hope that helps,
>
> Andrew
>
> On 1 November 2011 12:43, Christopher Steele <christopher.steele@uea.ac.uk
> > wrote:
> Hi everyone
>
> I've been attempting to write a script to sort out some
> meteorological observations from their original synop form into
> something usable in the MET tools software. Unfortunately I keep
> coming across this error message:
>
> fatal:Conditional statements (if and do while) require SCALAR
> logical values, see all and any functions
> fatal:Execute: Error occurred at or near line 122 in file
> read_synop.ncl
>
>
> SYNOP code is a bit of a mess to interpret. Attached you will find a
> sample of the code and my ncl file to decode it.
>
> Hope someone can help
>
> cheers
>
> Chris
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Dr Andrew Dawson
> Atmospheric, Oceanic & Planetary Physics
> Clarendon Laboratory
> Parks Road
> Oxford OX1 3PU, UK
> Tel: +44 (0)1865 282438
> Email: dawson@atm.ox.ac.uk
> Web Site: http://www2.physics.ox.ac.uk/contacts/people/dawson
>
>
>
> <read_synop.ncl>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 2 09:08:59 2011

This archive was generated by hypermail 2.1.8 : Fri Nov 04 2011 - 08:43:41 MDT