Board index » fortran. Note that Paul's code is essentially what "wc -l" does anyway. Most current operating systems don't store information about the number of records in a file, so the only way to find it out is to read through the file and count them. Even if the Fortran language defined such a query, that's how it would be implemented behind your back on most current actual operating systems. It can do this without, for example, needing a buffer big enough to store a line into.
I have had files with millions of characters and words, but no lines. That's close enough to be what I intended to cover with my "essentially". The fundamental approach theere is still "read through the file and count"; it just tries to be efficient about doing that. BTW, Paul's code doesn't necessarily need a buffer big enough to hold a record either as he doesn't read any data items. Active Oldest Votes. Improve this answer. Alexander Vogt Alexander Vogt Thanks so much this is exactly what I needed.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks. Podcast Making Agile work for data science. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked 1. My compiler supports modules so that should work. It is not working for me yet.
Hi eriehml, I created this version with module. Try if it works for you or not. If not, then the silvefrost fotran doesn't support allocatable arrays as subroutine arguments.
You are right Silverfrost is "no bueno" for allocatable in subroutine. Thanks for your help. In the meantime what I did is butcher your code and I apologize for that and removed dynamic arrays, so I put lines maximum array dimension , period. I don't know how to close my post, or maybe the host does that.
Anyways, has been a pleasure, I will stick around checking the forum, that is for sure. Hi eriehml, And what about using a free compiler? If you are a student and create programs for your study and not for business, why to pay for a compiler? Truly, I wonder, why so many students and professors prefer commercial fortran compilers and not the free ones. You have seen, although silverfrost is commercial, it doesn't support features as free compilers: g95 and gfortran. Hi eriehml, If silverfrost doesn't support allocatable arrays in the subroutines, you can do it at classic way, i.
But then when you want to change the size, you need to do it at more then one places, that is in the main program and in the all subroutines used. To define the array size only at one place in the program, you need a global variable. To define a global variable you can use Fortran90 module , or the Fortran77 common block. In the following example I'm using common block.
In the main program I define the array of size Nmax , which needs to be parameter I hope silvefrost support this too. The thing I don't like about it is though you're just writing noddy program, it wants at least a core 2 duo to install! It also has a C interface. It is not fast but it is an adequate teaching tool.
It does support allocatable stuff if the file extension is f It uses the file extension to decide which standard to follow. Fortran at work is a funny beast. There are a lot of Fortran77 programs about and lots of people still use Fortran 77 we use 77, 95 and on site. The new stuff is Ok for writing new code but very often, you have to maintain old code.
It is good that it is not still in Fortran II or Fortran In industry, you sometimes have to mix variations of Fortran is the same program. Hi xwb, I looked at Intel Visual Fortran now, I thought the Linux version was earlier free for personal or student usage, but now I couldn't find something free, it all costs money. I looked at silvefrost too. What are the differences from the full product?
There are of course restrictions on the licence. GNU compiler are adequate for the little fortran coding, that I do in this forum. On the other side I understand: silverfrost is for someone who doesn't want to bother with OpSys and command line and need an IDE.
0コメント