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.

[netcdfgroup] read array of strings with f90

  • To: netcdfgroup@xxxxxxxxxxxxxxxx
  • Subject: [netcdfgroup] read array of strings with f90
  • From: M P <mzp3769@xxxxxxxxx>
  • Date: Mon, 10 Oct 2022 19:52:30 -0600
  • Authentication-results: vscanx3.ucar.edu; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=csDyuqvf
  • Authentication-results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=csDyuqvf; spf=pass (google.com: domain of mzp3769@xxxxxxxxx designates 209.85.220.41 as permitted sender) smtp.mailfrom=mzp3769@xxxxxxxxx; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Hello,
Is it possible to read an array of strings (constant length) in fortran?
Below are specifics. Comments/help much appreciated - thanks.
Mark

netcdf file:
....

        int nlocs(nlocs) ;
                nlocs:suggested_chunk_dim = 429LL ;
....
group: MetaData {
  variables:
        string datetime(nlocs) ;
                string datetime:_FillValue = "" ;
                string datetime:units = "" ;


ncdump -v  datetime file.nc
.......
  datetime = "2021-09-30T23:02:25Z", "2021-09-30T23:07:25Z",
      "2021-09-30T23:09:23Z", "2021-09-30T23:17:25Z",
"2021-09-30T23:19:22Z",
.......

f90 code:
.......
INTEGER, PARAMETER :: date_string_length=20
CHARACTER(len=date_string_length), ALLOCATABLE :: aertimestr(:)
.......

CALL check_nc(nf90_inq_grp_ncid(ncid,"MetaData",grpid))
CALL check_nc(nf90_inq_varid(grpid,"datetime",varid))
CALL check_nc(nf90_get_var(grpid,varid,aertimestr))

.......
Error:
NetCDF: Attempt to convert between text & numbers