Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran 90 and Netcdf

Status
Not open for further replies.

SuOraiste

Programmer
Sep 23, 2011
5
Hi

I'm trying to read a netcdf but keep encountereing the same error, segmentation fault!

My code follows the netcdf manual. Here is it:

PROGRAM nc

USE netcdf

IMPLICIT NONE

INTEGER :: stat,id


stat=nf90_open(path="TestNetcdf2.nc",mode=nf90_write,ncid=id)
stat=nf90_close(id)


END PROGRAM nc

Then I start it with a shellscript with the following code

gfortran -ffixed-line-length-none -Wall -o netcdf.x netcdf.f $I $L -lnetcdff

./netcdf.x


The $I, $L being variables to the netcdf include and lib directories respectively.


Does anyone can help me why this doesn't work?

Thanks



 
I did not get it...

...are you having problems compiling the program in the first place?

or

...are you having problems running the program?

Provide error messages, warning, feedback, etc.

Also, it is not clear to me if you are trying to read an existing netcdf file or trying to write a new one...you say 'read' in the first line of your post; but, then, you open the file with 'write'...which would clean up an existing file!
 
The error only occurs when running the program! It compiles fine.


I'm trying to read an already existing file.
I also tried "mode=nf90_nowrite" but with the same result.
This shouldn't be the error sonce it only says if you want to read and write to the file or only read.

The netcdf libraries are also installed correct, since I have other programms who use them and they work fine.

SuOraiste

 
you did not post a sample attempt to run the file and resulting error message
 
just googled for netcdf documentation...I found that you either compiled just with " -lnetcdf" or, if needed, you compiled with with both " -lnetcdff -lnetcdf"

so, I think your compile command is incorrect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top