76 char *fil_icecld_landsfc,
77 char *fil_wtrcld_wtrsfc1,
char *fil_wtrcld_wtrsfc1_sd,
78 char *fil_icecld_wtrsfc1,
char *fil_icecld_wtrsfc1_sd,
79 char *fil_wtrcld_wtrsfc2,
char *fil_wtrcld_wtrsfc2_sd,
80 char *fil_icecld_wtrsfc2,
char *fil_icecld_wtrsfc2_sd,
81 char *fil_wtrcld_wtrsfc3,
char *fil_wtrcld_wtrsfc3_sd,
82 char *fil_icecld_wtrsfc3,
char *fil_icecld_wtrsfc3_sd,
83 int len1,
int len2,
int len_ww1,
int len_ww1sd,
int len_iw1,
int len_iw1sd,
84 int len_ww2,
int len_ww2sd,
int len_iw2,
int len_iw2sd,
85 int len_ww3,
int len_ww3sd,
int len_iw3,
int len_iw3sd )
90 int32_t
set_ms_file(
char *,
char *, int32_t , ms_finfo_struc * );
106 for(
int idim = 0; idim < 6; idim++ )
112 printf(
"%s, %d, E: Water and ice cloud over land dimension mismatch\n",
113 __FILE__, __LINE__ );
114 printf(
" file_water: %s\n", fil_wtrcld_landsfc );
115 printf(
" file_ice : %s\n", fil_icecld_landsfc );
125 if(
status != 0 ) exit(27);
133 for( int32_t isfc = 0; isfc < 3; isfc++ )
138 }
else if( isfc == 1 ) {
141 }
else if( isfc == 2 ) {
152 }
else if( isfc == 1 ) {
155 }
else if( isfc == 2 ) {
163 for(
int idim = 0; idim < 6; idim++ )
172 "%s, %d, E: water cloud over-water MS file dimension mismatch\n",
173 __FILE__, __LINE__ );
174 printf(
" dim # %d, water sfc # %d\n", idim, isfc );
176 if(
status != 0 ) exit(27);
185 "%s, %d, E: ice cloud over-water MS file dimension mismatch\n",
186 __FILE__, __LINE__ );
187 printf(
" dim # %d, water sfc # %d\n", idim, isfc );
189 if(
status != 0 ) exit(27);
194 for(
int idim = 0; idim < 3; idim++ )
220 fn = (
char *) malloc( ( len + 1 ) *
sizeof( char ) );
222 fn[ len ] = (char) 0;
226 extern"C" int32_t
set_ms_file(
char *fil_ms,
char *fil_ms_std, int32_t fil_typ,
227 ms_finfo_struc *finfo )
252 int rank, dim_id_lst[7], nattr, ret1, vtyp;
256 int32_t trg_rank = 6;
259 char *dim_sds_names[] = {
"ReflectanceSensorZenith",
"ReflectanceSolarZenith",
260 "ReflectanceRelativeAzimuth",
"OpticalThickness",
"Wavelengths",
267 DPTB( nc_open( fil_ms, NC_NOWRITE, &(finfo->fid_ms) ) );
270 DPTB( nc_inq_varid( finfo->fid_ms,
"MultiScatBDReflectance",
271 &(finfo->sds_id) ) );
274 DPTB( nc_inq_var( finfo->fid_ms, finfo->sds_id,
NULL, &vtyp, &
rank,
275 dim_id_lst, &nattr ) );
277 if(
rank != trg_rank )
279 printf(
"E: %s, %d: MS refl in cloud table file has wrong size\n",
280 __FILE__, __LINE__ );
281 printf(
" file: %s", fil_ms );
282 printf(
" SDS: MultiScatBDReflectance\n" );
288 for(
int i = 0;
i <
rank;
i++ )
289 DPTB( nc_inq_dimlen( finfo->fid_ms, dim_id_lst[
i], dim_lens +
i ) );
294 finfo->fid_ms_std = finfo->fid_ms;
296 DPTB( nc_open( fil_ms_std, NC_NOWRITE, &(finfo->fid_ms_std) ) );
303 DPTB( nc_inq_varid( finfo->fid_ms_std,
"StdDevMultiScatBDReflectance",
304 &(finfo->sds_id_std) ) );
307 DPTB( nc_inq_var( finfo->fid_ms_std, finfo->sds_id_std,
NULL, &vtyp, &
rank,
308 dim_id_lst, &nattr ) );
310 if(
rank != trg_rank )
312 printf(
"E: %s, %d: MS refl std in cloud table file has wrong size\n",
313 __FILE__, __LINE__ );
314 printf(
" file: %s", fil_ms );
315 printf(
" SDS: StdMultiScatBDReflectance\n" );
320 finfo->dim_siz = (int32_t *) malloc( trg_rank *
sizeof( int32_t ) );
321 finfo->dim_vals = (
double **) malloc( trg_rank *
sizeof(
double * ) );
326 for( int32_t isds = 0; isds < 6; isds++ )
328 if( nc_inq_varid( finfo->fid_ms, dim_sds_names[isds], &
sds_id )
331 printf(
"E: %s, %d: Can't read table SDS %s\n", __FILE__, __LINE__,
332 dim_sds_names[isds] );
337 dim_id_lst, &nattr ) );
338 DPTB( nc_inq_dimlen( finfo->fid_ms, dim_id_lst[0], dim_lens ) );
340 finfo->dim_siz[isds] = dim_lens[0];
341 finfo->dim_vals[isds] = (
double *) malloc( dim_lens[0] *
sizeof(
double) );
342 fstore = (
float *) malloc( dim_lens[0] *
sizeof(
float) );
344 end[0] = dim_lens[0];
348 if( ret1 != NC_NOERR )
350 printf(
"E: %s, %d: Can't read table SDS %s\n", __FILE__, __LINE__,
351 dim_sds_names[isds] );
354 for(
size_t ipx = 0; ipx <
end[0]; ipx++ )
355 finfo->dim_vals[isds][ipx] = *(fstore + ipx );
368 float *relaz_ang,
int *sfc_typ,
int *meas_typ,
int *
scan,
float *wtr_int,
369 float *ice_int,
int *stat )
425 int32_t ndim = 3, off_wtr, off_ice;
426 int32_t ntau, ntau1, nwav, nrad_wtr, nrad_ice, nrad;
427 static int32_t prune_called = 0;
451 if( ( *
scan % 200 ) == 199 )
454 if( prune_called == 0 )
472 ndat = pow( 2, ndim );
500 printf(
"%s, %d: mng_ms_get_lib error found of %d\n", __FILE__,
515 int32_t n_new_blobs = 0;
516 int32_t
offset[3], arr_off, tau_off;
517 int tsds_id, tfil_id;
524 double grid_senz, grid_solz;
526 size_t istart[6] = { 0, 0, 0, 0, 0, 0 };
527 size_t icount[6] = { 1, 1, 1, (size_t)ntau, (
size_t)nwav,
529 if( *sfc_typ != 0 ) icount[3] = ntau1;
531 for( int32_t idat = 0; idat < ndat; idat++ )
542 for( int32_t idim = 0; idim < 3; idim++ )
546 grid_senz = senz_set[ istart[0] ];
547 grid_solz = solz_set[ istart[1] ];
548 if( grid_senz < grid_solz )
551 for(
i = 0;
i < n_solz;
i++ )
553 if( solz_set[
i] == grid_senz )
559 for(
i = 0;
i < n_senz;
i++ )
561 if( senz_set[
i] == grid_solz )
576 for( int32_t isfc = 0; isfc < nsfc; isfc++ )
580 for( int32_t iarr = 0; iarr < narr; iarr++ )
651 int32_t ntau_mod = ( *sfc_typ == 0 ) ? ntau : ntau1;
652 float *tmp_dat = (
float *)malloc( ntau_mod * nwav * nrad *
656 if(
status = nc_get_vara_float( tfil_id, tsds_id, istart, icount,
657 tmp_dat ) != NC_NOERR )
660 "E: %s, %d, Read of cloud table data failed with status: %d\n",
661 __FILE__, __LINE__,
status );
665 for( int32_t irad = 0; irad < nrad; irad++ )
667 for( int32_t iwav = 0; iwav < nwav; iwav++ )
673 for( int32_t itau = 0; itau < ntau; itau++ )
675 *( dat_blob + arr_off + ( itau + tau_off ) + ntau1 *
676 ( iwav + nwav * irad ) ) =
677 *( tmp_dat + irad + nrad * ( iwav + nwav * itau ) );
682 for( int32_t itau = 0; itau < ntau + 1; itau++ )
684 *( dat_blob + arr_off + itau + ntau1 *
685 ( iwav + nwav * irad ) ) =
686 *( tmp_dat + irad + nrad * (iwav + nwav * itau ) );
695 pt_info->
dat_ptrs[idat] = (
void *)dat_blob;
718 int32_t sfc_typ_mult [] = { 0, 0, 1, 2 };
723 off_wtr = 0 + sfc_typ_mult[*sfc_typ] * sfc_typ_off;
724 off_ice = 2 *
wtrcld_nelts + sfc_typ_mult[*sfc_typ] * sfc_typ_off;
728 off_wtr =
wtrcld_nelts + sfc_typ_mult[*sfc_typ] * sfc_typ_off;
730 sfc_typ_mult[*sfc_typ] * sfc_typ_off;
732 for(
int idat = 0; idat < ndat; idat++ )
737 for( int32_t itau = 0; itau < ntau1; itau++ )
739 for( int32_t iwav = 0; iwav < nwav; iwav++ )
741 for( int32_t irad = 0; irad < nrad_wtr; irad++ )
743 *( wtr_int + itau + ntau1 * ( iwav + nwav * irad ) ) +=
744 pt_info->
wt_pt[idat] *
745 *( (
float *)pt_info->
dat_ptrs[idat] + off_wtr + itau + ntau1 *
746 ( iwav + nwav * irad ) );
749 for( int32_t irad = 0; irad < nrad_ice; irad++ )
751 *( ice_int + itau + ntau1 * ( iwav + nwav * irad ) ) +=
752 pt_info->
wt_pt[idat] *
753 *( (
float *)pt_info->
dat_ptrs[idat] + off_ice + itau + ntau1 *
754 ( iwav + nwav * irad ) );