@@ -797,6 +797,9 @@ int cdl_hdr_inq_format(int hid,
797797 if (hid >= NC_MAX_NFILES || cdl_filelist [hid ] == NULL )
798798 return NC_EBADID ;
799799
800+ if (format == NULL )
801+ return NC_NOERR ;
802+
800803 header = cdl_filelist [hid ];
801804
802805 * format = header -> format ;
@@ -814,6 +817,9 @@ int cdl_hdr_inq_ndims(int hid,
814817 if (hid >= NC_MAX_NFILES || cdl_filelist [hid ] == NULL )
815818 return NC_EBADID ;
816819
820+ if (ndims == NULL )
821+ return NC_NOERR ;
822+
817823 header = cdl_filelist [hid ];
818824
819825 * ndims = header -> dims .nelems ;
@@ -998,7 +1004,7 @@ int main(int argc, char **argv)
9981004 if (err != NC_NOERR ) exit (1 );
9991005 printf ("Input CDF file : %s\n" , argv [1 ]);
10001006
1001- /* retrieve the input file in CDL format */
1007+ /* retrieve file format information of the input file */
10021008 err = cdl_hdr_inq_format (hid , & format ); ERR
10031009 printf ("CDF file format: CDF-%d\n" , format );
10041010
@@ -1020,7 +1026,7 @@ int main(int argc, char **argv)
10201026 for (i = 0 ; i < nvars ; i ++ ) {
10211027 err = cdl_hdr_inq_var (hid , i , & name , & xtype , & ndims , & dimids ); ERR
10221028
1023- /* retrieve variable i's attributes */
1029+ /* retrieve the number of attributes associated with variable i */
10241030 err = cdl_hdr_inq_nattrs (hid , i , & nattrs ); ERR
10251031
10261032 printf ("\t name %s type %d ndims %d nattr %d\n" ,
@@ -1029,6 +1035,7 @@ int main(int argc, char **argv)
10291035 printf ("\t\tdimid %d\n" ,dimids [j ]);
10301036
10311037 for (j = 0 ; j < nattrs ; j ++ ) {
1038+ /* retrieve metadata of attribute j associated with variable j */
10321039 err = cdl_hdr_inq_attr (hid , i , j , & name , & xtype , & nelems , & value );
10331040 ERR
10341041 if (xtype == NC_CHAR )
@@ -1040,12 +1047,13 @@ int main(int argc, char **argv)
10401047 }
10411048 }
10421049
1043- /* retrieve metadata of global attributes */
1050+ /* retrieve the number of global attributes */
10441051 err = cdl_hdr_inq_nattrs (hid , NC_GLOBAL , & nattrs ); ERR
10451052#ifdef TEST_RUN
10461053 printf ("global attrs : nattrs %d \n ", nattrs );
10471054#endif
10481055
1056+ /* retrieve metadata of each global attribute */
10491057 for (i = 0 ; i < nattrs ; i + + ) {
10501058 err = cdl_hdr_inq_attr (hid , NC_GLOBAL , i , & name , & xtype , & nelems , & value );
10511059 ERR
0 commit comments