|
ocssw
1.0
|
00001 #include "L1A_prototype.h" 00002 #include "PGS_SMF.h" 00003 #include "PGS_MODIS_35005.h" 00004 #include "hdf.h" 00005 #include "hdfi.h" 00006 00007 00008 PGSt_SMF_status write_Vdata ( char *Vdata_name, 00009 unsigned char *data, 00010 int32 num_records ) 00011 00012 /* 00013 !C************************************************************************ 00014 00015 !Description: This function writes to the specified Vdata in the currently 00016 open hdf file, the Vdata values specified in data. 00017 00018 !Input Parameters: 00019 char *Vdata_name ** The name of the Vdata to write ** 00020 unsigned char *data ** The data to write (stored in a ** 00021 ** byte array) ** 00022 int32 num_records ** The number of records to write ** 00023 00024 !Output Parameters: 00025 None 00026 00027 Return Values: 00028 MODIS_S_SUCCESS (PGS_MODIS_35005.h) 00029 MODIS_E_RECALL_ID (PGS_MODIS_35005.h) 00030 MODIS_E_WRITE_VDATA (PGS_MODIS_35005.h) 00031 FAIL (hdf.h) 00032 00033 Externally Defined: 00034 PGSt_SMF_status (PGS_SMF.h) 00035 int32 (hdfi.h) 00036 FULL_INTERLACE (hdf.h) 00037 00038 Called By: 00039 write_eng_data 00040 write_failed_packets 00041 00042 Routines Called: 00043 recall_id 00044 VSwrite 00045 log_fmt_msg 00046 00047 !Revision History: 00048 Revision 2.0 1997/10/01 13:35 EDT 00049 Timi Adelekan/SAIC/GSC (adelekan@ltpmail.gsfc.nasa.gov) 00050 Originated Code. 00051 00052 Revision 1.1 1997/09/03 10:55 00053 Tom Johnson/GSC (johnson@ltpmail.gsfc.nasa.gov) 00054 Incorporate walkthrough comments 00055 00056 Revision 1.0 1997/07/14 15:58 EDT 00057 David Catozzi/SAIC/GSC (cato@ltpmail.gsfc.nasa.gov) 00058 Original design. 00059 00060 !Team-unique Header: 00061 This software is developed by the MODIS Science 00062 Data Support Team (SDST) for the National Aeronautics 00063 and Space Administration (NASA), Goddard Space Flight 00064 Center (GSFC), under contract NAS5-32373. 00065 00066 !References and Credits: 00067 HDF portions developed at the National Center for 00068 Supercomputing Applications at the University of Illinois 00069 at Urbana-Champaign. 00070 00071 !Design Notes: 00072 None 00073 00074 !END************************************************************************ 00075 */ 00076 00077 { 00078 /**************************************************************************/ 00079 /* */ 00080 /* Declare the local variables and initialize them. */ 00081 /* */ 00082 /**************************************************************************/ 00083 /* */ 00084 /* Set routine to "write_Vdata" */ 00085 /* Set returnStatus to MODIS_S_SUCCESS */ 00086 /* declare num_rcds_written and Vdata_id to be variables of type int32 */ 00087 /* */ 00088 /**************************************************************************/ 00089 00090 PGSt_SMF_status returnStatus; /* SMF-style message returned by function */ 00091 00092 char *routine = "write_Vdata"; 00093 00094 char msg[300]; 00095 00096 int32 num_rcds_written; 00097 00098 int32 Vdata_id; 00099 00100 00101 returnStatus = MODIS_S_SUCCESS; 00102 00103 00104 00105 /**************************************************************************/ 00106 /* */ 00107 /* CALL recall_id to get the Vdata id for the Vdata */ 00108 /* INPUTS: Vdata_name */ 00109 /* OUTPUTS: None */ 00110 /* RETURNS: Vdata_id */ 00111 /* */ 00112 /* IF Vdata_id is not equal to FAIL */ 00113 /* THEN */ 00114 /* {FULL_INTERLACE writes record by record (i.e all fields in a record} */ 00115 /* {are written before moving on to the next record)} */ 00116 /* CALL VSwrite to write the data to file */ 00117 /* INPUTS: Vdata_id, data, num_records, FULL_INTERLACE */ 00118 /* OUTPUTS: None */ 00119 /* RETURNS: returnStatus */ 00120 /* */ 00121 /* set num_rcds_written to returnStatus */ 00122 /* */ 00123 /**************************************************************************/ 00124 00125 Vdata_id = recall_id(Vdata_name); 00126 00127 if (Vdata_id != FAIL) { 00128 returnStatus = VSwrite(Vdata_id, data, num_records, FULL_INTERLACE); 00129 00130 num_rcds_written = returnStatus; 00131 00132 00133 /**************************************************************************/ 00134 /* */ 00135 /* IF ( returnStatus equals FAIL ) */ 00136 /* THEN */ 00137 /* CALL log_fmt_msg to report that the Vdata could not be written */ 00138 /* to the L1A granule */ 00139 /* INPUTS: Status, routine, msg */ 00140 /* OUTPUTS: None */ 00141 /* RETURN: None */ 00142 /* ELSE */ 00143 /* IF ( num_rcds_written is NOT equal to num_records ) */ 00144 /* THEN */ 00145 /* CALL log_fmt_msg to report that not all of the records */ 00146 /* requested were written to the Vdata in the L1A granule */ 00147 /* INPUTS: Status, routine, msg */ 00148 /* OUTPUTS: None */ 00149 /* RETURN: None */ 00150 /* */ 00151 /* set returnStatus to FAIL */ 00152 /* ENDIF */ 00153 /* ENDIF */ 00154 /* */ 00155 /**************************************************************************/ 00156 00157 if (returnStatus == FAIL) { 00158 sprintf(msg, "Vdata Name: %s", Vdata_name); 00159 log_fmt_msg (MODIS_E_WRITE_VDATA, routine, msg); 00160 } 00161 else if (num_rcds_written != num_records) { 00162 sprintf(msg, "VSwrite wrote fewer records than requested: " 00163 "Num Written %ld Num Requested %ld", 00164 (long)num_rcds_written, (long)num_records); 00165 log_fmt_msg(MODIS_E_WRITE_VDATA, routine, msg); 00166 00167 returnStatus = FAIL; 00168 } 00169 } 00170 00171 00172 /**************************************************************************/ 00173 /* */ 00174 /* ELSE */ 00175 /* CALL log_fmt_msg to report that the Vdata id could not be retrieved */ 00176 /* INPUTS: Status, routine, msg */ 00177 /* OUTPUTS: None */ 00178 /* RETURN: None */ 00179 /* */ 00180 /* set returnStatus to FAIL */ 00181 /* ENDIF */ 00182 /* */ 00183 /* return returnStatus */ 00184 /* */ 00185 /**************************************************************************/ 00186 00187 else { 00188 sprintf(msg, "Vdata Name: %s", Vdata_name); 00189 log_fmt_msg(MODIS_E_RECALL_ID, routine, msg); 00190 00191 returnStatus = FAIL; 00192 } 00193 00194 return returnStatus; 00195 00196 } /* End of routine write_Vdata */
1.7.6.1