This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Arjen, > Here is an illustration of the problem I mentioned. Since the time variable > in my program is a scalar value that is to be written during the simulation, > I thought this code should work - start is required to get the right record > and count is merely there for the symmetry with writing the actual model > result: > > module my_routines > use netcdf > > implicit none > > contains > subroutine write_scalar( ncid, varid, scalar ) > integer :: ncid, varid > real :: scalar > > integer :: ierror > integer, dimension(1) :: start > integer, dimension(1) :: count > > start = 1 > ierror = nf90_put_var( ncid, varid, scalar, start = start, count = count ) > end subroutine write_scalar > > end module my_routines > > This however gives the following error message: > > > D:\delft3d-netcdf>ifort -c netcdf_interface_problem.f90 -I.\netcdf > Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on > Intel(R) 64, Version 15.0.1.148 Build 20141023 > Copyright (C) 1985-2014 Intel Corporation. All rights reserved. > > netcdf_interface_problem.f90(20): error #6284: There is no matching specific > function for this generic function reference. [NF90_PUT_VAR] > ierror = nf90_put_var( ncid, varid, scalar, start = start, count = count ) > -------------^ > compilation aborted for netcdf_interface_problem.f90 (code 1) > > Curiously enough, leaving out the count= argument makes the compiler message > go away. > > I am not sure if this is intended before - one could use the start+count > arguments to write a single value into an array, after all, but this is the > problem I ran into. It was easily fixed of course. Yes, I see. The intention was that neither start nor count arguments should be used for a scalar, as illustrated in the test example. The start value has a default of 1, but the default for count involves the size(shape(values)), which is not defined for a scalar value. I'll modify the documentation to say that the otherwise optional start and count arguments should be omitted for scalar values. --Russ > > Although the f90 tutorial examples all write arrays, there's a test case > > (nf_test/f90tst_vars2.f90) in the source distribution that writes a single > > value to a > > scalar variable successfully and later reads the file to check that the > > right value gets > > read in: > > > > call check(nf90_put_var(ncid, varid3, TOE_SAN_VALUE)) > > ... > > call check(nf90_get_var(ncid, varid3_in, toe_san_in)) > > if (toe_san_in .ne. TOE_SAN_VALUE) stop 14 > > > > If you came up with an example scalar write that fails, we'd like to use it > > to debug the > > problem. > > > > DISCLAIMER: This message is intended exclusively for the addressee(s) and may > contain confidential and privileged information. If you are not the intended > recipient please notify the sender immediately and destroy this message. > Unauthorized use, disclosure or copying of this message is strictly > prohibited. The foundation 'Stichting Deltares', which has its seat at Delft, > The Netherlands, Commercial Registration Number 41146461, is not liable in > any way whatsoever for consequences and/or damages resulting from the > improper, incomplete and untimely dispatch, receipt and/or content of this > e-mail . > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: YJQ-627045 Department: Support netCDF Priority: Normal Status: Closed