I/O performance blues
Brendan Kochunas
bkochuna@umich.edu
Tue Nov 26 15:14:00 GMT 2013
I've seen issues with exceeding the I/O buffer. In your code if nnzero
or ncol are very large I would not be surprised if you experienced
performance issues. In fact if they are large enough you may get a
run-time error.
You might try two things both related to reading into a buffer first:
1) Read data into a fixed size buffer array then copy to the persistent
variable e.g. something like
--------------------
read(infile,fmt=valfmt) buffer(1:nbuf)
stt=1
DO WHILE(stt < nnz)
stp=MIN(stt+nbuf-1,nnz)
val(stt:stp)=buffer(1:bstp)
bstp=MIN(nbuf,nnz-stp+1)
read(infile,fmt=valfmt) buffer(1:bstp)
stt=stt+1
ENDDO
---------------------
2) Read in as a line of text and then do your formatted reads from the
character type variable to the real type variable. e.g.
---------------------
READ(infile,*) cbuffer
READ(cbuffer,fmt=valfmt) val(1:nnzero)
---------------------
One issue with the second option is setting a max line length for the
input files. Although you can get around that by using an allocatable
character array and searching for the LF or CR ascii characters to know
when you are at the end of a line. This approach just gets kind of messy
though.
Hope that helps.
Thanks,
-Brendan
p.s. My first post on list.
On 11/26/2013 3:40 AM, Salvatore Filippone wrote:
> Ah yes, I see, that's mmio.f for the MatrixMarket format, but it's
> irrelevant here.
>
> The code I tested is practically the same as
> http://math.nist.gov/MatrixMarket/src/hbcode1.f
>
> Thanks
> Salvatore
>
> On Tue, Nov 26, 2013 at 9:15 AM, Arjen Markus <arjen.markus895@gmail.com> wrote:
>> Oh, I was referring to the code in the Matrix Market. It struck me as
>> rather odd. Sorry for the noise.
>>
>> Regards,
>>
>> Arjen
>>
>> 2013/11/26 Salvatore Filippone <filippone.salvatore@gmail.com>:
>>> Uh?
>>> I don't have any BACKSPACEs in the code I tested.
>>>
More information about the Fortran
mailing list