For my postgraduate dissertation, I needed to process large amounts of meteorological data quickly, and since the university has a Unix system with FORTRAN, I decided to write a program in FORTRAN to do it.
In my program, I have 108 text files with my data in. A typical line from one of these files is:
1997 12 31 23:59, 9820, DCNN, 24, 1, NCM, 1585, 1011, 0, , , , , 0, 0, 0, 0, , , 1, 0, 0, 0, 1, 1, 1, 1, ,
My read command is this:
read(1,*,err=888)iyear,imon,iday,time,id...
& recst,sund,conc,lsnow,snowd,fsnow,snowda...
The variables I'm interested in are the ones with 'snow' in their names, as these correspond to the different snow measurements, as my data is from the MIDAS Land Surface stations observation (UK) data set. The variables after are not needed, so are not included in the read command.
My program checks the 'fsnow' (fresh snow) variable amount and if it is greater than or equal to 1 for that (weather) station on that day, it labels it as a 'day of snow'.
The program works fine for all years up to 1997, in that it only defines a day as a snow day if that 'column' contains a value. But in years 1997 onwards, if it reads a blank, it occasionally decides that the blank is actually a number. I've checked the original data and where my program has read values such as 1,2,4 and 7, there are blanks.
First of all, if anyone out there knows why it's deciding to read numbers from nowhere, then it would be useful to know.
Secondly I've read about read statements with formats. Previously I have used format statements for write commands but was unaware that they might be used for read commands. I have heard mention of 'BZ', which will apparently read blanks as zeros.
Sorry for the long description, I've tried to keep it as simple as possible. Thanks.
Tags: