/*--creadpathP  ----------------------------------------------------------------
  This function retrieves meta data and scientific data sets from a HDF
  formatted pathP data set

  input:
          hdf_file -  Name of HDF formatted pathP data file
  output:
          See data dictionary and documentation for description of
          variables TBD
 ------------------------------------------------------------------------------*/
# include <hdf.h>
# include <mfhdf.h>
# include <stdio.h>

int32 creadpathP(char *hdf_file, char *project, char *dataset_name,
		char *source_name, char *processing_level,char *reference_date,
		char *start_date,char *stop_date, char *position_type,
		char *grid_type,char *grid_name,char *projection,
		float32 *lat,float32 *lon,char *Temporal_Res,
		char *Spatial_X_Res,char *Spatial_Y_Res, float32 **latgrid,
		float32 **longrid, float32 ***temp,float32 ***wvapor,
		float32 **sktemp,float32 **fcld,float32 **clpress,
		float **cltemp, float32 **zangle,float32 **emiss,
		float32 **pbl_strat,float32 **Cd, float32 **alpha,
		int32 **obs, int32 **IIIreject,float32 ***temp_sd,
		float32 ***wvapor_sd,float32 **sktemp_sd,float32 **fcld_sd,
		float32 **clpress_sd,float **cltemp_sd, float32 **zangle_sd,
		float32 **emiss_sd,float32 **pbl_strat_sd,float32 **Cd_sd,
		float32 **alpha_sd)
{

/*internal variables */

  char attribute_name[256],sd_name[256];

  int32 attribute_index,number_type,n_elements,n_global_attributes,
        n_datasets,sds_id,sd_index,dimsizes[3],rank,ret,hdf_id,n_attributes;

  int32 start[3]={0,0,0};
  int32 error;

 /* check if input file is indeed an file in hdf format */

  if (!Hishdf(hdf_file)) {
   fprintf(stderr,"Input file is not an hdf file: %s\n",hdf_file);
   exit(1);
 }

/* open file */

  hdf_id = SDstart(hdf_file,DFACC_RDONLY);
/* obtain names of global attributes, those that apply to the entire file.
   Examples are start_date,stop_date, etc.
*/

  SDfileinfo(hdf_id,&n_datasets,&n_global_attributes);

/* retrieve global file attributes */

  if (n_global_attributes > 0) {

    strcpy(attribute_name,"PROJECT");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) project);
    project[n_elements]='\0';

    strcpy(attribute_name,"DATASET_NAME");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) dataset_name);
    dataset_name[n_elements]='\0';

    strcpy(attribute_name,"SOURCE_NAME");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) source_name);
    source_name[n_elements]='\0';

    strcpy(attribute_name,"PROCESSING_LEVEL");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) processing_level);
    processing_level[n_elements]='\0';

    strcpy(attribute_name,"REFERENCE_DATE");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) reference_date );

    strcpy(attribute_name,"START_DATE");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) start_date);
    start_date[n_elements]='\0';


    strcpy(attribute_name,"STOP_DATE");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) stop_date);
    stop_date[n_elements]='\0';

    strcpy(attribute_name,"POSITION_TYPE");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) position_type);
    position_type[n_elements]='\0';

    strcpy(attribute_name,"GRID_TYPE");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) grid_type);
    grid_type[n_elements]='\0';

    strcpy(attribute_name,"GRID_NAME");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) grid_name);
    grid_name[n_elements]='\0';

    strcpy(attribute_name,"PROJECTION");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) projection);
    grid_type[n_elements]='\0';
/*
    strcpy(attribute_name,"EASE_GPD");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) ease_gpd);
    grid_type[n_elements]='\0';

    strcpy(attribute_name,"EASE_MPP");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) ease_mpp);
    grid_type[n_elements]='\0';
*/
    strcpy(attribute_name,"LATITUDE");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) lat);

    strcpy(attribute_name,"LONGITUDE");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) lon);

    strcpy(attribute_name,"Temporal_Res");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);

    SDreadattr(hdf_id,attribute_index, (VOIDP) Temporal_Res);
    Temporal_Res[n_elements]='\0';

    strcpy(attribute_name,"Spatial_X_Res");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);

    SDreadattr(hdf_id,attribute_index, (VOIDP) Spatial_X_Res);
    Spatial_X_Res[n_elements]='\0';

    strcpy(attribute_name,"Spatial_Y_Res");
    attribute_index=SDfindattr(hdf_id,attribute_name);
    SDattrinfo(hdf_id,attribute_index,attribute_name,
	       &number_type,&n_elements);
    SDreadattr(hdf_id,attribute_index, (VOIDP) Spatial_Y_Res);
    Spatial_Y_Res[n_elements]='\0';
  }

/*
  Now we obtain all the Scientific Data sets we are interested in

*/

  if (n_datasets > 0) {

     strcpy(sd_name,"LATITUDE_GRID");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
     }

     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) latgrid);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     strcpy(sd_name,"LONGITUDE_GRID");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
     }

     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) longrid);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
/* Atmospheric Temperature 9-layers TMP */

     strcpy(sd_name,"TEMP");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) temp);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Water vapor (5 layers) WVAPOR */

     strcpy(sd_name,"WVAPOR");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) wvapor);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Surface Skin Temperature */

     strcpy(sd_name,"SKTEMP");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) sktemp);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Effective Cloud Fraction FCLD */

     strcpy(sd_name,"FCLD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) fcld);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Cloud Top Pressuire CLPRESS */

     strcpy(sd_name,"CLPRESS");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) clpress);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Cloud Top Temperature cltemp */

     strcpy(sd_name,"CLTEMP");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) cltemp);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }


/* Average Zenith Angle ZANGLE */

     strcpy(sd_name,"ZANGLE");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) zangle);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Surface Emissivity EMISS */

     strcpy(sd_name,"EMISS");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) emiss);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Stratification parameter PBLSTRAT */

     strcpy(sd_name,"PBLSTRAT");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) pbl_strat);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Drag coeeficient "Cd" */

     strcpy(sd_name,"Cg");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) Cd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Turning angle ALPHA */

     strcpy(sd_name,"ALPHA");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) alpha);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* now obtain the standard deviations for the above prarmeters */

     strcpy(sd_name,"TEMP-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) temp_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Water vapor (5 layers) WVAPOR */

     strcpy(sd_name,"WVAPOR-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) wvapor_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Surface Skin Temperature */

     strcpy(sd_name,"SKTEMP-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) sktemp_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Effective Cloud Fraction FCLD */

     strcpy(sd_name,"FCLD-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) fcld_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Cloud Top Pressuire CLPRESS */

     strcpy(sd_name,"CLPRESS-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) clpress_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Cloud Top Temperature cltemp */

     strcpy(sd_name,"CLTEMP-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) cltemp_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }


/* Average Zenith Angle ZANGLE */

     strcpy(sd_name,"ZANGLE-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) zangle_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Surface Emissivity EMISS */

     strcpy(sd_name,"EMISS-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) emiss_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Stratification parameter PBLSTRAT */

     strcpy(sd_name,"PBLSTRAT-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) pbl_strat_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* Drag coeeficient "Cg" */

     strcpy(sd_name,"Cg-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) Cd_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

     strcpy(sd_name,"ALPHA-SD");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) alpha_sd);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }

/* a few statistics */

     strcpy(sd_name,"IIIreject");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) IIIreject);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     strcpy(sd_name,"OBS");
     sd_index = SDnametoindex(hdf_id,sd_name);
     sds_id = SDselect(hdf_id, sd_index);
     ret = SDgetinfo(sds_id, sd_name, &rank,dimsizes, &number_type,
&n_attributes);
     if (ret < 0) {
       fprintf(stderr,"Error getting info on SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
     ret = SDreaddata(sds_id, start, NULL, dimsizes, (VOIDP) obs);
     if (ret < 0) {
       fprintf(stderr,"Error reading  SDS: %s\n", sd_name);
       HEprint(stderr,0);
       error++;
     }
   }
  if (error==0)
    return(0);
  else
    return(-1);
}












