Changeset e69e5c6 in tol
- Timestamp:
- Jun 21, 2009, 5:12:39 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- cd6c317
- Parents:
- 5390012
- File:
-
- 1 edited
-
tol/btol/matrix_type/matgra.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/btol/matrix_type/matgra.cpp
r5390012 re69e5c6 520 520 //-------------------------------------------------------------------- 521 521 DeclareContensClass(BMat, BMatTemporary, BMatReadFile); 522 DefExtOpr(1, BMatReadFile, "MatReadFile", 1, 1, "Text", 523 I2("(Text filename)", 524 "(Text nombreFichero)"), 525 I2("Reads a matrix from a file in binary format", 526 "Lee una matriz de un fichero en formato binario"), 522 DefExtOpr(1, BMatReadFile, "MatReadFile", 1, 2, "Text Text", 523 "(Text filename [, Text format=\"BINARY\"])", 524 I2("Reads a matrix from a file in the specified format", 525 "Lee una matriz de un fichero en el formato especificado")+":\n"+ 526 "BINARY: "+ 527 I2("Standard TOL binary format", 528 "Formato estándar binario de TOL")+ 529 "WGRIB2TXT: "+ 530 I2("Result of command", "Resultado del comando")+ 531 " wgrib2 ... -text file\n"+ 532 " rows cols\n"+ 533 " datum[1,1]\n" + 534 " datum[1,2]\n" + 535 " ...\n" + 536 " datum[rows,cols]\n"+ 537 I2("View more on ", "Ver más en ")+ 538 "http://www.cpc.noaa.gov/products/wesley/wgrib2/", 527 539 BOperClassify::MatrixAlgebra_); 528 540 //-------------------------------------------------------------------- … … 530 542 //-------------------------------------------------------------------- 531 543 { 532 BBM_BinRead(Text(Arg(1)),contens_); 533 } 544 BText fileName = Text(Arg(1)); 545 BText format = "BINARY"; 546 if(Arg(2)) { format = Text(Arg(2)); } 547 if(format=="BINARY") 548 { 549 BBM_BinRead(fileName,contens_); 550 } 551 else if(format=="WGRIB2TXT") 552 { 553 FILE* file = fopen(fileName.String(),"r"); 554 int i, j, rows, cols; 555 fscanf(file, "%ld %ld", &rows, &cols); 556 contens_.Alloc(rows, cols); 557 double* x = (double*)contens_.GetData().GetBuffer(); 558 for(i=0; !feof(file) && (i<rows); i++) 559 { 560 for(j=0; j<cols; j++, x++) 561 { 562 fscanf(file, "%lf",x); 563 } 564 } 565 } 566 } 567 534 568 535 569 //--------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.
