24 #ifndef MAX_PROP_LENGTH 25 #define MAX_PROP_LENGTH 100 33 #ifdef __INTEL_COMPILER 34 void fox_sax_equus_mp_read_xml_(
char* fnamget_eq_structurese,
long *fname_len,
char**
property_names,
int* numodProperties );
35 void fox_sax_equus_mp_get_eq_structure_(
EQstruct* eq_struct ,
int* idx);
36 void fox_sax_equus_mp_deallocatetargetnodes_();
37 int fox_sax_equus_mp_numtargetnodes_;
66 int nrhs,
const mxArray *prhs[])
85 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:nInput",
"Two inputs required.");
88 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:nOutput",
"Too many output arguments.");
94 if ((mxIsChar(prhs[0]) != 1)) {
95 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonString",
"First input must be a string.");
100 filename = mxArrayToString(prhs[0]);
102 mexPrintf(
"%s\n", filename );
105 if (access(filename, F_OK) == -1) {
106 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:FileNotExist",
"The given file %s does not exist.", filename);
114 if ((mxIsCell(prhs[1]) != 1)) {
115 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonCell",
"Second input must be a cell.");
117 if ( (mxGetN(prhs[1]) >1) && (mxGetM(prhs[1]) >1) ) {
118 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonVector",
"Second input must be a cell vector.");
120 numofProperties = mxGetN(prhs[1]) * mxGetM(prhs[1]);
122 for ( idx = 0; idx<numofProperties; idx++ ) {
123 cell = mxGetCell( prhs[1], idx);
125 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:MAX_PROP_LENGTH",
"Increase the maximal length of the proeprty names.");
127 if (!mxIsChar(cell)) {
128 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonString",
"Second input must contain of strings.");
131 buflen = (mxGetM(cell) * mxGetN(cell)) + 1;
139 buflen = (mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1;
142 #ifdef __INTEL_COMPILER 143 fox_sax_equus_mp_read_xml_( filename, &buflen,
property_names, &numofProperties);
144 numTargetNodes = fox_sax_equus_mp_numtargetnodes_;
146 __fox_sax_equus_MOD_read_hsx( filename, &buflen, eq_structs);
152 mexPrintf(
"Number of obtained target nodes: %d\n", numTargetNodes);
157 plhs[0] = mxCreateStructMatrix(1, 1, 0, NULL);
162 for( idx=1; idx<=numTargetNodes; idx++ ) {
164 #ifdef __INTEL_COMPILER 165 fox_sax_equus_mp_get_eq_structure_( &eq_struct, &idx );
180 mexPrintf(
"\nDeallocating Target nodes\n*********************************\n" );
183 #ifdef __INTEL_COMPILER 184 fox_sax_equus_mp_deallocatetargetnodes_();
202 char** localname = NULL;
204 if (mxIsStruct( Mstruct ) == 0) {
205 mexErrMsgIdAndTxt (
"read_SiestaXML:XMLnode2MatlabStruct:NotStructure",
"The given mxArray is not a structure.");
208 struct_tmp = mxCreateStructMatrix(1, 1, 0, NULL);
210 for( idx=0; idx<=eq_struct->
numfields-1; idx++ ) {
211 field = &eq_struct->
fields[idx];
212 if (( strcmp(field->
elementname,
"localname") == 0) && localname==NULL) {
213 localname = (
char**)field->
value;
215 else if ( strcmp(field->
elementname,
"subnodes") == 0) {
218 mxArray* Msubnode = mxCreateStructMatrix(1, 1, 0, NULL);
220 mexPrintf(
"number of subnodes: %d\n", subnodes->
numfields );
223 for( jdx=0; jdx<subnodes->
numfields; jdx++ ) {
235 if ( localname == NULL ) {
236 localname = (
char**)mxMalloc(
sizeof(
char*) );
237 strcpy( localname[0],
"Unknown");
240 setField( struct_tmp, localname[0], Mstruct );
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Gateway routine to read in the hsx structure generated by the SIESTA package (see http://www....
void __fox_sax_equus_MOD_read_xml(char *fnamget_eq_structurese, long *fname_len, char **property_names, int *numodProperties)
void __fox_sax_equus_MOD_get_eq_structure(EQstruct *eq_struct, int *idx)
Header file for felper functions for interlanguage conversions.
void __fox_sax_equus_MOD_deallocatetargetnodes()
#define MAX_PROP_LENGTH
====================================================================== Gateway routine to read in the...
void convert2FortranString(char *cstring, int strlength)
Converts a C string into fortran compatible character array.
void regularizeEQstruct(EQstruct *eq_struct)
Sort out invalid EQelements from an EQstruct structure prototype.
void setField(EQelement *eq_field, mxArray *Mstruct)
Set a field in a MATLAB structure.
void XMLnode2MatlabStruct(EQstruct *eq_struct, mxArray *Mstruct)
Routine to turn nested EQstruct structure prototypes into MATLAB structure.
int __fox_sax_equus_MOD_numtargetnodes
character(len=max_prop_length, kind=c_char), dimension(:), pointer property_names