- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Hello,
I am moving code from VAX VMS to the PC, most of this code is old F77 from the 70's and 80's.
The code has many variable length format statements;
as format(I)
and format(F10.6) where N4 is a variable (int).
What can I replace these with to make the code more portable?
Thanks
Nigel
- Balises:
- Intel® Fortran Compiler
Lien copié
4 Réponses
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
In most cases, 1000i4 will do (or whatever number is large enough). The Fortran rule is that "unused" format descriptors will be discarded after I/O operation is completed, and this won't affect the efficiency whatsoever.
The problem may occur if theIx is immediately followed by another descriptor on the same line. E.g. if you should read/write a number of integers followed by something else, like:
(I'm not sure if extra parens around i3 are required, but they won't harm. When the format descriptor is exhausted, the next item is read by "reversing" the format to the previous paren).
Finally, in such cases you can construct an appropriate format string on the fly (but you can't use FORMAT statement, but an "inline" FORM=). This is somewhat clumsy and should be used when the goal cannot be achieved by other means:
The problem may occur if the
4In such cases, you can use either non-advancing I/O:
12 66 38 52 3.14159
READ(11,"(i1)") nInt
READ(11,"(i3, f10.0)") (iX(i), i=1,nInt), Pi
READ(11,"((i3))", ADVANCE="no") (iX(i), i=1,nInt)
READ(11,"(F10.0)") Pi
(I'm not sure if extra parens around i3 are required, but they won't harm. When the format descriptor is exhausted, the next item is read by "reversing" the format to the previous paren).
Finally, in such cases you can construct an appropriate format string on the fly (but you can't use FORMAT statement, but an "inline" FORM=). This is somewhat clumsy and should be used when the goal cannot be achieved by other means:
CHARACTER(10) sFormat
...
READ(11,"(i1)") nInt
WRITE(sFormat, "(a,i0,a)") "(", nInt, "i3, f10.0)"
READ(11, sFormat) (iX(i), i=1,nInt), Pi
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Of course, you don't have to change it if you're using the Intel compiler.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks for the replies
Steve
We are due to get the intel compiler at work soon (takes about 2 months to buy anything!), I was just having a 'quick look ' at some of the code at home using the free G95 compiler.
Thanks
Nigel
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
We do have a free 30-day evaluation version of the Intel compiler.
Répondre
Options du sujet
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable