On Jul 23, 2014, at 4:39 PM, John Harper <[log in to unmask]> wrote:
> Gfortran, g95 and ifort all compile and run it but Sun Fortran 95 8.6 Linux_i386 2011/11/16 complains at run time that
>
> CALL lbc_backend( field, SIZE(field,1), 1, src=src )
>
> is an attempt to use a missing optional dummy. I note that field
It is allowed to use a missing optional dummy as an actual argument as long as the corresponding argument in the called routine is also optional. In that case, the dummy in the callee is also not present (PRESENT(src) returns false). This is a fairly recent Fortran feature, and your compiler appears to be a few years old. That might be the explanation for what you are seeing.
> is of rank 1 inside lbc_masspooint but rank 2 inside lbc_backend.
That’s OK since the dummy in lbc_backend is explicit-shape.
Cheers,
Bill
>
> On Wed, 23 Jul 2014, Bill Long wrote:
>
>> Date: Wed, 23 Jul 2014 17:30:38 +0000
>> From: Bill Long <[log in to unmask]>
>> Reply-To: Fortran 90 List <[log in to unmask]>
>> To: [log in to unmask]
>> Subject: Re: Explicitly shaped optional array argument
>> This should work. I filed a bug. In the mean time, does the problem go away if compiled with -Oipa0 ? (Disable inlining.)
>>
>> Cheers,
>> Bill
>>
>> On Jul 23, 2014, at 11:47 AM, Oliver Fuhrer (MeteoSwiss) <[log in to unmask]> wrote:
>>
>>> Dear all,
>>>
>>> I have a code which runs on PGI and GNU but segfaults on the Cray compiler which uses an explicitly shaped optional array argument.
>>>
>>> MODULE test
>>>
>>> CONTAINS
>>>
>>> SUBROUTINE lbc_masspoint(field, src )
>>> IMPLICIT NONE
>>> REAL , INTENT(INOUT) :: field(:)
>>> REAL , INTENT(IN), OPTIONAL :: src(:)
>>> CALL lbc_backend( field, SIZE(field,1), 1, src=src )
>>> END SUBROUTINE lbc_masspoint
>>>
>>> SUBROUTINE lbc_backend(field, id, kd, src )
>>> IMPLICIT NONE
>>> INTEGER, INTENT(IN) :: id, kd
>>> REAL , INTENT(INOUT) :: field(id,kd)
>>> REAL , INTENT(IN), OPTIONAL :: src(id,kd)
>>> END SUBROUTINE lbc_backend
>>>
>>> END MODULE test
>>>
>>> PROGRAM bug1
>>> USE test
>>> IMPLICIT NONE
>>> REAL :: fexp(45)
>>> CALL lbc_masspoint( fexp(:) )
>>> END PROGRAM bug1
>>>
>>> The problem is with the src field, which is actually not present but causes the executable to segfault. I am supposing that it’s legal to do this (I have searched Metcalf et al., but have not found anything to the contrary), but wanted to double check.
>>>
>>> Kind regards,
>>> Oli
>>>
>>>
>>> _________________________________________________
>>> Oliver Fuhrer
>>> Numerical Models
>>>
>>> Federal Department of Home Affairs FDHA
>>> Federal Office of Meteorology and Climatology MeteoSwiss
>>> We have moved and have new phone numbers:
>>> Operation Center 1
>>> Postfach 257
>>> 8058 Zürich-Flughafen
>>> T. +41 58 460 93 59
>>> M. +41 79 548 65 84
>>> F. +41 58 460 96 66
>>> [log in to unmask]
>>> http://www.meteoswiss.admin.ch/
>>
>> Bill Long [log in to unmask]
>> Fortran Technical Suport & voice: 651-605-9024
>> Bioinformatics Software Development fax: 651-605-9142
>> Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
>>
>>
>
>
> -- John Harper, School of Mathematics Statistics and Operations Research
> Victoria University, PO Box 600, Wellington 6140, New Zealand
> e-mail [log in to unmask] phone (+64)(4)463 5276 fax (+64)(4)463 5045
Bill Long [log in to unmask]
Fortran Technical Suport & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
|