OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
HDF_Lib.c File Reference
#include "HDF_Lib.h"
#include "PGS_Error_Codes.h"
#include <math.h>
#include <stdlib.h>
Include dependency graph for HDF_Lib.c:

Go to the source code of this file.

Macros

#define MAXRANK   7
 
#define ASSIGN_INT_VALUE(aptr, a, alb, aub, type_of_data)
 
#define CHECK_IVALS_ON_LB
 
#define CHECK_FVALS_ON_LB
 
#define CHECK_IVALS_ON_UB
 
#define CHECK_FVALS_ON_UB
 

Functions

PGSt_SMF_status read_attribute (int32 s_id, char *attr_name, int32 TypeID, void *buffer)
 
PGSt_SMF_status read_part_sds_rank2 (int32 sd_id, char *sds_name, int32 start0, int32 start1, int32 edge0, int32 edge1, void *data)
 
PGSt_SMF_status read_part_sds_rank3 (int32 sd_id, char *sds_name, int32 start0, int32 start1, int32 start2, int32 edge0, int32 edge1, int32 edge2, void *data)
 
PGSt_SMF_status read_sds_rank1 (int32 file_id, char *sds_name, int32 dim, void *data)
 
PGSt_SMF_status read_sds_rank2 (int32 file_id, char *sds_name, int32 dim1, int32 dim2, void *data)
 
PGSt_SMF_status read_sds_rank3 (int32 file_id, char *sds_name, int32 dim1, int32 dim2, int32 dim3, void *data)
 
PGSt_SMF_status read_sds_rank4 (int32 file_id, char *sds_name, int32 dim1, int32 dim2, int32 dim3, int32 dim4, void *data)
 
PGSt_SMF_status read_vdata (int32 v_id, int32 start_record, int32 records, char *vname, char *fname, void *buffer)
 
PGSt_SMF_status write_sds_rank1 (int32 file_id, char *sds_name, char *dim_name, int32 dim, char *datatype, void *data)
 
PGSt_SMF_status write_sds_rank2 (int32 file_id, char *sds_name, char *dim_name1, char *dim_name2, int32 dim1, int32 dim2, char *datatype, void *data)
 
PGSt_SMF_status write_sds_rank3 (int32 file_id, char *sds_name, char *dim_name1, char *dim_name2, char *dim_name3, int32 dim1, int32 dim2, int32 dim3, char *datatype, void *data)
 
PGSt_SMF_status write_sds_rank4 (int32 file_id, char *sds_name, char *dim_name1, char *dim_name2, char *dim_name3, char *dim_name4, int32 dim1, int32 dim2, int32 dim3, int32 dim4, char *datatype, void *data)
 
PGSt_SMF_status read_sds_rankn (int32 sd_id, char *sds_name, int32 data_type, int32 rank, int32 *start, int32 *edge, void *data)
 
PGSt_SMF_status write_sds_rankn (int32 file_id, char *sds_name, int32 data_type, int32 rank, int32 *edge, char **dim_name, void *data)
 
PGSt_SMF_status Check_Valid_Range (char *data_name, int32 data_type, char *a_lb, char *a_ub, char *a_fillvalue, int32 count, void *buffer)
 

Variables

char * invalidinputfile
 
char * corruptinputfile
 

Macro Definition Documentation

◆ ASSIGN_INT_VALUE

#define ASSIGN_INT_VALUE (   aptr,
  a,
  alb,
  aub,
  type_of_data 
)
Value:
i = atol(aptr); \
if (i < (int32) alb || i > (int32) aub) { \
errcode = MODIS_F_NOK; \
sprintf(errmsgbuf, \
"Checking valid range of \"%s\", the value \"%s\" is not\n" \
"a valid number for the precision of the data type.", \
data_name, aptr); \
L1BErrorMsg("Check_Valid_Range", errcode, errmsgbuf, NULL, 0, \
"Code defect.", False); \
return errcode; \
} \
else \
{ \
switch (type_of_data) \
{ case DFNT_INT8: a = (int8) i; break; \
case DFNT_UINT8: a = (uint8) i; break; \
case DFNT_INT16: a = (int16) i; break; \
case DFNT_UINT16: a = (uint16) i; break; \
case DFNT_INT32: a = (int32) i; break; \
case DFNT_UINT32: a = (uint32) i; \
} \
}

◆ CHECK_FVALS_ON_LB

#define CHECK_FVALS_ON_LB
Value:
for (i = 0; i < count; i++) { \
absd = fabs((double) data[i]); absdfv = fabs((double)fillvalue); \
del = fabs((double) (data[i] - fillvalue)); \
if (absd > 0) del /= absd; else if(absdfv > 0) del /= absdfv; \
if (data[i] < lb && del > 1.e-05) { \
errcode = MODIS_F_OUT_OF_RANGE; \
sprintf(errmsgbuf, \
"One or more values of \"%s\" is less than the lower bound.\n" \
"value[%ld] = %f\nlower bnd = %s\n", \
data_name, i, (double) data[i], a_lb); \
L1BErrorMsg("Check_Valid_Range", errcode, errmsgbuf, NULL, 0, \
return errcode; \
} \
}

◆ CHECK_FVALS_ON_UB

#define CHECK_FVALS_ON_UB
Value:
for (i = 0; i < count; i++) { \
absd = fabs((double) data[i]); absdfv = fabs((double)fillvalue); \
del = fabs((double) (data[i] - fillvalue)); \
if (absd > 0) del /= absd; else if(absdfv > 0) del /= absdfv; \
if (data[i] > ub && del > 1.e-05) { \
errcode = MODIS_F_OUT_OF_RANGE; \
sprintf(errmsgbuf, \
"One or more values of \"%s\" is greater than the upper bound.\n" \
"value[%ld] = %f\nupper bnd = %s\n", \
data_name, i, (double) data[i], a_ub); \
L1BErrorMsg("Check_Valid_Range", errcode, errmsgbuf, NULL, 0, \
return errcode; \
} \
}

◆ CHECK_IVALS_ON_LB

#define CHECK_IVALS_ON_LB
Value:
for (i = 0; i < count; i++) { \
if (data[i] < lb && data[i] != fillvalue) { \
errcode = MODIS_F_OUT_OF_RANGE; \
sprintf(errmsgbuf, \
"One or more values of \"%s\" is less than the lower bound.\n" \
"value[%ld] = %ld\nlower bnd = %s\n", \
data_name, i, (long) data[i], a_lb); \
L1BErrorMsg("Check_Valid_Range", errcode, errmsgbuf, NULL, 0, \
return errcode; \
} \
}

◆ CHECK_IVALS_ON_UB

#define CHECK_IVALS_ON_UB
Value:
for (i = 0; i < count; i++) { \
if (data[i] > ub && data[i] != fillvalue) { \
errcode = MODIS_F_OUT_OF_RANGE; \
sprintf(errmsgbuf, \
"One or more values of \"%s\" is greater than the upper bound.\n" \
"value[%ld] = %ld\nupper bnd = %s\n", \
data_name, i, (long) data[i], a_ub); \
L1BErrorMsg("Check_Valid_Range", errcode, errmsgbuf, NULL, 0, \
return errcode; \
} \
}

◆ MAXRANK

#define MAXRANK   7

Function Documentation

◆ Check_Valid_Range()

PGSt_SMF_status Check_Valid_Range ( char *  data_name,
int32  data_type,
char *  a_lb,
char *  a_ub,
char *  a_fillvalue,
int32  count,
void *  buffer 
)

Definition at line 1782 of file HDF_Lib.c.

◆ read_attribute()

PGSt_SMF_status read_attribute ( int32  s_id,
char *  attr_name,
int32  TypeID,
void *  buffer 
)

Definition at line 33 of file HDF_Lib.c.

◆ read_part_sds_rank2()

PGSt_SMF_status read_part_sds_rank2 ( int32  sd_id,
char *  sds_name,
int32  start0,
int32  start1,
int32  edge0,
int32  edge1,
void *  data 
)

Definition at line 150 of file HDF_Lib.c.

◆ read_part_sds_rank3()

PGSt_SMF_status read_part_sds_rank3 ( int32  sd_id,
char *  sds_name,
int32  start0,
int32  start1,
int32  start2,
int32  edge0,
int32  edge1,
int32  edge2,
void *  data 
)

Definition at line 249 of file HDF_Lib.c.

◆ read_sds_rank1()

PGSt_SMF_status read_sds_rank1 ( int32  file_id,
char *  sds_name,
int32  dim,
void *  data 
)

Definition at line 359 of file HDF_Lib.c.

◆ read_sds_rank2()

PGSt_SMF_status read_sds_rank2 ( int32  file_id,
char *  sds_name,
int32  dim1,
int32  dim2,
void *  data 
)

Definition at line 449 of file HDF_Lib.c.

◆ read_sds_rank3()

PGSt_SMF_status read_sds_rank3 ( int32  file_id,
char *  sds_name,
int32  dim1,
int32  dim2,
int32  dim3,
void *  data 
)

Definition at line 546 of file HDF_Lib.c.

◆ read_sds_rank4()

PGSt_SMF_status read_sds_rank4 ( int32  file_id,
char *  sds_name,
int32  dim1,
int32  dim2,
int32  dim3,
int32  dim4,
void *  data 
)

Definition at line 644 of file HDF_Lib.c.

◆ read_sds_rankn()

PGSt_SMF_status read_sds_rankn ( int32  sd_id,
char *  sds_name,
int32  data_type,
int32  rank,
int32 *  start,
int32 *  edge,
void *  data 
)

Definition at line 1478 of file HDF_Lib.c.

◆ read_vdata()

PGSt_SMF_status read_vdata ( int32  v_id,
int32  start_record,
int32  records,
char *  vname,
char *  fname,
void *  buffer 
)

Definition at line 748 of file HDF_Lib.c.

◆ write_sds_rank1()

PGSt_SMF_status write_sds_rank1 ( int32  file_id,
char *  sds_name,
char *  dim_name,
int32  dim,
char *  datatype,
void *  data 
)

Definition at line 944 of file HDF_Lib.c.

◆ write_sds_rank2()

PGSt_SMF_status write_sds_rank2 ( int32  file_id,
char *  sds_name,
char *  dim_name1,
char *  dim_name2,
int32  dim1,
int32  dim2,
char *  datatype,
void *  data 
)

Definition at line 1062 of file HDF_Lib.c.

◆ write_sds_rank3()

PGSt_SMF_status write_sds_rank3 ( int32  file_id,
char *  sds_name,
char *  dim_name1,
char *  dim_name2,
char *  dim_name3,
int32  dim1,
int32  dim2,
int32  dim3,
char *  datatype,
void *  data 
)

Definition at line 1192 of file HDF_Lib.c.

◆ write_sds_rank4()

PGSt_SMF_status write_sds_rank4 ( int32  file_id,
char *  sds_name,
char *  dim_name1,
char *  dim_name2,
char *  dim_name3,
char *  dim_name4,
int32  dim1,
int32  dim2,
int32  dim3,
int32  dim4,
char *  datatype,
void *  data 
)

Definition at line 1329 of file HDF_Lib.c.

◆ write_sds_rankn()

PGSt_SMF_status write_sds_rankn ( int32  file_id,
char *  sds_name,
int32  data_type,
int32  rank,
int32 *  edge,
char **  dim_name,
void *  data 
)

Definition at line 1648 of file HDF_Lib.c.

Variable Documentation

◆ corruptinputfile

char* corruptinputfile
Initial value:
= "Operationally, this should never occur.\n"
"The file may be incomplete or corrupted."

Definition at line 20 of file HDF_Lib.c.

◆ invalidinputfile

char* invalidinputfile
Initial value:
= "This is most likely due to an invalid file.\n"
"(does not meet file specs or is corrupted)"

Definition at line 18 of file HDF_Lib.c.

integer, parameter int16
Definition: cubeio.f90:3
char * invalidinputfile
Definition: HDF_Lib.c:18
#define NULL
Definition: decode_rs.h:63
#define MODIS_F_OUT_OF_RANGE
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT32
character(len=1000) if
Definition: names.f90:13
HDF4 data type of the output SDS Default is DFNT_FLOAT32 Common types used DFNT_INT16
#define MODIS_F_NOK
no change in intended resolving MODur00064 Corrected handling of bad ephemeris attitude data
Definition: HISTORY.txt:356
#define fabs(a)
Definition: misc.h:93
int i
Definition: decode_rs.h:71
PGE01 indicating that PGE02 PGE01 V6 for and PGE01 V2 for MOD03 were used to produce the granule By convention adopted in all MODIS Terra PGE02 code versions are The fourth digit of the PGE02 version denotes the LUT version used to produce the granule The source of the metadata environment variable ProcessingCenter was changed from a QA LUT value to the Process Configuration A sign used in error in the second order term was changed to a
Definition: HISTORY.txt:424
#define False
Definition: Granule.h:538
int count
Definition: decode_rs.h:79