LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-05-2012, 09:00 PM   #1
AQmodeller
LQ Newbie
 
Registered: Sep 2012
Posts: 1

Rep: Reputation: Disabled
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!
 
Old 10-06-2012, 03:22 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Write access to a iso9660 filesystem..mount a .iso image as read write ceazar123 Linux - Newbie 16 09-01-2010 09:07 AM
Read Write access to a iso9660 filesystem..mount a .iso image as read write ceazar123 Linux - General 2 08-26-2010 03:32 PM
problem of install netcdf with intel fortran on CENTOS xianghu Linux - Software 8 07-29-2010 05:34 AM
Bash: read/write the interface? J_Szucs Programming 7 06-04-2004 03:09 PM


All times are GMT -5. The time now is 04:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration