74 char *fil_icecld_landsfc,
75 char *fil_wtrcld_wtrsfc1,
char *fil_wtrcld_wtrsfc1_sd,
76 char *fil_icecld_wtrsfc1,
char *fil_icecld_wtrsfc1_sd,
77 char *fil_wtrcld_wtrsfc2,
char *fil_wtrcld_wtrsfc2_sd,
78 char *fil_icecld_wtrsfc2,
char *fil_icecld_wtrsfc2_sd,
79 char *fil_wtrcld_wtrsfc3,
char *fil_wtrcld_wtrsfc3_sd,
80 char *fil_icecld_wtrsfc3,
char *fil_icecld_wtrsfc3_sd,
81 int len1,
int len2,
int len_ww1,
int len_ww1sd,
int len_iw1,
int len_iw1sd,
82 int len_ww2,
int len_ww2sd,
int len_iw2,
int len_iw2sd,
83 int len_ww3,
int len_ww3sd,
int len_iw3,
int len_iw3sd )
88 int32_t
set_ms_file(
char *,
char *, int32_t , ms_finfo_struc * );
104 for(
int idim = 0; idim < 6; idim++ )
110 printf(
"%s, %d, E: Water and ice cloud over land dimension mismatch\n",
111 __FILE__, __LINE__ );
112 printf(
" file_water: %s\n", fil_wtrcld_landsfc );
113 printf(
" file_ice : %s\n", fil_icecld_landsfc );
123 if(
status != 0 ) exit(27);
131 for( int32_t isfc = 0; isfc < 3; isfc++ )
136 }
else if( isfc == 1 ) {
139 }
else if( isfc == 2 ) {
150 }
else if( isfc == 1 ) {
153 }
else if( isfc == 2 ) {
161 for(
int idim = 0; idim < 6; idim++ )
170 "%s, %d, E: water cloud over-water MS file dimension mismatch\n",
171 __FILE__, __LINE__ );
172 printf(
" dim # %d, water sfc # %d\n", idim, isfc );
174 if(
status != 0 ) exit(27);
183 "%s, %d, E: ice cloud over-water MS file dimension mismatch\n",
184 __FILE__, __LINE__ );
185 printf(
" dim # %d, water sfc # %d\n", idim, isfc );
187 if(
status != 0 ) exit(27);
192 for(
int idim = 0; idim < 3; idim++ )
218 fn = (
char *) malloc( ( len + 1 ) *
sizeof( char ) );
220 fn[ len ] = (char) 0;
224 extern"C" int32_t
set_ms_file(
char *fil_ms,
char *fil_ms_std, int32_t fil_typ,
225 ms_finfo_struc *finfo )
251 int rank, dim_lens[7], nattr, ret1, ret2, vtyp;
253 int32_t trg_rank = 6;
256 char *dim_sds_names[] = {
"ReflectanceSensorZenith",
"ReflectanceSolarZenith",
257 "ReflectanceRelativeAzimuth",
"OpticalThickness",
"Wavelengths",
263 finfo->fid_ms = SDstart( fil_ms, DFACC_READ );
264 finfo->sds_id = SDselect( finfo->fid_ms, SDnametoindex( finfo->fid_ms,
265 "MultiScatBDReflectance" ) );
266 SDgetinfo( finfo->sds_id, bl_nam, &
rank, dim_lens, &vtyp, &nattr );
267 if( (
rank != trg_rank ) || ( finfo->sds_id ==
FAIL ) )
269 printf(
"E: %s, %d: MS refl in cloud table file has wrong size\n",
270 __FILE__, __LINE__ );
271 printf(
" file: %s", fil_ms );
272 printf(
" SDS: MultiScatBDReflectance\n" );
279 finfo->fid_ms_std = finfo->fid_ms;
281 finfo->fid_ms_std = SDstart( fil_ms_std, DFACC_READ );
285 finfo->sds_id_std = SDselect( finfo->fid_ms_std,
286 SDnametoindex( finfo->fid_ms_std,
"StdDevMultiScatBDReflectance" ) );
287 SDgetinfo( finfo->sds_id_std, bl_nam, &
rank, dim_lens, &vtyp, &nattr );
288 if( (
rank != trg_rank ) || ( finfo->fid_ms_std ==
FAIL ) )
290 printf(
"E: %s, %d: MS refl std in cloud table file has wrong size\n",
291 __FILE__, __LINE__ );
292 printf(
" file: %s", fil_ms );
293 printf(
" SDS: StdMultiScatBDReflectance\n" );
298 finfo->dim_siz = (int32_t *) malloc( trg_rank *
sizeof( int32_t ) );
299 finfo->dim_vals = (
double **) malloc( trg_rank *
sizeof(
double * ) );
304 for( int32_t isds = 0; isds < 6; isds++ )
306 if( (
sds_id = SDselect( finfo->fid_ms, SDnametoindex( finfo->fid_ms,
307 dim_sds_names[isds] ) ) ) ==
FAIL )
309 printf(
"E: %s, %d: Can't read table SDS %s\n", __FILE__, __LINE__,
310 dim_sds_names[isds] );
313 SDgetinfo(
sds_id, bl_nam, &
rank, dim_lens, &vtyp, &nattr );
314 finfo->dim_siz[isds] = dim_lens[0];
315 finfo->dim_vals[isds] = (
double *) malloc( dim_lens[0] *
sizeof(
double) );
316 fstore = (
float *) malloc( dim_lens[0] *
sizeof(
float) );
318 end[0] = dim_lens[0];
320 for( int32_t ipx = 0; ipx < end[0]; ipx++ )
321 finfo->dim_vals[isds][ipx] = *(fstore + ipx );
323 ret2 = SDendaccess(
sds_id );
324 if( ( ret1 !=0 ) || ( ret2 !=0 ) )
326 printf(
"E: %s, %d: Can't read table SDS %s\n", __FILE__, __LINE__,
327 dim_sds_names[isds] );
340 float *relaz_ang,
int *sfc_typ,
int *meas_typ,
int *
scan,
float *wtr_int,
341 float *ice_int,
int *stat )
397 int32_t ndim = 3, off_wtr, off_ice;
398 int32_t ntau, ntau1, nwav, nrad_wtr, nrad_ice, nrad;
399 static int32_t prune_called = 0;
423 if( ( *
scan % 200 ) == 199 )
425 if( prune_called == 0 )
443 ndat = pow( 2, ndim );
471 printf(
"%s, %d: mng_ms_get_lib error found of %d\n", __FILE__,
486 int32_t n_new_blobs = 0;
487 int32_t
offset[3], arr_off, tau_off;
489 int32_t istart[6] = { 0, 0, 0, 0, 0, 0 };
490 int32_t icount[6] = { 1, 1, 1, ntau, nwav, nrad_wtr };
491 if( *sfc_typ != 0 ) icount[3] = ntau1;
493 for( int32_t idat = 0; idat < ndat; idat++ )
504 for( int32_t idim = 0; idim < 3; idim++ )
508 for( int32_t isfc = 0; isfc < nsfc; isfc++ )
512 for( int32_t iarr = 0; iarr < narr; iarr++ )
575 int32_t ntau_mod = ( *sfc_typ == 0 ) ? ntau : ntau1;
576 float *tmp_dat = (
float *)malloc( ntau_mod * nwav * nrad *
578 if(
status = ( SDreaddata( tsds_id, istart,
NULL, icount,
579 (
void *)tmp_dat ) ) != SUCCEED )
582 "E: %s, %d, Read of cloud table data failed with status: %d\n",
583 __FILE__, __LINE__,
status );
587 for( int32_t irad = 0; irad < nrad; irad++ )
589 for( int32_t iwav = 0; iwav < nwav; iwav++ )
595 for( int32_t itau = 0; itau < ntau; itau++ )
597 *( dat_blob + arr_off + ( itau + tau_off ) + ntau1 *
598 ( iwav + nwav * irad ) ) =
599 *( tmp_dat + irad + nrad * ( iwav + nwav * itau ) );
604 for( int32_t itau = 0; itau < ntau + 1; itau++ )
606 *( dat_blob + arr_off + itau + ntau1 *
607 ( iwav + nwav * irad ) ) =
608 *( tmp_dat + irad + nrad * (iwav + nwav * itau ) );
617 pt_info->
dat_ptrs[idat] = (
void *)dat_blob;
639 int32_t sfc_typ_mult [] = { 0, 0, 1, 2 };
644 off_wtr = 0 + sfc_typ_mult[*sfc_typ] * sfc_typ_off;
645 off_ice = 2 *
wtrcld_nelts + sfc_typ_mult[*sfc_typ] * sfc_typ_off;
649 off_wtr =
wtrcld_nelts + sfc_typ_mult[*sfc_typ] * sfc_typ_off;
651 sfc_typ_mult[*sfc_typ] * sfc_typ_off;
653 for(
int idat = 0; idat < ndat; idat++ )
658 for( int32_t itau = 0; itau < ntau1; itau++ )
660 for( int32_t iwav = 0; iwav < nwav; iwav++ )
662 for( int32_t irad = 0; irad < nrad_wtr; irad++ )
664 *( wtr_int + itau + ntau1 * ( iwav + nwav * irad ) ) +=
665 pt_info->
wt_pt[idat] *
666 *( (
float *)pt_info->
dat_ptrs[idat] + off_wtr + itau + ntau1 *
667 ( iwav + nwav * irad ) );
670 for( int32_t irad = 0; irad < nrad_ice; irad++ )
672 *( ice_int + itau + ntau1 * ( iwav + nwav * irad ) ) +=
673 pt_info->
wt_pt[idat] *
674 *( (
float *)pt_info->
dat_ptrs[idat] + off_ice + itau + ntau1 *
675 ( iwav + nwav * irad ) );