-   Programming (
-   -   netCDF Fortran 90 Interface (read/write) (

AQmodeller 10-05-2012 10:00 PM

netCDF Fortran 90 Interface (read/write)
Hi All,

Iím new to netCDF and Iíve seen multiple ways to open/read/write etc. netCDF files with Fortran 90. I've tried two methods and they both seem to work, but Iím not sure what the benefits to each method are (ie. why use one method over the other)

Method 1:
use netcdf
implicit none
integer :: ncid, status
status = nf90_create("", nf90_noclobber, ncid)
if (status /= nf90_noerr) call handle_err(status)
status = nf90_enddef(ncid)
if (status /= nf90_noerr) call handle_err(status)
status = nf90_def_dim(ncid, "Lat", 18, LatDimID)
if (status /= nf90_noerr) call handle_err(status)

! Create the netCDF file.
call check( nf90_create("", NF90_CLOBBER, ncid) )

! Define the dimensions.
call check( nf90_def_dim(ncid, "Lat", 18, LatDimID ) )

Thanks in advance!

colucix 10-06-2012 04:22 AM

Hi and welcome to LinuxQuestions!

Actually there is no difference: the subroutine check is exactly the same as the subroutine handle_err. The second one is only a more compact way to execute NetCDF functions and check their exit status: the only difference is in the coding style. But you might do the same with both handle_err and check!

All times are GMT -5. The time now is 07:28 AM.