# Metview Macro

# **************************** LICENSE START ***********************************
#
# Copyright 2012 ECMWF. This software is distributed under the terms
# of the Apache License version 2.0. In applying this license, ECMWF does not
# waive the privileges and immunities granted to it by virtue of its status as
# an Intergovernmental Organization or submit itself to any jurisdiction.
#
# ***************************** LICENSE END ************************************


tuv_data = read("../TUV_Data")
data = tuv_data[1]  # look only at the first field

lats = latitudes(data)
print(lats)

lons = longitudes(data)
print(lons)

vals = values(data)
print(vals)

# print one element
i = 100
print('i=', i, ', lat=', lats[i], ', lon=', lons[i], ', val=', vals[i])

# write the whole lot out to a file
fh = file(getenv('SCRATCH') & '/field_points.txt')
for i = 1 to count(vals) do
    write(fh, 'index=', i, ', lat=', lats[i], ', lon=', lons[i], ', val=', vals[i], newline)
end for
fh = 0 # close the file handle