...
> >> real(4) :: FUNC
> >
> > That's not portable.
...
> True, but it does depend on the world you inhabit. In the world of 32
> and 64 bit Windows with the Intel Fortran compiler and tens of thousands
> of lines of code it is portable. Another option for absolute portability is
Odd definition of portability - that it is "portable" to a specific
compiler. Usually "portable" refers to porting between multiple things.
There can be reasons for restricting oneself to a particular compiler,
but we don't normally call that "portable"; we just say that the
particular code doesn't require portability for whatever reason.
Admitedly, that particular form is actually portable to more than just
that compiler. It is not, however, portable to some other widely used
compilers, even in the world of 32- and 64-bit Windows.
> Another option for absolute portability is
...
> use iso_fortran_env
> real(real32) :: FUNC
...
> but then, of course, the compiler has to support F2008 so perhaps it's
>not (yet) that portable.
You omitted the widely-recommended way that has been portable since F90
first introduced kinds. Write your own module to define your own
parameter using selected_real_kind. Or, if selected_real_kind is just to
verbose for you or there are other reasons, just define your parameter
with the hard-wired value of 4. But at least if you hard-wire that
value, do so in such a module so that it only needs to be changed in one
place.
The standardized parameters introduced in f2008 are handy, I agree. They
are nice shorthand for the most common cases, and easier to explain than
selected_real_kind. In fact, if I recall correctly, I had pushed to have
something like them in f2003. But they are mostly just nice shorthand.
Selected_real_kind is in the standard and works with *ALL* f90 and later
compilers on all machines.
Strewing real(4) declarations all over a large code is asking for it.
Yes, I *HAVE* seen people who had porting difficulties because they have
done that. Sure, there are other people who have not happened to run
into problems. But when giving advice to 3rd parties, I don't think it
wise to give them advice based on what just happened to work for your
environment without at least mentioing the caveat. They will go away not
knowing that the caveat exists and then get in trouble because they
think their code is portable to all compilers. Yes, I have seen people
get that misimpression and get in trouble as a result. Examples have
appeared in this newsgroup.
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain