Crash if trying to write a parameter or a constant in a Fortran application
Wei-keng Liao
wkliao at ece.northwestern.edu
Tue Jul 9 16:23:37 CDT 2013
One problem is Fortran allows ones to define a parameter array.
Such as
integer, dimension(8192), parameter :: varp=0
I am not aware of a way to tell a subroutine argument is
parameter or not in Fortran or C. In the above case, segmentation
fault will still occur if writing the entire 8192 elements, though
I wonder if it is rare to see one using large parameter variables
in Fortran.
If we want to document this, we might want to generate an error
code corresponding to it.
One possible solution to forbidding parameter buffers is to declare
the intent of I/O buffer as inout
<type>, intent(inout) :: buf
but it works only for F90.
Wei-keng
On Jul 9, 2013, at 3:40 PM, Rob Latham wrote:
> On Tue, Jul 09, 2013 at 11:17:15AM -0500, Wei-keng Liao wrote:
>> NetCDF 3 and 4 pass the test, because they do internal caching. So
>> byte-swap is done on the cache buffer and the memory contents of
>> Fortran parameters are not touched.
>
> Ah, right, thank you for reminding me about the netcdf internal cache.
>
> I'm tempted to just document this in the release notes, unless there's
> a reasonably small threshold: for example, "if number of items is less
> than 1024, make a copy for byteswapping in case it's a parameter"
>
> ==rob
>
>> Wei-keng
>>
>> On Jul 9, 2013, at 10:14 AM, Rob Latham wrote:
>>
>>> On Tue, Jul 09, 2013 at 08:53:24AM -0500, Rob Latham wrote:
>>>> Does serial netcdf exhibit this behavior?
>>>
>>> Here's my serial netcdf-f90 version of your test case, but it's buggy:
>>> I am apparently trying to write to a variable that does not exist?
>>> Our policy is to be as netcdf-like as possible, or have a good reason
>>> not to be, and I'd like to know how serial netcdf handles the case of
>>> byte swapping data passed to it in this un-modifiable parameter form.
>>>
>>> ==rob
>>>
>>> --
>>> Rob Latham
>>> Mathematics and Computer Science Division
>>> Argonne National Lab, IL USA
>>> <netcdf_parameter.f90>
>>
>
> --
> Rob Latham
> Mathematics and Computer Science Division
> Argonne National Lab, IL USA
More information about the parallel-netcdf
mailing list