static char rcsid[]="$Id: scv_rdr.c,v 1.0 1992/07/28 23:07:53 maurer $"; /*********************************************************************** scv_rdr.c Function: Reads SCVDR data files into SCVDR data structures This file is part of the STARLab Magellan Altimeter Data Processing Software. Joe Twicken, June 1992. ***********************************************************************/ /* $Log: scv_rdr.c,v $ * Revision 1.0 1992/07/28 23:07:53 maurer * Initial revision * */ #include #include #include "scvdr.h" #include "scvparse.h" #define SCV_RDR_C #include "scvparse.i" #include "scv_rdr.i" /*********************************************************************** vhf_read Reads SFDU records that form the VHF file #1 CCSD file header #2 NJPL catalog items (keyword & value SFDU) #4 CCSD aggregation start The user must free the space allocated for the keyword/value lists with calls to free_catalog(). Returns 0 on success ***********************************************************************/ int vhf_read(f,psf1,psf2,pkv2,psf4,pkv4) FILE *f; /* File pointer */ sfdu *psf1; /* Pointer to CCSDS SFDU label */ sfdu *psf2; /* Pointer to catalog SFDU label */ keyval_t **pkv2; /* Pointer to catalog keyword/value list */ sfdu *psf4; /* Pointer to smarker SFDU */ keyval_t **pkv4; /* Pointer to smarker keyword/value list */ { sfdu sf3; /* Missing header record SFDU */ char *phdr; /* Pointer to missing SFDU */ int err; /* Function return code */ /* Allocate space for missing header record SFDU */ phdr = (char *) calloc(1,sizeof(sfdu)); /* Initialize the keyword/value list pointers */ *pkv2 = *pkv4 = NULL; /* Read the SFDU records */ err = scv_rhdr(f,psf1,psf2,pkv2,&sf3,&phdr,psf4,pkv4); /* Free the missing header record SFDU */ free(phdr); /* Return the error code (0=success) */ return(err); } /*********************************************************************** hdr_read Reads 4 SFDU records forming header of SCVDR files (except VHF & VTF) #1 CCSD file header #2 NJPL catalog items (keyword & value SFDU) #3 NJPL file header record #4 CCSD aggregation start The user must free the space allocated for the keyword/value lists with calls to free_catalog(). Returns 0 on success ***********************************************************************/ int hdr_read(f,psf1,psf2,pkv2,psf3,phdr,psf4,pkv4) FILE *f; /* File pointer */ sfdu *psf1; /* Pointer to CCSDS SFDU label */ sfdu *psf2; /* Pointer to catalog SFDU label */ keyval_t **pkv2; /* Pointer to catalog keyword/value list */ sfdu *psf3; /* Pointer to header record SFDU label */ char *phdr; /* Pointer to header record */ sfdu *psf4; /* Pointer to smarker SFDU */ keyval_t **pkv4; /* Pointer to smarker keyword/value list */ { /* Initialize the keyword/value list pointers */ *pkv2 = *pkv4 = NULL; /* Read the 4 SFDU records and return error code (0=success) */ return(scv_rhdr(f,psf1,psf2,pkv2,psf3,&phdr,psf4,pkv4)); } /*********************************************************************** anf_allocn Allocate space for the variable-length fields in the altimetry inversion data records. For each call to anf_allocn(), the user must call anf_freen() to free memory space allocated to the variable length fields. Since the amount of allocated memory space is sufficient to accommodate the largest altimetry inversion data record, this routine need only be called once per orbit Returns 0 on success ***********************************************************************/ int anf_allocn(nr,n,pnh) nr_rec *nr; /* Alt inv data record pointer */ int n; /* Number of records to read */ nh_rec *pnh; /* Alt inv header record pointer */ { int bsize; /* Size of scattering and angle vectors */ int nsize; /* Size of covariance matrix */ int i; /* Counter */ /* Loop through and allocate maximum necessary space for each variable-length field in each data record */ bsize = pnh->nh_maxB*sizeof(float); nsize = pnh->nh_maxN*sizeof(float); for (i=0;inr_sig0-(ulong)nr;ifh_nlaw*sizeof(fr_sslf_t); for (i=0;ifr_sslf-(ulong)fr;iih_maxB*sizeof(bin_t); isize = pih->ih_maxI*sizeof(ulong); for (i=0;iir_bins-(ulong)ir;igh_maxB*sizeof(float); rsize = pgh->gh_maxR*sizeof(float); fsize = pgh->gh_maxF*sizeof(float); brsize = pgh->gh_maxBR*sizeof(float); bfsize = pgh->gh_maxBF*sizeof(float); for (i=0;igr_b-(ulong)gr;i