[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #XMB-518408]: Definition of a scalar variable in netCDF-Fortran



Hello,

Thanks for reaching out; it is strange that this worked, and then didn't (with 
the updated compiler). I would have hoped it would have not worked from the 
get-go.  I am trying to debug this and see if a solution presents itself; to 
that end, can you tell me what versions of netCDF-C and netCDF-Fortran you are 
working with?

Thanks!

-Ward

> Dear Support-Team,
> 
> in a Fortran code I define a scalar variable in a netCDF file with
> something like
> 
> ...
> integer :: dimids(1)
> status = nf90_def_var(ncid, name, xtype, dimids(:0), varid)
> ...
> 
> 
> This way addresses the second of two possibilities mentioned in the
> Fortran netCDF documentation of nf90_def_var with respect to dimids:
> 
> /If this parameter (dimids) is not passed (or is a 1D array of size
> zero) it means the variable is a scalar with no dimensions./
> 
> My version of passing a 1D array of size zero worked with the Fortran
> compiler version
> 
> /gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)/
> 
> but no longer with a newer version
> 
> /gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)/
> 
> which I understand, since passing something of size zero within Fortran
> usually makes no sense.  (I receive the runtime error message: "/NetCDF:
> Invalid argument/".)
> Therefore, I tried the first option instead, i.e. omitting /dimids/, but
> got the Fortran compiler error message:
> 
> /Error: There is no specific function for the generic ‘nf90_def_var’/
> 
> Again, I understand this message, since in nf90_def_var the optional
> argument /dimids/ is positioned before the positional argument /varid/. 
> However, in my understanding, all positional arguments have to be placed
> before all optional arguments in Fortran subroutines.
> 
> What have I misunderstood?  Do you have a solution for me?
> 
> Thanks in advance and best wishes,
> 
> Peter
> 
> 


Ticket Details
===================
Ticket ID: XMB-518408
Department: Support netCDF
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with NSF Unidata User Support are recorded in the 
Unidata inquiry tracking system and then made publicly available through the 
web.  If you do not want to have your interactions made available in this way, 
you must let us know in each email you send to us.