(j3.2006) more enhancements to the Fortran Standard

Bill Long longb
Fri Sep 18 19:30:30 EDT 2009



Dan Nagle wrote:
> Hi,
> 
> For those who don't know, KAPL is Knowles Atomic Power Lab.
> See http://www.knollslab.com/ for details.
> 
> I have chatted via email with this guy off-and-on
> for some time now.  He may be interested in membership.  :-)
> 

Could qualify as a DOD member - something we've lacked.


> He has some features, which, of course, we can't consider now.
> I forward them to the list for the record.
> 



> 
>>
>> 1)  To the any function, add the optional intent(out) integer argument 
>> LOC=VAL, where VAL shall contain the mask-array index for which the 
>> mask is true.
>>
>> Whether or not VAL is a scalar, or an array of the same rank as the 
>> mask-array is an open question. (In my long-time counterpart of this 
>> function, VAL is a scalar that I've decoded into the actual array 
>> indices when I've needed them.)
>>
>> For me at least, this removes the ever-present need to subsequently 
>> invoke the maxloc or minloc functions. That is, I'm almost always 
>> interested in not only its truth, but where it is true.
>>
>> 2)  To the count function, add the optional intent(out) integer 
>> arguments LOC1=VAL1, LOC2=VAL2, and LOCS=VALS, where VAL1 and VAL2 
>> shall contain the first and last mask-array indices for which the mask 
>> is true, and VALS shall contain all of the indices for which the mask 
>> is true to the extent that its size allows. (That is, and as an 
>> example, VALS might not have the size to contain VAL2.)


integer,parameter :: n = 1000
logical :: mask(n)
integer,allocatable :: vals(:)
integer :: c,val1,val2

call compute_mask(mask,n)

vals = pack ( [ (i, i=1,n) ], mask )
val1 = vals(1)
c = size(vals)  ! count result
val2 = vals(c)


This seems like an alternative using existing routines. Or maybe I'm 
missing what he wants.

(Or just write the pre-f90 loop - compiler optimize this sort of thing 
pretty well.)



>>
>> 5) Enhance the RESULT clause of the function statement by allowing 
>> initialization of the return value, as in the illustrative
>>
>>        integer function XYZ ( ... )   RESULT  ( fvalue = 0 )
>>
>> declaration statement, and allow fvalue to be "dimensioned" as in the 
>> illustrative
>>
>>        integer function XYZ ( ... )   RESULT  ( fvalue(2) = 0 )
>>
>> declaration statement.

Interesting. Might be easier syntax to allow the initialization on a 
declaration of the result value, rather than within the RESULT( ). This 
sort of happens already if the result is of a type with all components 
having default initialization.


>>
>> 6) Make the old VAX run-time format descriptor <N>[AIFE]W... extension 
>> part of the Standard, where N is a run-time scalar integer variable 
>> that is defined within the scope of the format descriptor, and says 
>> for example, read/write N integer values in fields of width W.
>>
>> Some current compilers -- e.g., Intel's -- accept this descriptor, so 
>> it would be preferable to maintain the <...> syntax in the Standard.
>>
>> 

This was convenient. Considering that the Intel compiler is derived from 
the old VAX compiler, support there is no surprise.  It does sort of mix 
the concepts of a static format statement, and a variable format 
contained in a character array.

Cheers,
Bill



-- 
Bill Long                                   longb at cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120





More information about the J3 mailing list