Newsgroups: comp.lang.fortran
From: Infinity77 <andrea.gav...@gmail.com>
Date: Mon, 5 May 2008 09:54:58 -0700 (PDT)
Local: Mon, May 5 2008 12:54 pm
Subject: A Faster/Better way?
Hi All,
I have an unformatted file, and I open it for reading in big 'PARAMS' where "keyword" is an 8 character string, "number" is an integer which 'PARAMS ' 4200 'REAL' With the file I am working on, this 4200 stays constant for every time I have written the following routine to read and store the data from Thank you very much for your suggestions and comments. I apologize for Andrea. ! Begin Code subroutine ReadSMSPEC(fileName, miniSteps, dimens, matrix) ! PARAMETERS: character*1000, intent(in) :: fileName integer keywordNumber, internalCount, readBuffer, matrixIndex character*8 keywordName logical feof ! Open the file feof = .false. ! The numerical arrays are divided into blocks of up to 1000 items do while (.not.feof) ! Read the keyword, number and kind ! I look for the 'PARAMS' keyword ! A new time step has been found internalCount = 0 ! Loop by reading a block of 1000 items do while (internalCount <= readBuffer) ! Read a block of 1000 items until if (internalCount < readBuffer) then ! We are still far from the last block, read(1, end=40) matrix(1000*internalCount else ! We reached the last block of data: read(1, end=40) matrix(1000*internalCount+1:dimens, matrixIndex) endif internalCount = internalCount + 1 enddo endif enddo 40 continue close(1) end subroutine readSMSPEC ! End Code You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||