text data file record length has limit ??? 
Author Message
 text data file record length has limit ???

HI, all:
  I have a f90 program which need to read 'A LOT OF' data items
on one single line in a data file created by another software
called 'ArcView' as comma delimited text file, I wrote a little
perl script to s/,/ /g so that it could be read by read(unit,*),
but no matter what i do, it just can't read it right (ios /=0)
I even disect the read into small piece using part of the original
text file as input file, and they are OK, just when i put them all
on a line it wouldn't read. (OK, I want it to be like this)
SO, i wonder is there a limit as how character on one line of a
text data file ??? ( I 've rechecked the data types, no problem)

Any suggestions would be greatly appreciated !

The read part of the prog is as this:

 i=1
 DO
  READ (UNIT=11,FMT=*, IOSTAT=read_ios) paddock, scenario, gtarget(i),&
    sla(i), extcoef(i), ltcoef(i), lpeff(i), lslpr0(i), lslpr1(i),    &
    msgr20(i), rconst20(i), sencer20(i), pshoot(i), lfratio(i),       &
    yrsim, monbeg, datbeg, monend, datend, erain, rootdpth(i),        &
    dbug, fix, area(i), tmpsgr, tmprcnt, tmpsen, tming, tmaxg, toptg, &
    tminr, tmaxr, toptr, tmins, tmaxs, topts, gama, ctok, alcrop(i),  &
    alsoil(i), pcarbon, kdet, kvltlzn, kresr, knomr, kntfctn, totdays,&
    bulkden1(i), prtlden1(i), avlblws1(i), ws151(i), bulkden2(i),     &
    prtlden2(i), avlblws2(i), ws152(i), ws1(i), ws2(i), stgdw(i),     &
    strdw(i), n1t1(i), n1t2(i), naf(i), res(i), nres(i), cres(i),     &
    omr(i), nofert(i), (whenfert(i,k),k=1,nofert(i)),                 &
    (amountn1(i,k), k=1,nofert(i)), (amountn2(i,k),k=1,nofert(i)),    &
    (amountn3(i,k), k=1,nofert(i)), slope, intrct, herd(i), ipc,      &
    fleaf, fstem, ratecons, checkern, checkerw, lcoef, optmsn

  IF (read_ios /= 0) THEN
    PRINT *,"READ RECORD ERROR :"," read_ios= ",read_ios
    i = i-1
    BACKSPACE 11
   READ (UNIT=11,FMT=*, IOSTAT=read_ios) paddock, scenario, gtarget(i),  &
       sla(i), extcoef(i), ltcoef(i), lpeff(i), lslpr0(i), lslpr1(i),    &
       msgr20(i), rconst20(i), sencer20(i), pshoot(i), lfratio(i),       &
       yrsim, monbeg, datbeg, monend, datend, erain, rootdpth(i),        &
       dbug, fix, area(i), tmpsgr, tmprcnt, tmpsen, tming, tmaxg, toptg, &
       tminr, tmaxr, toptr, tmins, tmaxs, topts, gama, ctok, alcrop(i),  &
       alsoil(i), pcarbon, kdet, kvltlzn, kresr, knomr, kntfctn, totdays,&
       bulkden1(i), prtlden1(i), avlblws1(i), ws151(i), bulkden2(i),     &
       prtlden2(i), avlblws2(i), ws152(i), ws1(i), ws2(i), stgdw(i),     &
       strdw(i), n1t1(i), n1t2(i), naf(i), res(i), nres(i), cres(i),     &
       omr(i), nofert(i), (whenfert(i,k),k=1,nofert(i)),         &
       (amountn1(i,k), k=1,nofert(i)), (amountn2(i,k),k=1,nofert(i)),    &
       (amountn3(i,k), k=1,nofert(i)), slope, intrct, herd(i), ipc,      &
       fleaf, fstem, ratecons, checkern, checkerw, lcoef, optmsn
       PRINT *,"read_ios = ",read_ios
       PRINT *,"paddock= ",paddock," i= ",i," nofert(",i,")= ",nofert(i)
         EXIT
       END IF

      i = i + 1
 END DO

      write (88,*) 'leaving readata'

and one line of input text data file is as this: (well, it is
a continuous line in my vi editor, you get the idea)

1 0 1 40.000 0.500 0.120 0.0000000120 0.0000050000 0.0000005000 0.400
0.100 0.00
40 0.900 0.500 1993 4 7 10 30 1 1000.000 1 0 1000.000 0 0 0 0.000 40.000
20.000
0.000 40.000 20.000 0.000 40.000 20.000 0.680 273.150 0.230 0.200 0.400
0.000270
00 0.00270000 0.03000000 0.00007200 33.60000000 208 1.320 2.650 0.620
0.240 1.46
0 2.650 0.640 0.250 80.000 180.000 0.00800000 0.00800000 8.500 14.000
23.000 714
.000 42.000 672.000 50820.000 5 98 125 138 232 264 28.410 28.410 28.410
28.410 2
8.410 28.410 28.410 28.410 28.410 28.410 0.000 0.000 0.000 0.000 0.000
1.100 -58
.000 2 15.000 0.200 0.500 2.000 0 0 1.300 4.100

--------------------------------------------------------------------------
Tong Zhai                .  .  o  o  O  O         "Go not where the road
ABE Purdue Univ.         ,________,  ____   O      may lead, go instead
West Lafayette, IN       | PURDUE |  |[]|_,_Y      where there is no
47907                    |________|__|__|_|_|}     road and leave a trail"
1-765-494-1186            oo----oo    OO--oo\\                 -anonymous



Wed, 18 Jun 1902 08:00:00 GMT  
 text data file record length has limit ???
Tong,

you can read ArcView database files directly (i.e. without converting them
to comma delimited ascii files) using f90SQL, our database connectivity
library for fortran. We did some testing on this recently, and it worked
fine using the dBase IV ODBC drivers. There is a free version of f90SQL that
can be downloaded from our web site.

Marco A. Garcia
Canaima Software
3981 Utah St.
San Diego, CA 92104
U.S.A.

http://www.canaimasoft.com
Developers of f90SQL and f90ADO,
the Complete Database Connectivity Solution for Fortran

Quote:

>HI, all:
>  I have a f90 program which need to read 'A LOT OF' data items
>on one single line in a data file created by another software
>called 'ArcView' as comma delimited text file, I wrote a little
>perl script to s/,/ /g so that it could be read by read(unit,*),
>but no matter what i do, it just can't read it right (ios /=0)
>I even disect the read into small piece using part of the original
>text file as input file, and they are OK, just when i put them all
>on a line it wouldn't read. (OK, I want it to be like this)
>SO, i wonder is there a limit as how character on one line of a
>text data file ??? ( I 've rechecked the data types, no problem)

>Any suggestions would be greatly appreciated !

>The read part of the prog is as this:

> i=1
> DO
>  READ (UNIT=11,FMT=*, IOSTAT=read_ios) paddock, scenario, gtarget(i),&
>    sla(i), extcoef(i), ltcoef(i), lpeff(i), lslpr0(i), lslpr1(i),    &
>    msgr20(i), rconst20(i), sencer20(i), pshoot(i), lfratio(i),       &
>    yrsim, monbeg, datbeg, monend, datend, erain, rootdpth(i),        &
>    dbug, fix, area(i), tmpsgr, tmprcnt, tmpsen, tming, tmaxg, toptg, &
>    tminr, tmaxr, toptr, tmins, tmaxs, topts, gama, ctok, alcrop(i),  &
>    alsoil(i), pcarbon, kdet, kvltlzn, kresr, knomr, kntfctn, totdays,&
>    bulkden1(i), prtlden1(i), avlblws1(i), ws151(i), bulkden2(i),     &
>    prtlden2(i), avlblws2(i), ws152(i), ws1(i), ws2(i), stgdw(i),     &
>    strdw(i), n1t1(i), n1t2(i), naf(i), res(i), nres(i), cres(i),     &
>    omr(i), nofert(i), (whenfert(i,k),k=1,nofert(i)),                 &
>    (amountn1(i,k), k=1,nofert(i)), (amountn2(i,k),k=1,nofert(i)),    &
>    (amountn3(i,k), k=1,nofert(i)), slope, intrct, herd(i), ipc,      &
>    fleaf, fstem, ratecons, checkern, checkerw, lcoef, optmsn

>  IF (read_ios /= 0) THEN
>    PRINT *,"READ RECORD ERROR :"," read_ios= ",read_ios
>    i = i-1
>    BACKSPACE 11
>   READ (UNIT=11,FMT=*, IOSTAT=read_ios) paddock, scenario, gtarget(i),  &
>       sla(i), extcoef(i), ltcoef(i), lpeff(i), lslpr0(i), lslpr1(i),    &
>       msgr20(i), rconst20(i), sencer20(i), pshoot(i), lfratio(i),       &
>       yrsim, monbeg, datbeg, monend, datend, erain, rootdpth(i),        &
>       dbug, fix, area(i), tmpsgr, tmprcnt, tmpsen, tming, tmaxg, toptg, &
>       tminr, tmaxr, toptr, tmins, tmaxs, topts, gama, ctok, alcrop(i),  &
>       alsoil(i), pcarbon, kdet, kvltlzn, kresr, knomr, kntfctn, totdays,&
>       bulkden1(i), prtlden1(i), avlblws1(i), ws151(i), bulkden2(i),     &
>       prtlden2(i), avlblws2(i), ws152(i), ws1(i), ws2(i), stgdw(i),     &
>       strdw(i), n1t1(i), n1t2(i), naf(i), res(i), nres(i), cres(i),     &
>       omr(i), nofert(i), (whenfert(i,k),k=1,nofert(i)),         &
>       (amountn1(i,k), k=1,nofert(i)), (amountn2(i,k),k=1,nofert(i)),    &
>       (amountn3(i,k), k=1,nofert(i)), slope, intrct, herd(i), ipc,      &
>       fleaf, fstem, ratecons, checkern, checkerw, lcoef, optmsn
>       PRINT *,"read_ios = ",read_ios
>       PRINT *,"paddock= ",paddock," i= ",i," nofert(",i,")= ",nofert(i)
>         EXIT
>       END IF

>      i = i + 1
> END DO

>      write (88,*) 'leaving readata'

>and one line of input text data file is as this: (well, it is
>a continuous line in my vi editor, you get the idea)

>1 0 1 40.000 0.500 0.120 0.0000000120 0.0000050000 0.0000005000 0.400
>0.100 0.00
>40 0.900 0.500 1993 4 7 10 30 1 1000.000 1 0 1000.000 0 0 0 0.000 40.000
>20.000
>0.000 40.000 20.000 0.000 40.000 20.000 0.680 273.150 0.230 0.200 0.400
>0.000270
>00 0.00270000 0.03000000 0.00007200 33.60000000 208 1.320 2.650 0.620
>0.240 1.46
>0 2.650 0.640 0.250 80.000 180.000 0.00800000 0.00800000 8.500 14.000
>23.000 714
>.000 42.000 672.000 50820.000 5 98 125 138 232 264 28.410 28.410 28.410
>28.410 2
>8.410 28.410 28.410 28.410 28.410 28.410 0.000 0.000 0.000 0.000 0.000
>1.100 -58
>.000 2 15.000 0.200 0.500 2.000 0 0 1.300 4.100

>--------------------------------------------------------------------------
>Tong Zhai                .  .  o  o  O  O         "Go not where the road
>ABE Purdue Univ.         ,________,  ____   O      may lead, go instead
>West Lafayette, IN       | PURDUE |  |[]|_,_Y      where there is no
>47907                    |________|__|__|_|_|}     road and leave a trail"
>1-765-494-1186            oo----oo    OO--oo\\                 -anonymous




Wed, 18 Jun 1902 08:00:00 GMT  
 text data file record length has limit ???

Quote:

> HI, all:
>   I have a f90 program which need to read 'A LOT OF' data items
> on one single line in a data file created by another software
> called 'ArcView' as comma delimited text file, I wrote a little
> perl script to s/,/ /g so that it could be read by read(unit,*),

Try s/,/\n/g instead.

I would also urge you to read the full specification of list-directed
formatting (10.8 of the Fortran 95 standard). It begins with:

        "The characters in one or more list-directed records
        constitute a sequence of values and value separators. The end
        of a record has the same effect as a blank character, unless
        it is within a character constant. Any sequence of two or more
        consecutive blanks is treated as a single blank, unless it is
        within a character constant.

If your original data contain consecutive commas, it may not be a
good idea to replace them with blanks.

        "A value separator is
                (1) A comma optionally preceded by one or more
                    contiguous blanks and optionally followed by
                    one or more contiguous blanks,
                (2) [...], or
                (3) One or more contiguous blanks between two nonblank
                    values or following the last nonblank value, [...]

In other words, you may not even need to get rid of the commas in the
first place. (If your problem is one of very long records, you'll
simply need to insert line breaks after some of the commas.)

If you are concerned that splitting your original data record into
multiple lines will make it harder to spot the original record
separators, simply add a / at the end of each original record.
(It should be on the same line as the last item, lest it be
interpreted as part of the next list-directed record in the file.)

You may also add indentation to your continuation lines, e.g.
        s/,/,\n    /g
to make the result easier for humans to read.

Finally, since you are reading from a numbered unit you could also
try increasing the record length limit: just open the file with an
explicit RECL= specifier. (You need to start from the closed state,
as RECL= is not one of the specifiers you can use to change attributes
of an existing connection.)



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. processing variable length records in text file

2. Limiting text length in Entry widget

3. Limiting length of text widgets

4. Attempting to read variable length records as raw data

5. Data Base Limited To (x) records

6. Getting true length of a variable length record - IBM Mainframe

7. Finding Variable-Length Record Length

8. Record Length in Ascii File

9. problem ascii file with fixed record length

10. Import dos file variable record length

11. Writing Datalog Files with record length

12. Reading variable-length records from a file

 

 
Powered by phpBB® Forum Software