Hi Gerald,
When the documentation says that the data to be written "may be of any
type", it means, any fortran90 native type (real, double precision,
integer, etc.) The netcdf library does not know how to write out a derived
type that you create yourself.
My personal advice is that you will save yourself headaches down the line,
and your netcdf files will be more widely compatible with the world of
software already out there, if you avoid netcdf compound types. Some
problems really mandate a compound type, so it's great that they are
available, but it's just limiting the usefulness of your files if you use
compound types gratuitously. I.e., if you're writing a velocity field, just
write U and V fields rather than making a compound type that has U and V
components.
If you do absolutely need compound types, the solution would be to write
your own version of nf90_put_var() that would take as the argument your
derived type and write it appropriately into a netcdf compound type using
lower level calls.
Regards,
--Dave
On Tue, Jul 16, 2013 at 10:14 AM, Gérald Mercadier <
Gerald.mercadier@xxxxxxxxxxx> wrote:
> Dear all,****
>
> ** **
>
> I am using netCDF 4.1.3 in a Fortran90 code which is compiled with
> gfortran 4.4.5. I want to use the compound types. I have no problem to
> define a compound type, but I am currently encountering a problem when I
> try to put values into a well-defined compound type. The problem occurs at
> the compilation, when using nf90_put_var. The compilation fails with the
> error “Error: There is no specific function for the generic 'nf90_put_var'
> at (1)”****
>
> ** **
>
> In my code, I have defined a compound type using nf90_def_compound and
> nf90_insert_compound. This type contains variables of int/double/string
> type or another user defined type.****
>
> The definition works well, the .nc file created is correct. Unfortunately,
> the call of nf90_put_var leads to this compilation error. The third
> argument of the routine is “values”, which is the derived type (or
> Fortran90 structure) in my case, containing variables of different types.
> The documentation of nf90_put_var (see
> http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90/NF90_005fPUT_005fVAR.html#NF90_005fPUT_005fVAR)
> says that “the data may be of any type, and may be a scalar or an array of
> any rank”. I just call nf90_put_var with 3 arguments, like this
> “nf90_put_var(ncid, varid, values)”. ****
>
> ** **
>
> I would like to know how put a value of a derived type variable into a
> compound type variable with netCDF, in a Fortran90 code. Can someone help
> me please ? ****
>
> Thank you for your help !****
>
> ** **
>
> ** **
>
> [image: Description : Description : Description :
> cid:image001.png@01CD94BC.12226960] <http://www.noveltis.com/>****
>
> 153, rue du Lac****
>
> F-31670 LABEGE****
>
> Tel : +33 (0)5.62.88.11.28****
>
> Fax : +33 (0)5.62.88.11.12****
>
> www.noveltis.com****
>
> ** **
>
> ** **
>
> *Merci de considérer toutes les informations contenues dans cet email
> comme confidentielles. **Vous ne devez pas les transmettre sans
> autorisation. Si ce mail ne vous est pas destiné, merci de le signaler à
> l’expéditeur et de l’effacer de votre système. *
>
> *Please, consider email information as confidential. **Do not transfer
> without prior authorization. If this email is not intended for you, thank
> you to notify the sender and to delete this message from your computer.*
>
> ** **
>
> *Agissons au quotidien pour préserver notre environnement. **N’imprimez
> ce courrier et les documents joints que si nécessaire.***
>
> ** **
>
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
>
--
David W. Pierce
Division of Climate, Atmospheric Science, and Physical Oceanography
Scripps Institution of Oceanography, La Jolla, California, USA
(858) 534-8276 (voice) / (858) 534-8561 (fax) dpierce@xxxxxxxx