00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00022
00024
00033 #if HAVE_CONFIG_H
00034 #include "config.h"
00035 #endif
00036
00038
00040
00041 #include <math.h>
00042 #include "arts.h"
00043 #include "atm_funcs.h"
00044 #include "math_funcs.h"
00045 #include "messages.h"
00046 #include "auto_md.h"
00047 #include "make_array.h"
00048
00049 #ifdef HDF_SUPPORT
00050
00051 #include <hdf.h>
00052
00053
00054
00056
00058
00060
00071 void filename_bin(
00072 String& filename,
00073 const String& varname )
00074 {
00075 if ( "" == filename )
00076 {
00077 extern const String out_basename;
00078 filename = out_basename+"."+varname+".ab";
00079 }
00080 }
00081
00082
00083
00085
00095 void check_data_types()
00096 {
00097 if ( sizeof(Index) != 4 )
00098 throw runtime_error("An Index is expected to be 4 bytes.");
00099 if ( sizeof(float) != 4 )
00100 throw runtime_error("A float is expected to be 4 bytes.");
00101 if ( sizeof(double) != 8 )
00102 throw runtime_error("A double is expected to be 8 bytes.");
00103 if ( sizeof(char) != 1 )
00104 throw runtime_error("A char is expected to be 1 byte.");
00105 }
00106
00107
00108
00110
00122 void binfile_open_out(
00123 int& fid,
00124 const String& filename )
00125 {
00126
00127 fid = Hopen( filename.c_str(), DFACC_CREATE, 0 );
00128 if ( fid < 0 )
00129 {
00130 ostringstream os;
00131 os << "Cannot create output file: " << filename << '\n'
00132 << "Maybe you don't have write access to the directory or the file?";
00133 throw runtime_error(os.str());
00134 }
00135 out2 << " Opened file " << filename << " for writing.\n";
00136
00137
00138 if ( Vstart( fid ) < 0 )
00139 {
00140 ostringstream os;
00141 os << "Cannot initialize the VS interafce in file: " << filename;
00142 throw runtime_error(os.str());
00143 }
00144 }
00145
00146
00147
00149
00162 void binfile_open_in(
00163 int& fid,
00164 const String& filename )
00165 {
00166
00167 if ( Hishdf( filename.c_str() ) < 0 )
00168 {
00169 ostringstream os;
00170 os << "The file " << filename << " is not a HDF file.\n";
00171 throw runtime_error(os.str());
00172 }
00173
00174
00175 fid = Hopen( filename.c_str(), DFACC_READ, 0 );
00176 if ( fid < 0 )
00177 {
00178 ostringstream os;
00179 os << "Cannot open input file: " << filename << '\n'
00180 << "Maybe you don't have read access to the directory or the file?";
00181 throw runtime_error(os.str());
00182 }
00183 out2 << " Opened file " << filename << " for reading.\n";
00184
00185
00186 if ( Vstart( fid ) < 0 )
00187 {
00188 ostringstream os;
00189 os << "Cannot initialize the VS interafce in file: " << filename;
00190 throw runtime_error(os.str());
00191 }
00192 }
00193
00194
00195
00197
00209 void binfile_close(
00210 int& fid,
00211 const String& filename )
00212 {
00213
00214 if ( Vend( fid ) < 0 )
00215 {
00216 ostringstream os;
00217 os << "Cannot terminate access to the VS interface in: " << filename;
00218 throw runtime_error(os.str());
00219 }
00220
00221
00222 if ( Hclose( fid ) < 0 )
00223 {
00224 ostringstream os;
00225 os << "Cannot close file: " << filename;
00226 throw runtime_error(os.str());
00227 }
00228
00229 out2 << " Closed file " << filename << "\n";
00230 }
00231
00232
00233
00235
00251 void binfile_write_size(
00252 const String& filename,
00253 const String& dataname,
00254 const int& vdata_id,
00255 const Index& nrows,
00256 const Index& ncols )
00257 {
00258 Index v[2];
00259 v[0] = nrows;
00260 v[1] = ncols;
00261
00262 if ( VSsetattr( vdata_id, _HDF_VDATA, "SIZE", DFNT_UINT32, 2, v ) < 0 )
00263 {
00264 ostringstream os;
00265 os << "Cannot write size data for " << dataname << " in file " << filename;
00266 throw runtime_error(os.str());
00267 }
00268 }
00269
00270
00271
00273
00294 void binfile_read_init(
00295 int& vdata_id,
00296 Index& nrows,
00297 Index& ncols,
00298 const int& fid,
00299 const String& filename,
00300 const String& dataname,
00301 const String& storagetype,
00302 const Index& nrows0,
00303 const Index& ncols0 )
00304 {
00305
00306 int vdata_ref = VSfind( fid, dataname.c_str() );
00307 if ( vdata_ref <= 0 )
00308 {
00309 ostringstream os;
00310 os << "Cannot find the data " << dataname << " in file " <<filename<<"\n"
00311 << "Maybe the file contains data of other type";
00312 throw runtime_error(os.str());
00313 }
00314
00315
00316 vdata_id = VSattach( fid, vdata_ref, "r" );
00317 if ( vdata_id <= 0 )
00318 {
00319 ostringstream os;
00320 os << "Cannot attach the data " << dataname << " in file " << filename;
00321 throw runtime_error(os.str());
00322 }
00323
00324
00325 Index v[2];
00326 if ( VSgetattr( vdata_id, _HDF_VDATA, 0, v ) < 0 )
00327 {
00328 ostringstream os;
00329 os << "Cannot determine the size of " << dataname << "\n"
00330 << "in file " << filename;
00331 throw runtime_error(os.str());
00332 }
00333 nrows = v[0];
00334 ncols = v[1];
00335
00336
00337 if ( (nrows0>0) && (nrows!=nrows0) )
00338 {
00339 ostringstream os;
00340 os << nrows0 << " rows were expected, but the data have " <<nrows<<" rows";
00341 throw runtime_error(os.str());
00342 }
00343 if ( (ncols0>0) && (ncols!=ncols0) )
00344 {
00345 ostringstream os;
00346 os << ncols0 << " columns were expected, but the data have " << ncols
00347 << " columns";
00348 throw runtime_error(os.str());
00349 }
00350
00351
00352 if ( (nrows>0) && (ncols>0) )
00353 {
00354 if ( VSsetfields( vdata_id, storagetype.c_str() ) < 0 )
00355 {
00356 cout << dataname << endl;
00357 ostringstream os;
00358 os << "Cannot find the field " << storagetype << " in file " << filename
00359 << "\n" << "Maybe the file contains data of other type";
00360 throw runtime_error(os.str());
00361 }
00362 }
00363 }
00364
00365
00366
00368
00380 void binfile_read_end(
00381 int& vdata_id,
00382 const String& filename,
00383 const String& dataname )
00384 {
00385 if ( VSdetach( vdata_id ) < 0 )
00386 {
00387 ostringstream os;
00388 os << "Cannot detach the field " << dataname << " in file " << filename;
00389 throw runtime_error(os.str());
00390 }
00391 }
00392
00393
00394
00396
00405 void binfile_get_datatype(
00406 String& type_in_file,
00407 const int& vdata_id )
00408 {
00409 char c[50];
00410 VSgetclass( vdata_id, c );
00411 type_in_file = c;
00412 }
00413
00414
00415
00417
00419
00421
00440 void binfile_write(
00441 const int& fid,
00442 const String& filename,
00443 const String& dataname,
00444 const String& storagetype,
00445 const String& atomictype,
00446 const Index& nrows,
00447 const Index& ncols,
00448 const uint8* dpointer )
00449 {
00450
00451 check_data_types();
00452
00453 out3 << " Writing: " << dataname << "\n";
00454
00455
00456 int vdata_id = VSattach( fid, -1, "w" );
00457 if ( vdata_id < 0 )
00458 {
00459 ostringstream os;
00460 os << "Cannot create a new vdata in file " << filename;
00461 throw runtime_error(os.str());
00462 }
00463
00464
00465 if ( VSsetname( vdata_id, dataname.c_str() ) < 0 )
00466 {
00467 ostringstream os;
00468 os << "Cannot name the vdata " << dataname << " in file " << filename;
00469 throw runtime_error(os.str());
00470 }
00471
00472
00473 binfile_write_size( filename, dataname, vdata_id, nrows, ncols );
00474
00475
00476 int status1, status2;
00477
00478 if ( atomictype == "INDEX" )
00479 {
00480 status1 = VSsetclass( vdata_id, "UINT" );
00481 status2 = VSfdefine( vdata_id, storagetype.c_str(), DFNT_UINT32, 1);
00482 }
00483 else if ( atomictype == "NUMERIC" )
00484 {
00485 if ( sizeof(Numeric) == 4 )
00486 {
00487 status1 = VSsetclass( vdata_id, "FLOAT" );
00488 status2 = VSfdefine( vdata_id, storagetype.c_str(), DFNT_FLOAT32, 1);
00489 }
00490 else
00491 {
00492 status1 = VSsetclass( vdata_id, "DOUBLE" );
00493 status2 = VSfdefine( vdata_id, storagetype.c_str(), DFNT_FLOAT64, 1);
00494 }
00495 }
00496
00497 else if ( atomictype == "CHAR" )
00498 {
00499 status1 = VSsetclass( vdata_id, "CHAR" );
00500 status2 = VSfdefine( vdata_id, storagetype.c_str(), DFNT_CHAR, 1);
00501 }
00502 else
00503 {
00504 ostringstream os;
00505 os << "The atomic data type " << atomictype << " is not handled";
00506 throw runtime_error(os.str());
00507 }
00508
00509
00510 if ( status1 < 0 )
00511 {
00512 ostringstream os;
00513 os << "Cannot set class on " << dataname << " in file "<<filename;
00514 throw runtime_error(os.str());
00515 }
00516 if ( status2 < 0 )
00517 {
00518 ostringstream os;
00519 os << "Cannot create the field " << storagetype << " in file "<<filename;
00520 throw runtime_error(os.str());
00521 }
00522
00523
00524 if ( VSsetfields( vdata_id, storagetype.c_str() ) < 0 )
00525 {
00526 ostringstream os;
00527 os << "Cannot set the field " << storagetype << " in file " << filename;
00528 throw runtime_error(os.str());
00529 }
00530
00531
00532 if ( (nrows>0) && (ncols>0) )
00533 {
00534
00535 const Index nout = nrows*ncols;
00536 Index ndone = VSwrite( vdata_id, dpointer, nout, FULL_INTERLACE );
00537 if ( ndone != nout )
00538 {
00539 ostringstream os;
00540 os << "Could not write all data to field " << storagetype << "in file "
00541 << filename << "\nOut of memory?";
00542 throw runtime_error(os.str());
00543 }
00544 }
00545
00546
00547 if ( VSdetach( vdata_id ) < 0 )
00548 {
00549 ostringstream os;
00550 os << "Cannot detach the vdata " << dataname << " in file " << filename;
00551 throw runtime_error(os.str());
00552 }
00553 }
00554
00555
00556
00558
00576 void binfile_read1(
00577 ArrayOfIndex& x,
00578 const int& vdata_id,
00579 const Index& n,
00580 const String& ,
00581 const String& dataname )
00582 {
00583
00584 check_data_types();
00585
00586 out3 << " Reading: " << dataname << "\n";
00587
00588
00589 String type_in_file;
00590 binfile_get_datatype( type_in_file, vdata_id );
00591
00592
00593 x.resize(n);
00594
00595 if ( n > 0 )
00596 {
00597
00598 if ( type_in_file == "UINT" )
00599
00600 VSread( vdata_id, (uint8*)&x[0], n, FULL_INTERLACE );
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610 else
00611 {
00612 ostringstream os;
00613 os << "Files with data type " << type_in_file << " are not handled";
00614 throw runtime_error(os.str());
00615 }
00616 }
00617 }
00618
00619
00620
00622
00645 void binfile_read2(
00646 Matrix& x,
00647 const int& vdata_id,
00648 const Index& nrows,
00649 const Index& ncols,
00650 const String& ,
00651 const String& dataname )
00652 {
00653
00654 check_data_types();
00655
00656 out3 << " Reading: " << dataname << "\n";
00657
00658
00659 String type_in_file;
00660 binfile_get_datatype( type_in_file, vdata_id );
00661
00662
00663 x.resize(nrows,ncols);
00664
00665 if ( (nrows > 0) && (ncols > 0) )
00666 {
00667
00668 if ( type_in_file == "FLOAT" )
00669
00670 if ( sizeof(Numeric) == 4 )
00671
00672 VSread( vdata_id, (uint8*)&x(0,0), nrows*ncols, FULL_INTERLACE );
00673
00674 else
00675 {
00676 float *a = new float[nrows*ncols];
00677 Index i,j,j0;
00678 VSread( vdata_id, (uint8*)a, nrows*ncols, FULL_INTERLACE );
00679 for ( i=0; i<nrows; i++ )
00680 {
00681 j0 = i*ncols;
00682 for ( j=0; j<ncols; j++ )
00683 x(i,j) = a[j0+j];
00684 }
00685 delete[] a;
00686 }
00687
00688 else if ( type_in_file == "DOUBLE" )
00689
00690 if ( sizeof(Numeric) == 8 )
00691
00692 VSread( vdata_id, (uint8*)&x(0,0), nrows*ncols, FULL_INTERLACE );
00693
00694 else
00695 {
00696 double *a = new double[nrows*ncols];
00697 Index i,j,j0;
00698 VSread( vdata_id, (uint8*)a, nrows*ncols, FULL_INTERLACE );
00699 for ( i=0; i<nrows; i++ )
00700 {
00701 j0 = i*ncols;
00702 for ( j=0; j<ncols; j++ )
00703 x(i,j) = a[j0+j];
00704 }
00705 delete[] a;
00706 }
00707
00708 else
00709 {
00710 ostringstream os;
00711 os << "Files with data type " << type_in_file << " are not handled";
00712 throw runtime_error(os.str());
00713 }
00714 }
00715 }
00716
00717
00718
00720
00738 void binfile_read3(
00739 String& x,
00740 const int& vdata_id,
00741 const Index& n,
00742 const String& ,
00743 const String& dataname )
00744 {
00745
00746 check_data_types();
00747
00748 out3 << " Reading: " << dataname << "\n";
00749
00750
00751 String type_in_file;
00752 binfile_get_datatype( type_in_file, vdata_id );
00753
00754
00755 x.resize(n);
00756
00757 if ( n > 0 )
00758 {
00759
00760 if ( type_in_file == "CHAR" )
00761
00762 VSread( vdata_id, (uint8*)&x[0], n, FULL_INTERLACE );
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772 else
00773 {
00774 ostringstream os;
00775 os << "Files with data type " << type_in_file << " are not handled";
00776 throw runtime_error(os.str());
00777 }
00778 }
00779 }
00780
00781
00782
00784
00786
00788
00799 void binfile_write_index(
00800 const String& filename,
00801 const int& fid,
00802 const Index& x,
00803 const String& dataname )
00804 {
00805
00806
00807
00808
00809
00810
00811 binfile_write( fid, filename, dataname, "SCALAR", "INDEX", 1, 1,
00812 (uint8*)&x );
00813 }
00814
00815
00816
00818
00829 void binfile_read_index(
00830 Index& x,
00831 const String& filename,
00832 const int& fid,
00833 const String& dataname )
00834 {
00835 int vdata_id;
00836 Index nrows, ncols;
00837 ArrayOfIndex a;
00838
00839 binfile_read_init( vdata_id, nrows, ncols, fid, filename, dataname,
00840 "SCALAR", 1, 1 );
00841 binfile_read1( a, vdata_id, nrows, filename, dataname );
00842 x = a[0];
00843 binfile_read_end( vdata_id, filename, dataname );
00844 }
00845
00846
00847
00849
00860 void binfile_write_numeric(
00861 const String& filename,
00862 const int& fid,
00863 const Numeric& x,
00864 const String& dataname )
00865 {
00866
00867
00868 binfile_write( fid, filename, dataname, "SCALAR", "NUMERIC", 1, 1,
00869 (uint8*)&x );
00870 }
00871
00872
00873
00875
00886 void binfile_read_numeric(
00887 Numeric& x,
00888 const String& filename,
00889 const int& fid,
00890 const String& dataname )
00891 {
00892 int vdata_id;
00893 Index nrows, ncols;
00894 Matrix a;
00895
00896 binfile_read_init( vdata_id, nrows, ncols, fid, filename, dataname,
00897 "SCALAR", 1, 1 );
00898 binfile_read2( a, vdata_id, nrows, ncols, filename, dataname );
00899 x = a(0,0);
00900 binfile_read_end( vdata_id, filename, dataname );
00901 }
00902
00903
00904
00906
00917 void binfile_write_vector(
00918 const String& filename,
00919 const int& fid,
00920 const Vector& x,
00921 const String& dataname )
00922 {
00923 const Index n = x.nelem();
00924
00925 Numeric *a = new Numeric[n];
00926 for ( Index i=0; i<n; i++ )
00927 a[i] = x[i];
00928
00929 binfile_write( fid, filename, dataname, "VECTOR", "NUMERIC", n, 1,
00930 (uint8*)a );
00931
00932 delete a;
00933 }
00934
00935
00936
00938
00949 void binfile_read_vector(
00950 Vector& x,
00951 const String& filename,
00952 const int& fid,
00953 const String& dataname )
00954 {
00955 int vdata_id;
00956 Index nrows, ncols;
00957 Matrix a;
00958
00959 binfile_read_init( vdata_id, nrows, ncols, fid, filename, dataname,
00960 "VECTOR", 0, 1 );
00961 binfile_read2( a, vdata_id, nrows, ncols, filename, dataname );
00962 x.resize(nrows);
00963 for ( Index i=0; i<nrows; i++ )
00964 x[i] = a(i,0);
00965 binfile_read_end( vdata_id, filename, dataname );
00966 }
00967
00968
00969
00971
00986 void binfile_write_matrix(
00987 const String& filename,
00988 const int& fid,
00989 const Matrix& x,
00990 const String& dataname )
00991 {
00992 const Index nrows = x.nrows();
00993 const Index ncols = x.ncols();
00994
00995 Numeric *a = new Numeric[nrows*ncols];
00996 for ( Index r=0; r<nrows; r++ )
00997 for ( Index c=0; c<ncols; c++ )
00998 a[r*ncols+c] = x(r,c);
00999
01000 binfile_write( fid, filename, dataname, "MATRIX", "NUMERIC", nrows, ncols,
01001 (uint8*)a );
01002 delete a;
01003 }
01004
01005
01006
01008
01019 void binfile_read_matrix(
01020 Matrix& x,
01021 const String& filename,
01022 const int& fid,
01023 const String& dataname )
01024 {
01025 int vdata_id;
01026 Index nrows, ncols;
01027
01028 binfile_read_init( vdata_id, nrows, ncols, fid, filename, dataname,
01029 "MATRIX", 0, 0 );
01030 binfile_read2( x, vdata_id, nrows, ncols, filename, dataname );
01031 binfile_read_end( vdata_id, filename, dataname );
01032 }
01033
01034
01035
01037
01048 void binfile_write_indexarray(
01049 const String& filename,
01050 const int& fid,
01051 const ArrayOfIndex& x,
01052 const String& dataname )
01053 {
01054 const Index n = x.nelem();
01055
01056
01057
01058
01059
01060
01061
01062
01063 binfile_write( fid, filename, dataname, "ARRAY", "INDEX", n, 1,
01064 (uint8*)&x[0] );
01065 }
01066
01067
01068
01070
01081 void binfile_read_indexarray(
01082 ArrayOfIndex& x,
01083 const String& filename,
01084 const int& fid,
01085 const String& dataname )
01086 {
01087 int vdata_id;
01088 Index nrows, ncols;
01089
01090 binfile_read_init( vdata_id, nrows, ncols, fid, filename, dataname,
01091 "ARRAY", 0, 1 );
01092 binfile_read1( x, vdata_id, nrows, filename, dataname );
01093 binfile_read_end( vdata_id, filename, dataname );
01094 }
01095
01096
01097
01099
01110 void binfile_write_vectorarray(
01111 const String& filename,
01112 const int& fid,
01113 const ArrayOfVector& x,
01114 const String& dataname )
01115 {
01116 const Index n = x.nelem();
01117
01118
01119 binfile_write_index( filename, fid, n, "N_"+dataname );
01120
01121
01122 for (Index i=0; i<n; i++ )
01123 {
01124 ostringstream os;
01125 os << dataname << i;
01126 binfile_write_vector( filename, fid, x[i], os.str() );
01127 }
01128 }
01129
01130
01131
01133
01144 void binfile_read_vectorarray(
01145 ArrayOfVector& x,
01146 const String& filename,
01147 const int& fid,
01148 const String& dataname )
01149 {
01150
01151 Index n;
01152 binfile_read_index( n, filename, fid, "N_"+dataname );
01153
01154
01155 x.resize(n);
01156 for (Index i=0; i<n; i++ )
01157 {
01158 ostringstream os;
01159 os << dataname << i;
01160 binfile_read_vector( x[i], filename, fid, os.str() );
01161 }
01162 }
01163
01164
01165
01167
01178 void binfile_write_matrixarray(
01179 const String& filename,
01180 const int& fid,
01181 const ArrayOfMatrix& x,
01182 const String& dataname )
01183 {
01184 const Index n = x.nelem();
01185
01186
01187 binfile_write_index( filename, fid, n, "N_"+dataname );
01188
01189
01190 for ( Index i=0; i<n; i++ )
01191 {
01192 ostringstream os;
01193 os << dataname << i;
01194 binfile_write_matrix( filename, fid, x[i], os.str() );
01195 }
01196 }
01197
01198
01199
01201
01212 void binfile_read_matrixarray(
01213 ArrayOfMatrix& x,
01214 const String& filename,
01215 const int& fid,
01216 const String& dataname )
01217 {
01218
01219 Index n;
01220 binfile_read_index( n, filename, fid, "N_"+dataname );
01221
01222
01223 x.resize(n);
01224 for (Index i=0; i<n; i++ )
01225 {
01226 ostringstream os;
01227 os << dataname << i;
01228 binfile_read_matrix( x[i], filename, fid, os.str() );
01229 }
01230 }
01231
01232
01233
01235
01246 void binfile_write_String(
01247 const String& filename,
01248 const int& fid,
01249 const String& s,
01250 const String& dataname )
01251 {
01252 const Index n = s.length();
01253
01254 binfile_write( fid, filename, dataname, "STRING", "CHAR", n, 1,
01255 (uint8*)s.c_str() );
01256 }
01257
01258
01259
01261
01272 void binfile_read_String(
01273 String& x,
01274 const String& filename,
01275 const int& fid,
01276 const String& dataname )
01277 {
01278 int vdata_id;
01279 Index nrows, ncols;
01280
01281 binfile_read_init( vdata_id, nrows, ncols, fid, filename, dataname,
01282 "STRING", 0, 1 );
01283 binfile_read3( x, vdata_id, nrows, filename, dataname );
01284 binfile_read_end( vdata_id, filename, dataname );
01285 }
01286
01287
01288
01290
01301 void binfile_write_Stringarray(
01302 const String& filename,
01303 const int& fid,
01304 const ArrayOfString& x,
01305 const String& dataname )
01306 {
01307 const Index n = x.nelem();
01308
01309
01310 binfile_write_index( filename, fid, n, "N_"+dataname );
01311
01312
01313 for ( Index i=0; i<n; i++ )
01314 {
01315 ostringstream os;
01316 os << dataname << i;
01317 binfile_write_String( filename, fid, x[i], os.str() );
01318 }
01319 }
01320
01321
01322
01324
01335 void binfile_read_Stringarray(
01336 ArrayOfString& x,
01337 const String& filename,
01338 const int& fid,
01339 const String& dataname )
01340 {
01341
01342 Index n;
01343 binfile_read_index( n, filename, fid, "N_"+dataname );
01344
01345
01346 x.resize(n);
01347 for (Index i=0; i<n; i++ )
01348 {
01349 ostringstream os;
01350 os << dataname << i;
01351 binfile_read_String( x[i], filename, fid, os.str() );
01352 }
01353 }
01354
01355 #endif // HDF_SUPPORT
01356
01357
01358
01360
01362
01363
01364
01371
01372 #ifdef HDF_SUPPORT
01373 void IndexWriteBinary(
01374 const Index& v,
01375 const String& var_name,
01376 const String& f )
01377 {
01378 int fid;
01379 String filename = f;
01380 filename_bin( filename, var_name );
01381 binfile_open_out( fid, filename );
01382 binfile_write_index( filename, fid, v, "Index" );
01383 binfile_close( fid, filename );
01384 }
01385 #else
01386 void IndexWriteBinary(
01387 const Index& ,
01388 const String& ,
01389 const String& )
01390 {
01391 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01392 }
01393 #endif // HDF_SUPPORT
01394
01395
01396
01403
01404 #ifdef HDF_SUPPORT
01405 void IndexReadBinary(
01406 Index& v,
01407 const String& var_name,
01408 const String& f )
01409 {
01410 Index vtemp;
01411 int fid;
01412 String filename = f;
01413 filename_bin( filename, var_name );
01414 binfile_open_in( fid, filename );
01415 binfile_read_index( vtemp, filename, fid, "Index" );
01416 v = (int) vtemp;
01417 binfile_close( fid, filename );
01418 }
01419 #else
01420 void IndexReadBinary(
01421 Index& ,
01422 const String& ,
01423 const String& )
01424 {
01425 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01426 }
01427 #endif // HDF_SUPPORT
01428
01429
01430
01431
01438 #ifdef HDF_SUPPORT
01439 void NumericWriteBinary(
01440 const Numeric& v,
01441 const String& var_name,
01442 const String& f )
01443 {
01444 int fid;
01445 String filename = f;
01446 filename_bin( filename, var_name );
01447 binfile_open_out( fid, filename );
01448 binfile_write_numeric( filename, fid, v, "NUMERIC" );
01449 binfile_close( fid, filename );
01450 }
01451 #else
01452 void NumericWriteBinary(
01453 const Numeric& ,
01454 const String& ,
01455 const String& )
01456 {
01457 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01458 }
01459 #endif // HDF_SUPPORT
01460
01461
01462
01463
01470 #ifdef HDF_SUPPORT
01471 void NumericReadBinary(
01472 Numeric& v,
01473 const String& var_name,
01474 const String& f )
01475 {
01476 int fid;
01477 String filename = f;
01478 filename_bin( filename, var_name );
01479 binfile_open_in( fid, filename );
01480 binfile_read_numeric( v, filename, fid, "NUMERIC" );
01481 binfile_close( fid, filename );
01482 }
01483 #else
01484 void NumericReadBinary(
01485 Numeric& ,
01486 const String& ,
01487 const String& )
01488 {
01489 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01490 }
01491 #endif // HDF_SUPPORT
01492
01493
01494
01495
01496
01497
01504 #ifdef HDF_SUPPORT
01505 void VectorWriteBinary(
01506 const Vector& v,
01507 const String& var_name,
01508 const String& f )
01509 {
01510 int fid;
01511 String filename = f;
01512 filename_bin( filename, var_name );
01513 binfile_open_out( fid, filename );
01514 binfile_write_vector( filename, fid, v, "VECTOR" );
01515 binfile_close( fid, filename );
01516 }
01517 #else
01518 void VectorWriteBinary(
01519 const Vector& ,
01520 const String& ,
01521 const String& )
01522 {
01523 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01524 }
01525 #endif // HDF_SUPPORT
01526
01527
01528
01529
01536 #ifdef HDF_SUPPORT
01537 void VectorReadBinary(
01538 Vector& v,
01539 const String& var_name,
01540 const String& f )
01541 {
01542 int fid;
01543 String filename = f;
01544 filename_bin( filename, var_name );
01545 binfile_open_in( fid, filename );
01546 binfile_read_vector( v, filename, fid, "VECTOR" );
01547 binfile_close( fid, filename );
01548 }
01549 #else
01550 void VectorReadBinary(
01551 Vector& ,
01552 const String& ,
01553 const String& )
01554 {
01555 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01556 }
01557 #endif // HDF_SUPPORT
01558
01559
01560
01561
01562
01563
01570 #ifdef HDF_SUPPORT
01571 void MatrixWriteBinary(
01572 const Matrix& v,
01573 const String& var_name,
01574 const String& f )
01575 {
01576 int fid;
01577 String filename = f;
01578 filename_bin( filename, var_name );
01579 binfile_open_out( fid, filename );
01580 binfile_write_matrix( filename, fid, v, "MATRIX" );
01581 binfile_close( fid, filename );
01582 }
01583 #else
01584 void MatrixWriteBinary(
01585 const Matrix& ,
01586 const String& ,
01587 const String& )
01588 {
01589 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01590 }
01591 #endif // HDF_SUPPORT
01592
01593
01594
01595
01602 #ifdef HDF_SUPPORT
01603 void MatrixReadBinary(
01604 Matrix& v,
01605 const String& var_name,
01606 const String& f )
01607 {
01608 int fid;
01609 String filename = f;
01610 filename_bin( filename, var_name );
01611 binfile_open_in( fid, filename );
01612 binfile_read_matrix( v, filename, fid, "MATRIX" );
01613 binfile_close( fid, filename );
01614 }
01615 #else
01616 void MatrixReadBinary(
01617 Matrix& ,
01618 const String& ,
01619 const String& )
01620 {
01621 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01622 }
01623 #endif // HDF_SUPPORT
01624
01625
01626
01627
01628
01629
01636 #ifdef HDF_SUPPORT
01637 void ArrayOfIndexWriteBinary(
01638 const ArrayOfIndex& v,
01639 const String& var_name,
01640 const String& f )
01641 {
01642 int fid;
01643 String filename = f;
01644 filename_bin( filename, var_name );
01645 binfile_open_out( fid, filename );
01646 binfile_write_indexarray( filename, fid, v, "INDEXARRAY" );
01647 binfile_close( fid, filename );
01648 }
01649 #else
01650 void ArrayOfIndexWriteBinary(
01651 const ArrayOfIndex& ,
01652 const String& ,
01653 const String& )
01654 {
01655 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01656 }
01657 #endif // HDF_SUPPORT
01658
01659
01660
01661
01668 #ifdef HDF_SUPPORT
01669 void ArrayOfIndexReadBinary(
01670 ArrayOfIndex& v,
01671 const String& var_name,
01672 const String& f )
01673 {
01674 int fid;
01675 String filename = f;
01676 filename_bin( filename, var_name );
01677 binfile_open_in( fid, filename );
01678 binfile_read_indexarray( v, filename, fid, "INDEXARRAY" );
01679 binfile_close( fid, filename );
01680 }
01681 #else
01682 void ArrayOfIndexReadBinary(
01683 ArrayOfIndex& ,
01684 const String& ,
01685 const String& )
01686 {
01687 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01688 }
01689 #endif // HDF_SUPPORT
01690
01691
01692
01693
01694
01695
01702 #ifdef HDF_SUPPORT
01703 void ArrayOfVectorWriteBinary(
01704 const ArrayOfVector& v,
01705 const String& var_name,
01706 const String& f )
01707 {
01708 int fid;
01709 String filename = f;
01710 filename_bin( filename, var_name );
01711 binfile_open_out( fid, filename );
01712 binfile_write_vectorarray( filename, fid, v, "VECTOR" );
01713 binfile_close( fid, filename );
01714 }
01715 #else
01716 void ArrayOfVectorWriteBinary(
01717 const ArrayOfVector& ,
01718 const String& ,
01719 const String& )
01720 {
01721 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01722 }
01723 #endif // HDF_SUPPORT
01724
01725
01726
01727
01734 #ifdef HDF_SUPPORT
01735 void ArrayOfVectorReadBinary(
01736 ArrayOfVector& v,
01737 const String& var_name,
01738 const String& f )
01739 {
01740 int fid;
01741 String filename = f;
01742 filename_bin( filename, var_name );
01743 binfile_open_in( fid, filename );
01744 binfile_read_vectorarray( v, filename, fid, "VECTOR" );
01745 binfile_close( fid, filename );
01746 }
01747 #else
01748 void ArrayOfVectorReadBinary(
01749 ArrayOfVector& ,
01750 const String& ,
01751 const String& )
01752 {
01753 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01754 }
01755 #endif // HDF_SUPPORT
01756
01757
01758
01759
01760
01761
01768 #ifdef HDF_SUPPORT
01769 void ArrayOfMatrixWriteBinary(
01770 const ArrayOfMatrix& v,
01771 const String& var_name,
01772 const String& f )
01773 {
01774 int fid;
01775 String filename = f;
01776 filename_bin( filename, var_name );
01777 binfile_open_out( fid, filename );
01778 binfile_write_matrixarray( filename, fid, v, "MATRIX" );
01779 binfile_close( fid, filename );
01780 }
01781 #else
01782 void ArrayOfMatrixWriteBinary(
01783 const ArrayOfMatrix& ,
01784 const String& ,
01785 const String& )
01786 {
01787 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01788 }
01789 #endif // HDF_SUPPORT
01790
01791
01792
01793
01800 #ifdef HDF_SUPPORT
01801 void ArrayOfMatrixReadBinary(
01802 ArrayOfMatrix& v,
01803 const String& var_name,
01804 const String& f )
01805 {
01806 int fid;
01807 String filename = f;
01808 filename_bin( filename, var_name );
01809 binfile_open_in( fid, filename );
01810 binfile_read_matrixarray( v, filename, fid, "MATRIX" );
01811 binfile_close( fid, filename );
01812 }
01813 #else
01814 void ArrayOfMatrixReadBinary(
01815 ArrayOfMatrix& ,
01816 const String& ,
01817 const String& )
01818 {
01819 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01820 }
01821 #endif // HDF_SUPPORT
01822
01823
01824
01825
01826
01827
01834 #ifdef HDF_SUPPORT
01835 void StringWriteBinary(
01836 const String& v,
01837 const String& var_name,
01838 const String& f )
01839 {
01840 int fid;
01841 String filename = f;
01842 filename_bin( filename, var_name );
01843 binfile_open_out( fid, filename );
01844 binfile_write_String( filename, fid, v, "STRING" );
01845 binfile_close( fid, filename );
01846 }
01847 #else
01848 void StringWriteBinary(
01849 const String& ,
01850 const String& ,
01851 const String& )
01852 {
01853 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01854 }
01855 #endif // HDF_SUPPORT
01856
01857
01858
01859
01866 #ifdef HDF_SUPPORT
01867 void StringReadBinary(
01868 String& v,
01869 const String& var_name,
01870 const String& f )
01871 {
01872 int fid;
01873 String filename = f;
01874 filename_bin( filename, var_name );
01875 binfile_open_in( fid, filename );
01876 binfile_read_String( v, filename, fid, "STRING" );
01877 binfile_close( fid, filename );
01878 }
01879 #else
01880 void StringReadBinary(
01881 String& ,
01882 const String& ,
01883 const String& )
01884 {
01885 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01886 }
01887 #endif // HDF_SUPPORT
01888
01889
01890
01891
01892
01893
01900 #ifdef HDF_SUPPORT
01901 void ArrayOfStringWriteBinary(
01902 const ArrayOfString& v,
01903 const String& var_name,
01904 const String& f )
01905 {
01906 int fid;
01907 String filename = f;
01908 filename_bin( filename, var_name );
01909 binfile_open_out( fid, filename );
01910 binfile_write_Stringarray( filename, fid, v, "STRING" );
01911 binfile_close( fid, filename );
01912 }
01913 #else
01914 void ArrayOfStringWriteBinary(
01915 const ArrayOfString& ,
01916 const String& ,
01917 const String& )
01918 {
01919 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01920 }
01921 #endif // HDF_SUPPORT
01922
01923
01924
01925
01932 #ifdef HDF_SUPPORT
01933 void ArrayOfStringReadBinary(
01934 ArrayOfString& v,
01935 const String& var_name,
01936 const String& f )
01937 {
01938 int fid;
01939 String filename = f;
01940 filename_bin( filename, var_name );
01941 binfile_open_in( fid, filename );
01942 binfile_read_Stringarray( v, filename, fid, "STRING" );
01943 binfile_close( fid, filename );
01944 }
01945 #else
01946 void ArrayOfStringReadBinary(
01947 ArrayOfString& ,
01948 const String& ,
01949 const String& )
01950 {
01951 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01952 }
01953 #endif // HDF_SUPPORT
01954
01955
01956
01957
01958
01959
01966 #ifdef HDF_SUPPORT
01967 void LosWriteBinary(
01968 const Los& los,
01969 const String& var_name,
01970 const String& f )
01971 {
01972 int fid;
01973 String filename = f;
01974 filename_bin( filename, var_name );
01975
01976 binfile_open_out( fid, filename );
01977 binfile_write_vectorarray( filename, fid, los.p, "LOS.P" );
01978 binfile_write_vectorarray( filename, fid, los.psi, "LOS.PSI" );
01979 binfile_write_vectorarray( filename, fid, los.z, "LOS.Z" );
01980 binfile_write_vector( filename, fid, los.l_step, "LOS.L_STEP" );
01981 binfile_write_indexarray( filename, fid, los.ground, "LOS.GROUND" );
01982 binfile_write_indexarray( filename, fid, los.start, "LOS.START" );
01983 binfile_write_indexarray( filename, fid, los.stop, "LOS.STOP" );
01984 binfile_close( fid, filename );
01985 }
01986 #else
01987 void LosWriteBinary(
01988 const Los& ,
01989 const String& ,
01990 const String& )
01991 {
01992 throw runtime_error("This method is only available when arts is compiled with HDF support.");
01993 }
01994 #endif // HDF_SUPPORT
01995
01996
01997
01998
02005 #ifdef HDF_SUPPORT
02006 void LosReadBinary(
02007 Los& los,
02008 const String& var_name,
02009 const String& f )
02010 {
02011 int fid;
02012 String filename = f;
02013 filename_bin( filename, var_name );
02014
02015 binfile_open_in( fid, filename );
02016 binfile_read_vectorarray( los.p, filename, fid, "LOS.P" );
02017 binfile_read_vectorarray( los.psi, filename, fid, "LOS.PSI" );
02018 binfile_read_vectorarray( los.z, filename, fid, "LOS.Z" );
02019 binfile_read_vector( los.l_step, filename, fid, "LOS.L_STEP" );
02020 binfile_read_indexarray( los.ground, filename, fid, "LOS.GROUND" );
02021 binfile_read_indexarray( los.start, filename, fid, "LOS.START" );
02022 binfile_read_indexarray( los.stop, filename, fid, "LOS.STOP" );
02023 binfile_close( fid, filename );
02024 }
02025 #else
02026 void LosReadBinary(
02027 Los& ,
02028 const String& ,
02029 const String& )
02030 {
02031 throw runtime_error("This method is only available when arts is compiled with HDF support.");
02032 }
02033 #endif // HDF_SUPPORT
02034