PSyclone icon indicating copy to clipboard operation
PSyclone copied to clipboard

[PSyData] Check dimension in driver

Open hiker opened this issue 2 years ago • 0 comments

At the moment it is possible to read in a 4-d variable using a 2-d array (the NetCDF read code will ignore that there are sizes for dimensions 3 and 4 specified) ... not even sure what exactly happens in this case :)

The following patch should detect this inconsistency (which would be caused by bug creating the driver):

~/work/psyclone/lib/extract/netcdf$ git diff extract_netcdf_base.jinja
diff --git a/lib/extract/netcdf/extract_netcdf_base.jinja b/lib/extract/netcdf/extract_netcdf_base.jinja
index f53577e7e..675b124e3 100644
--- a/lib/extract/netcdf/extract_netcdf_base.jinja
+++ b/lib/extract/netcdf/extract_netcdf_base.jinja
@@ -524,8 +524,14 @@ contains
         retval = CheckError(nf90_inquire_dimension(this%ncid, dim_id, &
                                                    len=dim_size{{i}}))
         {% endfor %}
+        retval = nf90_inq_dimid(this%ncid, trim(name//"dim%{{dim+1}}"), &
+                                           dim_id)
+        if (retval == nf90_noerr) then
+        print *,"RETVAL for ",name,{{dim+1}}," is", retval
+        endif
 
         ! Allocate enough space to store the values to be read:
        allocate(value({{dim_sizes}}), Stat=ierr)
         if (ierr /= 0) then
             write(stderr,*) "Cannot allocate array for ", name, &

hiker avatar Jun 01 '22 06:06 hiker