JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2001

COMP-FORTRAN-90 2001

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: your mail

From:

Bob Cohen <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Tue, 10 Jul 2001 17:53:54 -0400

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (128 lines)

It's always nice to see a practical programmer.   In fact, I use this
method to read a large survey file with multiple record types.  There's
Household, family level and person level data.   I have a program that
reads the raw data which has one record per person that is fixed in size
and which repeats the relevant household and family data on each person
record.  The file also contains longitudinal data up to 48 months.   The
file size is over 1 GB.  The programs that use this data is a micro
simulation model which can create new variables on the file.  I keep track
of the variables on the files by creating an ASCII text file with variable
names and sizes on the file.

I wanted to create read statements that would read this data quickly.   So
I ended up breaking the data into three different arrays, one each for
Household data which occurs 1 time, family records which can occur multiple
times for each household and person records which can occur multiple times
per household.

In the end, I wrote my program so that the file was written out as a binary
file, with a few variables at the beginning which defined the dimensions
for each of my 3 arrays.  The household array is one dimension, the family
and person arrays are 3 dimensional with the number of families, by the
number of month and finally by the number of variables in the family array.
The person array is the same but dimensioned by persons instead of families.

So before I read the arrays, I have enough information to allocate arrays
of exactly the size I need.   So all I need to do is read the allocated arrays
in a read statement that looks like: READ(8,END=NNNN) HHLD, FAMILY,
PERSON.  It's an extremely fast read.

Of course I use equivalences so I don't need to create 6 arrays.   Now the
powers that be don't seem to like equivalences, but it's not hard to keep
track of the few real variables.

I read the ASCII data dictionary in once at the beginning, this file tells
me the location in the variable dimension.   This way I don't need to have
the input variables in a fixed location since I can lookup the location in
my data dictionary once.

I hope this gives you some idea of the flexibility of writing out entire
arrays and associating a data dictionary with the data.



From: Jing Guo <[log in to unmask]>


At 05:00 PM 7/10/01 -0400, you wrote:
> >
> > It's maybe a simple question.
>
>It may be a simple question, but there is no simple answer.
>
>If I were your programmer given this assignment, I would first ask you
>for the specifications of the file format and the data to be extracted
>from the file.  I would say that the size of the file is not the same
>thing as the size of the data.  There may be and may be not a simple
>relationship between them.
>
>Assume the data in the file were written out as a flat data stream.  In
>this case, one may be able to link the file size to the data size in a
>simple expression.  Even so, one won't be able to tell if the data is a
>simple 1-d array for a row or a column vector or a 2-d array for a
>matrix.  All that information, if not specified in the file, would have
>to be specified somewhere else (Even the software engineers of MATLAB
>would have to either store dimensional information in a data file or ask
>users to specify them).
>
>Now it may be geting more controvertial.
>
>For your specific problem, I would first suggest a long term solution,
>by redefine your output file format, such that all dimensional
>information are the _first_ piece of data one can get from a file (why
>does anyone want to read a file twice?).  It is simply because losing
>information is not a reversiable adiabatic process.  It is not always
>possible to reverse engineering data dimensional information from file
>sizes.
>
>If you have no control over the output data format, and the file size
>data can be easily mapped to data dimensional information, why don't you
>collect the file size data _before_ you use them?  For instance, one can
>create a list of files with their sizes listed next to their names, such
>as:
>
>13579 "file1.dat"
>2468  "file2.dat"
>999   "file3.dat"
>
>I won't suggest some "smart" solutions in Fortran.  In my programming
>life, I tried to program some "smart" solutions myself.  I now believe
>all those solutions were wrong.  If the data integraty is broken, the
>best solution should be to patch the data, not to create some generic
>solutions that in the best require some very case-specific information
>to work.
>
>
> > Suppose you have several data files, each
>
> > of them have different length and will be read in by your program. Usually
> > you have to specify the corresponding array length in your program
> > otherwise you would run in trouble in read. I want to know if there is a
> > mean in Fortran to read data file without specify the size, something like
> > that in MATLAB:
> >
> >   r1=myfile(:,1)
> >
> > or
> >
> >    fscanf(fid,'%g %g',[2 inf]);
> >
> > Thus, all the data will be read in and we can get the size of array by
> > simple command size(...).
> >
> > Many thanks.
> >
> > Yongcheng
> >
>
>
>--
>________________________________ _-__-_-_ _-___---
>Jing Guo, [log in to unmask], (301)614-6172(o), (301)614-6297(fx)
>Data Assimilation Office, Code 910.3, NASA/GSFC, Greenbelt, MD 20771


Bob Cohen
(703) 534-7618
[log in to unmask]

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager