Opened 10 years ago

Closed 4 years ago

#47182 closed defect (worksforme)

netcdf-fortran 4.4.2: Seg fault in nf90_get_att

Reported by: Dave-Allured (Dave Allured) Owned by: Dave-Allured (Dave Allured)
Priority: Normal Milestone:
Component: ports Version: 2.3.3
Keywords: Cc:
Port: netcdf-fortran

Description

With netcdf-fortran 4.4.2, this program seg faults on the first call to nf90_get_att. The function call is supposed to read a file attribute of type integer*2 into a program variable of integer*4.

My current software configuration is:

Mac OS X version 10.10.2
Gfortran version MacPorts gcc49 4.9.2_1
Netcdf-C version 4.3.3.1 (Mac ports)
Netcdf-fortran version 4.4.2 (Mac ports)

program test
   use netcdf
   implicit none
   character(*), parameter :: infile  = 'test.nc'
   character(*), parameter :: varname = 'olr'
   character(*), parameter :: attname = 'missing_value'
   integer ncid, varid, status, ival

   print *, 'Netcdf-C version = ' // trim (nf90_inq_libvers())

   print *, 'Call nf90_open.'
   print *, '  Input file = ' // trim (infile)
   status = nf90_open (infile, nf90_nowrite, ncid)
   print '(a,i0)', '   return status = ', status
   if (status /= 0) print *, 'Error stop.'
   if (status /= 0) call exit (1)

   print *, 'Call nf90_inq_varid "' // trim (varname) // '"'
   status = nf90_inq_varid (ncid, varname, varid)
   print '(a,i0)', '   return status = ', status
   if (status /= 0) print *, 'Error stop.'
   if (status /= 0) call exit (1)

   print '(3a,i0)', '   varid for "', trim (varname), '" = ', varid

   print *, 'Call nf90_get_att for '// trim (attname)
   status = nf90_get_att (ncid, varid, attname, ival)
   print '(a,i0)', '   return status = ', status
   print '(a,i0)', '   return value = ', ival

   print *, 'End program.'
end program test

Compile command:

gfortran -g -fcheck=all -I/opt/local/include -L/opt/local/lib -lnetcdff test.get-att.f90

Complete contents of input file, via ncdump:

mac56:~/bugs/netcdf/get-att.4.4 227> ncdump test.nc
netcdf test {
dimensions:
	time = 3 ;
variables:
	short olr(time) ;
		olr:missing_value = 99s ;
data:

 olr = 10, 20, 30 ;
}

Console output of test program:

mac56:~/bugs/netcdf/get-att.4.4 225> ./a.out
 Netcdf-C version = 4.3.3.1 of Mar  9 2015 07:31:25 $
 Call nf90_open.
   Input file = test.nc
   return status = 0
 Call nf90_inq_varid "olr"
   return status = 0
   varid for "olr" = 1
 Call nf90_get_att for missing_value

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x104484fbc
#1  0x1044854df
#2  0x7fff8f666f19
Segmentation fault

Attachments (1)

test.nc (120 bytes) - added by Dave-Allured (Dave Allured) 10 years ago.
Netcdf test input file

Download all attachments as: .zip

Change History (10)

Changed 10 years ago by Dave-Allured (Dave Allured)

Attachment: test.nc added

Netcdf test input file

comment:1 Changed 10 years ago by Dave-Allured (Dave Allured)

Cc: dave.allured@… added

Cc Me!

comment:2 Changed 10 years ago by basmac

This problem does not occur when clang35 variant is used to build netcdf and netcdf-fortran

comment:3 Changed 10 years ago by mf2k (Frank Schima)

Cc: dave.allured@… removed
Keywords: netcdf netcdf-fortran nf90_get_att nf_get_att nf_get_att_int removed
Owner: changed from macports-tickets@… to takeshi@…
Port: 4.4.2 removed

In the future, please Cc the port maintainers (port info --maintainers netcdf-fortran), if any. As reporter, you do not need to Cc yourself.

comment:4 in reply to:  3 Changed 10 years ago by Dave-Allured (Dave Allured)

mf2k, Thank you for your guidance. I searched excessively for guidance on how to create a new ticket. Where was any of this presented in Mac Ports documentation? Why did you remove my keywords? Why did you remove the port version number?

comment:5 Changed 10 years ago by mf2k (Frank Schima)

There is a big red link at the top of the new ticket page with guidelines. The ticket wiki page notes proper keywords that are useful, but also see DraftKeywordGuidelines. The port version is not relevant for the port field. The version of the port should be in the description as you correctly noted.

comment:6 in reply to:  5 Changed 10 years ago by Dave-Allured (Dave Allured)

mf2k, you are right, I failed to read to the bottom of 7.1.2 in the guidelines, which answers most of my questions. Sorry for the outburst.

comment:7 Changed 5 years ago by Dave-Allured (Dave Allured)

Owner: changed from tenomoto to Dave-Allured
Status: newassigned

comment:8 Changed 4 years ago by Dave-Allured (Dave Allured)

Problem cause unknown. Fix unknown. Recent versions work fine for me now.

Please close this ticket.

comment:9 Changed 4 years ago by mf2k (Frank Schima)

Resolution: worksforme
Status: assignedclosed
Note: See TracTickets for help on using tickets.