* g77's 8-byte record descriptor @ 1998-10-15 4:00 G. Hugh SONG 1998-10-15 4:00 ` Toon Moene 1998-10-16 4:00 ` Robert Corbett 0 siblings, 2 replies; 9+ messages in thread From: G. Hugh SONG @ 1998-10-15 4:00 UTC (permalink / raw) Hi, I just heard that Dec FORTRAN (for alpha?) uses 4-byte record descriptor unlike g77 for alpha whcih uses 8-byte. Is that really true? If that is true, I can't understand g77's decision for 8-byte descriptor rather than 4-byte. Can someone clarify this? Thanks. - G. Hugh Song PS: Please remove "Spamspoiler" when replying ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: g77's 8-byte record descriptor 1998-10-15 4:00 g77's 8-byte record descriptor G. Hugh SONG @ 1998-10-15 4:00 ` Toon Moene 1998-10-15 4:00 ` Greg Lindahl ` (2 more replies) 1998-10-16 4:00 ` Robert Corbett 1 sibling, 3 replies; 9+ messages in thread From: Toon Moene @ 1998-10-15 4:00 UTC (permalink / raw) "G. Hugh SONG" <ghsong@\"Spamspoiler\"kjist.ac.kr> wrote: > I just heard that Dec FORTRAN (for alpha?) uses 4-byte record > descriptor unlike g77 for alpha whcih uses 8-byte. Is that really true? > > If that is true, I can't understand g77's decision for 8-byte > descriptor rather than 4-byte. > > Can someone clarify this? What I can clarify is that "decision" is the wrong word to use here - we detected the incompatibility (not being able to read unformatted files produced by a Dec Fortran compiled program in a g77 compiled one (on Alpha/DEC Unix) and vice versa) far too late to do anything on it. Note (again - as I explained in a previous message) that the Fortran Standard doesn't guarantee you anything here, so this is just bad luck. We're unlikely to "repair" this, as that would mean that files produced by g77-x.y.z would not be readable by g77-x.y.z+1, an even less preferable situation. -- Toon Moene (mailto:toon@moene.indiv.nluug.nl) Saturnushof 14, 3738 XG Maartensdijk, The Netherlands Phone: +31 346 214290; Fax: +31 346 214286 g77 Support: mailto:fortran@gnu.org; egcs: mailto:egcs-bugs@cygnus.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: g77's 8-byte record descriptor 1998-10-15 4:00 ` Toon Moene @ 1998-10-15 4:00 ` Greg Lindahl 1998-10-16 4:00 ` Craig Burley 1998-10-16 4:00 ` g77's 8-byte record descriptor Feng Liu 2 siblings, 0 replies; 9+ messages in thread From: Greg Lindahl @ 1998-10-15 4:00 UTC (permalink / raw) Toon Moene <toon@moene.indiv.nluug.nl> writes: > We're unlikely to "repair" this, as that would mean that files produced by > g77-x.y.z would not be readable by g77-x.y.z+1, an even less preferable > situation. It's an easy repair to do something like the ASSIGN statement; either program-external or program-internal picking of the size of the record size. I don't need the default to be the same on both platforms, so it can stay the same as today. But this is the, uh, 3rd time this has come up? Probably could have been done for less work than we spent typing... -- g ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: g77's 8-byte record descriptor 1998-10-15 4:00 ` Toon Moene 1998-10-15 4:00 ` Greg Lindahl @ 1998-10-16 4:00 ` Craig Burley 1998-10-18 4:00 ` Internal IO bug in g77? (was Re: g77's 8-byte record descriptor) G. Hugh SONG 1998-10-16 4:00 ` g77's 8-byte record descriptor Feng Liu 2 siblings, 1 reply; 9+ messages in thread From: Craig Burley @ 1998-10-16 4:00 UTC (permalink / raw) Toon Moene <toon@moene.indiv.nluug.nl> writes: > What I can clarify is that "decision" is the wrong word to use here - we > detected the incompatibility (not being able to read unformatted files > produced by a Dec Fortran compiled program in a g77 compiled one (on > Alpha/DEC Unix) and vice versa) far too late to do anything on it. Some background info might be appropriate here. Most questions about g77 and I/O facilities are really questions about libf2c, since g77 just uses that. (But it's nice to see that so many questions about libf2c on c.l.f are phrased as questions about g77, anyway; there was a time, even while g77 was available, that that wasn't true.) libf2c "happened" to pick a type for the record header that became 8 bytes, not 4, on some (or all) OSes on the Alpha, and probably on other machines as well. It's true we're loathe to make gratuitous incompatible changes to g77, from one version to the next, for the same machine/OS combo, especially in a case where the only problems resulting from the current situation occur when moving unformatted files between different systems -- something users should not be depending upon anyway. However, while I haven't investigated this fully myself, I believe there might be some good reasons to use the 8-byte header, or at least something more than 4 bytes. In particular, if, as I suspect is the case, the header counts bytes, not words, and given that the canonical Alpha configuration for programming uses 4-byte integers (and thus 4-byte array indexes) but 8-byte pointers (and thus vastly more than a 2GB limit on array size), it seems to me that there are arrays one could reasonably declare and use on an Alpha, but not be able to write to a file if that file's format limited record sizes to byte counts represented as 4-byte integers. Whether a particular version of *g77* can take advantage of these implications for normal, non-I/O code anyway, I don't know offhand, but the kind of thing I'm thinking of is this: PARAMETER (IMAX=2147483647) DOUBLE PRECISION A(IMAX) The array is definitely not too big for an Alpha, although the compiler has to be careful to multiply out byte offsets in the 8-byte integer type instead of the 4-byte (so A(IMAX) itself can be addressed without overflowing a register). However, I believe the array A could not be properly written to an unformatted file if g77 defaulted to the 4-byte record headers, as people are recommending be done. (I don't know what the failure mode would be -- perhaps a small amount of the array would be written, with no diagnostic or other evidence of a problem.) Even if g77 can't currently handle the above even for non-I/O stuff, it *should* be able to (I think, speaking offhand), and other compilers on Alphas might well be able to (and, if so, they should be defaulting to 8-byte headers as well). Getting code generation perfectly right is an ongoing battle, but as Toon suggested with his post, it is much harder to "fix" file-format problems after releasing products that ensconse those problems into peoples' files. -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.org ^ permalink raw reply [flat|nested] 9+ messages in thread
* Internal IO bug in g77? (was Re: g77's 8-byte record descriptor) 1998-10-16 4:00 ` Craig Burley @ 1998-10-18 4:00 ` G. Hugh SONG 0 siblings, 0 replies; 9+ messages in thread From: G. Hugh SONG @ 1998-10-18 4:00 UTC (permalink / raw) Craig Burley wrote: > Toon Moene <toon@moene.indiv.nluug.nl> writes: > > > What I can clarify is that "decision" is the wrong word to use here - we > > detected the incompatibility (not being able to read unformatted files > > produced by a Dec Fortran compiled program in a g77 compiled one (on > > Alpha/DEC Unix) and vice versa) far too late to do anything on it. > > Some background info might be appropriate here. Most questions about > g77 and I/O facilities are really questions about libf2c, since g77 > just uses that. (But it's nice to see that so many questions about > libf2c on c.l.f are phrased as questions about g77, anyway; there > was a time, even while g77 was available, that that wasn't true.) > > libf2c "happened" to pick a type for the record header that became > 8 bytes, not 4, on some (or all) OSes on the Alpha, and probably > on other machines as well. > > It's true we're loathe to make gratuitous incompatible changes to > g77, from one version to the next, for the same machine/OS combo, > especially in a case where the only problems resulting from the > current situation occur when moving unformatted files between > different systems -- something users should not be depending upon > anyway. > > However, while I haven't investigated this fully myself, I believe > there might be some good reasons to use the 8-byte header, or at > least something more than 4 bytes. > > In particular, if, as I suspect is the case, the header counts bytes, > not words, and given that the canonical Alpha configuration for > programming uses 4-byte integers (and thus 4-byte array indexes) > but 8-byte pointers (and thus vastly more than a 2GB limit on array > size), it seems to me that there are arrays one could reasonably > declare and use on an Alpha, but not be able to write to a file > if that file's format limited record sizes to byte counts represented > as 4-byte integers. > > Whether a particular version of *g77* can take advantage of these > implications for normal, non-I/O code anyway, I don't know offhand, > but the kind of thing I'm thinking of is this: > > PARAMETER (IMAX=2147483647) > DOUBLE PRECISION A(IMAX) > > The array is definitely not too big for an Alpha, although the compiler > has to be careful to multiply out byte offsets in the 8-byte integer > type instead of the 4-byte (so A(IMAX) itself can be addressed without > overflowing a register). > > However, I believe the array A could not be properly written to an > unformatted file if g77 defaulted to the 4-byte record headers, as > people are recommending be done. (I don't know what the failure > mode would be -- perhaps a small amount of the array would be written, > with no diagnostic or other evidence of a problem.) > > Even if g77 can't currently handle the above even for non-I/O stuff, > it *should* be able to (I think, speaking offhand), and other compilers > on Alphas might well be able to (and, if so, they should be defaulting > to 8-byte headers as well). Getting code generation perfectly right > is an ongoing battle, but as Toon suggested with his post, it is > much harder to "fix" file-format problems after releasing products > that ensconse those problems into peoples' files. > -- > > "Practice random senselessness and act kind of beautiful." > James Craig Burley, Software Craftsperson burley@gnu.org We now have our James here. Thank you James. I now can understand your preferrence to 8-byte. Anyway, right after I posted the first article in this thread, With a help of my friend here, I wrote a small C buffer, which must be very useful for any one. What it does is to forget Fortran record-oriented IO all together and to rely on generating a C-style binary file. In the course of the development of this small buffer, I think I found a compiler bug of g77. The internal IO cannot take write(label(1),'(''This is the '',i1,''st string.\0'')') 1 The code compiles OK with the above line. But the execution will halt at the above "\0". Putting "\\0" does not make sense because we do not actually want a string of "\0" to be save for some printing. BTW, I guess I spent total of 10 hours to develop the C buffer. I don't know much about C myself. -------------test.f-------------------------------- program test implicit none integer i, Fbinout, IDUM1, LSTR parameter(LSTR = 72) integer i4(3) real*4 r4(20) character label(3)*72, TERM0*2 parameter(TERM0 = '\0') i4(1) = 4 i4(2) = 5 i4(3) = 1 do i = 1, 20 r4(i) = i end do write(label(1),'(''This is the '',i1,''st string.'',a2)') 1, TERM0 label(2) = 'That\0' label(3) = 'That and this\0' IDUM1 = fbinout('r4.un\0', 3, LSTR, label, 3, i4, 20, r4) 153 format(5(1x,1pe15.7e3)) stop end ---------------------fbinout.c-------------------------- #include <stdio.h> #include <strings.h> #include <stdlib.h> #include <time.h> int fbinout_(char *fname, int *ms, int *lstr, char strings[], int *mi, int I4[], int *md, float r4[]) { short size, csize; int j; long timev; FILE *fout; char *ctimep; time(&timev); ctimep = ctime(&timev); csize = strlen(ctimep); /* for(j=0; j<*ms; ++j) fprintf(stdout, "string[%d] = %s\n", j, strings+j*(*lstr)); for(j = 0; j < *mi; j++) fprintf(stdout, "I4[%d] = %d\n", j, I4[j]); for(j = 0; j < *md; j++) fprintf(stdout, "r4[%d] = %f\n", j, r4[j]); fprintf(stdout, "%s\n", ctimep); */ /* binary write */ fout = fopen(fname, "wb"); fwrite(ms, sizeof(int), 1L, fout); for(j = 0; j < *ms; j++) { size = strlen(strings+j*(*lstr)); fwrite(&size, sizeof(short), 1L, fout); fwrite(strings+j*(*lstr), sizeof(char), (size_t)size, fout); } fwrite(mi, sizeof(int), 1L, fout); fwrite(I4, sizeof(int), (size_t)*mi, fout); fwrite(md, sizeof(int), 1L, fout); fwrite(r4, sizeof(float), (size_t)*md, fout); fwrite(ctimep, sizeof(char), (size_t)csize, fout); fclose(fout); return 0; } -------------------Makefile--------------- SHELL=/bin/sh CFLAGS =-g FFLAGS =-g test.x: test.o fbinout.o $(FC) -o test.x $^ clean: rm *.o ------------------------------------------ Finally, I would like to use the opportunity of talking to James directly. When would the optimization with double precision complex be working? Thank you very much for all. -- G. Hugh Song PS: Please remove "Spamspoiler" when replying ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: g77's 8-byte record descriptor 1998-10-15 4:00 ` Toon Moene 1998-10-15 4:00 ` Greg Lindahl 1998-10-16 4:00 ` Craig Burley @ 1998-10-16 4:00 ` Feng Liu 1998-10-18 4:00 ` Craig Burley 1998-10-18 4:00 ` Toon Moene 2 siblings, 2 replies; 9+ messages in thread From: Feng Liu @ 1998-10-16 4:00 UTC (permalink / raw) Toon Moene (mailto:toon@moene.indiv.nluug.nl) wrote: > We're unlikely to "repair" this, as that would mean that files produced by > g77-x.y.z would not be readable by g77-x.y.z+1, an even less preferable > situation. I would disagree with this! In our place, we have DEC machines with DEC's f77 and f90 under DEC unix, Intel machines with g77 under Linux, and Alpha PCs with g77 under Linux. We share files through NFS. I must say that all my students and myself find it a nuisance to have to keep 2 copies of our data files in order to communicate. It is far easier and desirableto convert some old files once and for all rather than perpetuate the problem! Feng Liu, Associate Professor Department of Mechanical and Aerospace Engineering University of California, Irvine Irvine, CA 92697-3975 phone: 949-824-1750, or 949-824-5406(MAE Department) Fax: 949-824-1750, or 949-824-8585(MAE Department) e-mail: fliu@uci.edu http://yoda.eng.uci.edu/fliu/home.html ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: g77's 8-byte record descriptor 1998-10-16 4:00 ` g77's 8-byte record descriptor Feng Liu @ 1998-10-18 4:00 ` Craig Burley 1998-10-18 4:00 ` Toon Moene 1 sibling, 0 replies; 9+ messages in thread From: Craig Burley @ 1998-10-18 4:00 UTC (permalink / raw) fliu@uci.edu (Feng Liu) writes: > Toon Moene (mailto:toon@moene.indiv.nluug.nl) wrote: > > > We're unlikely to "repair" this, as that would mean that files produced > by > > g77-x.y.z would not be readable by g77-x.y.z+1, an even less preferable > > situation. > > I would disagree with this! In our place, we have DEC machines with DEC's > f77 and f90 under > DEC unix, Intel machines with g77 under Linux, and Alpha PCs with g77 > under Linux. We share files through NFS. I must say that all my students > and myself find it a nuisance to have to keep 2 copies of our data files > in order to communicate. It is far easier and desirableto convert some old > files once and for all rather than perpetuate the problem! I think Toon meant, by "preferable", preferable for the general user base of g77 on Alphas, not preferable for every single g77/Alpha user. Also, I've already posted another, IMO rather important, reason to not go back to 4-byte headers on Alphas, having to do with not crippling writing large arrays using unformatted I/O just to default to compatibility with ancient machines, like 32-bit Pentiums. :) g77 really needs to offer (someday) better ways to select the formats of data files than it currently does. In the meantime, sites where inter-machine compatibility is important (and achievable without bit-twiddling), it isn't really all that hard to patch g77 specifically for those sites to achieve this effect. E.g. I think there's already a macro in gcc/f/runtime/libI77 (UIOLEN_int or some such thing), and in egcs/libf2c/libI77, that, when defined, forces 4-byte headers (or equivalent). -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.org ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: g77's 8-byte record descriptor 1998-10-16 4:00 ` g77's 8-byte record descriptor Feng Liu 1998-10-18 4:00 ` Craig Burley @ 1998-10-18 4:00 ` Toon Moene 1 sibling, 0 replies; 9+ messages in thread From: Toon Moene @ 1998-10-18 4:00 UTC (permalink / raw) fliu@uci.edu (Feng Liu) wrote: > Toon Moene (mailto:toon@moene.indiv.nluug.nl) wrote: > > We're unlikely to "repair" this, as that would mean that files produced > by > > g77-x.y.z would not be readable by g77-x.y.z+1, an even less preferable > > situation. > I would disagree with this! In our place, we have DEC machines with DEC's > f77 and f90 under > DEC unix, Intel machines with g77 under Linux, and Alpha PCs with g77 > under Linux. We share files through NFS. I must say that all my students > and myself find it a nuisance to have to keep 2 copies of our data files > in order to communicate. It is far easier and desirableto convert some old > files once and for all rather than perpetuate the problem! Aahh, but that's the beauty of open source software: You'd just make a local version of g77 that works according to your needs ! (I do not know exactly where the location of these files was in the egcs-1.1 release, but you have to go to the directory ending in .../libf2c/libI77) Edit the file `Makefile.in', changing the line: $(CC) -c -DSkip_f2c_Undefs -DAllow_TYQUAD $(ALL_CFLAGS) $< into: $(CC) -c -DSkip_f2c_Undefs -DAllow_TYQUAD -DUIOLEN_int $(ALL_CFLAGS) $< and then rebuild. Hope this helps. -- Toon Moene (mailto:toon@moene.indiv.nluug.nl) Saturnushof 14, 3738 XG Maartensdijk, The Netherlands Phone: +31 346 214290; Fax: +31 346 214286 g77 Support: mailto:fortran@gnu.org; egcs: mailto:egcs-bugs@cygnus.com ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: g77's 8-byte record descriptor 1998-10-15 4:00 g77's 8-byte record descriptor G. Hugh SONG 1998-10-15 4:00 ` Toon Moene @ 1998-10-16 4:00 ` Robert Corbett 1 sibling, 0 replies; 9+ messages in thread From: Robert Corbett @ 1998-10-16 4:00 UTC (permalink / raw) In article <704fpu$835$1@news.kjist.ac.kr>, G. Hugh SONG <ghsong@\"Spamspoiler\"kjist.ac.kr> wrote: >Hi, >I just heard that Dec FORTRAN (for alpha?) uses 4-byte record >descriptor unlike g77 for alpha whcih uses 8-byte. Is that really true? How does Digital Fortran represent unformatted records larger than 4GB? When we faced this issue here at Sun, we had many proposals and no consensus. We decided to punt until a later release. I am not speaking for Sun. Sincerely, Bob Corbett ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~1998-10-18 4:00 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1998-10-15 4:00 g77's 8-byte record descriptor G. Hugh SONG 1998-10-15 4:00 ` Toon Moene 1998-10-15 4:00 ` Greg Lindahl 1998-10-16 4:00 ` Craig Burley 1998-10-18 4:00 ` Internal IO bug in g77? (was Re: g77's 8-byte record descriptor) G. Hugh SONG 1998-10-16 4:00 ` g77's 8-byte record descriptor Feng Liu 1998-10-18 4:00 ` Craig Burley 1998-10-18 4:00 ` Toon Moene 1998-10-16 4:00 ` Robert Corbett
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox