Crash if trying to write a parameter or a constant in a Fortran application

Rob Latham robl at mcs.anl.gov
Tue Jul 9 10:14:02 CDT 2013


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
-------------- next part --------------
program netcdf_parameter_bug
  use netcdf
  implicit none

  integer           :: f_id, var_id, varp_id
  integer           :: ierr, mode, status, var
  integer,parameter :: varp = 1
  integer,dimension(1),parameter :: one=(/1/)


  mode = NF90_CLOBBER
  status = nf90_create("test.nc",mode,f_id)

  status = nf90_def_var(f_id,'var', NF90_INT,0,var_id)
  status = nf90_def_var(f_id,'varp',NF90_INT,0,varp_id)
  status = nf90_enddef(f_id)

  var = 1
  !Write of an integer is OK
  status = nf90_put_var(f_id,var_id, var, one)
  !Crash if we try to write a parameter (or constant)
  status = nf90_put_var(f_id,varp_id,varp, one)

  status = nf90_close(f_id)
end program


More information about the parallel-netcdf mailing list