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_;
63 int nrhs,
const mxArray *prhs[])
82 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:nInput",
"Two inputs required.");
85 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:nOutput",
"Too many output arguments.");
91 if ((mxIsChar(prhs[0]) != 1)) {
92 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonString",
"First input must be a string.");
97 filename = mxArrayToString(prhs[0]);
99 mexPrintf(
"%s\n", filename );
102 if (access(filename, F_OK) == -1) {
103 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:FileNotExist",
"The given file %s does not exist.", filename);
111 if ((mxIsCell(prhs[1]) != 1)) {
112 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonCell",
"Second input must be a cell.");
114 if ( (mxGetN(prhs[1]) >1) && (mxGetM(prhs[1]) >1) ) {
115 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonVector",
"Second input must be a cell vector.");
117 numofProperties = mxGetN(prhs[1]) * mxGetM(prhs[1]);
119 for ( idx = 0; idx<numofProperties; idx++ ) {
120 cell = mxGetCell( prhs[1], idx);
122 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:MAX_PROP_LENGTH",
"Increase the maximal length of the proeprty names.");
124 if (!mxIsChar(cell)) {
125 mexErrMsgIdAndTxt (
"siesta_EQuUs:read_SiestaXML:NonString",
"Second input must contain of strings.");
128 buflen = (mxGetM(cell) * mxGetN(cell)) + 1;
136 buflen = (mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1;
139 #ifdef __INTEL_COMPILER 140 fox_sax_equus_mp_read_xml_( filename, &buflen,
property_names, &numofProperties);
141 numTargetNodes = fox_sax_equus_mp_numtargetnodes_;
143 __fox_sax_equus_MOD_read_hsx( filename, &buflen, eq_structs);
149 mexPrintf(
"Number of obtained target nodes: %d\n", numTargetNodes);
154 plhs[0] = mxCreateStructMatrix(1, 1, 0, NULL);
159 for( idx=1; idx<=numTargetNodes; idx++ ) {
161 #ifdef __INTEL_COMPILER 162 fox_sax_equus_mp_get_eq_structure_( &eq_struct, &idx );
177 mexPrintf(
"\nDeallocating Target nodes\n*********************************\n" );
180 #ifdef __INTEL_COMPILER 181 fox_sax_equus_mp_deallocatetargetnodes_();
199 char** localname = NULL;
201 if (mxIsStruct( Mstruct ) == 0) {
202 mexErrMsgIdAndTxt (
"read_SiestaXML:XMLnode2MatlabStruct:NotStructure",
"The given mxArray is not a structure.");
205 struct_tmp = mxCreateStructMatrix(1, 1, 0, NULL);
207 for( idx=0; idx<=eq_struct->
numfields-1; idx++ ) {
208 field = &eq_struct->
fields[idx];
209 if (( strcmp(field->
elementname,
"localname") == 0) && localname==NULL) {
210 localname = (
char**)field->
value;
212 else if ( strcmp(field->
elementname,
"subnodes") == 0) {
215 mxArray* Msubnode = mxCreateStructMatrix(1, 1, 0, NULL);
217 mexPrintf(
"number of subnodes: %d\n", subnodes->
numfields );
220 for( jdx=0; jdx<subnodes->
numfields; jdx++ ) {
232 if ( localname == NULL ) {
233 localname = (
char**)mxMalloc(
sizeof(
char*) );
234 strcpy( localname[0],
"Unknown");
237 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)
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