//mexData.C // can efficiently extract data from a file which contains ASCII data and text. // written by Mike.Zhang, 5-5/28/2002, Copyright reserved. // run under MatLab enviroment and compiled by MatLab embeded Lcc C compiler. // Copyright (C) 2002 ABINIT group (Mike Zhang) // This file is distributed under the terms of the // GNU General Public License, see ~abinit/COPYING // or http://www.gnu.org/copyleft/gpl.txt . // For the initials of contributors, see ~abinit/doc/developers/contributors . #include "mex.h" #include #include mxArray *data; double *Data; int dataDims; int M, N, L; // Support max dimensions is up to 3 char strSign[128] = "Eigenvalues ( eV ) for nkpt=", strSign2[128] = "", strInnerInterval[128] = "coord)", strOuterInterval[128] = ""; int fstrstr(FILE *fp, const char* Str, const int ScanLen) { int ScanChar; long curFP, bytes=0; if (ScanLen == 0) return 1; // null string always return TRUE. curFP = ftell(fp); do { ScanChar = fgetc(fp); if ((char)ScanChar == Str[0]) { int i; for (i=1; i= 2) { mxGetString(prhs[1], name, 127); if (nrhs >= 3) mxGetString(prhs[2], strSign, 127); if (nrhs >= 4) mxGetString(prhs[3], strInnerInterval, 127); if (nrhs >= 5) mxGetString(prhs[4], strOuterInterval, 127); if (nrhs >= 6) mxGetString(prhs[5], strSign2, 127); } mexPrintf("Data Extractor\n" "Read file : '%s'\n" "Signature string : '%s'\n" "InnerInterval string : '%s'\n" "OuterInterval string : '%s'\n" "2nd Signature string : '%s'\n" "Output array dimensions: %d x %d x %d\n", name, strSign, strInnerInterval, strOuterInterval, strSign2, M, N, L); status = readData(name); if (status == 1) mexPrintf("Data extracted success.\n"); else if (status == -1) mexPrintf("Error: Can't open file '%s'.\n", name); else if (status == -3) mexPrintf("Error: Can't find string '%s'.\n", strSign); else if (status == -5) mexPrintf("Error: Can't find string '%s'.\n", strInnerInterval); else if (status == -7) mexPrintf("Error: Can't find string '%s'.\n", strSign2); else if (status == -9) mexPrintf("Error: Can't find string '%s'.\n", strOuterInterval); plhs[0] = data; }