LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   netCDF Fortran 90 Interface (read/write) (http://www.linuxquestions.org/questions/programming-9/netcdf-fortran-90-interface-read-write-4175430776/)

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("foo.nc", 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)
...

Method2:
! Create the netCDF file.
call check( nf90_create("foo.nc", 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:35 PM.