NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdfgroup] Fortran90 interface

Karsten Bolding wrote:
Hi Dave

On Tue, Mar 31, 2009 at 11:06:09 -0600, Dave Allured wrote:
Karsten,

That function has five arguments. Your function call has six arguments. I believe this will cause that exact error message.

You are right I should have checked that.

I actually find it a pitty that there is a difference between the F77
and F90 argument list for this function.

I used to allocate and array like:
integer :: dims(4)

that could be re-used like:
dims(1) = lon_dim
iret = nf_def_var(ncid,'lon',NF_REAL,1,dims,lon_id)

dims(1) = lon_dim
dims(2) = lat_dim
dims(3) = time_dim
iret = nf_def_var(ncid,'sst',NF_REAL,3,dims, sst_id)
call check_err(iret)

i.e. the number of dimensiosn for a specific variable is given
explicitly and not determined by the size of the dimids vector.

Instead I now have to do like:
integer :: dims_3(3)
integer :: dims_4(4)

Well, if you still want to use the f77 interface, why not do,

 integer :: dims(4), n_dims

 n_dims = 1
 dims(1) = lon_dim
 iret = nf_def_var(ncid,'lon',NF_REAL,n_dims,dims(1:n_dims),lon_id)

 n_dims = 3
 dims(1) = lon_dim
 dims(2) = lat_dim
 dims(3) = time_dim
 iret = nf_def_var(ncid,'sst',NF_REAL,n_dims,dims(1:n_dims), sst_id)

?

Does that classify as reuse? I would prefer the latter style anyway since the code is more "self-documenting". Overall the f90 interface is superior since it does away with the need for the redundant "n_dims" argument,

 integer :: dims(4), n_dims

 n_dims = 1
 dims(1) = lon_dim
 iret = nf90_def_var(ncid,'lon',NF90_FLOAT,dims(1:n_dims),lon_id)

 n_dims = 3
 dims(1) = lon_dim
 dims(2) = lat_dim
 dims(3) = time_dim
 iret = nf90_def_var(ncid,'sst',NF90_FLOAT,dims(1:n_dims), sst_id)


But, in the end, it's the same dog just a different leg, right? :o)

cheers,

paulv



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: