xp_comm_proj/rd_cgns/scan_cgns.c
/* return 1 if all OK, 0 otherwise */
/* scan the Bases info in the f_indx CGNS file, fillin DVread_cgns_id */
return 1 if all OK, 0 otherwise
scan the Bases info in the f_indx CGNS file, fillin DVread_cgns_id
return 1 if all OK 0 otherwise scan the Bases info in the f_indx CGNS file fillin DVread_cgns_id
static int
scan_bases(OMobj_id DVread_cgns_id, int f_indx)
{
	OMobj_id	nBase_id, base_info_id, base_info_el_id;
	int	nBases;
	int	i;
	char	name[CGNS_NAME_MAX_LEN];
	int	cell_dim, phys_dim;
	if(cg_nbases(f_indx, &nBases))
	{
		OMset_name_str_val(DVread_cgns_id, OMstr_to_name("status"),
			cg_get_error());
		return (0);
	}
	if(!nBases) 
	{
		return (0);
	}
	nBase_id = OMlookup_subobj(DVread_cgns_id, OMstr_to_name("nBase"),
		OM_OBJ_RW);
	if(OMis_null_obj(nBase_id))
	{
		ERRverror("DVread_cgns:scan_bases",ERR_INFO,
			"can't locate nBase subobject\n");
		return (0);
	}
	if(OMset_int_val(nBase_id, 0) != OM_STAT_SUCCESS)
	{
		ERRverror("DVread_cgns:scan_bases",ERR_INFO,
			"can't set nBase object\n");
		return (0);
	}
	base_info_id = OMlookup_subobj(DVread_cgns_id, OMstr_to_name("base_info"),
		OM_OBJ_RW);
	if(OMis_null_obj(base_info_id))
	{
		ERRverror("DVread_cgns:scan_bases",ERR_INFO,
			"can't locate base_info subobject\n");
		return (0);
	}
	if(OMset_array_size(base_info_id, nBases) != OM_STAT_SUCCESS)
	{
		ERRverror("DVread_cgns:scan_bases",ERR_INFO,
			"can't change dimentionality of base_info object\n");
		return (0);
	}
	for(i=0;i<nBases;++i)
	{
		if(cg_base_read(f_indx, i+1, name, &cell_dim, &phys_dim))
		{
			OMset_name_str_val(DVread_cgns_id, OMstr_to_name("status"),
				cg_get_error());
			return (0);
		}
		if(OMget_array_val(base_info_id, i, &base_info_el_id, OM_OBJ_RW) !=
			OM_STAT_SUCCESS)
		{
			ERRverror("DVread_cgns:scan_bases",ERR_INFO,
				"can't access array element of base_info object\n");
			return (0);
		}
		if(OMset_name_int_val(base_info_el_id, OMstr_to_name("cell_dim"),
			cell_dim) != OM_STAT_SUCCESS)
		{
			ERRverror("DVread_cgns:scan_bases",ERR_INFO,
				"can't set cell_dim of base_info array object\n");
			return (0);
		}
		if(OMset_name_int_val(base_info_el_id, OMstr_to_name("phys_dim"),
			phys_dim) != OM_STAT_SUCCESS)
		{
			ERRverror("DVread_cgns:scan_bases",ERR_INFO,
				"can't set phys_dim of base_info array object\n");
			return (0);
		}
		if(OMset_name_str_val(base_info_el_id, OMstr_to_name("base_name"), name)
			!= OM_STAT_SUCCESS)
		{
			ERRverror("DVread_cgns:scan_bases",ERR_INFO,
				"can't set name of base_info array object\n");
			return (0);
		}
	}
	if(OMset_int_val(nBase_id, nBases) != OM_STAT_SUCCESS)
	{
		ERRverror("DVread_cgns:scan_bases",ERR_INFO,
			"can't set nBase object\n");
		return (0);
	}
	return (1);
}
static int scan_bases ( OMobj_id DVread_cgns_id , int f_indx ) { OMobj_id nBase_id , base_info_id , base_info_el_id ; int nBases ; int i ; char name [ CGNS_NAME_MAX_LEN ] ; int cell_dim , phys_dim ; if ( cg_nbases ( f_indx , & nBases ) ) { OMset_name_str_val ( DVread_cgns_id , OMstr_to_name ( " " ) , cg_get_error ( ) ) ; return ( 0 ) ; } if ( ! nBases ) { return ( 0 ) ; } nBase_id = OMlookup_subobj ( DVread_cgns_id , OMstr_to_name ( " " ) , OM_OBJ_RW ) ; if ( OMis_null_obj ( nBase_id ) ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } if ( OMset_int_val ( nBase_id , 0 ) != OM_STAT_SUCCESS ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } base_info_id = OMlookup_subobj ( DVread_cgns_id , OMstr_to_name ( " " ) , OM_OBJ_RW ) ; if ( OMis_null_obj ( base_info_id ) ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } if ( OMset_array_size ( base_info_id , nBases ) != OM_STAT_SUCCESS ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } for ( i = 0 ; i < nBases ; ++ i ) { if ( cg_base_read ( f_indx , i + 1 , name , & cell_dim , & phys_dim ) ) { OMset_name_str_val ( DVread_cgns_id , OMstr_to_name ( " " ) , cg_get_error ( ) ) ; return ( 0 ) ; } if ( OMget_array_val ( base_info_id , i , & base_info_el_id , OM_OBJ_RW ) != OM_STAT_SUCCESS ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } if ( OMset_name_int_val ( base_info_el_id , OMstr_to_name ( " " ) , cell_dim ) != OM_STAT_SUCCESS ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } if ( OMset_name_int_val ( base_info_el_id , OMstr_to_name ( " " ) , phys_dim ) != OM_STAT_SUCCESS ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } if ( OMset_name_str_val ( base_info_el_id , OMstr_to_name ( " " ) , name ) != OM_STAT_SUCCESS ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } } if ( OMset_int_val ( nBase_id , nBases ) != OM_STAT_SUCCESS ) { ERRverror ( " " , ERR_INFO , " \n " ) ; return ( 0 ) ; } return ( 1 ) ; }
return 1 if all OK, 0 otherwise
scan the Bases info in the f_indx CGNS file, fillin DVread_cgns_id
return 1 if all OK 0 otherwise scan the Bases info in the f_indx CGNS file fillin DVread_cgns_id
/* CGNS get number of Bases */ /* if 0 Bases - possible ? */ /* find obj_id of the nBase */ /* reset value of nBase object */ /* find obj_id of the base_info */ /* change dimentionality of base_info object */ /* CGNS get Bases names - fill out the base_info object */ /* CGNS get Base no i+1 name */ /* get obj_id of array element from base_options array */ /* set call and phys dims in base_options subarray element */ /* set label to name in base_options subarray element */ /* set correct value of nBase object */