ARTS  2.2.66
xml_io_array_types.cc
Go to the documentation of this file.
1 /* Copyright (C) 2003-2012 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
18 
20 // File description
22 
31 #include "arts.h"
32 #include "xml_io_private.h"
33 #include "xml_io_types.h"
34 #include "jacobian.h"
35 
36 
38 // Overloaded functions for reading/writing data from/to XML stream
40 
41 //=== Array<SpeciesRecord> ================================================
42 
44 
49 void xml_read_from_stream(istream& is_xml,
50  Array<SpeciesRecord>& asrecord,
51  bifstream* pbifs,
52  const Verbosity& verbosity)
53 {
54  ArtsXMLTag tag(verbosity);
55  Index nelem;
56 
57  tag.read_from_stream(is_xml);
58  tag.check_name("Array");
59  tag.check_attribute("type", "SpeciesData");
60 
61  tag.get_attribute_value("nelem", nelem);
62  asrecord.resize(nelem);
63 
64  Index n;
65  try
66  {
67  for (n = 0; n < nelem; n++)
68  {
69  xml_read_from_stream(is_xml, asrecord[n], pbifs, verbosity);
70  }
71  }
72  catch (runtime_error e)
73  {
74  ostringstream os;
75  os << "Error reading SpeciesData: "
76  << "\n Element: " << n
77  << "\n" << e.what();
78  throw runtime_error(os.str());
79  }
80 
81  tag.read_from_stream(is_xml);
82  tag.check_name("/Array");
83 }
84 
85 
87 
93 void xml_write_to_stream(ostream& os_xml,
94  const Array<SpeciesRecord>& asrecord,
95  bofstream* pbofs,
96  const String& name,
97  const Verbosity& verbosity)
98 {
99  ArtsXMLTag open_tag(verbosity);
100  ArtsXMLTag close_tag(verbosity);
101 
102  open_tag.set_name("Array");
103  if (name.length())
104  open_tag.add_attribute("name", name);
105 
106  open_tag.add_attribute("type", "SpeciesData");
107  open_tag.add_attribute("nelem", asrecord.nelem());
108 
109  open_tag.write_to_stream(os_xml);
110  os_xml << '\n';
111 
112  for (Index n = 0; n < asrecord.nelem(); n++)
113  {
114  xml_write_to_stream(os_xml, asrecord[n], pbofs, "", verbosity);
115  }
116 
117  close_tag.set_name("/Array");
118  close_tag.write_to_stream(os_xml);
119 
120  os_xml << '\n';
121 }
122 
123 
124 //=== ArrayOfArrayOfSpeciesTag ================================================
125 
127 
132 void xml_read_from_stream(istream& is_xml,
133  ArrayOfArrayOfSpeciesTag& aastag,
134  bifstream* pbifs,
135  const Verbosity& verbosity)
136 {
137  ArtsXMLTag tag(verbosity);
138  Index nelem;
139 
140  tag.read_from_stream(is_xml);
141  tag.check_name("Array");
142  tag.check_attribute("type", "ArrayOfSpeciesTag");
143 
144  tag.get_attribute_value("nelem", nelem);
145  aastag.resize(nelem);
146 
147  Index n;
148  try
149  {
150  for (n = 0; n < nelem; n++)
151  {
152  xml_read_from_stream(is_xml, aastag[n], pbifs, verbosity);
153  }
154  }
155  catch (runtime_error e)
156  {
157  ostringstream os;
158  os << "Error reading ArrayOfArrayOfSpeciesTag: "
159  << "\n Element: " << n
160  << "\n" << e.what();
161  throw runtime_error(os.str());
162  }
163 
164 
165  tag.read_from_stream(is_xml);
166  tag.check_name("/Array");
167 }
168 
169 
171 
177 void xml_write_to_stream(ostream& os_xml,
178  const ArrayOfArrayOfSpeciesTag& aastag,
179  bofstream* pbofs,
180  const String& name,
181  const Verbosity& verbosity)
182 {
183  ArtsXMLTag open_tag(verbosity);
184  ArtsXMLTag close_tag(verbosity);
185 
186  open_tag.set_name("Array");
187  if (name.length())
188  open_tag.add_attribute("name", name);
189 
190  open_tag.add_attribute("type", "ArrayOfSpeciesTag");
191  open_tag.add_attribute("nelem", aastag.nelem());
192 
193  open_tag.write_to_stream(os_xml);
194  os_xml << '\n';
195 
196  for (Index n = 0; n < aastag.nelem(); n++)
197  {
198  xml_write_to_stream(os_xml, aastag[n], pbofs, "", verbosity);
199  }
200 
201  close_tag.set_name("/Array");
202  close_tag.write_to_stream(os_xml);
203 
204  os_xml << '\n';
205 }
206 
207 
208 //=== ArrayOfPpath =========================================================
209 
211 
216 void xml_read_from_stream(istream& is_xml,
217  ArrayOfPpath& appath,
218  bifstream* pbifs,
219  const Verbosity& verbosity)
220 {
221  ArtsXMLTag tag(verbosity);
222  Index nelem;
223 
224  tag.read_from_stream(is_xml);
225  tag.check_name("Array");
226  tag.check_attribute("type", "Ppath");
227 
228  tag.get_attribute_value("nelem", nelem);
229  appath.resize(nelem);
230 
231  Index n;
232  try
233  {
234  for (n = 0; n < nelem; n++)
235  {
236  xml_read_from_stream(is_xml, appath[n], pbifs, verbosity);
237  }
238  }
239  catch (runtime_error e)
240  {
241  ostringstream os;
242  os << "Error reading ArrayOfPpath: "
243  << "\n Element: " << n
244  << "\n" << e.what();
245  throw runtime_error(os.str());
246  }
247 
248 
249  tag.read_from_stream(is_xml);
250  tag.check_name("/Array");
251 }
252 
253 
254 
256 
262 void xml_write_to_stream(ostream& os_xml,
263  const ArrayOfPpath& appath,
264  bofstream* pbofs,
265  const String& name,
266  const Verbosity& verbosity)
267 {
268  ArtsXMLTag open_tag(verbosity);
269  ArtsXMLTag close_tag(verbosity);
270 
271  open_tag.set_name("Array");
272  if (name.length())
273  open_tag.add_attribute("name", name);
274 
275  open_tag.add_attribute("type", "Ppath");
276  open_tag.add_attribute("nelem", appath.nelem());
277 
278  open_tag.write_to_stream(os_xml);
279  os_xml << '\n';
280 
281  for (Index n = 0; n < appath.nelem(); n++)
282  {
283  xml_write_to_stream(os_xml, appath[n], pbofs, "", verbosity);
284  }
285 
286  close_tag.set_name("/Array");
287  close_tag.write_to_stream(os_xml);
288 
289  os_xml << '\n';
290 }
291 
292 
293 
294 //=== ArrayOfArrayOfTensor3==================================================
295 
297 
302 void xml_read_from_stream(istream& is_xml,
303  ArrayOfArrayOfTensor3& aatensor3,
304  bifstream* pbifs,
305  const Verbosity& verbosity)
306 {
307  ArtsXMLTag tag(verbosity);
308  Index nelem;
309 
310  tag.read_from_stream(is_xml);
311  tag.check_name("Array");
312  tag.check_attribute("type", "ArrayOfTensor3");
313 
314  tag.get_attribute_value("nelem", nelem);
315  aatensor3.resize(nelem);
316 
317  Index n;
318  try
319  {
320  for (n = 0; n < nelem; n++)
321  xml_read_from_stream(is_xml, aatensor3[n], pbifs, verbosity);
322  }
323  catch (runtime_error e)
324  {
325  ostringstream os;
326  os << "Error reading ArrayOfArrayOfTensor3: "
327  << "\n Element: " << n
328  << "\n" << e.what();
329  throw runtime_error(os.str());
330  }
331 
332 
333  tag.read_from_stream(is_xml);
334  tag.check_name("/Array");
335 }
336 
337 
339 
345 void xml_write_to_stream(ostream& os_xml,
346  const ArrayOfArrayOfTensor3& aatensor3,
347  bofstream* pbofs,
348  const String& name,
349  const Verbosity& verbosity)
350 {
351  ArtsXMLTag open_tag(verbosity);
352  ArtsXMLTag close_tag(verbosity);
353 
354  open_tag.set_name("Array");
355  if (name.length())
356  open_tag.add_attribute("name", name);
357 
358  open_tag.add_attribute("type", "ArrayOfTensor3");
359  open_tag.add_attribute("nelem", aatensor3.nelem());
360 
361  open_tag.write_to_stream(os_xml);
362  os_xml << '\n';
363 
364  for (Index n = 0; n < aatensor3.nelem(); n++)
365  {
366  xml_write_to_stream(os_xml, aatensor3[n], pbofs, "", verbosity);
367  }
368 
369  close_tag.set_name("/Array");
370  close_tag.write_to_stream(os_xml);
371 
372  os_xml << '\n';
373 }
374 
375 
376 //=== ArrayOfArrayOfTensor6==================================================
377 
379 
384 void xml_read_from_stream(istream& is_xml,
385  ArrayOfArrayOfTensor6& aatensor6,
386  bifstream* pbifs,
387  const Verbosity& verbosity)
388 {
389  ArtsXMLTag tag(verbosity);
390  Index nelem;
391 
392  tag.read_from_stream(is_xml);
393  tag.check_name("Array");
394  tag.check_attribute("type", "ArrayOfTensor6");
395 
396  tag.get_attribute_value("nelem", nelem);
397  aatensor6.resize(nelem);
398 
399  Index n;
400  try
401  {
402  for (n = 0; n < nelem; n++)
403  xml_read_from_stream(is_xml, aatensor6[n], pbifs, verbosity);
404  }
405  catch (runtime_error e)
406  {
407  ostringstream os;
408  os << "Error reading ArrayOfArrayOfTensor6: "
409  << "\n Element: " << n
410  << "\n" << e.what();
411  throw runtime_error(os.str());
412  }
413 
414  tag.read_from_stream(is_xml);
415  tag.check_name("/Array");
416 }
417 
418 
420 
426 void xml_write_to_stream(ostream& os_xml,
427  const ArrayOfArrayOfTensor6& aatensor6,
428  bofstream* pbofs,
429  const String& name,
430  const Verbosity& verbosity)
431 {
432  ArtsXMLTag open_tag(verbosity);
433  ArtsXMLTag close_tag(verbosity);
434 
435  open_tag.set_name("Array");
436  if (name.length())
437  open_tag.add_attribute("name", name);
438 
439  open_tag.add_attribute("type", "ArrayOfTensor6");
440  open_tag.add_attribute("nelem", aatensor6.nelem());
441 
442  open_tag.write_to_stream(os_xml);
443  os_xml << '\n';
444 
445  for (Index n = 0; n < aatensor6.nelem(); n++)
446  xml_write_to_stream(os_xml, aatensor6[n], pbofs, "", verbosity);
447 
448  close_tag.set_name("/Array");
449  close_tag.write_to_stream(os_xml);
450 
451  os_xml << '\n';
452 }
453 
454 
455 //=== ArrayOfGridPos =========================================================
456 
458 
463 void xml_read_from_stream(istream& is_xml,
464  ArrayOfGridPos& agpos,
465  bifstream* pbifs,
466  const Verbosity& verbosity)
467 {
468  ArtsXMLTag tag(verbosity);
469  Index nelem;
470 
471  tag.read_from_stream(is_xml);
472  tag.check_name("Array");
473  tag.check_attribute("type", "GridPos");
474 
475  tag.get_attribute_value("nelem", nelem);
476  agpos.resize(nelem);
477 
478  Index n;
479  try
480  {
481  for (n = 0; n < nelem; n++)
482  xml_read_from_stream(is_xml, agpos[n], pbifs, verbosity);
483  }
484  catch (runtime_error e)
485  {
486  ostringstream os;
487  os << "Error reading ArrayOfGridPos: "
488  << "\n Element: " << n
489  << "\n" << e.what();
490  throw runtime_error(os.str());
491  }
492 
493 
494  tag.read_from_stream(is_xml);
495  tag.check_name("/Array");
496 }
497 
498 
500 
506 void xml_write_to_stream(ostream& os_xml,
507  const ArrayOfGridPos& agpos,
508  bofstream* pbofs,
509  const String& name,
510  const Verbosity& verbosity)
511 {
512  ArtsXMLTag open_tag(verbosity);
513  ArtsXMLTag close_tag(verbosity);
514 
515  open_tag.set_name("Array");
516  if (name.length())
517  open_tag.add_attribute("name", name);
518 
519  open_tag.add_attribute("type", "GridPos");
520  open_tag.add_attribute("nelem", agpos.nelem());
521 
522  open_tag.write_to_stream(os_xml);
523  os_xml << '\n';
524 
525  for (Index n = 0; n < agpos.nelem(); n++)
526  xml_write_to_stream(os_xml, agpos[n], pbofs, "", verbosity);
527 
528  close_tag.set_name("/Array");
529  close_tag.write_to_stream(os_xml);
530 
531  os_xml << '\n';
532 }
533 
534 //=== ArrayOfArrayOfGridPos =====================================
535 
537 
542 void xml_read_from_stream(istream& is_xml,
543  ArrayOfArrayOfGridPos& aagpos,
544  bifstream* pbifs,
545  const Verbosity& verbosity)
546 {
547  ArtsXMLTag tag(verbosity);
548  Index nelem;
549 
550  tag.read_from_stream(is_xml);
551  tag.check_name("Array");
552  tag.check_attribute("type", "ArrayOfGridPos");
553 
554  tag.get_attribute_value("nelem", nelem);
555  aagpos.resize(nelem);
556 
557  Index n;
558  try
559  {
560  for (n = 0; n < nelem; n++)
561  xml_read_from_stream(is_xml, aagpos[n], pbifs, verbosity);
562  }
563  catch (runtime_error e)
564  {
565  ostringstream os;
566  os << "Error reading ArrayOfArrayOfGridPos: "
567  << "\n Element: " << n
568  << "\n" << e.what();
569  throw runtime_error(os.str());
570  }
571 
572 
573  tag.read_from_stream(is_xml);
574  tag.check_name("/Array");
575 }
576 
577 
579 
585 void xml_write_to_stream(ostream& os_xml,
586  const ArrayOfArrayOfGridPos& aagpos,
587  bofstream* pbofs,
588  const String& name,
589  const Verbosity& verbosity)
590 {
591  ArtsXMLTag open_tag(verbosity);
592  ArtsXMLTag close_tag(verbosity);
593 
594  open_tag.set_name("Array");
595  if (name.length())
596  open_tag.add_attribute("name", name);
597 
598  open_tag.add_attribute("type", "ArrayOfGridPos");
599  open_tag.add_attribute("nelem", aagpos.nelem());
600 
601  open_tag.write_to_stream(os_xml);
602  os_xml << '\n';
603 
604  for (Index n = 0; n < aagpos.nelem(); n++)
605  xml_write_to_stream(os_xml, aagpos[n], pbofs, "", verbosity);
606 
607  close_tag.set_name("/Array");
608  close_tag.write_to_stream(os_xml);
609 
610  os_xml << '\n';
611 }
612 
613 //=== ArrayOfArrayOfArrayOfGridPos =====================================
614 
616 
621 void xml_read_from_stream(istream& is_xml,
623  bifstream* pbifs,
624  const Verbosity& verbosity)
625 {
626  ArtsXMLTag tag(verbosity);
627  Index nelem;
628 
629  tag.read_from_stream(is_xml);
630  tag.check_name("Array");
631  tag.check_attribute("type", "ArrayOfArrayOfGridPos");
632 
633  tag.get_attribute_value("nelem", nelem);
634  aaagpos.resize(nelem);
635 
636  Index n;
637  try
638  {
639  for (n = 0; n < nelem; n++)
640  xml_read_from_stream(is_xml, aaagpos[n], pbifs, verbosity);
641  }
642  catch (runtime_error e)
643  {
644  ostringstream os;
645  os << "Error reading ArrayOfArrayOfArrayOfGridPos: "
646  << "\n Element: " << n
647  << "\n" << e.what();
648  throw runtime_error(os.str());
649  }
650 
651 
652  tag.read_from_stream(is_xml);
653  tag.check_name("/Array");
654 }
655 
656 
658 
664 void xml_write_to_stream(ostream& os_xml,
665  const ArrayOfArrayOfArrayOfGridPos& aaagpos,
666  bofstream* pbofs,
667  const String& name,
668  const Verbosity& verbosity)
669 {
670  ArtsXMLTag open_tag(verbosity);
671  ArtsXMLTag close_tag(verbosity);
672 
673  open_tag.set_name("Array");
674  if (name.length())
675  open_tag.add_attribute("name", name);
676 
677  open_tag.add_attribute("type", "ArrayOfArrayOfGridPos");
678  open_tag.add_attribute("nelem", aaagpos.nelem());
679 
680  open_tag.write_to_stream(os_xml);
681  os_xml << '\n';
682 
683  for (Index n = 0; n < aaagpos.nelem(); n++)
684  xml_write_to_stream(os_xml, aaagpos[n], pbofs, "", verbosity);
685 
686  close_tag.set_name("/Array");
687  close_tag.write_to_stream(os_xml);
688 
689  os_xml << '\n';
690 }
691 
692 
693 //=== ArrayOfArrayOfArrayOfArrayOfGridPos =====================================
694 
696 
701 void xml_read_from_stream(istream& is_xml,
703  bifstream* pbifs,
704  const Verbosity& verbosity)
705 {
706  ArtsXMLTag tag(verbosity);
707  Index nelem;
708 
709  tag.read_from_stream(is_xml);
710  tag.check_name("Array");
711  tag.check_attribute("type", "ArrayOfArrayOfArrayOfGridPos");
712 
713  tag.get_attribute_value("nelem", nelem);
714  aaaagpos.resize(nelem);
715 
716  Index n;
717  try
718  {
719  for (n = 0; n < nelem; n++)
720  xml_read_from_stream(is_xml, aaaagpos[n], pbifs, verbosity);
721  }
722  catch (runtime_error e)
723  {
724  ostringstream os;
725  os << "Error reading ArrayOfArrayOfArrayOfArrayOfGridPos: "
726  << "\n Element: " << n
727  << "\n" << e.what();
728  throw runtime_error(os.str());
729  }
730 
731  tag.read_from_stream(is_xml);
732  tag.check_name("/Array");
733 }
734 
735 
737 
743 void xml_write_to_stream(ostream& os_xml,
744  const ArrayOfArrayOfArrayOfArrayOfGridPos& aaaagpos,
745  bofstream* pbofs,
746  const String& name,
747  const Verbosity& verbosity)
748 {
749  ArtsXMLTag open_tag(verbosity);
750  ArtsXMLTag close_tag(verbosity);
751 
752  open_tag.set_name("Array");
753  if (name.length())
754  open_tag.add_attribute("name", name);
755 
756  open_tag.add_attribute("type", "ArrayOfArrayOfArrayOfGridPos");
757  open_tag.add_attribute("nelem", aaaagpos.nelem());
758 
759  open_tag.write_to_stream(os_xml);
760  os_xml << '\n';
761 
762  for (Index n = 0; n < aaaagpos.nelem(); n++)
763  xml_write_to_stream(os_xml, aaaagpos[n], pbofs, "", verbosity);
764 
765  close_tag.set_name("/Array");
766  close_tag.write_to_stream(os_xml);
767 
768  os_xml << '\n';
769 }
770 
771 
772 
773 //=== ArrayOfIndex ===========================================================
774 
776 
781 void xml_read_from_stream(istream& is_xml,
782  ArrayOfIndex& aindex,
783  bifstream* pbifs,
784  const Verbosity& verbosity)
785 {
786  ArtsXMLTag tag(verbosity);
787  Index nelem;
788 
789  tag.read_from_stream(is_xml);
790  tag.check_name("Array");
791  tag.check_attribute("type", "Index");
792 
793  tag.get_attribute_value("nelem", nelem);
794  aindex.resize(nelem);
795 
796  Index n;
797  try
798  {
799  for (n = 0; n < nelem; n++)
800  xml_read_from_stream(is_xml, aindex[n], pbifs, verbosity);
801  }
802  catch (runtime_error e)
803  {
804  ostringstream os;
805  os << "Error reading ArrayOfIndex: "
806  << "\n Element: " << n
807  << "\n" << e.what();
808  throw runtime_error(os.str());
809  }
810 
811  tag.read_from_stream(is_xml);
812  tag.check_name("/Array");
813 }
814 
815 
817 
823 void xml_write_to_stream(ostream& os_xml,
824  const ArrayOfIndex& aindex,
825  bofstream* pbofs,
826  const String& name,
827  const Verbosity& verbosity)
828 {
829  ArtsXMLTag open_tag(verbosity);
830  ArtsXMLTag close_tag(verbosity);
831 
832  open_tag.set_name("Array");
833  if (name.length())
834  open_tag.add_attribute("name", name);
835 
836  open_tag.add_attribute("type", "Index");
837  open_tag.add_attribute("nelem", aindex.nelem());
838 
839  open_tag.write_to_stream(os_xml);
840  os_xml << '\n';
841 
842  for (Index n = 0; n < aindex.nelem(); n++)
843  xml_write_to_stream(os_xml, aindex[n], pbofs, "", verbosity);
844 
845  close_tag.set_name("/Array");
846  close_tag.write_to_stream(os_xml);
847 
848  os_xml << '\n';
849 }
850 
851 
852 
853 //=== ArrayOfArrayOfIndex =====================================================
854 
856 
861 void xml_read_from_stream(istream& is_xml,
862  ArrayOfArrayOfIndex& aaindex,
863  bifstream* pbifs,
864  const Verbosity& verbosity)
865 {
866  ArtsXMLTag tag(verbosity);
867  Index nelem;
868 
869  tag.read_from_stream(is_xml);
870  tag.check_name("Array");
871  tag.check_attribute("type", "ArrayOfIndex");
872 
873  tag.get_attribute_value("nelem", nelem);
874  aaindex.resize(nelem);
875 
876  Index n;
877  try
878  {
879  for (n = 0; n < nelem; n++)
880  xml_read_from_stream(is_xml, aaindex[n], pbifs, verbosity);
881  }
882  catch (runtime_error e)
883  {
884  ostringstream os;
885  os << "Error reading ArrayOfArrayOfIndex: "
886  << "\n Element: " << n
887  << "\n" << e.what();
888  throw runtime_error(os.str());
889  }
890 
891  tag.read_from_stream(is_xml);
892  tag.check_name("/Array");
893 }
894 
895 
897 
903 void xml_write_to_stream(ostream& os_xml,
904  const ArrayOfArrayOfIndex& aaindex,
905  bofstream* pbofs,
906  const String& name,
907  const Verbosity& verbosity)
908 {
909  ArtsXMLTag open_tag(verbosity);
910  ArtsXMLTag close_tag(verbosity);
911 
912  open_tag.set_name("Array");
913  if (name.length())
914  open_tag.add_attribute("name", name);
915 
916  open_tag.add_attribute("type", "ArrayOfIndex");
917  open_tag.add_attribute("nelem", aaindex.nelem());
918 
919  open_tag.write_to_stream(os_xml);
920  os_xml << '\n';
921 
922  for (Index n = 0; n < aaindex.nelem(); n++)
923  xml_write_to_stream(os_xml, aaindex[n], pbofs, "", verbosity);
924 
925  close_tag.set_name("/Array");
926  close_tag.write_to_stream(os_xml);
927 
928  os_xml << '\n';
929 }
930 
931 
932 
933 //=== ArrayOfCIARecord ===========================================
934 
936 
941 void xml_read_from_stream(istream& is_xml,
942  ArrayOfCIARecord& acr,
943  bifstream* pbifs,
944  const Verbosity& verbosity)
945 {
946  ArtsXMLTag tag(verbosity);
947  Index nelem;
948 
949  tag.read_from_stream(is_xml);
950  tag.check_name("Array");
951  tag.check_attribute("type", "CIARecord");
952 
953  tag.get_attribute_value("nelem", nelem);
954  acr.resize(nelem);
955 
956  Index n;
957  try
958  {
959  for (n = 0; n < nelem; n++)
960  xml_read_from_stream(is_xml, acr[n], pbifs, verbosity);
961  }
962  catch (runtime_error e)
963  {
964  ostringstream os;
965  os << "Error reading ArrayOfCIARecord: "
966  << "\n Element: " << n
967  << "\n" << e.what();
968  throw runtime_error(os.str());
969  }
970 
971  tag.read_from_stream(is_xml);
972  tag.check_name("/Array");
973 }
974 
975 
977 
983 void xml_write_to_stream(ostream& os_xml,
984  const ArrayOfCIARecord& acr,
985  bofstream* pbofs,
986  const String& name,
987  const Verbosity& verbosity)
988 
989 {
990  ArtsXMLTag open_tag(verbosity);
991  ArtsXMLTag close_tag(verbosity);
992 
993  open_tag.set_name("Array");
994  if (name.length())
995  open_tag.add_attribute("name", name);
996 
997  open_tag.add_attribute("type", "CIARecord");
998  open_tag.add_attribute("nelem", acr.nelem());
999 
1000  open_tag.write_to_stream(os_xml);
1001  os_xml << '\n';
1002 
1003  for (Index n = 0; n < acr.nelem(); n++)
1004  xml_write_to_stream(os_xml, acr[n], pbofs, "", verbosity);
1005 
1006  close_tag.set_name("/Array");
1007  close_tag.write_to_stream(os_xml);
1008 
1009  os_xml << '\n';
1010 }
1011 
1012 
1013 
1014 //=== ArrayOfIsotopologueRecord ===================================================
1015 
1017 
1022 void xml_read_from_stream(istream& is_xml,
1023  Array<IsotopologueRecord>& airecord,
1024  bifstream* pbifs,
1025  const Verbosity& verbosity)
1026 {
1027  ArtsXMLTag tag(verbosity);
1028  Index nelem;
1029 
1030  tag.read_from_stream(is_xml);
1031  tag.check_name("Array");
1032  tag.check_attribute("type", "IsotopologueRecord");
1033 
1034  tag.get_attribute_value("nelem", nelem);
1035  airecord.resize(nelem);
1036 
1037  Index n;
1038  try
1039  {
1040  for (n = 0; n < nelem; n++)
1041  xml_read_from_stream(is_xml, airecord[n], pbifs, verbosity);
1042  }
1043  catch (runtime_error e)
1044  {
1045  ostringstream os;
1046  os << "Error reading ArrayOfIsotopologueRecord: "
1047  << "\n Element: " << n
1048  << "\n" << e.what();
1049  throw runtime_error(os.str());
1050  }
1051 
1052  tag.read_from_stream(is_xml);
1053  tag.check_name("/Array");
1054 }
1055 
1056 
1058 
1064 void xml_write_to_stream(ostream& os_xml,
1065  const Array<IsotopologueRecord>& airecord,
1066  bofstream* pbofs,
1067  const String& name,
1068  const Verbosity& verbosity)
1069 {
1070  ArtsXMLTag open_tag(verbosity);
1071  ArtsXMLTag close_tag(verbosity);
1072 
1073  open_tag.set_name("Array");
1074  if (name.length())
1075  open_tag.add_attribute("name", name);
1076 
1077  open_tag.add_attribute("type", "IsotopologueRecord");
1078  open_tag.add_attribute("nelem", airecord.nelem());
1079 
1080  open_tag.write_to_stream(os_xml);
1081  os_xml << '\n';
1082 
1083  for (Index n = 0; n < airecord.nelem(); n++)
1084  xml_write_to_stream(os_xml, airecord[n], pbofs, "", verbosity);
1085 
1086  close_tag.set_name("/Array");
1087  close_tag.write_to_stream(os_xml);
1088 
1089  os_xml << '\n';
1090 }
1091 
1092 
1093 
1094 //=== ArrayOfMatrix ==========================================================
1095 
1097 
1102 void xml_read_from_stream(istream& is_xml,
1103  ArrayOfMatrix& amatrix,
1104  bifstream* pbifs,
1105  const Verbosity& verbosity)
1106 {
1107  ArtsXMLTag tag(verbosity);
1108  Index nelem;
1109 
1110  tag.read_from_stream(is_xml);
1111  tag.check_name("Array");
1112  tag.check_attribute("type", "Matrix");
1113 
1114  tag.get_attribute_value("nelem", nelem);
1115  amatrix.resize(nelem);
1116 
1117  Index n;
1118  try
1119  {
1120  for (n = 0; n < nelem; n++)
1121  xml_read_from_stream(is_xml, amatrix[n], pbifs, verbosity);
1122  }
1123  catch (runtime_error e)
1124  {
1125  ostringstream os;
1126  os << "Error reading ArrayOfMatrix: "
1127  << "\n Element: " << n
1128  << "\n" << e.what();
1129  throw runtime_error(os.str());
1130  }
1131 
1132  tag.read_from_stream(is_xml);
1133  tag.check_name("/Array");
1134 }
1135 
1136 
1138 
1144 void xml_write_to_stream(ostream& os_xml,
1145  const ArrayOfMatrix& amatrix,
1146  bofstream* pbofs,
1147  const String& name,
1148  const Verbosity& verbosity)
1149 {
1150  ArtsXMLTag open_tag(verbosity);
1151  ArtsXMLTag close_tag(verbosity);
1152 
1153  open_tag.set_name("Array");
1154  if (name.length())
1155  open_tag.add_attribute("name", name);
1156 
1157  open_tag.add_attribute("type", "Matrix");
1158  open_tag.add_attribute("nelem", amatrix.nelem());
1159 
1160  open_tag.write_to_stream(os_xml);
1161  os_xml << '\n';
1162 
1163  for (Index n = 0; n < amatrix.nelem(); n++)
1164  xml_write_to_stream(os_xml, amatrix[n], pbofs, "", verbosity);
1165 
1166  close_tag.set_name("/Array");
1167  close_tag.write_to_stream(os_xml);
1168 
1169  os_xml << '\n';
1170 }
1171 
1172 
1173 //=== ArrayOfArrayOfMatrix====================================================
1174 
1176 
1181 void xml_read_from_stream(istream& is_xml,
1182  ArrayOfArrayOfMatrix& aamatrix,
1183  bifstream* pbifs,
1184  const Verbosity& verbosity)
1185 {
1186  ArtsXMLTag tag(verbosity);
1187  Index nelem;
1188 
1189  tag.read_from_stream(is_xml);
1190  tag.check_name("Array");
1191  tag.check_attribute("type", "ArrayOfMatrix");
1192 
1193  tag.get_attribute_value("nelem", nelem);
1194  aamatrix.resize(nelem);
1195 
1196  Index n;
1197  try
1198  {
1199  for (n = 0; n < nelem; n++)
1200  xml_read_from_stream(is_xml, aamatrix[n], pbifs, verbosity);
1201  }
1202  catch (runtime_error e)
1203  {
1204  ostringstream os;
1205  os << "Error reading ArrayOfArrayOfMatrix: "
1206  << "\n Element: " << n
1207  << "\n" << e.what();
1208  throw runtime_error(os.str());
1209  }
1210 
1211  tag.read_from_stream(is_xml);
1212  tag.check_name("/Array");
1213 }
1214 
1215 
1217 
1223 void xml_write_to_stream(ostream& os_xml,
1224  const ArrayOfArrayOfMatrix& aamatrix,
1225  bofstream* pbofs,
1226  const String& name,
1227  const Verbosity& verbosity)
1228 {
1229  ArtsXMLTag open_tag(verbosity);
1230  ArtsXMLTag close_tag(verbosity);
1231 
1232  open_tag.set_name("Array");
1233  if (name.length())
1234  open_tag.add_attribute("name", name);
1235 
1236  open_tag.add_attribute("type", "ArrayOfMatrix");
1237  open_tag.add_attribute("nelem", aamatrix.nelem());
1238 
1239  open_tag.write_to_stream(os_xml);
1240  os_xml << '\n';
1241 
1242  for (Index n = 0; n < aamatrix.nelem(); n++)
1243  xml_write_to_stream(os_xml, aamatrix[n], pbofs, "", verbosity);
1244 
1245  close_tag.set_name("/Array");
1246  close_tag.write_to_stream(os_xml);
1247 
1248  os_xml << '\n';
1249 }
1250 
1251 
1252 //=== ArrayOfArrayOfVector====================================================
1253 
1255 
1260 void xml_read_from_stream(istream& is_xml,
1261  ArrayOfArrayOfVector& aavector,
1262  bifstream* pbifs,
1263  const Verbosity& verbosity)
1264 {
1265  ArtsXMLTag tag(verbosity);
1266  Index nelem;
1267 
1268  tag.read_from_stream(is_xml);
1269  tag.check_name("Array");
1270  tag.check_attribute("type", "ArrayOfVector");
1271 
1272  tag.get_attribute_value("nelem", nelem);
1273  aavector.resize(nelem);
1274 
1275  Index n;
1276  try
1277  {
1278  for (n = 0; n < nelem; n++)
1279  xml_read_from_stream(is_xml, aavector[n], pbifs, verbosity);
1280  }
1281  catch (runtime_error e)
1282  {
1283  ostringstream os;
1284  os << "Error reading ArrayOfArrayOfVector: "
1285  << "\n Element: " << n
1286  << "\n" << e.what();
1287  throw runtime_error(os.str());
1288  }
1289 
1290  tag.read_from_stream(is_xml);
1291  tag.check_name("/Array");
1292 }
1293 
1294 
1296 
1302 void xml_write_to_stream(ostream& os_xml,
1303  const ArrayOfArrayOfVector& aaVector,
1304  bofstream* pbofs,
1305  const String& name,
1306  const Verbosity& verbosity)
1307 {
1308  ArtsXMLTag open_tag(verbosity);
1309  ArtsXMLTag close_tag(verbosity);
1310 
1311  open_tag.set_name("Array");
1312  if (name.length())
1313  open_tag.add_attribute("name", name);
1314 
1315  open_tag.add_attribute("type", "ArrayOfVector");
1316  open_tag.add_attribute("nelem", aaVector.nelem());
1317 
1318  open_tag.write_to_stream(os_xml);
1319  os_xml << '\n';
1320 
1321  for (Index n = 0; n < aaVector.nelem(); n++)
1322  xml_write_to_stream(os_xml, aaVector[n], pbofs, "", verbosity);
1323 
1324  close_tag.set_name("/Array");
1325  close_tag.write_to_stream(os_xml);
1326 
1327  os_xml << '\n';
1328 }
1329 
1330 
1331 //=== ArrayOfSparse ==========================================================
1332 
1334 
1339 void xml_read_from_stream(istream& is_xml,
1340  ArrayOfSparse& asparse,
1341  bifstream* pbifs,
1342  const Verbosity& verbosity)
1343 {
1344  ArtsXMLTag tag(verbosity);
1345  Index nelem;
1346 
1347  tag.read_from_stream(is_xml);
1348  tag.check_name("Array");
1349  tag.check_attribute("type", "Sparse");
1350 
1351  tag.get_attribute_value("nelem", nelem);
1352  asparse.resize(nelem);
1353 
1354  Index n;
1355  try
1356  {
1357  for (n = 0; n < nelem; n++)
1358  xml_read_from_stream(is_xml, asparse[n], pbifs, verbosity);
1359  }
1360  catch (runtime_error e)
1361  {
1362  ostringstream os;
1363  os << "Error reading ArrayOfSparse: "
1364  << "\n Element: " << n
1365  << "\n" << e.what();
1366  throw runtime_error(os.str());
1367  }
1368 
1369  tag.read_from_stream(is_xml);
1370  tag.check_name("/Array");
1371 }
1372 
1373 
1375 
1381 void xml_write_to_stream(ostream& os_xml,
1382  const ArrayOfSparse& asparse,
1383  bofstream* pbofs,
1384  const String& name,
1385  const Verbosity& verbosity)
1386 {
1387  ArtsXMLTag open_tag(verbosity);
1388  ArtsXMLTag close_tag(verbosity);
1389 
1390  open_tag.set_name("Array");
1391  if (name.length())
1392  open_tag.add_attribute("name", name);
1393 
1394  open_tag.add_attribute("type", "Sparse");
1395  open_tag.add_attribute("nelem", asparse.nelem());
1396 
1397  open_tag.write_to_stream(os_xml);
1398  os_xml << '\n';
1399 
1400  for (Index n = 0; n < asparse.nelem(); n++)
1401  xml_write_to_stream(os_xml, asparse[n], pbofs, "", verbosity);
1402 
1403  close_tag.set_name("/Array");
1404  close_tag.write_to_stream(os_xml);
1405 
1406  os_xml << '\n';
1407 }
1408 
1409 
1410 //=== ArrayOfRetrievalQuantity =======================================
1411 
1413 
1418 void xml_read_from_stream(istream& is_xml,
1420  bifstream* pbifs,
1421  const Verbosity& verbosity)
1422 {
1423  ArtsXMLTag tag(verbosity);
1424  Index nelem;
1425 
1426  tag.read_from_stream(is_xml);
1427  tag.check_name("Array");
1428  tag.check_attribute("type", "RetrievalQuantity");
1429 
1430  tag.get_attribute_value("nelem", nelem);
1431  arq.resize(nelem);
1432 
1433  Index n;
1434  try
1435  {
1436  for (n = 0; n < nelem; n++)
1437  xml_read_from_stream(is_xml, arq[n], pbifs, verbosity);
1438  }
1439  catch (runtime_error e)
1440  {
1441  ostringstream os;
1442  os << "Error reading ArrayOfRetrievalQuantity: "
1443  << "\n Element: " << n
1444  << "\n" << e.what();
1445  throw runtime_error(os.str());
1446  }
1447 
1448  tag.read_from_stream(is_xml);
1449  tag.check_name("/Array");
1450 }
1451 
1452 
1454 
1460 void xml_write_to_stream(ostream& os_xml,
1461  const ArrayOfRetrievalQuantity& arq,
1462  bofstream* pbofs,
1463  const String& name,
1464  const Verbosity& verbosity)
1465 {
1466  ArtsXMLTag open_tag(verbosity);
1467  ArtsXMLTag close_tag(verbosity);
1468 
1469  open_tag.set_name("Array");
1470  if (name.length())
1471  open_tag.add_attribute("name", name);
1472 
1473  open_tag.add_attribute("type", "RetrievalQuantity");
1474  open_tag.add_attribute("nelem", arq.nelem());
1475 
1476  open_tag.write_to_stream(os_xml);
1477  os_xml << '\n';
1478 
1479  for (Index n = 0; n < arq.nelem(); n++)
1480  xml_write_to_stream(os_xml, arq[n], pbofs, "", verbosity);
1481 
1482  close_tag.set_name("/Array");
1483  close_tag.write_to_stream(os_xml);
1484 
1485  os_xml << '\n';
1486 }
1487 
1488 
1489 //=== ArrayOfSpeciesTag ================================================
1490 
1492 
1497 void xml_read_from_stream(istream& is_xml,
1498  ArrayOfSpeciesTag& astag,
1499  bifstream* pbifs,
1500  const Verbosity& verbosity)
1501 {
1502  ArtsXMLTag tag(verbosity);
1503  Index nelem;
1504 
1505  tag.read_from_stream(is_xml);
1506  tag.check_name("Array");
1507  tag.check_attribute("type", "SpeciesTag");
1508 
1509  tag.get_attribute_value("nelem", nelem);
1510  astag.resize(nelem);
1511 
1512  Index n;
1513  try
1514  {
1515  for (n = 0; n < nelem; n++)
1516  xml_read_from_stream(is_xml, astag[n], pbifs, verbosity);
1517  }
1518  catch (runtime_error e)
1519  {
1520  ostringstream os;
1521  os << "Error reading ArrayOfSpeciesTag: "
1522  << "\n Element: " << n
1523  << "\n" << e.what();
1524  throw runtime_error(os.str());
1525  }
1526 
1527  tag.read_from_stream(is_xml);
1528  tag.check_name("/Array");
1529 }
1530 
1531 
1533 
1539 void xml_write_to_stream(ostream& os_xml,
1540  const ArrayOfSpeciesTag& astag,
1541  bofstream* pbofs,
1542  const String& name,
1543  const Verbosity& verbosity)
1544 {
1545  ArtsXMLTag open_tag(verbosity);
1546  ArtsXMLTag close_tag(verbosity);
1547 
1548  open_tag.set_name("Array");
1549  if (name.length())
1550  open_tag.add_attribute("name", name);
1551 
1552  open_tag.add_attribute("type", "SpeciesTag");
1553  open_tag.add_attribute("nelem", astag.nelem());
1554 
1555  open_tag.write_to_stream(os_xml);
1556  os_xml << '\n';
1557 
1558  for (Index n = 0; n < astag.nelem(); n++)
1559  xml_write_to_stream(os_xml, astag[n], pbofs, "", verbosity);
1560 
1561  close_tag.set_name("/Array");
1562  close_tag.write_to_stream(os_xml);
1563 
1564  os_xml << '\n';
1565 }
1566 
1567 
1568 //=== ArrayOfSingleScatteringData===========================================
1569 
1571 
1576 void xml_read_from_stream(istream& is_xml,
1577  ArrayOfSingleScatteringData& assdata,
1578  bifstream* pbifs,
1579  const Verbosity& verbosity)
1580 {
1581  ArtsXMLTag tag(verbosity);
1582  Index nelem;
1583 
1584  tag.read_from_stream(is_xml);
1585  tag.check_name("Array");
1586  tag.check_attribute("type", "SingleScatteringData");
1587 
1588  tag.get_attribute_value("nelem", nelem);
1589  assdata.resize(nelem);
1590 
1591  Index n;
1592  try
1593  {
1594  for (n = 0; n < nelem; n++)
1595  xml_read_from_stream(is_xml, assdata[n], pbifs, verbosity);
1596  }
1597  catch (runtime_error e)
1598  {
1599  ostringstream os;
1600  os << "Error reading ArrayOfSingleScatteringData: "
1601  << "\n Element: " << n
1602  << "\n" << e.what();
1603  throw runtime_error(os.str());
1604  }
1605 
1606  tag.read_from_stream(is_xml);
1607  tag.check_name("/Array");
1608 }
1609 
1610 
1612 
1618 void xml_write_to_stream(ostream& os_xml,
1619  const ArrayOfSingleScatteringData& assdata,
1620  bofstream* pbofs,
1621  const String& name,
1622  const Verbosity& verbosity)
1623 {
1624  ArtsXMLTag open_tag(verbosity);
1625  ArtsXMLTag close_tag(verbosity);
1626 
1627  open_tag.set_name("Array");
1628  if (name.length())
1629  open_tag.add_attribute("name", name);
1630 
1631  open_tag.add_attribute("type", "SingleScatteringData");
1632  open_tag.add_attribute("nelem", assdata.nelem());
1633 
1634  open_tag.write_to_stream(os_xml);
1635  os_xml << '\n';
1636 
1637  for (Index n = 0; n < assdata.nelem(); n++)
1638  xml_write_to_stream(os_xml, assdata[n], pbofs, "", verbosity);
1639 
1640  close_tag.set_name("/Array");
1641  close_tag.write_to_stream(os_xml);
1642 
1643  os_xml << '\n';
1644 }
1645 
1646 
1647 //=== ArrayOfScatteringMetaData===========================================
1648 
1650 
1655 void xml_read_from_stream(istream& is_xml,
1656  ArrayOfScatteringMetaData& asmdata,
1657  bifstream* pbifs,
1658  const Verbosity& verbosity)
1659 {
1660  ArtsXMLTag tag(verbosity);
1661  Index nelem;
1662 
1663  tag.read_from_stream(is_xml);
1664  tag.check_name("Array");
1665  tag.check_attribute("type", "ScatteringMetaData");
1666 
1667  tag.get_attribute_value("nelem", nelem);
1668  asmdata.resize(nelem);
1669 
1670  Index n;
1671  try
1672  {
1673  for (n = 0; n < nelem; n++)
1674  xml_read_from_stream(is_xml, asmdata[n], pbifs, verbosity);
1675  }
1676  catch (runtime_error e)
1677  {
1678  ostringstream os;
1679  os << "Error reading ArrayOfScatteringMetaData: "
1680  << "\n Element: " << n
1681  << "\n" << e.what();
1682  throw runtime_error(os.str());
1683  }
1684 
1685  tag.read_from_stream(is_xml);
1686  tag.check_name("/Array");
1687 }
1688 
1689 
1691 
1697 void xml_write_to_stream(ostream& os_xml,
1698  const ArrayOfScatteringMetaData& asmdata,
1699  bofstream* pbofs,
1700  const String& name,
1701  const Verbosity& verbosity)
1702 {
1703  ArtsXMLTag open_tag(verbosity);
1704  ArtsXMLTag close_tag(verbosity);
1705 
1706  open_tag.set_name("Array");
1707  if (name.length())
1708  open_tag.add_attribute("name", name);
1709 
1710  open_tag.add_attribute("type", "ScatteringMetaData");
1711  open_tag.add_attribute("nelem", asmdata.nelem());
1712 
1713  open_tag.write_to_stream(os_xml);
1714  os_xml << '\n';
1715 
1716  for (Index n = 0; n < asmdata.nelem(); n++)
1717  xml_write_to_stream(os_xml, asmdata[n], pbofs, "", verbosity);
1718 
1719  close_tag.set_name("/Array");
1720  close_tag.write_to_stream(os_xml);
1721 
1722  os_xml << '\n';
1723 }
1724 
1725 
1726 
1727 //=== ArrayOfGriddedField1 ===========================================
1728 
1730 
1735 void xml_read_from_stream(istream& is_xml,
1736  ArrayOfGriddedField1& agfield,
1737  bifstream* pbifs,
1738  const Verbosity& verbosity)
1739 {
1740  ArtsXMLTag tag(verbosity);
1741  Index nelem;
1742 
1743  tag.read_from_stream(is_xml);
1744  tag.check_name("Array");
1745  tag.check_attribute("type", "GriddedField1");
1746 
1747  tag.get_attribute_value("nelem", nelem);
1748  agfield.resize(nelem);
1749 
1750  Index n;
1751  try
1752  {
1753  for (n = 0; n < nelem; n++)
1754  xml_read_from_stream(is_xml, agfield[n], pbifs, verbosity);
1755  }
1756  catch (runtime_error e)
1757  {
1758  ostringstream os;
1759  os << "Error reading ArrayOfGriddedField1: "
1760  << "\n Element: " << n
1761  << "\n" << e.what();
1762  throw runtime_error(os.str());
1763  }
1764 
1765  tag.read_from_stream(is_xml);
1766  tag.check_name("/Array");
1767 }
1768 
1769 
1771 
1777 void xml_write_to_stream(ostream& os_xml,
1778  const ArrayOfGriddedField1& agfield,
1779  bofstream* pbofs,
1780  const String& name,
1781  const Verbosity& verbosity)
1782 {
1783  ArtsXMLTag open_tag(verbosity);
1784  ArtsXMLTag close_tag(verbosity);
1785 
1786  open_tag.set_name("Array");
1787  if (name.length())
1788  open_tag.add_attribute("name", name);
1789 
1790  open_tag.add_attribute("type", "GriddedField1");
1791  open_tag.add_attribute("nelem", agfield.nelem());
1792 
1793  open_tag.write_to_stream(os_xml);
1794  os_xml << '\n';
1795 
1796  for (Index n = 0; n < agfield.nelem(); n++)
1797  xml_write_to_stream(os_xml, agfield[n], pbofs, "", verbosity);
1798 
1799  close_tag.set_name("/Array");
1800  close_tag.write_to_stream(os_xml);
1801 
1802  os_xml << '\n';
1803 }
1804 
1805 
1806 //=== ArrayOfGriddedField2 ===========================================
1807 
1809 
1814 void xml_read_from_stream(istream& is_xml,
1815  ArrayOfGriddedField2& agfield,
1816  bifstream* pbifs,
1817  const Verbosity& verbosity)
1818 {
1819  ArtsXMLTag tag(verbosity);
1820  Index nelem;
1821 
1822  tag.read_from_stream(is_xml);
1823  tag.check_name("Array");
1824  tag.check_attribute("type", "GriddedField2");
1825 
1826  tag.get_attribute_value("nelem", nelem);
1827  agfield.resize(nelem);
1828 
1829  Index n;
1830  try
1831  {
1832  for (n = 0; n < nelem; n++)
1833  xml_read_from_stream(is_xml, agfield[n], pbifs, verbosity);
1834  }
1835  catch (runtime_error e)
1836  {
1837  ostringstream os;
1838  os << "Error reading ArrayOfGriddedField2: "
1839  << "\n Element: " << n
1840  << "\n" << e.what();
1841  throw runtime_error(os.str());
1842  }
1843 
1844  tag.read_from_stream(is_xml);
1845  tag.check_name("/Array");
1846 }
1847 
1848 
1850 
1856 void xml_write_to_stream(ostream& os_xml,
1857  const ArrayOfGriddedField2& agfield,
1858  bofstream* pbofs,
1859  const String& name,
1860  const Verbosity& verbosity)
1861 {
1862  ArtsXMLTag open_tag(verbosity);
1863  ArtsXMLTag close_tag(verbosity);
1864 
1865  open_tag.set_name("Array");
1866  if (name.length())
1867  open_tag.add_attribute("name", name);
1868 
1869  open_tag.add_attribute("type", "GriddedField2");
1870  open_tag.add_attribute("nelem", agfield.nelem());
1871 
1872  open_tag.write_to_stream(os_xml);
1873  os_xml << '\n';
1874 
1875  for (Index n = 0; n < agfield.nelem(); n++)
1876  xml_write_to_stream(os_xml, agfield[n], pbofs, "", verbosity);
1877 
1878  close_tag.set_name("/Array");
1879  close_tag.write_to_stream(os_xml);
1880 
1881  os_xml << '\n';
1882 }
1883 
1884 
1885 //=== ArrayOfGriddedField3 ===========================================
1886 
1888 
1893 void xml_read_from_stream(istream& is_xml,
1894  ArrayOfGriddedField3& agfield,
1895  bifstream* pbifs,
1896  const Verbosity& verbosity)
1897 {
1898  ArtsXMLTag tag(verbosity);
1899  Index nelem;
1900 
1901  tag.read_from_stream(is_xml);
1902  tag.check_name("Array");
1903  tag.check_attribute("type", "GriddedField3");
1904 
1905  tag.get_attribute_value("nelem", nelem);
1906  agfield.resize(nelem);
1907 
1908  Index n;
1909  try
1910  {
1911  for (n = 0; n < nelem; n++)
1912  xml_read_from_stream(is_xml, agfield[n], pbifs, verbosity);
1913  }
1914  catch (runtime_error e)
1915  {
1916  ostringstream os;
1917  os << "Error reading ArrayOfGriddedField3: "
1918  << "\n Element: " << n
1919  << "\n" << e.what();
1920  throw runtime_error(os.str());
1921  }
1922 
1923  tag.read_from_stream(is_xml);
1924  tag.check_name("/Array");
1925 }
1926 
1927 
1929 
1935 void xml_write_to_stream(ostream& os_xml,
1936  const ArrayOfGriddedField3& agfield,
1937  bofstream* pbofs,
1938  const String& name,
1939  const Verbosity& verbosity)
1940 {
1941  ArtsXMLTag open_tag(verbosity);
1942  ArtsXMLTag close_tag(verbosity);
1943 
1944  open_tag.set_name("Array");
1945  if (name.length())
1946  open_tag.add_attribute("name", name);
1947 
1948  open_tag.add_attribute("type", "GriddedField3");
1949  open_tag.add_attribute("nelem", agfield.nelem());
1950 
1951  open_tag.write_to_stream(os_xml);
1952  os_xml << '\n';
1953 
1954  for (Index n = 0; n < agfield.nelem(); n++)
1955  xml_write_to_stream(os_xml, agfield[n], pbofs, "", verbosity);
1956 
1957  close_tag.set_name("/Array");
1958  close_tag.write_to_stream(os_xml);
1959 
1960  os_xml << '\n';
1961 }
1962 
1963 
1964 //=== ArrayOfArrayOfGriddedField1 ===========================================
1965 
1967 
1972 void xml_read_from_stream(istream& is_xml,
1973  ArrayOfArrayOfGriddedField1& aagfield,
1974  bifstream* pbifs,
1975  const Verbosity& verbosity)
1976 {
1977  ArtsXMLTag tag(verbosity);
1978  Index nelem;
1979 
1980  tag.read_from_stream(is_xml);
1981  tag.check_name("Array");
1982  tag.check_attribute("type", "ArrayOfGriddedField1");
1983 
1984  tag.get_attribute_value("nelem", nelem);
1985  aagfield.resize(nelem);
1986 
1987  Index n;
1988  try
1989  {
1990  for (n = 0; n < nelem; n++)
1991  xml_read_from_stream(is_xml, aagfield[n], pbifs, verbosity);
1992  }
1993  catch (runtime_error e)
1994  {
1995  ostringstream os;
1996  os << "Error reading ArrayOfArrayOfGriddedField1: "
1997  << "\n Element: " << n
1998  << "\n" << e.what();
1999  throw runtime_error(os.str());
2000  }
2001 
2002  tag.read_from_stream(is_xml);
2003  tag.check_name("/Array");
2004 }
2005 
2006 
2008 
2014 void xml_write_to_stream(ostream& os_xml,
2015  const ArrayOfArrayOfGriddedField1& aagfield,
2016  bofstream* pbofs,
2017  const String& name,
2018  const Verbosity& verbosity)
2019 {
2020  ArtsXMLTag open_tag(verbosity);
2021  ArtsXMLTag close_tag(verbosity);
2022 
2023  open_tag.set_name("Array");
2024  if (name.length())
2025  open_tag.add_attribute("name", name);
2026 
2027  open_tag.add_attribute("type", "ArrayGriddedField1");
2028  open_tag.add_attribute("nelem", aagfield.nelem());
2029 
2030  open_tag.write_to_stream(os_xml);
2031  os_xml << '\n';
2032 
2033  for (Index n = 0; n < aagfield.nelem(); n++)
2034  xml_write_to_stream(os_xml, aagfield[n], pbofs, "", verbosity);
2035 
2036  close_tag.set_name("/Array");
2037  close_tag.write_to_stream(os_xml);
2038 
2039  os_xml << '\n';
2040 }
2041 
2042 
2043 //=== ArrayOfArrayOfGriddedField2 ===========================================
2044 
2046 
2051 void xml_read_from_stream(istream& is_xml,
2052  ArrayOfArrayOfGriddedField2& aagfield,
2053  bifstream* pbifs,
2054  const Verbosity& verbosity)
2055 {
2056  ArtsXMLTag tag(verbosity);
2057  Index nelem;
2058 
2059  tag.read_from_stream(is_xml);
2060  tag.check_name("Array");
2061  tag.check_attribute("type", "ArrayOfGriddedField2");
2062 
2063  tag.get_attribute_value("nelem", nelem);
2064  aagfield.resize(nelem);
2065 
2066  Index n;
2067  try
2068  {
2069  for (n = 0; n < nelem; n++)
2070  xml_read_from_stream(is_xml, aagfield[n], pbifs, verbosity);
2071  }
2072  catch (runtime_error e)
2073  {
2074  ostringstream os;
2075  os << "Error reading ArrayOfArrayOfGriddedField2: "
2076  << "\n Element: " << n
2077  << "\n" << e.what();
2078  throw runtime_error(os.str());
2079  }
2080 
2081  tag.read_from_stream(is_xml);
2082  tag.check_name("/Array");
2083 }
2084 
2085 
2087 
2093 void xml_write_to_stream(ostream& os_xml,
2094  const ArrayOfArrayOfGriddedField2& aagfield,
2095  bofstream* pbofs,
2096  const String& name,
2097  const Verbosity& verbosity)
2098 {
2099  ArtsXMLTag open_tag(verbosity);
2100  ArtsXMLTag close_tag(verbosity);
2101 
2102  open_tag.set_name("Array");
2103  if (name.length())
2104  open_tag.add_attribute("name", name);
2105 
2106  open_tag.add_attribute("type", "ArrayGriddedField2");
2107  open_tag.add_attribute("nelem", aagfield.nelem());
2108 
2109  open_tag.write_to_stream(os_xml);
2110  os_xml << '\n';
2111 
2112  for (Index n = 0; n < aagfield.nelem(); n++)
2113  xml_write_to_stream(os_xml, aagfield[n], pbofs, "", verbosity);
2114 
2115  close_tag.set_name("/Array");
2116  close_tag.write_to_stream(os_xml);
2117 
2118  os_xml << '\n';
2119 }
2120 
2121 
2122 //=== ArrayOfArrayOfGriddedField3 ===========================================
2123 
2125 
2130 void xml_read_from_stream(istream& is_xml,
2131  ArrayOfArrayOfGriddedField3& aagfield,
2132  bifstream* pbifs,
2133  const Verbosity& verbosity)
2134 {
2135  ArtsXMLTag tag(verbosity);
2136  Index nelem;
2137 
2138  tag.read_from_stream(is_xml);
2139  tag.check_name("Array");
2140  tag.check_attribute("type", "ArrayOfGriddedField3");
2141 
2142  tag.get_attribute_value("nelem", nelem);
2143  aagfield.resize(nelem);
2144 
2145  Index n;
2146  try
2147  {
2148  for (n = 0; n < nelem; n++)
2149  xml_read_from_stream(is_xml, aagfield[n], pbifs, verbosity);
2150  }
2151  catch (runtime_error e)
2152  {
2153  ostringstream os;
2154  os << "Error reading ArrayOfArrayOfGriddedField3: "
2155  << "\n Element: " << n
2156  << "\n" << e.what();
2157  throw runtime_error(os.str());
2158  }
2159 
2160  tag.read_from_stream(is_xml);
2161  tag.check_name("/Array");
2162 }
2163 
2164 
2166 
2172 void xml_write_to_stream(ostream& os_xml,
2173  const ArrayOfArrayOfGriddedField3& aagfield,
2174  bofstream* pbofs,
2175  const String& name,
2176  const Verbosity& verbosity)
2177 {
2178  ArtsXMLTag open_tag(verbosity);
2179  ArtsXMLTag close_tag(verbosity);
2180 
2181  open_tag.set_name("Array");
2182  if (name.length())
2183  open_tag.add_attribute("name", name);
2184 
2185  open_tag.add_attribute("type", "ArrayGriddedField3");
2186  open_tag.add_attribute("nelem", aagfield.nelem());
2187 
2188  open_tag.write_to_stream(os_xml);
2189  os_xml << '\n';
2190 
2191  for (Index n = 0; n < aagfield.nelem(); n++)
2192  xml_write_to_stream(os_xml, aagfield[n], pbofs, "", verbosity);
2193 
2194  close_tag.set_name("/Array");
2195  close_tag.write_to_stream(os_xml);
2196 
2197  os_xml << '\n';
2198 }
2199 
2200 
2201 //=== ArrayOfGriddedField4 ===========================================
2202 
2204 
2209 void xml_read_from_stream(istream& is_xml,
2210  ArrayOfGriddedField4& agfield,
2211  bifstream* pbifs,
2212  const Verbosity& verbosity)
2213 {
2214  ArtsXMLTag tag(verbosity);
2215  Index nelem;
2216 
2217  tag.read_from_stream(is_xml);
2218  tag.check_name("Array");
2219  tag.check_attribute("type", "GriddedField4");
2220 
2221  tag.get_attribute_value("nelem", nelem);
2222  agfield.resize(nelem);
2223 
2224  Index n;
2225  try
2226  {
2227  for (n = 0; n < nelem; n++)
2228  xml_read_from_stream(is_xml, agfield[n], pbifs, verbosity);
2229  }
2230  catch (runtime_error e)
2231  {
2232  ostringstream os;
2233  os << "Error reading ArrayOfGriddedField4: "
2234  << "\n Element: " << n
2235  << "\n" << e.what();
2236  throw runtime_error(os.str());
2237  }
2238 
2239  tag.read_from_stream(is_xml);
2240  tag.check_name("/Array");
2241 }
2242 
2243 
2245 
2251 void xml_write_to_stream(ostream& os_xml,
2252  const ArrayOfGriddedField4& agfield,
2253  bofstream* pbofs,
2254  const String& name,
2255  const Verbosity& verbosity)
2256 {
2257  ArtsXMLTag open_tag(verbosity);
2258  ArtsXMLTag close_tag(verbosity);
2259 
2260  open_tag.set_name("Array");
2261  if (name.length())
2262  open_tag.add_attribute("name", name);
2263 
2264  open_tag.add_attribute("type", "GriddedField4");
2265  open_tag.add_attribute("nelem", agfield.nelem());
2266 
2267  open_tag.write_to_stream(os_xml);
2268  os_xml << '\n';
2269 
2270  for (Index n = 0; n < agfield.nelem(); n++)
2271  xml_write_to_stream(os_xml, agfield[n], pbofs, "", verbosity);
2272 
2273  close_tag.set_name("/Array");
2274  close_tag.write_to_stream(os_xml);
2275 
2276  os_xml << '\n';
2277 }
2278 
2279 
2280 //=== ArrayOfLineMixingRecord ===========================================
2281 
2283 
2288 void xml_read_from_stream(istream& is_xml,
2290  bifstream* pbifs,
2291  const Verbosity& verbosity)
2292 {
2293  ArtsXMLTag tag(verbosity);
2294  Index nelem;
2295 
2296  tag.read_from_stream(is_xml);
2297  tag.check_name("Array");
2298  tag.check_attribute("type", "LineMixingRecord");
2299 
2300  tag.get_attribute_value("nelem", nelem);
2301  almr.resize(nelem);
2302 
2303  Index n;
2304  try
2305  {
2306  for (n = 0; n < nelem; n++)
2307  xml_read_from_stream(is_xml, almr[n], pbifs, verbosity);
2308  }
2309  catch (runtime_error e)
2310  {
2311  ostringstream os;
2312  os << "Error reading ArrayOfLineMixingRecord: "
2313  << "\n Element: " << n
2314  << "\n" << e.what();
2315  throw runtime_error(os.str());
2316  }
2317 
2318  tag.read_from_stream(is_xml);
2319  tag.check_name("/Array");
2320 }
2321 
2322 
2324 
2330 void xml_write_to_stream(ostream& os_xml,
2331  const ArrayOfLineMixingRecord& almr,
2332  bofstream* pbofs,
2333  const String& name,
2334  const Verbosity& verbosity)
2335 
2336 {
2337  ArtsXMLTag open_tag(verbosity);
2338  ArtsXMLTag close_tag(verbosity);
2339 
2340  open_tag.set_name("Array");
2341  if (name.length())
2342  open_tag.add_attribute("name", name);
2343 
2344  open_tag.add_attribute("type", "LineMixingRecord");
2345  open_tag.add_attribute("nelem", almr.nelem());
2346 
2347  open_tag.write_to_stream(os_xml);
2348  os_xml << '\n';
2349 
2350  for (Index n = 0; n < almr.nelem(); n++)
2351  xml_write_to_stream(os_xml, almr[n], pbofs, "", verbosity);
2352 
2353  close_tag.set_name("/Array");
2354  close_tag.write_to_stream(os_xml);
2355 
2356  os_xml << '\n';
2357 }
2358 
2359 
2360 //=== ArrayOfArrayOfLineMixingRecord ===========================================
2361 
2363 
2368 void xml_read_from_stream(istream& is_xml,
2370  bifstream* pbifs,
2371  const Verbosity& verbosity)
2372 {
2373  ArtsXMLTag tag(verbosity);
2374  Index nelem;
2375 
2376  tag.read_from_stream(is_xml);
2377  tag.check_name("Array");
2378  tag.check_attribute("type", "ArrayOfLineMixingRecord");
2379 
2380  tag.get_attribute_value("nelem", nelem);
2381  aalmr.resize(nelem);
2382 
2383  Index n;
2384  try
2385  {
2386  for (n = 0; n < nelem; n++)
2387  xml_read_from_stream(is_xml, aalmr[n], pbifs, verbosity);
2388  }
2389  catch (runtime_error e)
2390  {
2391  ostringstream os;
2392  os << "Error reading ArrayOfArrayOfLineMixingRecord: "
2393  << "\n Element: " << n
2394  << "\n" << e.what();
2395  throw runtime_error(os.str());
2396  }
2397 
2398  tag.read_from_stream(is_xml);
2399  tag.check_name("/Array");
2400 }
2401 
2402 
2404 
2410 void xml_write_to_stream(ostream& os_xml,
2411  const ArrayOfArrayOfLineMixingRecord& aalmr,
2412  bofstream* pbofs,
2413  const String& name,
2414  const Verbosity& verbosity)
2415 
2416 {
2417  ArtsXMLTag open_tag(verbosity);
2418  ArtsXMLTag close_tag(verbosity);
2419 
2420  open_tag.set_name("Array");
2421  if (name.length())
2422  open_tag.add_attribute("name", name);
2423 
2424  open_tag.add_attribute("type", "ArrayOfLineMixingRecord");
2425  open_tag.add_attribute("nelem", aalmr.nelem());
2426 
2427  open_tag.write_to_stream(os_xml);
2428  os_xml << '\n';
2429 
2430  for (Index n = 0; n < aalmr.nelem(); n++)
2431  xml_write_to_stream(os_xml, aalmr[n], pbofs, "", verbosity);
2432 
2433  close_tag.set_name("/Array");
2434  close_tag.write_to_stream(os_xml);
2435 
2436  os_xml << '\n';
2437 }
2438 
2439 
2440 //=== ArrayOfLineRecord ===========================================
2441 
2443 
2448 void xml_read_from_stream(istream& is_xml,
2449  ArrayOfLineRecord& alrecord,
2450  bifstream* pbifs,
2451  const Verbosity& verbosity)
2452 {
2453  xml_read_from_stream(is_xml, alrecord, NAN, NAN, pbifs, verbosity);
2454 }
2455 
2456 
2459 
2466 void xml_read_from_stream(istream& is_xml,
2467  ArrayOfLineRecord& alrecord,
2468  const Numeric fmin,
2469  const Numeric fmax,
2470  bifstream* pbifs _U_,
2471  const Verbosity& verbosity)
2472 {
2473  CREATE_OUT2;
2474 
2475  ArtsXMLTag tag(verbosity);
2476  Index nelem;
2477 
2478  tag.read_from_stream(is_xml);
2479  tag.check_name("ArrayOfLineRecord");
2480 
2481  tag.get_attribute_value("nelem", nelem);
2482 
2483  LineRecord dummy_line_record;
2484  String version;
2485  tag.get_attribute_value("version", version);
2486 
2487  Index artscat_version;
2488 
2489  if (version == "3")
2490  {
2491  artscat_version = 3;
2492  }
2493  else if (version.substr(0, 8) != "ARTSCAT-")
2494  {
2495  ostringstream os;
2496  os << "The ARTS line file you are trying to read does not contain a valid version tag.\n"
2497  << "Probably it was created with an older version of ARTS that used different units.";
2498  throw runtime_error(os.str());
2499  }
2500  else
2501  {
2502  istringstream is(version.substr(8));
2503  is >> artscat_version;
2504  }
2505 
2506  if (artscat_version < 3 or artscat_version > 4)
2507  {
2508  ostringstream os;
2509  os << "Unknown ARTS line file version: " << version;
2510  throw runtime_error(os.str());
2511  }
2512 
2513  alrecord.resize(0);
2514 
2515  Index n;
2516  try
2517  {
2518  for (n = 0; n < nelem; n++)
2519  {
2520  LineRecord lr;
2521  switch (artscat_version)
2522  {
2523  case 3:
2524  if (lr.ReadFromArtscat3Stream(is_xml, verbosity))
2525  throw runtime_error("Cannot read line from file");
2526  break;
2527  case 4:
2528  if (lr.ReadFromArtscat4Stream(is_xml, verbosity))
2529  throw runtime_error("Cannot read line from file");
2530  break;
2531  default:
2532  throw runtime_error("Programmer error. This should never be reached.\n"
2533  "Fix version number check above!");
2534  break;
2535  }
2536 
2537  if ((isnan(fmin) || fmin <= lr.F()) && (isnan(fmax) || lr.F() <= fmax))
2538  alrecord.push_back(lr);
2539  }
2540  }
2541  catch (runtime_error e)
2542  {
2543  ostringstream os;
2544  os << "Error reading ArrayOfLineRecord: "
2545  << "\n Element: " << n
2546  << "\n" << e.what();
2547  throw runtime_error(os.str());
2548  }
2549 
2550  out2 << " Read " << alrecord.nelem() << " out of " << nelem << " lines.\n";
2551 
2552  tag.read_from_stream(is_xml);
2553  tag.check_name("/ArrayOfLineRecord");
2554 }
2555 
2556 
2558 
2564 void xml_write_to_stream(ostream& os_xml,
2565  const ArrayOfLineRecord& alrecord,
2566  bofstream* pbofs _U_,
2567  const String& name,
2568  const Verbosity& verbosity)
2569 
2570 {
2571  static const LineRecord dummy_linerecord;
2572  ArtsXMLTag open_tag(verbosity);
2573  ArtsXMLTag close_tag(verbosity);
2574  Index catalog_version = dummy_linerecord.Version();
2575 
2576  open_tag.set_name("ArrayOfLineRecord");
2577  if (name.length())
2578  open_tag.add_attribute("name", name);
2579 
2580  if (alrecord.nelem())
2581  {
2582  catalog_version = alrecord[0].Version();
2583  open_tag.add_attribute("version", alrecord[0].VersionString());
2584  }
2585  else
2586  {
2587  open_tag.add_attribute("version", dummy_linerecord.VersionString());
2588  }
2589 
2590  open_tag.add_attribute("nelem", alrecord.nelem());
2591 
2592  open_tag.write_to_stream(os_xml);
2593  os_xml << '\n';
2594 
2595  for (ArrayOfLineRecord::const_iterator it = alrecord.begin();
2596  it != alrecord.end();
2597  it++)
2598  {
2599  if (catalog_version != it->Version())
2600  {
2601  ostringstream os;
2602  os << "This ArrayOfLineRecords contains a mixture of lines from different\n"
2603  << "ARTS catalog versions (writing ARTSCAT-" << catalog_version
2604  << ", this LineRecord is ARTSCAT-" << it->Version() << ").\n"
2605  << "Writing them to the same catalog file is unsupported."
2606  << "The offending LineRecord is: \n" << *it;
2607 
2608  throw runtime_error(os.str());
2609  }
2610  os_xml << *it << "\n";
2611  }
2612 
2613  close_tag.set_name("/ArrayOfLineRecord");
2614  close_tag.write_to_stream(os_xml);
2615 
2616  os_xml << '\n';
2617 }
2618 
2619 
2620 //=== ArrayOfArrayOfLineRecord ===========================================
2621 
2623 
2628 void xml_read_from_stream(istream& is_xml,
2629  ArrayOfArrayOfLineRecord& aalrecord,
2630  bifstream* pbifs,
2631  const Verbosity& verbosity)
2632 {
2633  ArtsXMLTag tag(verbosity);
2634  Index nelem;
2635 
2636  tag.read_from_stream(is_xml);
2637  tag.check_name("Array");
2638  tag.check_attribute("type", "ArrayOfLineRecord");
2639 
2640  tag.get_attribute_value("nelem", nelem);
2641  aalrecord.resize(nelem);
2642 
2643  Index n;
2644  try
2645  {
2646  for (n = 0; n < nelem; n++)
2647  xml_read_from_stream(is_xml, aalrecord[n], pbifs, verbosity);
2648  }
2649  catch (runtime_error e)
2650  {
2651  ostringstream os;
2652  os << "Error reading ArrayOfArrayOfLineRecord: "
2653  << "\n Element: " << n
2654  << "\n" << e.what();
2655  throw runtime_error(os.str());
2656  }
2657 
2658  tag.read_from_stream(is_xml);
2659  tag.check_name("/Array");
2660 }
2661 
2662 
2664 
2670 void xml_write_to_stream(ostream& os_xml,
2671  const ArrayOfArrayOfLineRecord& aalrecord,
2672  bofstream* pbofs,
2673  const String& name,
2674  const Verbosity& verbosity)
2675 
2676 {
2677  ArtsXMLTag open_tag(verbosity);
2678  ArtsXMLTag close_tag(verbosity);
2679 
2680  open_tag.set_name("Array");
2681  if (name.length())
2682  open_tag.add_attribute("name", name);
2683 
2684  open_tag.add_attribute("type", "ArrayOfLineRecord");
2685  open_tag.add_attribute("nelem", aalrecord.nelem());
2686 
2687  open_tag.write_to_stream(os_xml);
2688  os_xml << '\n';
2689 
2690  for (Index n = 0; n < aalrecord.nelem(); n++)
2691  xml_write_to_stream(os_xml, aalrecord[n], pbofs, "", verbosity);
2692 
2693  close_tag.set_name("/Array");
2694  close_tag.write_to_stream(os_xml);
2695 
2696  os_xml << '\n';
2697 }
2698 
2699 
2700 //=== ArrayOfLineshapeSpec ===========================================
2701 
2703 
2708 void xml_read_from_stream(istream& is_xml _U_,
2709  ArrayOfLineshapeSpec& alspec _U_,
2710  bifstream* pbifs _U_,
2711  const Verbosity&)
2712 {
2713  // FIXME: OLE: Implement this.
2714  throw runtime_error("Boo. Not yet implemented.");
2715 }
2716 
2717 
2719 
2725 void xml_write_to_stream(ostream& os_xml _U_,
2726  const ArrayOfLineshapeSpec& alspec _U_,
2727  bofstream* pbofs _U_,
2728  const String& name _U_,
2729  const Verbosity&)
2730 
2731 {
2732  // FIXME: OLE: Implement this.
2733  throw runtime_error("Boo. Not yet implemented.");
2734 }
2735 
2736 
2737 //=== ArrayOfTensor3=========================================================
2738 
2740 
2745 void xml_read_from_stream(istream& is_xml,
2746  ArrayOfTensor3& atensor3,
2747  bifstream* pbifs,
2748  const Verbosity& verbosity)
2749 {
2750  ArtsXMLTag tag(verbosity);
2751  Index nelem;
2752 
2753  tag.read_from_stream(is_xml);
2754  tag.check_name("Array");
2755  tag.check_attribute("type", "Tensor3");
2756 
2757  tag.get_attribute_value("nelem", nelem);
2758  atensor3.resize(nelem);
2759 
2760  Index n;
2761  try
2762  {
2763  for (n = 0; n < nelem; n++)
2764  xml_read_from_stream(is_xml, atensor3[n], pbifs, verbosity);
2765  }
2766  catch (runtime_error e)
2767  {
2768  ostringstream os;
2769  os << "Error reading ArrayOfTensor3: "
2770  << "\n Element: " << n
2771  << "\n" << e.what();
2772  throw runtime_error(os.str());
2773  }
2774 
2775 
2776  tag.read_from_stream(is_xml);
2777  tag.check_name("/Array");
2778 }
2779 
2780 
2782 
2788 void xml_write_to_stream(ostream& os_xml,
2789  const ArrayOfTensor3& atensor3,
2790  bofstream* pbofs,
2791  const String& name,
2792  const Verbosity& verbosity)
2793 {
2794  ArtsXMLTag open_tag(verbosity);
2795  ArtsXMLTag close_tag(verbosity);
2796 
2797  open_tag.set_name("Array");
2798  if (name.length())
2799  open_tag.add_attribute("name", name);
2800 
2801  open_tag.add_attribute("type", "Tensor3");
2802  open_tag.add_attribute("nelem", atensor3.nelem());
2803 
2804  open_tag.write_to_stream(os_xml);
2805  os_xml << '\n';
2806 
2807  for (Index n = 0; n < atensor3.nelem(); n++)
2808  xml_write_to_stream(os_xml, atensor3[n], pbofs, "", verbosity);
2809 
2810  close_tag.set_name("/Array");
2811  close_tag.write_to_stream(os_xml);
2812 
2813  os_xml << '\n';
2814 }
2815 
2816 
2817 
2818 //=== ArrayOfTensor4=========================================================
2819 
2821 
2826 void xml_read_from_stream(istream& is_xml,
2827  ArrayOfTensor4& atensor4,
2828  bifstream* pbifs,
2829  const Verbosity& verbosity)
2830 {
2831  ArtsXMLTag tag(verbosity);
2832  Index nelem;
2833 
2834  tag.read_from_stream(is_xml);
2835  tag.check_name("Array");
2836  tag.check_attribute("type", "Tensor4");
2837 
2838  tag.get_attribute_value("nelem", nelem);
2839  atensor4.resize(nelem);
2840 
2841  Index n;
2842  try
2843  {
2844  for (n = 0; n < nelem; n++)
2845  xml_read_from_stream(is_xml, atensor4[n], pbifs, verbosity);
2846  }
2847  catch (runtime_error e)
2848  {
2849  ostringstream os;
2850  os << "Error reading ArrayOfTensor4: "
2851  << "\n Element: " << n
2852  << "\n" << e.what();
2853  throw runtime_error(os.str());
2854  }
2855 
2856 
2857  tag.read_from_stream(is_xml);
2858  tag.check_name("/Array");
2859 }
2860 
2861 
2863 
2869 void xml_write_to_stream(ostream& os_xml,
2870  const ArrayOfTensor4& atensor4,
2871  bofstream* pbofs,
2872  const String& name,
2873  const Verbosity& verbosity)
2874 {
2875  ArtsXMLTag open_tag(verbosity);
2876  ArtsXMLTag close_tag(verbosity);
2877 
2878  open_tag.set_name("Array");
2879  if (name.length())
2880  open_tag.add_attribute("name", name);
2881 
2882  open_tag.add_attribute("type", "Tensor4");
2883  open_tag.add_attribute("nelem", atensor4.nelem());
2884 
2885  open_tag.write_to_stream(os_xml);
2886  os_xml << '\n';
2887 
2888  for (Index n = 0; n < atensor4.nelem(); n++)
2889  xml_write_to_stream(os_xml, atensor4[n], pbofs, "", verbosity);
2890 
2891  close_tag.set_name("/Array");
2892  close_tag.write_to_stream(os_xml);
2893 
2894  os_xml << '\n';
2895 }
2896 
2897 
2898 
2899 //=== ArrayOfTensor6=========================================================
2900 
2902 
2907 void xml_read_from_stream(istream& is_xml,
2908  ArrayOfTensor6& atensor6,
2909  bifstream* pbifs,
2910  const Verbosity& verbosity)
2911 {
2912  ArtsXMLTag tag(verbosity);
2913  Index nelem;
2914 
2915  tag.read_from_stream(is_xml);
2916  tag.check_name("Array");
2917  tag.check_attribute("type", "Tensor6");
2918 
2919  tag.get_attribute_value("nelem", nelem);
2920  atensor6.resize(nelem);
2921 
2922  Index n;
2923  try
2924  {
2925  for (n = 0; n < nelem; n++)
2926  xml_read_from_stream(is_xml, atensor6[n], pbifs, verbosity);
2927  }
2928  catch (runtime_error e)
2929  {
2930  ostringstream os;
2931  os << "Error reading ArrayOfTensor6: "
2932  << "\n Element: " << n
2933  << "\n" << e.what();
2934  throw runtime_error(os.str());
2935  }
2936 
2937  tag.read_from_stream(is_xml);
2938  tag.check_name("/Array");
2939 }
2940 
2941 
2943 
2949 void xml_write_to_stream(ostream& os_xml,
2950  const ArrayOfTensor6& atensor6,
2951  bofstream* pbofs,
2952  const String& name,
2953  const Verbosity& verbosity)
2954 {
2955  ArtsXMLTag open_tag(verbosity);
2956  ArtsXMLTag close_tag(verbosity);
2957 
2958  open_tag.set_name("Array");
2959  if (name.length())
2960  open_tag.add_attribute("name", name);
2961 
2962  open_tag.add_attribute("type", "Tensor6");
2963  open_tag.add_attribute("nelem", atensor6.nelem());
2964 
2965  open_tag.write_to_stream(os_xml);
2966  os_xml << '\n';
2967 
2968  for (Index n = 0; n < atensor6.nelem(); n++)
2969  xml_write_to_stream(os_xml, atensor6[n], pbofs, "", verbosity);
2970 
2971  close_tag.set_name("/Array");
2972  close_tag.write_to_stream(os_xml);
2973 
2974  os_xml << '\n';
2975 }
2976 
2977 
2978 //=== ArrayOfTensor7=========================================================
2979 
2981 
2986 void xml_read_from_stream(istream& is_xml,
2987  ArrayOfTensor7& atensor7,
2988  bifstream* pbifs,
2989  const Verbosity& verbosity)
2990 {
2991  ArtsXMLTag tag(verbosity);
2992  Index nelem;
2993 
2994  tag.read_from_stream(is_xml);
2995  tag.check_name("Array");
2996  tag.check_attribute("type", "Tensor7");
2997 
2998  tag.get_attribute_value("nelem", nelem);
2999  atensor7.resize(nelem);
3000 
3001  Index n;
3002  try
3003  {
3004  for (n = 0; n < nelem; n++)
3005  xml_read_from_stream(is_xml, atensor7[n], pbifs, verbosity);
3006  }
3007  catch (runtime_error e)
3008  {
3009  ostringstream os;
3010  os << "Error reading ArrayOfTensor7: "
3011  << "\n Element: " << n
3012  << "\n" << e.what();
3013  throw runtime_error(os.str());
3014  }
3015 
3016  tag.read_from_stream(is_xml);
3017  tag.check_name("/Array");
3018 }
3019 
3020 
3022 
3028 void xml_write_to_stream(ostream& os_xml,
3029  const ArrayOfTensor7& atensor7,
3030  bofstream* pbofs,
3031  const String& name,
3032  const Verbosity& verbosity)
3033 {
3034  ArtsXMLTag open_tag(verbosity);
3035  ArtsXMLTag close_tag(verbosity);
3036 
3037  open_tag.set_name("Array");
3038  if (name.length())
3039  open_tag.add_attribute("name", name);
3040 
3041  open_tag.add_attribute("type", "Tensor7");
3042  open_tag.add_attribute("nelem", atensor7.nelem());
3043 
3044  open_tag.write_to_stream(os_xml);
3045  os_xml << '\n';
3046 
3047  for (Index n = 0; n < atensor7.nelem(); n++)
3048  xml_write_to_stream(os_xml, atensor7[n], pbofs, "", verbosity);
3049 
3050  close_tag.set_name("/Array");
3051  close_tag.write_to_stream(os_xml);
3052 
3053  os_xml << '\n';
3054 }
3055 
3056 
3057 //=== ArrayOfString ==========================================================
3058 
3060 
3066 void xml_parse_from_stream(istream& is_xml,
3067  ArrayOfString& astring,
3068  bifstream* pbifs,
3069  ArtsXMLTag& tag,
3070  const Verbosity& verbosity)
3071 {
3072  Index nelem;
3073 
3074  tag.check_attribute("type", "String");
3075 
3076  tag.get_attribute_value("nelem", nelem);
3077  astring.resize(nelem);
3078 
3079  Index n;
3080  try
3081  {
3082  for (n = 0; n < nelem; n++)
3083  xml_read_from_stream(is_xml, astring[n], pbifs, verbosity);
3084  }
3085  catch (runtime_error e)
3086  {
3087  ostringstream os;
3088  os << "Error reading ArrayOfString: "
3089  << "\n Element: " << n
3090  << "\n" << e.what();
3091  throw runtime_error(os.str());
3092  }
3093 }
3094 
3095 
3097 
3102 void xml_read_from_stream(istream& is_xml,
3103  ArrayOfString& astring,
3104  bifstream* pbifs,
3105  const Verbosity& verbosity)
3106 {
3107  ArtsXMLTag tag(verbosity);
3108 
3109  tag.read_from_stream(is_xml);
3110  tag.check_name("Array");
3111 
3112  xml_parse_from_stream(is_xml, astring, pbifs, tag, verbosity);
3113 
3114  tag.read_from_stream(is_xml);
3115  tag.check_name("/Array");
3116 }
3117 
3118 
3120 
3126 void xml_write_to_stream(ostream& os_xml,
3127  const ArrayOfString& astring,
3128  bofstream* pbofs,
3129  const String& name,
3130  const Verbosity& verbosity)
3131 {
3132  ArtsXMLTag open_tag(verbosity);
3133  ArtsXMLTag close_tag(verbosity);
3134 
3135  open_tag.set_name("Array");
3136  if (name.length())
3137  open_tag.add_attribute("name", name);
3138 
3139  open_tag.add_attribute("type", "String");
3140  open_tag.add_attribute("nelem", astring.nelem());
3141 
3142  open_tag.write_to_stream(os_xml);
3143  os_xml << '\n';
3144 
3145  for (Index n = 0; n < astring.nelem(); n++)
3146  xml_write_to_stream(os_xml, astring[n], pbofs, "", verbosity);
3147 
3148  close_tag.set_name("/Array");
3149  close_tag.write_to_stream(os_xml);
3150 
3151  os_xml << '\n';
3152 }
3153 
3154 //=== ArrayOfVector ==========================================================
3155 
3157 
3162 void xml_read_from_stream(istream& is_xml,
3163  ArrayOfVector& avector,
3164  bifstream* pbifs,
3165  const Verbosity& verbosity)
3166 {
3167  ArtsXMLTag tag(verbosity);
3168  Index nelem;
3169 
3170  tag.read_from_stream(is_xml);
3171  tag.check_name("Array");
3172  tag.check_attribute("type", "Vector");
3173 
3174  tag.get_attribute_value("nelem", nelem);
3175  avector.resize(nelem);
3176 
3177  Index n;
3178  try
3179  {
3180  for (n = 0; n < nelem; n++)
3181  xml_read_from_stream(is_xml, avector[n], pbifs, verbosity);
3182  }
3183  catch (runtime_error e)
3184  {
3185  ostringstream os;
3186  os << "Error reading ArrayOfVector: "
3187  << "\n Element: " << n
3188  << "\n" << e.what();
3189  throw runtime_error(os.str());
3190  }
3191 
3192  tag.read_from_stream(is_xml);
3193  tag.check_name("/Array");
3194 }
3195 
3196 
3198 
3204 void xml_write_to_stream(ostream& os_xml,
3205  const ArrayOfVector& avector,
3206  bofstream* pbofs,
3207  const String& name,
3208  const Verbosity& verbosity)
3209 {
3210  ArtsXMLTag open_tag(verbosity);
3211  ArtsXMLTag close_tag(verbosity);
3212 
3213  open_tag.set_name("Array");
3214  if (name.length())
3215  open_tag.add_attribute("name", name);
3216 
3217  open_tag.add_attribute("type", "Vector");
3218  open_tag.add_attribute("nelem", avector.nelem());
3219 
3220  open_tag.write_to_stream(os_xml);
3221  os_xml << '\n';
3222 
3223  for (Index n = 0; n < avector.nelem(); n++)
3224  xml_write_to_stream(os_xml, avector[n], pbofs, "", verbosity);
3225 
3226  close_tag.set_name("/Array");
3227  close_tag.write_to_stream(os_xml);
3228 
3229  os_xml << '\n';
3230 }
3231 
LineRecord::ReadFromArtscat3Stream
bool ReadFromArtscat3Stream(istream &is, const Verbosity &verbosity)
Read one line from a stream associated with an ARTSCAT-3 file.
Definition: linerecord.cc:2064
ArtsXMLTag::check_name
void check_name(const String &expected_name)
Check tag name.
Definition: xml_io.cc:56
xml_write_to_stream
void xml_write_to_stream(ostream &os_xml, const Array< SpeciesRecord > &asrecord, bofstream *pbofs, const String &name, const Verbosity &verbosity)
Writes SpeciesData to XML output stream.
Definition: xml_io_array_types.cc:93
xml_parse_from_stream
void xml_parse_from_stream(istream &is_xml, ArrayOfString &astring, bifstream *pbifs, ArtsXMLTag &tag, const Verbosity &verbosity)
Parse ArrayOfString from XML input stream.
Definition: xml_io_array_types.cc:3066
ArtsXMLTag::get_attribute_value
void get_attribute_value(const String &aname, String &value)
Returns value of attribute as String.
Definition: xml_io.cc:131
CREATE_OUT2
#define CREATE_OUT2
Definition: messages.h:213
ArtsXMLTag::check_attribute
void check_attribute(const String &aname, const String &value)
Checks whether attribute has the expected value.
Definition: xml_io.cc:103
ArtsXMLTag::write_to_stream
void write_to_stream(ostream &os)
Write XML tag.
Definition: xml_io.cc:321
Array
This can be used to make arrays out of anything.
Definition: array.h:107
xml_io_private.h
This file contains private function declarations and template instantiation to handle XML data files.
_U_
#define _U_
Definition: config.h:167
ArtsXMLTag::read_from_stream
void read_from_stream(istream &is)
Reads next XML tag.
Definition: xml_io.cc:183
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:64
xml_io_types.h
This file contains private function declarations and template instantiation to handle XML data files.
jacobian.h
Declarations required for the calculation of jacobians.
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
Verbosity
Definition: messages.h:50
ArtsXMLTag::add_attribute
void add_attribute(const String &aname, const String &value)
Adds a String attribute to tag.
Definition: xml_io.cc:69
bifstream
Binary output file stream class.
Definition: bifstream.h:45
LineRecord::VersionString
String VersionString() const
Return the version String.
Definition: linerecord.cc:34
LineRecord
Spectral line catalog data.
Definition: linerecord.h:196
LineRecord::ReadFromArtscat4Stream
bool ReadFromArtscat4Stream(istream &is, const Verbosity &verbosity)
Read one line from a stream associated with an ARTSCAT-4 file.
Definition: linerecord.cc:2259
LineRecord::Version
Index Version() const
Return the version number.
Definition: linerecord.h:298
xml_read_from_stream
void xml_read_from_stream(istream &is_xml, Array< SpeciesRecord > &asrecord, bifstream *pbifs, const Verbosity &verbosity)
Reads SpeciesData from XML input stream.
Definition: xml_io_array_types.cc:49
ArtsXMLTag
The ARTS XML tag class.
Definition: xml_io_private.h:79
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
LineRecord::F
Numeric F() const
The line center frequency in Hz.
Definition: linerecord.h:339
ArtsXMLTag::set_name
void set_name(const String &new_name)
Definition: xml_io_private.h:87
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:176
arts.h
The global header file for ARTS.
bofstream
Binary output file stream class.
Definition: bofstream.h:45